; PBXA64 Release Template assembler sample
; Theme: 08_graphics_media
; Focus: raster, audio, and signal processing models
; The leaf routine is suitable for deterministic object compilation.
.code
main PROC
    mov rax, 851
    mov rcx, 29
    imul rax, rcx
    add rax, 870
    xor rax, rcx
    mov rdx, rax
    shl rdx, 3
    shr rdx, 1
    add rax, rdx
    mov r8, 65535
    and rax, r8
    mov r9, 17
sample_loop:
    add rax, r9
    xor rax, rcx
    dec r9
    test r9, r9
    jne sample_loop
    mov r10, rax
    or r10, 1
    and r10, 255
    sub r10, 1
    add rax, r10
    ; Fold a second independent lane back into the return value.  Keeping the
    ; lanes explicit makes this a useful object-code inspection example.
    mov r11, rax
    add r11, rdx
    xor r11, r10
    shr r11, 2
    add rax, r11
    and rax, 1048575
    ret
main ENDP
END
