// Wave-6 slice 6-assembler: branch group (loop/loope/loopne, jrcxz/jecxz,
// short jcc, call rel32, jcxz) — encoder expansion group
// Expected exit code: 42
section .text
global main

add_seven:
    add eax, 7
    ret

main:
    xor eax, eax
    ; loop: count down from 10, eax += 1 each time
    mov ecx, 10
count_loop:
    add eax, 1
    loop count_loop        ; 10 iterations -> eax = 10
    cmp eax, 10
    jne fail
    ; call rel32 through a local function
    call add_seven         ; eax = 17
    ; jrcxz: rcx is 0 here -> taken
    jrcxz rcxz_taken
    jmp fail
rcxz_taken:
    add eax, 9             ; eax = 26
    ; short forward jump (rel8)
    cmp eax, 26
    je short_target
    jmp fail
short_target:
    add eax, 16            ; eax = 42
    ret
fail:
    mov eax, 1
    ret
