flat assembler
Message board for the users of flat assembler.

Index > Main > [help needed] Converting MASM to FASM.

Author
Thread Post new topic Reply to topic
SomeoneNew



Joined: 12 Aug 2006
Posts: 54
SomeoneNew 09 May 2008, 12:59
Hello, I need help converting the following line to FASM:

Code:
add eax,((OFFSET @SendDta - OFFSET @ThreadSendDta) + SIZEOF DWORD)    


(you guys thought I was going to post a humongous source didn't you Very Happy)

SendDta and ThreadSendDta are labels in the source.

I have a few other lines using OFFSET too, I just don't know how to port it into FASM, any help will be appreciated.

Thanks.

-edit-

It seems as if I can't port this preprocessor statement either:

Code:
.IF edx!=0
       inc ax
.ENDIF    


I tried the following:

Code:
if edx <> 0
      inc ax
end if    


But I get "invalid value" as error.

-edit-

_________________
Im new, sorry if I bothered with any stupid question Smile
Post 09 May 2008, 12:59
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4019
Location: vpcmpistri
bitRAKE 09 May 2008, 13:31
add eax,@SendDta - @ThreadSendDta + 4

on the later piece you want to use .if/.endif

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 09 May 2008, 13:31
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 09 May 2008, 13:52
Make sure you have included "if.inc" (win32ax.inc will automatically include it), and use lower case for .if/.endif like bitRAKE mentioned.
Post 09 May 2008, 13:52
View user's profile Send private message Visit poster's website Reply with quote
SomeoneNew



Joined: 12 Aug 2006
Posts: 54
SomeoneNew 09 May 2008, 13:56
I tried doing add eax,SendDta - ThreadSendDta + 4 and sure it works (apparently) but the point is, I don't like to hard-code values such as that, even if DWORD is a constant 4 bytes :/

what bitRAKE suggested (with the @) gives me undefined symbol error, any ideas? - again, they are labels.

thanks Smile
Post 09 May 2008, 13:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 09 May 2008, 14:03
How did you define the symbols? If you define them with a @... then you must also reference them with the @.

Are SendDta and ThreadSendDta structures? If so how are you defining them? Are you using the fasm macro struct or the assembler struc (note the trailing t, is it there or not)? IIRC the fasm macro struct will also define sizeof.SendDta and sizeof.ThreadSendDta.
Post 09 May 2008, 14:03
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4019
Location: vpcmpistri
bitRAKE 09 May 2008, 14:20
SomeoneNew wrote:
I tried doing add eax,SendDta - ThreadSendDta + 4 and sure it works (apparently) but the point is, I don't like to hard-code values such as that, even if DWORD is a constant 4 bytes :/
You have to answer the question "What is the (4)?" in order to abstract out the (4) because a DWORD is aways 4 bytes in x86.

Let us pretend it is a pointer:
Code:
virtual at 0
  POINTER rd 1
  POINTER.bytes = $-POINTER
end virtual

add eax,SendDta - ThreadSendDta + POINTER.bytes    
Just change the definition to suit your needs.

Maybe adding a comment to the code line is sufficient?

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 09 May 2008, 14:20
View user's profile Send private message Visit poster's website Reply with quote
SomeoneNew



Joined: 12 Aug 2006
Posts: 54
SomeoneNew 09 May 2008, 14:54
Hi, thanks Smile

The symbols are actually labels in the code, I defined them without the @ so my bad for asking (I become even dumber after 24hs of straight coding).


I see theres no need to use PTR or OFFSET in FASM because its got a cleaner syntax, right?. I got confused at first but now its crystal clear!

_________________
Im new, sorry if I bothered with any stupid question Smile
Post 09 May 2008, 14:54
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4019
Location: vpcmpistri
bitRAKE 10 May 2008, 01:02
SomeoneNew wrote:
I see theres no need to use PTR or OFFSET in FASM because its got a cleaner syntax, right?. I got confused at first but now its crystal clear!
Seems like you understand. FASM syntax is very straight forward. I forgot who said it, but one person remarked that it took them longer to learn MASM syntax then it did to learn x86 assembly, lol. FASM really matches the architecture without bringing baggage from other languages or legacy architectures that existed prior to x86. I used TASM, then NASM, and then MASM for years (worked really hard to convince myself it was the right language for Windows programming in x86). I've got my problems with FASM, but it's the closest to perfect for me and the source is available.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 10 May 2008, 01:02
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 24 May 2008, 22:14
You could also try JWasm, a fork of OpenWatcom's assembler that's intended to have better MASM support.
Post 24 May 2008, 22:14
View user's profile Send private message Visit poster's website Reply with quote
ic2



Joined: 19 Jan 2008
Posts: 75
ic2 25 May 2008, 04:45
Just FYI... When I finally try FASM seriously, I had tranlanted years of MASM basic coding to POASM than this year I hit FASM. Lucky me, most of my project was FASM ready becaause of that... POASM is really something special and I hope no one of MASM ever overlook that fact.
Post 25 May 2008, 04:45
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.