General > The Campus

Any version of my program not flying

(1/2) > >>

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?


--- Code: ---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

--- End code ---

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

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,

--- Code: ---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

--- End code ---

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.

Navigation

[0] Message Index

[#] Next page

Go to full version