Advertisement
MichaelPetch

getkeyh.asm masm

Aug 11th, 2020 (edited)
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. ; Assemble and link with Turbo Assembler to getkeyh.com file with:
  2. ; tasm getkeyh.asm
  3. ; tlink /t getkeyh
  4. ;
  5. ; You can use JWASM a MASM clone available on MacOS/Linux/Windows to
  6. ; build getkeyh.com . You can use:
  7. ; jwasm -bin -Fo=getkeyh.com -0 getkeyh.asm
  8. ;
  9. ; -0 generates code that can run on 8088/8086 processors
  10. ; -1 for 186+ processors
  11. ; -2 for 286+ processors
  12. ;
  13. ; MASM 6.0+ and Segmented Linker LINK.EXE (5.60) can generate getkeyh.com:
  14. ; masm getkeyh.asm;
  15. ; link /t getkeyh,getkeyh.com;
  16. ;
  17. ; MASM5.x doesn't support ".model tiny" you have to use ".model small"
  18. ; and use LINK.EXE 5.60:
  19. ; masm getkeyh.asm;
  20. ; link /t getkeyh,getkeyh.com;
  21.  
  22. .model tiny ; We will generate a COM file
  23.  
  24. .code
  25. org 100h ; COM Programs have an ORG 100h
  26.  
  27. GetKeyH PROC
  28. push bp
  29. mov bp, sp
  30. les bx, [bp+6] ; ES:BX = address of variable to return value in
  31. ; [bp+0] is where BP was pushed
  32. ; [bp+2] is where the 32-bit far return address is
  33. ; [bp+6] is where last parameter is
  34. ; Parameters are pushed on stack left to right
  35. ; like pascal calling convention.
  36.  
  37. in al,60h ; Get scancode from keyboard
  38. xchg dx,ax
  39. xor ax,ax ; assume no key (AX=0)
  40. test dl,10000000b ; is it key up event?
  41. jnz short getkeyhD ; if it is return 0 (in AX)
  42. mov al, dl ; Otherwise keydown, AX = scan code
  43. getkeyhD:
  44. mov es:[bx], ax ; Update var with scancode so Turbo Basic can read it
  45. pop bp ; Do not use `RET`, Turbo Basic will return for us
  46. GetKeyH ENDP
  47.  
  48. END GetKeyH ; Entrypoint is GetKeyH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement