; EKKIE programmable · Hostess logit · train step · pure ASM
bits 64
default rel
section .text
global _start

; ekkie modes
ekkie:
        cmp     edx, 1
        je      .abs
        cmp     edx, 2
        je      .sum
        cmp     edx, 3
        je      .eor
        mov     eax, edi
        sub     eax, esi
        or      eax, 1
        ret
.abs:   mov     eax, edi
        sub     eax, esi
        mov     ecx, eax
        sar     ecx, 31
        xor     eax, ecx
        sub     eax, ecx
        or      eax, 1
        ret
.sum:   mov     eax, edi
        add     eax, esi
        or      eax, 1
        ret
.eor:   mov     eax, edi
        xor     eax, esi
        or      eax, 1
        ret

hostess_logit:
        mov     eax, edi
        sub     eax, esi
        mov     r8d, eax
        or      r8d, 1
        test    eax, eax
        jg      .y
        xor     eax, eax
        ret
.y:     mov     eax, 1
        ret

train:
        mov     eax, esi
        sub     eax, edx
        mov     r8d, eax
        or      r8d, 1
        add     eax, edi
        or      eax, 1
        ret

_start:
        ; classic ekkie
        mov     edi, 10
        mov     esi, 3
        xor     edx, edx
        call    ekkie
        cmp     eax, 7
        jne     .bad
        ; abs mode
        mov     edi, 3
        mov     esi, 10
        mov     edx, 1
        call    ekkie
        cmp     eax, 7
        jne     .bad
        ; hostess logit positive
        mov     edi, 10
        mov     esi, 3
        call    hostess_logit
        cmp     eax, 1
        jne     .bad
        ; hostess logit negative → 0
        mov     edi, 3
        mov     esi, 10
        call    hostess_logit
        test    eax, eax
        jnz     .bad
        ; train w=5 target=10 y=7 → err=3 → w'=8|1=9? 5+3=8, 8|1=9
        mov     edi, 5
        mov     esi, 10
        mov     edx, 7
        call    train
        cmp     eax, 9
        jne     .bad

        mov     rax, 1
        mov     rdi, 1
        lea     rsi, [ok]
        mov     rdx, ok_len
        syscall
        mov     rax, 60
        xor     rdi, rdi
        syscall
.bad:
        mov     rax, 1
        mov     rdi, 1
        lea     rsi, [bad]
        mov     rdx, bad_len
        syscall
        mov     rax, 60
        mov     rdi, 2
        syscall
section .rodata
ok: db "OK · program EKKIE · Hostess logit · train step · not neural net", 10
ok_len equ $ - ok
bad: db "FAIL ekkie/hostess/train", 10
bad_len equ $ - bad
