From 8616ae10ece9f145fe47ce414eac16f1ef072e54 Mon Sep 17 00:00:00 2001 From: Maxime Vorwerk Date: Tue, 11 Jun 2024 15:59:05 +0200 Subject: [PATCH] ARMssembly 2 --- ARMssembly_2/chall_2.S | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 ARMssembly_2/chall_2.S diff --git a/ARMssembly_2/chall_2.S b/ARMssembly_2/chall_2.S new file mode 100755 index 0000000..236b835 --- /dev/null +++ b/ARMssembly_2/chall_2.S @@ -0,0 +1,57 @@ + .arch armv8-a + .file "chall_2.c" + .text + .align 2 + .global func1 + .type func1, %function +func1: + sub sp, sp, #32 + str w0, [sp, 12] + str wzr, [sp, 24] + str wzr, [sp, 28] + b .L2 +.L3: + ldr w0, [sp, 24] + add w0, w0, 3 + str w0, [sp, 24] + ldr w0, [sp, 28] + add w0, w0, 1 + str w0, [sp, 28] +.L2: + ldr w1, [sp, 28] + ldr w0, [sp, 12] + cmp w1, w0 + bcc .L3 + ldr w0, [sp, 24] + add sp, sp, 32 + ret + .size func1, .-func1 + .section .rodata + .align 3 +.LC0: + .string "Result: %ld\n" + .text + .align 2 + .global main + .type main, %function +main: + stp x29, x30, [sp, -48]! + add x29, sp, 0 + str w0, [x29, 28] + str x1, [x29, 16] + ldr x0, [x29, 16] + add x0, x0, 8 + ldr x0, [x0] + bl atoi + bl func1 + str w0, [x29, 44] + adrp x0, .LC0 + add x0, x0, :lo12:.LC0 + ldr w1, [x29, 44] + bl printf + nop + ldp x29, x30, [sp], 48 + ret + .size main, .-main + .ident "GCC: (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0" + .section .note.GNU-stack,"",@progbits