Re: A82: i gots a kwestun 4 yous people
[Prev][Next][Index][Thread]
Re: A82: i gots a kwestun 4 yous people
>is there any way to detect a register overflow (like "jr o, label") with
>the z80? it could really help if there was an instruction... else, is
>there a simple routine i can use?
If you are adding, the flag you are looking for is Carry. All adds on a
Z80 are 17 bits long (or 9 if you're doing an 8 bit add). Carry is the
highest bit.
Let's consider adding FFFF + FFFF, a combination bound to overflow.
1111 1111 1111 1111
+ 1111 1111 1111 1111
-----------------------
1 1111 1111 1111 1110
^ ^-----------------^
| destination reg
carry flag
The one is "carried" past the destination, so it represents overflow.
For an add, the instruction you want is "jr c, label".
-- Barubary
Follow-Ups: