← Back to archive

Stdle #167 · memory · 2026-11-20

What does this Assembly snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

.global _main
.align 2
_main:
stp x29, x30, [sp, #-32]!
adrp x8, arr@PAGE
add x8, x8, arr@PAGEOFF
mov w9, #0
mov w10, #4
sum_loop:
ldr w11, [x8], #4
add w9, w9, w11
subs w10, w10, #1
b.ne sum_loop
sub sp, sp, #16
str x9, [sp]
adrp x0, fmt@PAGE
add x0, x0, fmt@PAGEOFF
bl _printf
add sp, sp, #16
ldp x29, x30, [sp], #32
mov w0, #0
ret
.section __DATA,__data
.align 2
arr: .long 10, 20, 30, 40
.section __TEXT,__cstring
fmt: .asciz "%d\n"
Memory
4 attempts left

Answer & explanation