I have a very simple program where I've stored a number in a dw
variable called asciiCode
. I want to then use the print
macro declared in masm32rt.inc
to print the ASCII character represented by this value, A
, but attempting to do this crashes the program:
.386
option casemap:none
include \masm32\include\masm32rt.inc
.data
asciiCode dw 65
.code
start:
print asciiCode
exit
end start
The program still crashes when asciiCode
is declared as a db
or dd
.
Is there another function that I must use first to convert this dw
into a printable ASCII character?
The simplest way might be to use the printf
macro:
; prints 65. If you want the character A instead, use the format specifier %c
printf("%d", asciiCode)
You should probably declare asciiCode
using dd
in this case - dw
gives you a word, not a dword.