CRACK Solution
Magic Sum
CRACK byte-sum checksum

Prerequisites
Unlocks
HACK
Techniquebyte-sum checksum
Rulenonzero
SampleHACK
Walkthrough
Recover the accepted input below, then submit it to the CRACK verifier.
Reject Samples
- HAC
- HACKX
- AAAA
- ZZZZ
- GACK
Verifier Listing
; z1_sum_target: Magic Sum. No per-character compare: the routine sums all four
; input bytes and checks the 16-bit total against a magic constant 279 (0x117).
; Find four uppercase letters whose ASCII codes sum to the target.
; r0 = 1 on accept (nonzero rule).
;
; The target 279 exceeds one byte, so the running total is kept by hand as a
; high/low pair: r4 = high byte (carry count), r3 = low byte. Each add that wraps
; (new sum < the digit just added) bumps the carry. Expected: high=1, low=0x17.
; "HACK": 72+65+67+75 = 279. Length must be 4. Answer: HACK
len r1
cmp r1, 4
jnz bad ; length must be exactly 4
mov r3, 0 ; low byte of the running total
mov r4, 0 ; high byte (carry count)
mov r7, 0 ; index 0..3
loop: cmp r7, 4
jge final
ldb r0, [r7] ; r0 = input[r7]
add r3, r0 ; low += byte (wraps mod 256)
cmp r3, r0 ; if the new low is below the byte we added, it wrapped
jge nocar
inc r4 ; carry into the high byte
nocar: inc r7
jmp loop
final: cmp r4, 1 ; high byte of 279 is 1
jnz bad
cmp r3, 0x17 ; low byte of 279 is 0x17 (23)
jnz bad
mov r0, 1
ret
bad: mov r0, 0
ret