我认为在具体示例中很容易解释,我理解 beq 的工作方式类似于 if r9==r10 该语句调用显示在同一行的标签,但我不完全理解其他人。
开始:.word 0 .word INSTR1:.word 1 .word 77 .word INSTR2 INSTR2:.word 2 .word 15 .word FIN:.word 3
acc:
.word 0
.text
.global main
main: movia r8, START
movia r9, acc
myloop: movi r10, 1
ldw r11, 0x0(r8)
beq r11, r0, clear
beq r11, r10, add
addi r10, r10, 1
beq r11, r10, sub
addi r10, r10, 1
beq r11, r10, exit
br fail
clear: stw r0, 0x0(r9)
ldw r8, 0x4(r8)
br myloop
add: ldw r12, 0x0(r9)
ldw r13, 0x4(r9)
addi r12, r12, r13
stw r12, 0x0(r9)
ldw r8, 0x8(r8)
br myloop
sub: ldw r12, 0x0(r9)
ldw r13, 0x4(r9)
sub r12, r12, r13
stw r12, 0x0(r9)
ldw r8, 0x8(r8)
br myloop
exit: ret
fail: movia r12, 0xFFFFFFFF
stw r12, 0x0(r9)
ret