좋은 예는 The MASM Forum (posting here)에서 찾아 볼 수 있습니다. 코드는 제 것이 아니지만 전에 이와 비슷한 비트를 작성했습니다.
.XCREF
.NOLIST
INCLUDE \masm32\include\masm32rt.inc
.LIST
;#########################################################################
.CODE
;*************************************************************************
_main PROC
print chr$('Press Esc to Exit'),13,10
jmp short kloop2
kloop1: INVOKE Sleep,40
kloop2: call InKyb
jz kloop1
push eax
cmp ah,0
jz kloop3
push 2020h
jmp short kloop4
kloop3: mov ah,20h
push eax
kloop4: print esp
pop edx
pop eax
push eax
print right$(uhex$(eax),4),13,10
pop eax
cmp eax,1Bh
jnz kloop2
exit
_main ENDP
;*************************************************************************
InKyb PROC
;Polled Keyboard Input - DednDave 8, 2010
;
;This function returns a keystroke in EAX if there is one in the buffer.
;If the buffer is empty, the function returns immediately.
;
;If the keyboard buffer is empty, AH = 0, AL = 0, ZF = 1.
;If the stroke is a regular key, AH = 0, AL = key char, ZF = 0.
;If the stroke is an extended key, AH = extended key, AL = E0h, ZF = 0.
;If the stroke is a function key, AH = function key, AL = 0, ZF = 0.
;
;ECX, EDX are not preserved.
call crt__kbhit
or eax,eax
jz InKyb1
call crt__getch
and eax,0FFh
jz InKyb0
cmp al,0E0h
jnz InKyb1
InKyb0: push eax
call crt__getch
pop edx
shl eax,8
or eax,edx
InKyb1: retn
InKyb ENDP
;#########################################################################
END _main