lab2: add formula v2 calculation
This commit is contained in:
parent
c1f9c00fc6
commit
d7a311c06e
39
lab1_v2.S
39
lab1_v2.S
|
@ -8,6 +8,10 @@
|
||||||
bkpt 0xAB
|
bkpt 0xAB
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
#define A 0x0321
|
||||||
|
#define B 0x7005
|
||||||
|
#define C 0x0050
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
|
|
||||||
lab1_v2:
|
lab1_v2:
|
||||||
|
@ -16,8 +20,42 @@ lab1_v2:
|
||||||
mov r0, #2073
|
mov r0, #2073
|
||||||
bl int_to_str
|
bl int_to_str
|
||||||
|
|
||||||
|
ldr r0, =2473005196
|
||||||
|
bl int_to_str
|
||||||
|
|
||||||
|
bl calculate_formula_v2
|
||||||
|
bl int_to_str
|
||||||
|
|
||||||
pop.n {pc}
|
pop.n {pc}
|
||||||
|
|
||||||
|
calculate_formula_v2:
|
||||||
|
ldr r0, =A
|
||||||
|
ldr r1, =B
|
||||||
|
ldr r2, =C
|
||||||
|
|
||||||
|
cmp r0, r1
|
||||||
|
bgt gret
|
||||||
|
blt less
|
||||||
|
|
||||||
|
same: @ default
|
||||||
|
add r2, r0, r2, lsr #3
|
||||||
|
add r0, r2, r1
|
||||||
|
b finish
|
||||||
|
|
||||||
|
gret:
|
||||||
|
rsb r0, r0, #192
|
||||||
|
sub r0, r0, r1
|
||||||
|
add r0, r2, r0, lsl #2
|
||||||
|
b finish
|
||||||
|
|
||||||
|
less:
|
||||||
|
orr r1, r1, r2
|
||||||
|
mul r0, r0, r1
|
||||||
|
|
||||||
|
finish:
|
||||||
|
mov r10, r0
|
||||||
|
mov pc, lr
|
||||||
|
|
||||||
int_to_str:
|
int_to_str:
|
||||||
mov r3, sp
|
mov r3, sp
|
||||||
|
|
||||||
|
@ -45,7 +83,6 @@ int_to_str:
|
||||||
cmp r0, #0
|
cmp r0, #0
|
||||||
bne proceed_with_conversion
|
bne proceed_with_conversion
|
||||||
|
|
||||||
finish:
|
|
||||||
BKPT_WRITE r3
|
BKPT_WRITE r3
|
||||||
|
|
||||||
mov pc, lr
|
mov pc, lr
|
||||||
|
|
Loading…
Reference in New Issue