Hi,
I was trying to get a grip on type conversions in MASM, but my program is always crashing.
I was wondering if somebody can help me out?
include \masm32\include\masm32rt.inc
.data
MyWord Word 123
MyResult Word 4
.code
start:
this proc
mov eax,MyWord
mov MyResult, eax
ret
this endp
call this
printf("MASM: %u\n",MyResult)
printf("\n\n")
exit0:
inkey
exit
end start
Regards,
"this" is a reserved word (see doc), so you must first rename the proc. Also, you start label is placed in such way that the program execution starts with proc "this".
The defined variables does not match the register size (16 bit vs. 32 bit).
regards
Build this with "console assembler and link"
; ------------------------------
include \masm32\include\masm32rt.inc
; ------------------------------
.data
MyWord DWORD 123
MyResult DWORD 4
.code
; ------------------------------
start:
call thisproc
printf("MASM: %u\n",MyResult)
printf("\n\n")
inkey
exit
; ------------------------------
thisproc proc
mov eax,MyWord
mov MyResult, eax
ret
thisproc endp
; ------------------------------
end start
Thanks Hutch, Thanks qWord, I managed with this :biggrin: Have to learn visit the masm32 compilers debugger, instead of VS code.
Is this a misconception with the register size, it looks more like a 32/64 mismatch, right?
I came up with this,
include \masm32\include\masm32rt.inc
.data
MyWord DWord 123
MyResult DWord 4
.code
Module1 proc
mov eax,MyWord
mov MyResult, eax
ret
Module1 endp
start:
call Module1
printf("MASM: %u\n",MyResult)
printf("\n\n")
exit0:
inkey
exit
end start
From the reversed order of your code, it looks like you used to write code in TASM. There is no reason to do this in masm.
Ever heard of a program called SynthMaker (https://www.google.nl/search?q=synthmaker+assembler&client=firefox-b-ab&dcr=0&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjtiPKCm9fWAhXLExoKHUlyDOMQ_AUICigB&biw=1920&bih=971#imgrc=_)?
word=16 bits
dword=32 bits its 16/32 bit mismatch
qword=64 bits