format PE console
entry @start

STD_OUTPUT_HANDLE    = $0FFFFFFF5
FOREGROUND_RED	     = $0004
FOREGROUND_INTENSITY = $0008

section '.flat' readable writeable executable
@start:
    pushd STD_OUTPUT_HANDLE
    call [GetStdHandle]
    mov [output_handle], eax

    pushd FOREGROUND_RED or FOREGROUND_INTENSITY
    pushd eax
    call [SetConsoleTextAttribute]

    mov edi, $0FFFFFFFF
    xor ebx, ebx
@timer:
    call [GetTickCount]
    sub eax, ebx
    cmp eax, $0FA
    jl @timer

    inc edi
    add eax, ebx
    mov ebx, eax

    xor ecx, ecx
@@:
    mov [_buf+ecx], $20
    inc ecx
    cmp ecx, edi
    jl @b

    push edi

    mov esi, _hello
    lea edi, dword[_buf+edi]
    call @lstrcpy

    pop edi

    mov esi, _buf
    call @lstrlen

    pushd 0
    pushd 0
    pushd ecx
    pushd _buf
    pushd [output_handle]
    call [WriteConsoleA]

    cmp edi, $41
    jl @timer

    xor eax, eax
    retn
;---

@lstrlen:
    mov ecx, esi

@@:
    lodsb
    or al, al
    jnz @b
    dec esi
    xchg ecx, esi
    sub ecx, esi
    retn
;---

@lstrcpy:
    mov ecx, esi

@@:
    lodsb
    or al, al
    jnz @b
    xchg ecx, esi
    sub ecx, esi
    rep movsb
    retn
;---

_hello db 'namit is my name', 13, 0
_buf rb 128

output_handle dd ?
;---

data import
dd 0, 0, 0, RVA _kernel32, RVA @kernel32
dd 0, 0, 0, 0, 0

_kernel32 db 'kernel32.dll', 0

;kernel32
_GetStdHandle dw 0
    db 'GetStdHandle', 0
_WriteConsoleA dw 0
    db 'WriteConsoleA', 0
_GetTickCount dw 0
    db 'GetTickCount', 0
_SetConsoleTextAttribute dw 0
    db 'SetConsoleTextAttribute', 0

@kernel32:
    GetStdHandle dd RVA _GetStdHandle
    WriteConsoleA dd RVA _WriteConsoleA
    GetTickCount dd RVA _GetTickCount
    SetConsoleTextAttribute dd RVA _SetConsoleTextAttribute
    dd 0
end data
;---

;bye