PDP-11 の場合、アセンブリの次のスニペットを変更して 2 つの命令だけにする方法を教えてください。
tst r0
blt label
cmp r0, #75
bgt label
I've never worked with a PDP-11, but I have some experience with the way testing and branching works on x86 systems, and this looks like it may be similar.
On the x86 instruction set, the "test" instruction is equivalent to a comparison against 0; the "less than" flag is set if the value is less than 0, etc. I'm going to guess that #75 means a numeric literal in hexadecimal -- 0x75.
If my assumptions are correct, the code you have there is doing two signed comparisons:
If you instead treat it as an unsigned value, then -- assuming PDP-11 systems use 2's-complement encoding -- values that were negative become values greater than or equal to 0x8000 (since the PDP-11 is a 16-bit system). Thus, if you do an unsigned comparison, checking against 0x75 will take care of the negative values as well; the smallest possible value becomes 0, which is acceptable for the tests here.
I'm not sure whether an unsigned comparison on the PDP-11 is a different comparison opcode or a different flag, but I'm sure you can figure that part out. :-)
おそらく宿題には遅すぎるので、答えは次のとおりです。
cmp r0,#75 bcc ラベル; r0 に 75..65535、つまり 75..32767、-32768..-1 が含まれる場合に分岐します。
bcc には bhis のアセンブリ シノニムがあります (HIgher または Same unsigned の場合は分岐)。
比較の結果がより大きいか小さい場合に同じラベルにジャンプしたい場合は、等しくない場合は分岐命令を使用して、2つの命令に絞り込むことができます(なぜなら、!= bの場合、a <b && a> b)、および他の1つの命令。
ヒント:これはテスト命令ではありません。