Home > Enterprise >  How can I get the range of numbers that would produce certain flag conditions when subtracted from 4
How can I get the range of numbers that would produce certain flag conditions when subtracted from 4

Time:04-28

I started learning Z80 recently, but I'm struggling with flags.

I want to get the range of register "B" in Z80 assembly.

This is the problem that I faced. Register "A" is 43H (in Hexadecimal number) and I want to sub register "B" from that, doing in 8-bit subtraction.

How can I get the each range of register "B" that would produce:

  • C Flag becomes 1
  • S flag becomes 1
  • P/V flag becomes 1

CodePudding user response:

67 - x sets C if x >= 0 and x < 68.
It sets S if x > 67 or x < -60.
It sets V if x < -60.

In hexadecimal, 43h - x sets C if x < 44h.
It sets S if x > 43h and x < c4h.
It sets V if x > 7fh and x < c4h.

  • Related