[A83] Re: Stack Problems


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

[A83] Re: Stack Problems




You can only push and pop register PAIRS, not single registers.

The pairs you can push and pop are:
AF (register A and the Flags register)
BC (registers B and C...)
DE
HL
IX
IY

So there, push AF instead of pushing A.

Also watch out!  RET and CALL also use the same stack, so be very careful.  
If you jumped to _getcsc, it would return to an address stored on the stack, 
which is BAD if you put data there. (_getcsc ends with a ret, so call this 
one instead of jumping to it)

But in this case it looks like getcsc is just a label used in your code, and 
not a romcall.  It is VERY confusing to name labels the same as romcalls, so 
give your code different labels.  (it's not always easy to tell the 
difference between getcsc and _getcsc)

If you DON'T pop what you push, CRASH.  If you jumped to your getcsc, you 
would need to pop af, or else it would either crash at the next ret, or 
overflow the stack and corrupt the program. (crash)

Stack problems create most crashes, good use of the stack creates cool 
programs.


>From: "Steve Watson" <fif_freak00@hotmail.com>
>Reply-To: assembly-83@lists.ticalc.org
>To: Assembly-83@lists.ticalc.org
>Subject: [A83] Stack Problems
>Date: Fri, 30 Mar 2001 20:07:02 -0700
>
>
>Can anyone tell me what's wrong in this label?  I'm very sure it's with the
>stack (I am trying to make a test program that when you press up or down an
>arrow moves up and down):
>
>down:
>	push	a
>	ld	a,l
>	cp	12
>	jp	z,getcsc
>	pop	a
>	ld	ix,spriteblank
>	sub	7
>	ld	ix,sprite
>
>a=X coordinate
>l=Y coordinate
>
>I also want to know how to set the Xmin, Xmax, Ymin, and Ymax from an Ion
>program, unless it's already this:
>0-Xmin
>0-Ymin
>94-Xmax
>62-Ymax
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com





Follow-Ups: