i want to create MBR with assembly language . But i have code , give by somebody that i don't understand . When you write
push ax
push bx
What is the meaning , when we use segment and offset
For more details, read this code :
[BITS 16]
[ORG 0x0]
mov ax, 0x07C0
mov ds , ax
mov es , ax
mov ax , 0x8000
mov ss , ax
mov sp , 0xf000
mov si ,msgDebut
call afficher
end :
jmp end
msgDebut db "HelloWorld!!!!",13,10,0
afficher :
push ax
push bx
.debut :
lodsb
cmp al ,0
jz .fin
mov ah , 0x0E
mov bx , 0x07
int 0x10
jmp .debut
.fin :
pop bx
pop ax
ret
times 510-($-$$) db 144
dw 0xAA55
can you explain me this code line by line using memory addressing, segmentation, and offset abstraction
The push
instruction places its operand on the stack for conservation.
The stack is an area of memory set aside for this purpose.
The stackpointer determines where the data will be stored in memory. When the stackpointer SS:SP
is equal to 0x8000:0xEFFE, push ax
will first lower the stackpointer by 2 so it becomes 0x8000:0xEFFC and then write the contents of the AX
register in that memory address.
Hereafter push bx
will again lower the stackpointer by 2 so it now becomes 0x8000:0xEFFA and then write the contents of the BX
register in that memory address.
The pop
instruction reverses the actions of push
. You use these to restore the registers to their original values.
afficher :
push ax ; Preserve AX
push bx ; Preserve BX
...
pop bx ; Restore BX
pop ax ; Restore AX
ret
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.