Re: A83: Does this have any problems


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

Re: A83: Does this have any problems




> > There is no "ld a,a+1", if you want to add 1 to a, then do "inc a"..
> > There's also no 'z' register so you cannot do "ld z,255"
> 
>   What do you mean inc a, does that add one to a?  And how do I get it to do
> jp z, lbl, what is z set at?

Yes, "inc a" adds 1 to a, and "dec a" subracts one from a.

jp z, lbl will jump to "lbl" is the zero flag is set ..  the zero flag
is set/cleared when an arithmetic operation is done .. such as "add" or
"sub".. or when a "cp" or a few other operations are done ...

"cp" just means compare -- "cp 5" compares the 'a' register to 5 by
subracting 5 from it...  if the result of that subraction is zero, then
the zero flag is set, otherwise the zero flag is cleared..

So .. 

	ld a,5
	cp 10
	jp z,TestLabel

Would jump to TestLabel if 5 minus 10 equals zero .. or basically, if 5
equals 10 .. Which it obviously doesn't ..  If you replaced the "jp
z,TestLabel" with "jp nz,TestLabel" it would jump to TestLabel if 5 is
not equal to 10 ..  "jp c,TestLabel" would jump to TestLabel if 10 is
greater than 5 .. and "jp nc,TestLabel" would jump to TestLabel if 5 is
greater than or equal to 10 ..


References: