A macro that waits for a keystroke and returns the key that was pressed. The macro should include parameters for the ASCII code and keyboard scan code.
I have the following code but I am getting two errors. The errors are below with my source code underneath them.
Errors:
error A2006: undefined syV
error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\ch10_01.obj" /Fl"zprob1.lst" /I "c:\Irvine" /W3 /errorReport:prompt /Ta"....\ASM Solutions\ch10\ch10_01.asm"" exited with code 1
Source Code:
INCLUDE Irvine16.inc
ASSUME DS:_DATA
mReadkey MACRO ascii, scan
mov ah,10h ; BIOS keyboard input function
int 16h
mov scan,ah
mov ascii,al
ENDM
.data
ascii BYTE ?
scan BYTE ?
str1 BYTE "ASCII code: ",0
str2 BYTE "Scan code: ",0
.code
main PROC
mov ax,@data
mov ds,ax
; Wait for a key; when the macro returns, the two arguments
; contain the ASCII code and scan code of the key.
mReadkey ascii, scan
; Display the values.
mov edx,OFFSET str1
call WriteString
movzx eax,ascii
call WriteHex
call Crlf
mov edx,OFFSET str2
call WriteString
movzx eax,scan
call WriteHex
call Crlf
exit
main ENDP
END main
You tried to compile a 16-bit real mode code to a 32-bit protected mode executable. That won't work. Add a /omf
to the command line of ml.exe
and ensure that link16.exe
will be used as linker.