0

私は問題を解決しようとしていますが、最初はrol命令をテストしていて、テストが正しくない非常にばかげたことをしていると確信しています。

ここにスニペットがあります:

    li $t0, 101 ## our data 
    li $t1, 32 ## our loop because we will rotate 32 times later
loop: 
    ## whatever the bit is, just print it or put it inside the asciiz
    ## and print it later, after we finish rotating,
    ## so we rotate starting with the first bit,
    ## and we put it as the first bit lsb

    ## first we rotate##
    rol $t2, $t0, 1 ## rotate and store the new rotated inside $t7
    and $t3, $t2, 1 ## now we AND to check our lsb if it one or not

    li $v0, 1
    move $a0, $t3 ## Print the result of AND
    syscall

私が基本的にやろうとしているのは、私の MSB をt0LSB に回転させ、それを 1 と AND することです。しかし、私が得ているのは常に 0 です。

誰かが私の間違いとそれを修正する方法について教えてくれることを願っています.

4

2 に答える 2

0

loopあなたのコードにはジャンプがありません。ループはどのように実行できますか?

ラベルの下のコード全体loopがループ コンテンツである場合、結果を $t0 に保存せずに回転しているため、ループは常に戻ります(101 rol 1) and 1

li $t0, 101 ## our data
## where did you store the new rotated value to $t0? If not, it's always 101
rol $t2, $t0, 1 ## $t2 = $t0 rol 1 = 101 rol 1 = 202
and $t3, $t2, 1 ## $t3 = $t2 and 1 = 202 and 1 = 0
于 2013-10-28T01:26:07.243 に答える