简体   繁体   English

MIPS组装中的BNE分支

[英]BNE branch in MIPS assembly

Right now I'm preparing for a test in computer architecture, and being stuck in a task that I don't really understand. 现在,我正在为计算机体系结构的测试做准备,并被困在一个我不太了解的任务中。 * $1=4, $2=2, $3=x Here's the code * $ 1 = 4,$ 2 = 2,$ 3 = x这是代码

LOOP:
ADDI $2,$2-1
SLL $2,$2,2
MULT $3,$1
MFLO $3
SW $3, 0($2)
BNE $2,$1,LOOP

My question is, which value does $2 have after this? 我的问题是,此后,$ 2的值是多少? Is this 4 or 4x? 这是4倍还是4倍?

Maybe it will be clearer if you write it out as ordinary paper math: 如果您将其写成普通的纸上数学,也许会更清楚:

$1  = 4
$2  = 2
$3  = x
LOOP:
$2  = $2 -1
$2  = $2 * 2^2
$lo = $3 * $1
$3  = $lo
"contents of memory address in $2" = $3 
if $2 != $1 GOTO LOOP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM