RE: A82: Either I'm crazy or my 82 is...


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

RE: A82: Either I'm crazy or my 82 is...



On Monday, July 07, 1997 9:59 PM, Ryan N Gillespie[SMTP:ryan.gillespie@juno.com] wrote:
> I'm assuming you have a Keyloop label?
> 
> Keyloop:
> >       CALL   GET_KEY              
> >       CP $37
> >       JR NZ,ND
> You want JR Z, ND - With CP, the 0 flag is set if they are equal.
> Therefore, if the person pressed [MODE], the calc. will make a relative
> jump to the label ND.
> 
> >       CP $04
> >       JR z,UP
> This code is fine.
> 
> >       CP $01
> >       JR z,DWN
> Same here. 
> 
> >       JR NZ,Keyloop       
> This should be JR Z, Keyloop because if no key is pressed, the value
> returned is 0.
> 
> 			-Scoobie

Actually, that's all right, except for the last line... if he wants it to keep repeating over and over, he only needs a regular JR back to Keyloop.  The reason your JR Z wouldn't work as well is that if the Zero flag was set, it would have already jumped to 'DWN' (the flags don't get restored after conditional JR's).  If you wanted to specifically check if there was no key pressed, you would have to do this:
	CP 0
(or more efficiently, and to the same effect)
	AND A
(or equivilantly to AND A)
	OR A
then the zero flag will be set according to the contents of A (Z if it's 0, NZ if it's not Z)

	Got that?  (Sorry scoobie ;)
	Sam
-- 
Sam Davies <sdavies@mail.trilogy.net>


Follow-Ups: