Re: Positive negative asm tests


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

Re: Positive negative asm tests



On Sat, 25 Oct 1997 19:06:38 -0600, ilya winham
<ilyamojo@GEOCITIES.COM> wrote:

>I was looking at Greg Parker's (I think) zshell/asm lessons and in it it
>says.
>ld a,number_to_check_if_positive_or_negative
>JUMP_P(aispositive) ;it says these will work?
>JUMP_N(aisnegative) ;Is this true, I have never seen this used before
>
>Please, if those are legal please tell me, they would be very useful!!

Well, since the JUMP_x stuff are macros for the JP instruction, and
since 'jp p,label' and 'jp n,label ' does exist, one would suspect
JUMP_P and JUMP_N to work. However, does instructions aren't
used very often (the zero and carry flag is enough) so the ZShell
authors didn't create macros for those instructions.

Also, the code above would still not work, because the LD instruction
wouln'd set the sign flag.

If you want to check if a number is negative, you type

 ld a,number_to_check_if_positive_or_negative
 bit 7,a  ; Check sign bit
 jr z,a_is_positive
 jr nz,a_is_negative

Jimmy Merdell <mja@algonet.se>
http://www.algonet.se/~mja
IRC: Yarin


References: