我有麻煩的「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