Comparison Instruction Number Optimization (PDP-11)
I've never worked with a PDP-11, but I have some experience with how testing and branching works on x86 systems and it looks like it might be similar.
In the x86 instruction set, the "test" instruction is equivalent to comparison with 0; the "less" flag is set if the value is less than 0, and so on. I'm going to assume that # 75 means a numeric literal in hexadecimal format - 0x75.
If my assumptions are correct, the code you have is doing two signed comparisons:
- Is the (signed) r0 value less than 0?
- Is the (signed) r0 value greater than 0x75?
If you treat it as an unsigned value instead , then - assuming PDP-11 systems use layer 2 appended encoding - values that were negative become values greater than or equal to 0x8000 (since the PDP-11 is 16- discharge system). Thus, if you do an unsigned comparison, checking for 0x75 will also take care of negative values; the smallest possible value becomes 0, which is acceptable for the tests here.
I'm not sure if unsigned comparison on PDP-11 is a different comparison comparison code or a different flag, but I'm sure you can understand this part. :-)
a source to share