arm汇编语言实现下列c语言语句 if(a>=b) x=(a+b)*8 ;else y=(a-c)*b;

2024-12-05 10:30:05
推荐回答(1个)
回答1:

GNU汇编语法:
a: .word 1
b: .word 2
c: .word 3
x: .word
y: .word

prog:
ldr r0, =a
ldr r1, [r0]
ldr r0, =b
ldr r2, [r0]
ldr r0, =c
ldr r3, [r0]

cmp r1, r2
bge true
sub r1, r1, r3
mul r1, r1, r2
ldr r0, =y
b end
true:
mov r4, #8
add r1, r1, r2
mul r1, r1, r4
ldr r0, =x
end:
str r1, [r0]