Author Topic: Any version of my program not flying  (Read 112 times)

Camper

  • Regular Member
  • *
  • Posts: 22
Any version of my program not flying
« 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?

Code: [Select]
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

  • Member
  • *****
  • Posts: 1454
  • The base type of a type is the type itself
    • SmplMath macros
Re: Any version of my program not flying
« Reply #1 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

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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4807
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Any version of my program not flying
« Reply #2 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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Camper

  • Regular Member
  • *
  • Posts: 22
Re: Any version of my program not flying
« Reply #3 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,
Code: [Select]
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--

  • Administrator
  • Member
  • ******
  • Posts: 4807
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Any version of my program not flying
« Reply #4 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Camper

  • Regular Member
  • *
  • Posts: 22
Re: Any version of my program not flying
« Reply #5 on: October 05, 2017, 01:52:31 AM »
Ever heard of a program called SynthMaker?

BugCatcher

  • Regular Member
  • *
  • Posts: 31
Re: Any version of my program not flying
« Reply #6 on: October 05, 2017, 04:18:25 AM »
word=16 bits
dword=32 bits its 16/32 bit mismatch
qword=64 bits