Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Assemble and link with Turbo Assembler to getkeyh.com file with:
- ; tasm getkeyh.asm
- ; tlink /t getkeyh
- ;
- ; You can use JWASM a MASM clone available on MacOS/Linux/Windows to
- ; build getkeyh.com . You can use:
- ; jwasm -bin -Fo=getkeyh.com -0 getkeyh.asm
- ;
- ; -0 generates code that can run on 8088/8086 processors
- ; -1 for 186+ processors
- ; -2 for 286+ processors
- ;
- ; MASM 6.0+ and Segmented Linker LINK.EXE (5.60) can generate getkeyh.com:
- ; masm getkeyh.asm;
- ; link /t getkeyh,getkeyh.com;
- ;
- ; MASM5.x doesn't support ".model tiny" you have to use ".model small"
- ; and use LINK.EXE 5.60:
- ; masm getkeyh.asm;
- ; link /t getkeyh,getkeyh.com;
- .model tiny ; We will generate a COM file
- .code
- org 100h ; COM Programs have an ORG 100h
- GetKeyH PROC
- push bp
- mov bp, sp
- les bx, [bp+6] ; ES:BX = address of variable to return value in
- ; [bp+0] is where BP was pushed
- ; [bp+2] is where the 32-bit far return address is
- ; [bp+6] is where last parameter is
- ; Parameters are pushed on stack left to right
- ; like pascal calling convention.
- in al,60h ; Get scancode from keyboard
- xchg dx,ax
- xor ax,ax ; assume no key (AX=0)
- test dl,10000000b ; is it key up event?
- jnz short getkeyhD ; if it is return 0 (in AX)
- mov al, dl ; Otherwise keydown, AX = scan code
- getkeyhD:
- mov es:[bx], ax ; Update var with scancode so Turbo Basic can read it
- pop bp ; Do not use `RET`, Turbo Basic will return for us
- GetKeyH ENDP
- END GetKeyH ; Entrypoint is GetKeyH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement