我这里有一个简单的程序,它被设置为产生输出,
The value of a is 2005
The value of b is 1959
The value of c is 1
The value of d is 0
The value of (a - b) * (c + d) is 46
我正在寻找优化代码的最佳方法,我正在重复代码!是否可以直接从其他寄存器打印?例如 SWI 0 但对于不在 R0 中的整数?
B main
aval DEFW 2005
bval DEFW 1959
cval DEFW 1
dval DEFW 0
valOf DEFB 'The value of \0'
isStr DEFB ' is \0'
lstStr DEFB 'The value of (a - b) * (c + d) is \0'
ALIGN
main ADR R0, valOf ;Value a
SWI 3
MOV R0, #97
SWI 0
ADR R0, isStr
SWI 3
LDR R0, aval
SWI 4
MOV R0, #10 ;print new line
SWI 0
ADR R0, valOf ;Value b
SWI 3
MOV R0, #98
SWI 0
ADR R0, isStr
SWI 3
LDR R0, bval
SWI 4
MOV R0, #10 ;print new line
SWI 0
ADR R0, valOf ;Value c
SWI 3
MOV R0, #99
SWI 0
ADR R0, isStr
SWI 3
LDR R0, cval
SWI 4
MOV R0, #10 ;print new line
SWI 0
ADR R0, valOf ;print 'value of '
SWI 3
MOV R0, #100
SWI 0
ADR R0, isStr ;
SWI 3
LDR R0, dval
SWI 4
MOV R0, #10 ;print new line
SWI 0
ADR R0, lstStr
SWI 3
LDR R3, aval
LDR R4, bval
LDR R5, cval
LDR R6, dval
SUB R1, R3, R4
SUB R2, R5, R6
MUL R0, R1, R2
SWI 4
SWI 2 ;exit
任何想法都非常感谢:)