[A83] Re: advanced stack-stuff
[Prev][Next][Index][Thread]
[A83] Re: advanced stack-stuff
STUPID STACK EXAMPLE THAT'S PROBABLY CONFUSING AS HELL:
Code1:
ld hl,4
push hl ;Stack: 4
call Code2 ;Stack: 4, [return]
pop hl
ret
Code2:
pop hl ;Stack: 4
;hl= [return]
pop de ;Stack: Empty
;de= 4
ld de,Code3
push de ;Stack: Code3
ret ;Ret returns to Code3, which was just pushed on the stack
Code3:
ld de,4096 ;Stack: Empty
push de ;Stack: 4096,
push hl ;Stack: 4096, [return]
ret ;Returns way back to the first call, with a different
;HL value...
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
Follow-Ups: