Re: A83: Switching the calculator off


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

Re: A83: Switching the calculator off




Here, I dunno if this helps or not, but here's a brief explanation of the
'stack:'
First of all, have you ever seen an HP48?  Or some calc with
reverse-polish calculations?  Basically, it's where, to add 5+6, you'd
enter 5 and it'd show up on the bottomt of the screen (slot 1, say) and
then you'd enter 6, and it'd move the 5 up (into slot 2) and put the 6
underneath it (into slot 1).
You then press + and it adds the second-to-the-bottom (slot 2) number to
the bottom number (slot 1), erasing the 5 and the 6 and putting an 11 on
the bottom (slot 1).  Now, think of it this way: those slots make up the
'stack' (it's actually called that).
See, here, you enter 1234h and it places into slot 1 of the stack.  You
then enter 5678h and it places it at slot 1 and 1234h at slot 2, etc,
etc...

Another thing to keep in mind: whenever you use 'call,' it puts the
current program execution pointer onto the bottom of the stack.
So, say you have this:
.org 9327h
ld a,5
call Imreallytired
.
.
.
Imreallytired:
.
ret
.
.
at the beginning of the the prog, the prog exec ptr is 9327h.  And as the
83 runs the code, it updates the ptr.  So, after the ld a,5 (3E05), the
ptr is now 9329h, and that is what's stored onto the bottom of the stack
as it jumps to Imreallytired (which is, say, 9400h).  And when it hits
that ret, it recalls that number off the bottom of the stack and jumps
back to it ('course, if the bottom number has been changed to hl (5678h),
then the prog exec ptr jumps to address 5678h, which is
lord-know-what...so keep that in mind-make sure you preserve the prg exec
ptr @ the bottom of the stack and/or make sure it's there when you hit
that ret...)

Well, I hopes that helped.  I know I wrote a lot, I guess I just got
arried away... (C8:*

		-Dimitri


On Tue, 5 May 1998, Trey Jazz wrote:

> 
> its 5678h thats popped into hl, last value pushed is first to be popped
> 
> >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
> 


References: