flat assembler
Message board for the users of flat assembler.

Index > Windows > Translation, Mast to Fasm questions

Author
Thread Post new topic Reply to topic
shack



Joined: 19 Sep 2009
Posts: 6
shack
I am studying with the well-known Izcelion's tutorial,I just finished 1/3 of it,so I am a noob.
I like the tutorial itself but I don't like "ADDR" and "OFFSET". So I am trying to switch to another assembler that is FASM. Now I need to translate the code in the tutorial from MASM to FASM and need your help.

There is a code like this in the tutorial,in which MASM is used.

Code:
proc WinMain hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
  LOCAL wc:WNDCLASSEX
     LOCAL msg:MSG
   LOCAL hDlg:HWND
 mov   [wc.cbSize],SIZEOF WNDCLASSEX
 ......
    

Question(1)
I found that "HINSTANCE" is not defined in FASM. I typed just "DWORD" then I could move on,but why this?
I searched through all the INC file in the fasmw directory but I couldn't find a word "HINSTANCE", so I thought it's not defined.But is it defined somewhere else?
Or is this because the creator of FASM thought all these things(HINSTANCE,LPSTR,etc ) unnecessary and useless?(Actually I thought this useless cuz this makes things complicated for a noob like me)
Or is this because FASM is under construction?
Or am I supposed to use windows.inc of the MASM for FASM somehow? but is this possible? I typed >>include "windows.inc" , but got an error.
"include file created with l2extia.exe as they require
error : invalid argument."




Question(2), is about "LOCAL".
How should I rewrite the "LOCAL wc:WNDCLASSEX" ?
I am told "error: illegal instrucion."




Question(3),
In the tutorial, there are sections ".data" and ".data?" .
As far as I learned from examples on this site, ".data" should be like this

section ".data" data readable writeable

then how about ".data? " ?
Or is it unnecessary to make 2 sections for .data and .data? because FASM is going to automatically allocate memory cleverly? I found in an example on this site that uses a same section for intialized and unintialized data.





Question(4),
What is "format PE GUI 4.0"?
I found this in a sample.
What does this mean,expecially "4.0"?
Is this equal to ".386" or ".486" or soething ike that in the MASM?


Thanks for reading, I am stuck! plz help!
Code:
    
Code:
    
Post 19 Sep 2009, 23:32
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
There are FASM versions somewhere. I'll look for them and edit when I find them.

EDIT: Ok, try this.

_________________
----> * <---- My star, won HERE
Post 19 Sep 2009, 23:41
View user's profile Send private message Reply with quote
shack



Joined: 19 Sep 2009
Posts: 6
shack
Thanks windwakr, but I can't seem to compile the sulaiman's asm.
All of the scripts cause error when compiled.

Code:
**.asm[82]
    return
error:illegal instrucion.
    

Maybe due to update of FASM itself?
Post 20 Sep 2009, 02:13
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Try changing to ret, those files are quite old.

BTW: Those were converted to FASM by our very own sleepsleep. Maybe he can tell you what needs to be changed to work with modern FASM versions if he sees this.

_________________
----> * <---- My star, won HERE
Post 20 Sep 2009, 02:16
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Hello shack,

Newer conversions for some of them can be found below.

http://nap.koduleht.net/Madis/cache/Iczelion-FASM/
Post 20 Sep 2009, 16:45
View user's profile Send private message Reply with quote
shack



Joined: 19 Sep 2009
Posts: 6
shack
Hello Picnic, and thank you.
This one looks better to me than Sulaiman's translation.
It uses locals directive which simply answers my question(2).
LOCAL in MASM is perhaps "locals" in FASM... maybe.

And some of the scripts in Sulaiman's don't work as I expected
even when compiled without an error.

But all samples encluding the above translation,don't make a section for unintialized data.
Why? there is no assembler directive for making a section for uninitialized data in FASM?
In NASM, .bss is used. This helps reduce the file size because .bss section is not included in the file itself( this is what I learned from a book.).
Post 21 Sep 2009, 00:53
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

Why? there is no assembler directive for making a section for uninitialized data in FASM?

Not completely sure about the other formats but with PE format (fasm is able of producing them without needing a linker), there is no such a thing as ".bss" or ".data?". What you do instead is to make sure that no uninitialized variables are followed by either initialized data and/or instructions in the same section.

For instance, this will be a 2560 bytes executable:
Code:
format pe gui 4.0

section '.text' code readable executable
  ret

section '.data' data readable writable
rb 1024

hello db "hello", 0    


And this one 1536 bytes:
Code:
format pe gui 4.0

section '.text' code readable executable
  ret

section '.data' data readable writable
hello db "hello", 0

rb 1024    
Post 21 Sep 2009, 01:17
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
You could also allocate memory manually.

_________________
Previously known as The_Grey_Beast
Post 21 Sep 2009, 15:22
View user's profile Send private message Reply with quote
shack



Joined: 19 Sep 2009
Posts: 6
shack
Thanks,LocoDelAssembly. I understand that.
Quote:

You could also allocate memory manually.

How? plz?

And what do you think about my question(1)? what I want to know is the reason why they differ in type defintion.

MASM
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwndButton HWND ?
hwndEdit HWND ?


FASM
hInstance dd ?
CommandLine dd ?
hWndButton dd ?
hWndEdit dd ?

I am beggining to think that it's just a persnal preference,but since I am very new to programming, I am not sure. Which is better? Are you FASM users are including custom_windows.inc or just typing "dd"?
Post 23 Sep 2009, 09:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
HINSTANCE, LPSTR, etc. are the HeLLish way of doing things. Assembly is more "bare metal", so everything becomes a dword.
Post 23 Sep 2009, 10:22
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
shack wrote:
Quote:

You could also allocate memory manually.

How? plz?
With VirtualAlloc, free the memory with VirtualFree, or use the Heap functions if you don't want to allocate pages but rather more "high-level" memory: HeapAlloc, HeapFree, etc...

_________________
Previously known as The_Grey_Beast
Post 23 Sep 2009, 16:08
View user's profile Send private message Reply with quote
bkerr



Joined: 04 Oct 2009
Posts: 1
bkerr
Picnic wrote:
Hello shack,

Newer conversions for some of them can be found below.

http://nap.koduleht.net/Madis/cache/Iczelion-FASM/

Thank you for the link. I'm also trying to follow Iczelion's tutorials.
Post 05 Oct 2009, 00:01
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.