%define _START _main

        extern _getchar
        extern _putchar
        extern _exit
        extern _fflush

%macro EXIT_ 0
        push 0 ; return code 0
        call _exit
%endmacro

%macro GETCHAR 0
        call _getchar
        cmp  eax, -1
        jne  L0
        mov  ebx, 1
        mov  edx, eof_reached
        mov  [edx], ebx
        ret
L0:
        and  eax, 255 ; mask out char value
%endmacro

%macro PUTCHAR 0
        mov  eax, [edi]
        push eax
        call _putchar
        add  esp, 4
        xor  eax, eax 
        push eax
        call _fflush
        add  esp, 4
%endmacro

