Re: A83: Boolean operators


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

Re: A83: Boolean operators



The question isn't that bad!! Ok, look there are various flags on the Z80: the Zero flag and the Carry flag! I think you know how the zero flag works... So I can tell you, the Carry flag is just the same! Let's say you got a number in a and another number in b. You want to compare them:

   ld a,FirstNumber
   ld b,SecoundNumber
   cp b				; compare a with b
   jp z,they_are_the_same	; if a-b=0 goto they_are_the_same
   jp c,a_is_smaller_than_b	; if a-b produces an overflow --> b > a --> a-b= -c then jp
a_is_higher_than_b:		; ...

So you see, it's pretty logical, the carry-flag is just like having 9 bits instead of 8, that means if you add (or substract) a value to another and there is not enough "space" in a 8 bit register, the 9th bit (= the carry flag) will also be set. You have to know, that the cp substracts the accumulator form the value after cp. Afterwards it resets the accumulater to the value it had before.
You see, this is as simple as possible(, because the Processor can't do wonders in algebra like us, humens).
Greez
	Sebastian

P.s.: I also had such problems when I stated of whith ASM. This methode can be used also by other operators!

Frank Schoep[SMTP:dsfs98@concepts.nl] wrote:

OK, I might be going for The Worst Question Ever Asked on ASM83 (tm), but I need to know the following:

how can you check if a number is larger than another (I only need to know how to do this with 8 bit numbers.)? Is there a way to load the 1st number in the accumulator and cp/and/or/xor/rr/slr/sla/rl it with another number to do this?

Please let me know...

Frank
Warning
Could not process part with given Content-Type: application/ms-tnef