flat assembler
Message board for the users of flat assembler.

Index > Heap > There are programs that are possible only with FASM

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Do you agree?

I think it's only possible to build some kinds of programs using FASM, because of how it's designed.
With FASM, what you type is what the executable is. I think it's almost a perfect image of the executable. If I put the resource section at the start of the source, it'll be placed at the start of the executable. I type the code section at the end of the source, it'll be placed at the end of the executable.
Also, with FASM's macros it's possible to write crypted code at assembly time, and put a decryptor routine inside.

I think most of these aren't possible with HLL's and even with assemblers that use linkers, like masm32.
What do you people think?
I think FASM is best tool for programming EVER.
It is as low level as you want and is as high level as you want too, thanks to macros!
Why people still use masm32?
Post 16 Feb 2006, 02:49
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
The people still using masm32 hutch's package maybe because it has a more complete include files than FASM. Today FASM package is powerfull but some time ago I remember that every win32 program I wanted to write was very difficult because of the poor includes files support, so I'd used FASM just for boot code but now I'm very happy with the package. However masm32 package stills having more constants defined
Post 16 Feb 2006, 03:32
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
I have a nice include set at my website you can download:
http://users.egl.net/talktomatt/default.html
Post 16 Feb 2006, 07:25
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
OzzY wrote:
Why people still use masm32?

I'm a masmer, so here are my points why I use MASM:

  1. Debugging informations: AFAIK, there is almost no support of debugging informations in FASM. It is inconceivable to me to debug middle-sized project (100.000 lines) without such informations.

  2. Listing output: I use this output to debug macros. AFAIK, FASM's listing output is still work-in-progress. MASM has this output fully documented and stable.

  3. Readability: FASM uses very cryptic operators like \, ` or #. These make some macros very unreadable. Can you quickly say, for instance, what means the following?
    Code:
    macro pkmov [def]
    {
      common
       mask@pkmov = 0
      forward
       match reg:value, def
       \{ rept 8 i:0
          \\{ if reg in <regs\\#i\\#@pkmov>
               store@pkmov i,reg,value
              end if \\} \}
      common
       rept 8 i:0
       \{ match regs, regs\#i\#@pkmov
          \\{ make@pkmov i,regs \\} \}
    }
        

    I've seen worse macros here, but the search facility can't find such operators.

  4. The future: AFAIK, Thomasz is the only developer of FASM. FASM's sources are poorly commented. What will happen when Thomasz lost his interest in further developing? Or when, by accident, Thomasz will not be able to maintain the project? Or when he will get married and he stops the project because of lacking time? Smile I bet that in such case there will arise more incompatible FASM clones and FASM dies.
    I'm not Microsoft-lover, but it is huge company and its support for MASM is still sufficient.

  5. User-base: FASM has many users, but not so many as MASM.

  6. Macro-language: FASM has really advanced macro language, but MASM is also not so bad at this point.

Correct me if I'm wrong Smile

I was thinking about moving to FASM, but because of the first four points I decided not to.
Post 16 Feb 2006, 10:19
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
1 and 2 seem to be solved soon

3 - these are very special macros, not actual code. I don't know how often you use macros, but these are special things which are almost not needed. And simple macros are nicely readable.

4 - same happened with Fresh & JohnFound and it lives again. Someone would probably take it over... of course that code wouldn't stay so nice then. And after adding symbolic infos, FASM will be kind-of "completed", i think that there will be no need for further upgrades.

FASM code doesn't really need comments, it is "commented" with label names, bigger problem are unnamed internal constants.

btw: I thought that MS stoped MASM support.

5 - this is true

6 - i don't know MASM's macrolanguage, but i don't believe it is so "clearly defined" (predictable) and so powerful as FASM's
Post 16 Feb 2006, 11:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
Let's focus at the most important things for me:
vid wrote:
3 - these are very special macros, not actual code. I don't know how often you use macros, but these are special things which are almost not needed. And simple macros are nicely readable.

I use macros heavily. For some part of my project I defined dedicated language using them.
As for about general concept, look at the following macro declarations. For me, the latter MASM one seems to me more readable. Even though I forgot the macro syntax, words like req or CatStr remind me what is going here. Operators like * or # can't work this way.
Code:
macro jif op1*, cond*, op2*, label*
{
        cmp op1, op2
        j#cond label
}
    

Code:
jif macro op1:req, cond:req, op2:req, label:req
        cmp op1, op2
        @CatStr(<j>, cond) label
endm
    

And what I really dislike is syntax of declaration of macro inside another macro and similar things. It may lead to really unreadable and complicated macro declaration (I mean \\\\{ and similar):
Code:
macro PARSECOND parsed,cond
{
 ...
 \{
   ...
   match >,symb
   \\{
      ...
   \\}
   match <,symb
   \\{
      ...
   \\}
   ...
   match ,current@cond
   \\{
      match ~,symb
      \\\{
          ...
          match ~~,neg@cond
          \\\\{
               ...
          \\\\}
          ...
      \\\}
      match (,symb
      \\\{
          ...
      \\\}
      match any,symb@cond
      \\\{
          ...
      \\\}
   \\}
   match status,current@cond
   \\{
      match &,symb
      \\\{
          ...
      \\\}
      match |,symb
      \\\{
          ...
      \\\}
      match (,symb
      \\\{
          ...
      \\\}
      match ),symb
      \\\{
          match +,nest@cond
          \\\\{
               ...
          \\\\}
          ...
      \\\}
      match any,symb@cond
      \\\{
          ...
      \\\}
   \\}
 \}
}
    

vid wrote:
6 - i don't know MASM's macrolanguage, but i don't believe it is so "clearly defined" (predictable) and so powerful as FASM's

Too bad, MASM's macrolanguage is very strong, but underdocumented or undocumented at all (for instance, child macro can see parent's arguments). There are very nice examples of MASM advanced macro techniques at winasmcommunity, posted mostly by bitRAKE. It's true there are some annoying limitations, but one can manage them in most cases or make "hacks" (for instance, macro function has to be always called with parentheses).
BTW, I don't like macros from MASM32 package, those are really not good example of MASM's macrolanguage.
And I simply love some of FASM's macro facilities, like instruction "overloading" (you can make macro "mov") with purge or assembly-time code encryption. These things are partially doable in MASM, but in very complicated way.
vid wrote:
btw: I thought that MS stoped MASM support.

MASM is updated with every new version of Visual Studio. MASM for compiling 64-bit code was released few months ago with MSVS2005. The biggest problem is lacking documentation, Microsoft provides only very brief descriptions about MASM features. That's bad for newcomers. Luckily, there are some independent coders digging in it.
Post 16 Feb 2006, 12:55
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
yes, i agree macros are only part of fasm which are hardly readable.

But it is great (unbelieveable) power you get by combining quite simple features. MASM macrosyntax seem to me to be overbloated (like all MS stuff i have ever seen). If they find they need something they can't do, then they just "add" it, instead of adjusting what is already done, resulting in mess. This happens in most bad-managed apps, you can often see people tend to use older versions of programs

With this approach macrolanguage is extremely easy to learn. how many things do you need to know until you become "macrolanguage expert" in MASM? In FASM it's about 30 things + general understanding how preprocessor works.

I disliked macros totally until i got into FASM, and now i love simple small set of powerfull features, instead of need to have everything built-in.
Post 16 Feb 2006, 13:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
vid wrote:
MASM macrosyntax seem to me to be overbloated (like all MS stuff i have ever seen). If they find they need something they can't do, then they just "add" it, instead of adjusting what is already done, resulting in mess.

I've spent some time skimming through FASM sources and documentation, so find something too and show it Smile
I think MASM macrosyntax is clear and simple. You just need to know how to use %, & and ! operators, IIRC.
vid wrote:
With this approach macrolanguage is extremely easy to learn. how many things do you need to know until you become "macrolanguage expert" in MASM? In FASM it's about 30 things + general understanding how preprocessor works.

Well, I can't count it. MASM Programmer's Guide is very clear and detailed in the macrosyntax basics, but I spent many hours searching winasmcommunity and experimenting with the advanced techniques.
On the other side, I don't feel I need to know something about MASM preprocessor. The only thing I know is "=" and equ operators are preprocessed differently, but I can't say how at the moment Smile
vid wrote:
I disliked macros totally until i got into FASM, and now i love simple small set of powerfull features, instead of need to have everything built-in

There are a few build-in macro functions in MASM (like the @CatStr above), but it doesn't make the syntax overbloated. You could be interested in the MASM manual Smile
Post 16 Feb 2006, 14:05
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
okay, gimme some link vole, please
Post 16 Feb 2006, 14:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Why I prefer FASM:

1) FASM is still in development and support DOS, Win32/Win64, Linux 32/64, Unix, and is easy to port to other OS, in a single package, with same assembler, same syntax!

2) I think FASM has the better documentation and support message board.

3) I prefer FASM's syntax and FASM's macro syntax too. I just learned asm because of FASM. I started studying asm in 2001, and in 2003 I found FASM, and I finally managed to build my first DOS program, then a simple bootable code, and now I'm using it for all kinds of Win32 dev.

4) There are things that can only be done in FASM or is very hackish to do it in MASM. Example:
Code:
;There is no need for a linker. FASM is smart enough to simulate a linker.
format PE GUI 4.0 ;FASM support many formats
include '%fasminc%\win32a.inc' ;All I need in one single include. I could also use win32ax.inc and make it simpler!
;Forget .code and .data crap! FASM will output .flat code!

;Macros
macro CryptCode
{
    local x
    repeat EndCrypt-BeginCrypt
           load x byte from BeginCrypt+%-1
           x=x xor 8
           store x at BeginCrypt+%-1
    end repeat
}
;End of Macros


;Begin code

;Decryption routine
main:
mov esi,BeginCrypt ;Begin encryption
mov ecx,EndCrypt-BeginCrypt  ;Size of code
mov eax,0008 ;Key
call Decrypt ;Decrypt at runtime!

;All the code and data is crypted!
BeginCrypt:
invoke LoadLibrary,user32
invoke GetProcAddress,eax,MsgBox
mov [MessageBox],eax
invoke MessageBox,0,mess,cap,0

jmp OverData
mess db 'FASM IS POWERFUL!',0
cap db 'This was crypted Smile',0
MessageBox dd 0
MsgBox db 'MessageBoxA',0
user32 db 'user32.dll',0
OverData:

ret
EndCrypt:

;Little decrypt routine
Decrypt:
xor byte[esi],al
inc esi
loop Decrypt
ret

;FASM places the import section where I want it to be!
data import
library kernel32,'KERNEL32.DLL'
import kernel32,\
LoadLibrary,'LoadLibraryA',\
GetProcAddress,'GetProcAddress'
end data

;Use the macro. FASM is multi-pass, so I put it anywhere!
CryptCode
    

Laughing
This was just example. FASM macro language is able to build from EXE self-extractors to scripting languages and even more.

5) If you miss something, you can allways ask Tomasz to add to FASM if it is great feature, or you add by your own, because FASM is open-source and written in itself (no need to learn other language to make FASM more friendly to you!).


Last edited by OzzY on 16 Feb 2006, 15:24; edited 1 time in total
Post 16 Feb 2006, 14:52
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Code:
;Call the macro. FASM is multi-pass, so I put it anywhere! 
CryptCode    

you really mixed up things here... change comment to ";Use the macro", but it would be nicer if macro would take arguments like From, To, so it is more generally usable.
Post 16 Feb 2006, 15:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Yes, I really meant "Use". Changed.

It was just a test, so I didn't use arguments. Anyway there is a better example at "macro instructions" forum.
Soon, I'll create my new website and put all my sources, tools, tutorials there. I just need to code very good examples and upload. So, coming soon... ;D
Post 16 Feb 2006, 15:29
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
btw, are you sure you can place it anywhere? "load" directive is one of very few unclear fasm things... but i don't think you can load data "forward"
Post 16 Feb 2006, 15:34
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
http://flatassembler.net/docs.php?article=manual#2.2.4
As it states, you can always use "load" and "store" only for addresses between $$ and $.
Post 16 Feb 2006, 15:36
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
You're right. Just tested now. It can be placed anywhere AFTER code to be crypted.
Post 16 Feb 2006, 15:39
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
hey when did you add $$? I missed that.

You could also describe / name WHAT exactly is addresing space. Is DOS segment addressing space? or "data" directive...
Post 16 Feb 2006, 15:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
vid wrote:
okay, gimme some link vole, please

I'd kill you with your "vole" Laughing

Ok, download MASM Programmer's Guide. You get several .doc files. Open Chap_09.doc and learn masm macros Smile
There is also on-line version of this chapter, but the .doc is more readable for me.
Post 16 Feb 2006, 15:59
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
OzzY wrote:
1) FASM is still in development and support DOS, Win32/Win64, Linux 32/64, Unix, and is easy to port to other OS, in a single package, with same assembler, same syntax!

Yes, it is more difficult to code for other OS than Win in MASM.
As for porting to other OS, it wouldn't be so easy because of different APIs between different OSs.
OzzY wrote:
2) I think FASM has the better documentation and support message board.

I'm not sure about it. MASM message board is also very helpful. MASM Guide is very old, but still sufficient, but I miss some things in FASM documentation. For instance, where can I learn how to set default value of macro argument? I know it is possible, but you have to figure it out yourself.
OzzY wrote:
3) I prefer FASM's syntax and FASM's macro syntax too.

It's a matter of everyone's choice.
OzzY wrote:
4) There are things that can only be done in FASM or is very hackish to do it in MASM. Example:

;There is no need for a linker. FASM is smart enough to simulate a linker.

I never used that, but MASM can assemble and link in one step too.
OzzY wrote:
format PE GUI 4.0 ;FASM support many formats

Yes, MASM is intended only for MZ and PE executables.
OzzY wrote:
;Forget .code and .data crap! FASM will output .flat code!

These are sections, not some crap Rolling Eyes
OzzY wrote:

...
;FASM places the import section where I want it to be!

How often you really need this what-you-see-is-what-you-get feature? Only in a few cases.
OzzY wrote:
This was just example. FASM macro language is able to build from EXE self-extractors to scripting languages and even more.

I agree, FASM is the best for such special tasks.
OzzY wrote:
5) If you miss something, you can allways ask Tomasz to add to FASM if it is great feature, or you add by your own, because FASM is open-source and written in itself (no need to learn other language to make FASM more friendly to you!).

Yeah, Thomasz's support is very good... but it will not be forever Wink
I agree, bug fixes in Microsoft are slow...
Post 16 Feb 2006, 16:29
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
MazeGen wrote:
AFAIK, Thomasz is the only developer of FASM.

Tomasz is doing a hard job explaining design philosophy, inner workings, self-documented sources and general functioning, way beyond other software projects tend to do.
With his laudable effort and the available information, FASM has already passed its creator dependance and has a live on its own.

Following Fasm license, Tomasz didn't impose himself as the leader. The community respect him as the leader based in a natural best-interest practice that will hold true even if for some reason he needs to renounce to the project.
Post 16 Feb 2006, 16:30
View user's profile Send private message Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
okay, i had a peek on it, and i now i am more sure with FASM:

1. In FASM output depends ONLY on contents of source, nothing more. This is just wonderful.

2.
Quote:
And what I really dislike is syntax of declaration of macro inside another macro and similar things. It may lead to really unreadable and complicated macro declaration (I mean \\\\{ and similar)

But in MASM way, you must declare entire macro within parent macro, having much you many possibilities:
Code:
macro BEGIN_MACRO name { macro name \{ }
END_MACRO fix }
BEGIN_MACRO nop
db 90h
END_MACRO    


3. You also have recursion instead of macro overloading, which again removes you more possibilities than it offers.

4.
Quote:
The future: AFAIK, Thomasz is the only developer of FASM. FASM's sources are poorly commented. What will happen when Thomasz lost his interest in further developing? Or when, by accident, Thomasz will not be able to maintain the project? Or when he will get married and he stops the project because of lacking time? I bet that in such case there will arise more incompatible FASM clones and FASM dies.
I'm not Microsoft-lover, but it is huge company and its support for MASM is still sufficient.

After thinking it over again, i think this is great advantage of FASM. It's source is clear, all decisions are made by single person so result is really compact, and if you want to change something you can convice Tomasz (i have suggested some changes which were done myself)

I must admit that advantage of MASM over FASM is that it's preprocessor can work with numeric expressions, in FASM it can only increment with tricky usage of "rept".

Well, MASM macrosyntax isn't as bad as i thought Wink
but FASM macrosyntax is just better Twisted Evil
Post 16 Feb 2006, 16:42
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.