The MASM Forum

General => The Campus => Topic started by: Camper on October 05, 2017, 12:24:18 AM

Title: Any version of my program not flying
Post by: Camper on October 05, 2017, 12:24:18 AM
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,


Title: Re: Any version of my program not flying
Post by: qWord on October 05, 2017, 01:06:40 AM
"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

Title: Re: Any version of my program not flying
Post by: hutch-- on October 05, 2017, 01:21:56 AM
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
Title: Re: Any version of my program not flying
Post by: Camper on October 05, 2017, 01:34:51 AM
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


Title: Re: Any version of my program not flying
Post by: hutch-- on October 05, 2017, 01:37:30 AM
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.
Title: Re: Any version of my program not flying
Post by: Camper on October 05, 2017, 01:52:31 AM
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=_)?
Title: Re: Any version of my program not flying
Post by: BugCatcher on October 05, 2017, 04:18:25 AM
word=16 bits
dword=32 bits its 16/32 bit mismatch
qword=64 bits