push pop example for bootloaders
Posted: Tue Dec 22, 2015 12:07 pm
Code: Select all
bits 16
org 0x7c00
;
;Initialisation requires zeroing and setting some registers (SS, SP, CS, DS and ES)
;
jmp short $ + 2 ; or jmp short start ; or jmp short 0x7c02
start:
xor ax, ax ; get ready to zero some registers
mov ss, ax ; zero SS
mov sp, 0x7c00 ; set SP to beginning of stack
mov ds, ax ; zero DS
mov es, ax ; zero ES
jmp word 0x0000:next ; zero CS
;
; Function will alter value of AX
;
next:
push ax
call do_something ; function that changes DL
pop ax
...
times 510 - ($ - $$) db 0
dw 0xaa55