Re: A86: PUSH and POP


[Prev][Next][Index][Thread]

Re: A86: PUSH and POP



You write:

> Could someone please explain the use of push and pop to me?  sorry to
>  bother ya'll but i am a newbie to ASM
>  
>  thanx,
>      Patrick
 
push bc (or af, de, or hl), for example will take bc (or whatever) and copy
what is in it to the top of the stack, moving everything else down (actually,
it just moves the top up, but anyway).

When you pop bc, (or de or hl or af) it takes what's on top of the stack and
moves it to bc (or whatever).

Uses include:

saving variables that will be changed:
ld hl,Text
push hl
ld hl,$0000        ;we changed hl
ld (_curRow),hl
pop hl              ;but now we get it back
call _puts         ;and use it

and doing 16 bit ld's (because there are no opcodes to do it):
push hl
pop de        ;same as ld de,hl   , if that opcode existed.

The uses are endless...

~Stephen Hicks


Follow-Ups: