CRACK Solution

Mirror Image

CRACK palindrome check

In-game screenshot of Mirror Image
In-game view
FamilyCRACK Graph0.072 DifficultyTutorial Ring01 IDllama_mirror

Prerequisites

LENGTH RECEIPT

Unlocks

POLARITY

Accepted input RADAR
Techniquepalindrome check Rulenonzero SampleRADAR

Walkthrough

Recover the accepted input below, then submit it to the CRACK verifier.

Reject Samples

  • RADIO
  • ABCDE
  • RADA
  • RADARX
Verifier Listing
; llama_mirror: true palindrome gate. The old version pinned four literal
; bytes, so the answer read straight off the constants (a plain compare wearing a
; "palindrome" label). This loads the input from BOTH ends and compares the pairs,
; so any 5-byte palindrome passes and the player has to see the symmetry rather
; than copy a word out of the disassembly. Technique: palindrome (mirror) check.
; r0 = 1 on accept. Accept rule: nonzero.
;
; sample "RADAR": s[0]==s[4], s[1]==s[3], the middle byte is free.

        len   r1
        cmp   r1, 5
        jnz   bad           ; exactly 5 bytes

        mov   r7, 0
        ldb   r2, [r7]      ; s[0]
        mov   r7, 4
        ldb   r0, [r7]      ; s[4]
        cmp   r0, r2
        jnz   bad           ; ends differ -> not a mirror

        mov   r7, 1
        ldb   r2, [r7]      ; s[1]
        mov   r7, 3
        ldb   r0, [r7]      ; s[3]
        cmp   r0, r2
        jnz   bad           ; inner pair differs -> not a mirror

        mov   r0, 1         ; symmetric -> accept
        ret
bad:    mov   r0, 0
        ret