Advertisement
MichaelPetch

getkeyh.asm

Aug 10th, 2020 (edited)
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ; Assemble with nasm -f bin getkeyh.asm -o getkeyh.com
  2.  
  3. GetKeyH:
  4. push bp
  5. mov bp, sp
  6. les bx, [bp+6] ; ES:BX = address of variable to return value in
  7. ; [bp+0] is where BP was pushed
  8. ; [bp+2] is where the 32-bit far return address is
  9. ; [bp+6] is where last parameter is
  10. ; Parameters are pushed on stack left to right
  11. ; like pascal calling convention.
  12.  
  13. in al,60h ; Get scancode from keyboard
  14. xchg dx,ax
  15. xor ax,ax ; assume no key (AX=0)
  16. test dl,10000000b ; is it key up event?
  17. jnz short getkeyhD ; if it is return 0 (in AX)
  18. mov al, dl ; Otherwise keydown, AX = scan code
  19. getkeyhD:
  20. mov [es:bx], ax ; Update variable with scancode so BASIC can read it.
  21. pop bp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement