assembly - Optimizing comparison instruction count (PDP-11) -


for pdp-11, how can change following snippet of assembly it's 2 instructions, yet same work these four?

tst r0 blt label cmp r0, #75 bgt label 

i've never worked pdp-11, have experience way testing , branching works on x86 systems, , looks may similar.

on x86 instruction set, "test" instruction equivalent comparison against 0; "less than" flag set if value less 0, etc. i'm going guess #75 means numeric literal in hexadecimal -- 0x75.

if assumptions correct, code have there doing 2 signed comparisons:

  • is (signed) value of r0 less 0?
  • is (signed) value of r0 greater 0x75?

if instead treat unsigned value, -- assuming pdp-11 systems use 2's-complement encoding -- values negative become values greater or equal 0x8000 (since pdp-11 16-bit system). thus, if unsigned comparison, checking against 0x75 take care of negative values well; smallest possible value becomes 0, acceptable tests here.

i'm not sure whether unsigned comparison on pdp-11 different comparison opcode or different flag, i'm sure can figure part out. :-)


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -