From d7a311c06e4ae9f4b7830cacd18f2cde19769542 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Sun, 9 Feb 2025 19:41:52 +0200 Subject: [PATCH] lab2: add formula v2 calculation --- lab1_v2.S | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lab1_v2.S b/lab1_v2.S index e3377eb..8d1d386 100644 --- a/lab1_v2.S +++ b/lab1_v2.S @@ -8,6 +8,10 @@ bkpt 0xAB .endm +#define A 0x0321 +#define B 0x7005 +#define C 0x0050 + .section .text lab1_v2: @@ -16,8 +20,42 @@ lab1_v2: mov r0, #2073 bl int_to_str + ldr r0, =2473005196 + bl int_to_str + + bl calculate_formula_v2 + bl int_to_str + 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: mov r3, sp @@ -45,7 +83,6 @@ int_to_str: cmp r0, #0 bne proceed_with_conversion - finish: BKPT_WRITE r3 mov pc, lr