News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Any version of my program not flying

Started by Camper, October 05, 2017, 12:24:18 AM

Previous topic - Next topic

Camper

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,



qWord

"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

MREAL macros - when you need floating point arithmetic while assembling!

hutch--

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

Camper

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



hutch--

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.

Camper


BugCatcher

word=16 bits
dword=32 bits its 16/32 bit mismatch
qword=64 bits