flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem assembly small code

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello,

I'm a totally newbie in FASM (too many years with MASM Smile) and I have a strange issue in a small code snipet. I'm using version 1.64.

This is the code:

---

format MS COFF

include 'win32a.inc'

section '.text' code readable executable

proc MyFunc
local a: DWORD

mov a, eax
ret

endp

mylabel:
call MyFunc

----

When I assemble it I get the error at line:

mov a, eax

The interesting thing is that if I comment the "call MyFunc" it works fine Confused

Any hint about this issue?

Thanks.
Post 05 Jan 2006, 14:35
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Quote:

local a: DWORD

mov a, eax


hi, you should read fasm documentation i think, it explains this and many other things (i know i didnt read it at first either :p)

Code:
mov [a], eax ;now a holds eax
    


"a" by itself, (not in brackets) refers to the address

here are some equivalents
Code:
;in MASM
mov a, eax
;in FASM
mov [a], eax
    


Code:
;in MASM
mov offset a, eax
;in FASM
mov a, eax
    


Quote:

The interesting thing is that if I comment the "call MyFunc" it works fine


i dont know too much about the fasm compiler, since i havn't studied the source very much, but i assume that it will not error because since "MyFunc" is never called, the code in MyFunc is never assembled in runtime so it doesn't matter

also welcome to FASM, imo MASM is kind of crap Smile

_________________
redghost.ca
Post 05 Jan 2006, 15:19
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
If you'd also like to know why after commenting out the call it assembled fine: there's an "if used MyFunc" buried withing the "proc MyFunc" macro, which causes the whole procedure to be skipped (not assembled) when it is not used anywhere else.
Post 05 Jan 2006, 15:33
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks RegGhost, it works now Very Happy

I read about the use of the brackets, but I just copy paste from my MASM code and I got the weird error message and it did not happen when I remove the "call" instruciton. So, I was kind of blind and couldn't see the forest by the trees Smile

Thanks, I also think that FASM is great...I'm just too used to MASM, hence I'm still suffering with FASM learning curve Smile
Post 05 Jan 2006, 15:37
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
RedGhost: BTW.
Code:
;in MASM
mov offset a, eax
;in FASM
mov a, eax    
This is not possible Smile You can copy offset value to eax, not the other way. I guess you meant:
Code:
;in MASM
mov eax, offset a
;in FASM
mov eax, a    
Post 05 Jan 2006, 19:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
He just wanted to show the analogy to explain why "mov a,eax" causes an error in fasm - in the same way as "mov offset a,eax" would cause an error with MASM.
Post 05 Jan 2006, 19:50
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
I thought it was a try to show how to access offsets. If so, the given example was incorrect.
But if it's the way you, Tomasz, say, so I am sorry for misleading anyone
Post 05 Jan 2006, 21:02
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Reverend wrote:
RedGhost: BTW.
Code:
;in MASM
mov offset a, eax
;in FASM
mov a, eax    
This is not possible Smile You can copy offset value to eax, not the other way. I guess you meant:
Code:
;in MASM
mov eax, offset a
;in FASM
mov eax, a    

what Tomasz said Smile, i just wanted to show the equivalents, i do realize it is not correct syntax for either syntax (hmm, does that sound right Very Happy)

_________________
redghost.ca
Post 06 Jan 2006, 13:45
View user's profile Send private message AIM Address MSN Messenger Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks guys for all your posts. I have been these days with FASM and I love it each day even more!!! Very Happy

Tomasz, you did a great work with FASM Wink

Cheers
Post 06 Jan 2006, 23:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.