我有麻烦的“XXXXXXX”搞清楚了这一点的第一个两个部分一点点我有如何操作位汇编语言MIPS32
add $t0, $v0, $0 # $t0 gets copy of input x
sub $t1, $0, $t0 # $t1 gets mask1 that is "-x"
,但其余的我感到困惑。我不想要一个确切的答案,但一个解释将非常有帮助!
UPDATE:
我能够使它发挥作用。这是解决方案。谢谢!
**move $t0, $v0** # $t0 gets copy of input x
**sub $t1, $zero, $t0** # $t1 gets mask1 that is "-x"
li $v0, 1
move $a0, $t0
syscall
li $v0, 4
la $a0, outLab1
syscall # print output label 1
li $v0, 1
**and $a0, $t0, $t1** # $a0 gets "all bits of x cleared except the
rightmost 1"
syscall
not $t2, $a0 # $t2 gets mask2 that is "$a0 with all its bits
toggled"
li $v0, 4
la $a0, outLab2
syscall # print output label 2
li $v0, 1
**and $a0, $t0, $t2** # $a0 gets "all bits of x with the rightmost 1
cleared"
syscall
li $v0, 10 # exit
syscall