x86-16

“times 510-($-$$) db 0” does not work

穿精又带淫゛_ 提交于 2019-12-06 04:09:11
I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; Michael Petch I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems to me your are attempting to find the proper way to access the variable the_secret and then

Difference between byte ptr and word ptr

懵懂的女人 提交于 2019-12-06 03:37:16
问题 I saw the following question on a test paper, Question VarM DWORD ABBF01598h Give the contents of registers al , bx , and dl after the execution of mov al, byte ptr VarM + 1 mov bx, word ptr VarM + 2 mov dl, byte ptr VarM + 3 Now I know word ptr and byte ptr by definitions but I am unable to pickup the concept of them. According to me al = b bx = 0 dl = F Please help me out in understanding these. Thanks in advance. 回答1: In the cases you're looking at, the byte ptr and word ptr don't

Interchange Letters From String in Assembly Language 8086

混江龙づ霸主 提交于 2019-12-06 02:21:17
I have a very simple problem that i need to achieve. First you enter a string, the first output should copy the last letter of the string and replace the first letter of the string and then the last letter should be replace with the first letter. The second output should capitalize the first letter of the string. I've already did the second output, my problem now is the first output. Please see the expected result below. Expected Result Enter string: jon jones son jonej Jon jones Current Code .MODEL SMALL .STACK 100H .DATA INPUT_STRING DB 10,13,"Enter string: $" USER_INPUT_STRING DB 80 DUP('$'

Stack Overflow of 8086 microprocessor

痞子三分冷 提交于 2019-12-06 00:10:59
What'll be the behaviour of the 8086 Microprocessor when the stack is full and even then I push something into it? On the 8086, a PUSH instruction or implicit stack push will decrement the SP register by two and store the appropriate quantity at SS:SP (i.e. 16*SS+SP). If the SP register was $0000, the data will go to SS:$FFFE. If the SP register was $0001, the MSB of the data will go to SS:$0000 and the LSB will go to SS:$FFFF. The processor will not take any special notice of the stack wraparound. While stack wraparound would typically be a bad thing, there are some situations on the 8086

Change the background color of dosbox console when executing a tasm program

纵饮孤独 提交于 2019-12-05 15:36:46
I am trying to display x in the center of the screen and then change the background color of the console to blue. I have the following code that accomplishes everything except for changing the background color: TITLE screen1.ASM .MODEL SMALL .STACK 0100h .DATA .CODE start: MOV AX,@DATA MOV DS,AX MOV AX,0600h MOV BH,07h MOV CX,0000h MOV DX,184Fh INT 10h MOV AH,02h MOV BH,00h MOV DH,0Ch MOV DL,28h INT 10h MOV AH,02h MOV DL,'x' INT 21h MOV AX,4C00h INT 21h END start The code clears the screen, displays x at the center of the dosbox window and gives control back to DOS. I'm trying to find out what

Moving data from memory to memory in micro controllers

北战南征 提交于 2019-12-05 15:28:51
Why can't we move data directly from a memory location into another memory location. Pardon me if I am asking a dumb question, but I think this is a true situation, at least for the ones I've encountered (8085,8086 n 80386) I am not really looking for a solution for moving the data (like for eg, using movs n all), but actually the reason for this anomaly. Most CPU varieties don't allow memory-to-memory moves. Normally the CPU can access only one memory location at at time, which means you need a temporary spot to store the value when moving it (a general purpose register, usually). If you

What is the purpose of the reserved/undefined bit in the flag register?

余生颓废 提交于 2019-12-05 12:26:21
In the flag register of Z80, 8080, 8085, and 8086 processors, what is the purpose of bits 1, 3, 5, which are documented as "reserved" or "undefined"? Konamiman These bits are unused; that is, no instruction explicitly sets them to any value. The designers decided that 5/6 flags was enough, and they just left the remaining bits of the flags register unused. They are documented as being "undefined" because it is not possible to know in advance which value will they have after any of the instructions are executed—the processor design is simpler that way, as opposed to setting them explicitly to 0

Why does CMP (compare) sometimes sets a Carry Flag in 8086 assembly?

偶尔善良 提交于 2019-12-05 03:26:10
I've been reading around and with the 8086 Instruction Set, it says that a CMP (compare) can set the Carry Flag. I understand that a compare subtracts two operands but I was wondering if anyone can provide an example when that is the case. I just can't grasp the idea of adding a number and a negative number will set the carry flag. I've read into the borrow flag but I just needed an example to clarify my understanding of a compare instruction. Also, I understand that if 3 - 5 = -2 would set the negative flag... when is carry set? The carry flag is set after an operation that resulted in an

Printing 3 digits in assembly

五迷三道 提交于 2019-12-04 19:19:19
This is my printing function, it should output a 3digit result. I store my result in RES which is a dw. The push and pop fixed my problems with printing before now I don't know where it goes wrong. XOR AX, AX XOR BX, BX ;this divides my 3digit number by 100 giving me my, hundredth digit MOV AX, RES MOV BX, 100 DIV BX ;prints the hundredth digit ADD AL, '0' MOV DL, AL PUSH AX ; save AX on the stack MOV AH, 02h INT 21h POP AX ; restore ax ;divides the remainder by 10 giving me my tens digit MOV BX, 10 DIV BX ;prints my tens digit ADD AL, '0' MOV DL, AL PUSH AX ; save AX on the stack MOV AH, 02h

nasm/ld “relocation truncated to fit: R_386_16”

荒凉一梦 提交于 2019-12-04 15:51:34
问题 Assembly: [BITS 16] global _start _start: mov ax, 0x07C0 mov ds, ax mov si, hw call print_string jmp $ print_string: mov ah, 0x0E .char: lodsb cmp al, 0 je .exit int 0x10 jmp .char .exit: ret times 0x100-($-$$) db 0 hw: db "Hello, World!", 0 times 510-($-$$) db 0 dw 0xAA55 Assembling this with: $ nasm file.asm -felf -o file.o And then linking it with: $ ld -melf_i386 -o file.bin file.o --oformat binary Gives the following error: file.asm:(.text+0x6): relocation truncated to fit: R_386_16