         .386
         .model flat,stdcall
          option casemap:none      ; различаем регистр символов
          include \masm32\include\windows.inc
          include \masm32\include\user32.inc
          include \masm32\include\kernel32.inc
          include \masm32\include\masm32.inc
          includelib \masm32\lib\user32.lib
          includelib \masm32\lib\kernel32.lib
          includelib \masm32\lib\masm32.lib
         .data
conTitle    DB 	"Assembler console appplication",0
mes         DB 	"Hello, Wolrd!",0
len_mes     EQU	 $-mes
readBuf     DB  ?
lenReadBuf  DD 1
hStdIn      DD  0
hStdOut     DD  0
chrsRead    DD  0
chrsWritten DD  0

STD_INP_HNDL  DD -10
STD_OUTP_HNDL DD -11

         .code
start:   call AllocConsole
         test EAX,EAX
         jnz   ex
         push offset conTitle
         call SetConsoleTitleA
         test EAX,EAX
         jz   ex
         call  getout_hndl
         call  getinp_hndl
         push  EBX
         mov   EBX,offset mes
         mov   ECX,len_mes-1
         call  write_con
         pop   EBX
         call  read_con
ex:      push  0
         call  ExitProcess

getout_hndl proc
         push  STD_OUTP_HNDL
         call  GetStdHandle
         mov   hStdOut,EAX
         ret
getout_hndl endp

getinp_hndl proc
         push  STD_INP_HNDL
         call  GetStdHandle
         mov   hStdIn,EAX
         ret
getinp_hndl endp

write_con proc
         push  0
         push  chrsWritten
         push  ECX
         push  EBX
         push  hStdOut
         call  WriteConsoleA
         ret
write_con endp

read_con proc
         push  0
         push  chrsRead
         push  lenReadBuf
         push  offset readBuf
         push  hStdIn
         call  ReadConsole
         ret
read_con endp
         end   start 
