Reputation: 1471
In Little Man computer(LMC), the condition Branch on Positive(BRP) includes zero as a positive number( I thought number>0 is positive). I know LMC is a imaginative concept, but I was wondering if any processor (outdated or current ones) uses Branch on positive including zero as positive number?
Upvotes: 0
Views: 4136
Reputation: 350335
BPL Branch if plus (N=0)
...where N is the negative flag (0 or 1), and so it applies when the tested value is not negative.
bpl - branch if pl (positive or zero)
...this includes the 6502:
BPL - Branch if Positive
If the negative flag is clear then add the relative displacement to the program counter to cause a branch to a new location.
Upvotes: 0
Reputation: 1502
Your question asked about specific processors, and the closest I can come is the PDP-8 SPA – Skip on AC ≥ 0. I can describe the rationale for including zero as a positive number. Virtually all modern computers use two's complement format for integers. That makes the leftmost bit the sign bit. Negative numbers have a one in the sign bit, and positive numbers have a zero in the sign bit. The number zero is represented as all zeros, including the sign bit. So, if branch on positive were implemented on a two's complement computer that tested the sign bit, the number zero would be positive.
Alternatively, when Dr. Madnick designed LMC, and also now, calculators do not display a minus sign with the number zero.
That said, I wish Madnick had called it BNN: branch if not negative.
Upvotes: 0
Reputation: 129
BRZ sets instructions to be executed specifically if Branch is Zero, but BRP does count zero as a positive number, so the only way around this is to contradict the BRP instructions with BRZ instructions.
Upvotes: 0