@ My second ARM assembly program! .syntax unified .code 16 .thumb_func .globl main main: push {r4, r5, r6, lr} @ r0 is argc; r1 is argv. r2-r6 are available; r4-6 are callee-saved. @ So they are suitable for local vars. @ First validate argc. cmp r0, 3 bne fail movs r4, r1 @ argv ldr r0, [r4, #4] @ argv[1] bl atoi movs r5, r0 @ save result ldr r0, [r4, #8] bl atoi movs r1, r5 movs r2, r0 adds r3, r2, r5 @ third arg is sum ldr r0, =format .data format: .asciz "%d + %d = %d\n" .text bl printf movs r0, #0 done: pop {r4, r5, r6, pc} fail: movs r0, #53 b done