Re: A83: Switching the calculator off


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

Re: A83: Switching the calculator off




Thank you so much for that info Trey. I did read that somewhere, but didn't
fully understand it. Now I think I do. Now let me see if this is right.
"Push" saves the regester into memory (or stack as it really called), and
pop loads it back into the register. Question, say you do this...
    ld hl, 1234h
    ld bc, 5678h
    push hl
    push bc
    pop hl             ; ****** My question is in this case, is the number
poped into hl, is that
                                        5678h or is it 1234h? My guess that
it is 5678h. Am I right or
                                        completly wrong?
Thank you
>From Conway

-----Original Message-----
From: Trey Jazz <joemama@minot.com>
To: assembly-83@lists.ticalc.org <assembly-83@lists.ticalc.org>
Date: Monday, 4 May 1998 3:49
Subject: Re: A83: Switching the calculator off


>
>>I didn't use any push or pop's (mainly cause I don't understand them).
>
>o ok.... pushes and pops are a big way to save lots of memory in routines
>and a good way to keep from doing stupid stuff.
>push af ; this pushes af onto the stack
>pop af ;this pops the last values put on the stack into af
>this can be done with af,bc,de,hl theres also calls to push and pop the OPs
>
>heres one use for the push/pop
> ld hl,sprite
> ld b,14
> ld a,0 ;load the x-coord of the sprite into a
>loop:
> ld e,y-coord
> push af ;push whatever is in af onto the stack because the call destroys a
> push bc ;push this too because b and c are destroyed too
> call PutSprite
> pop bc ;pop the last register you pushed first so you dont end up with the
>values in the wrong registers
> pop af ;pop the values back into a
> push bc ;push the original loop counter so we dont lose it
> ld b,8
>loop2:
> inc a ;increases a 8 times so the next sprite is side by side with the
last
>one
> djnz loop2
> pop bc ;restore the original loop counter
> djnz loop
>