flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Understanding fasm (draft)

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
Recently, while I was writing some additions to the manual, came to my mind the idea of defining and describing some overall characterstics of fasm's language. I already wrote the "Design Principles", which explain how it happened that some of the things in fasm were done the way they were, however what I'm hoping to do this time, is to write something finally arranged, from the current point of view (after six years of development), which would summarize its design and rules, especially those features, that may be confusing because of failing to conform with the expectations. Most of such problems arise from the fact of assembly language having some layers - which in case of fasm are more distinct than in case of classic assemblers.

[edit]This text has been moved to the Documentation section.[/edit]


Last edited by Tomasz Grysztar on 18 Mar 2006, 18:43; edited 18 times in total
Post 24 Jan 2006, 22:45
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
This text has just been started, but any comments are welcome. I'd perhaps better do continuing the tutorial, which anyway should cover all those topics sooner or later, but some of things I put here I consider so important that I want to have this finished first, before I go on with the tutorial.
Post 26 Jan 2006, 22:24
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: 15976
Location: Qo'noS
While I understand all that you are saying above I just can't seem to grasp what point you are trying to make with it. Are you trying to get people to think in two different mindsets when writing the files intended for FASM to process? I think it might more important to explain the things like rept/repeat and equ/= differences, this always seems to cause confusion for new comers. In another thread you posted a very good table showing at which processing stage various things were done, and sorry to repeat myself, but tables like that are much better at showing a concept than sentences of English (or any text language).
Post 27 Jan 2006, 00:43
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 444
Location: BC, Canada
revolution wrote:
more important to explain the things like rept/repeat and equ/= difference


that is explained in the documentation, this is more a guide to fasm-style assembler i believe

_________________
redghost.ca
Post 27 Jan 2006, 01:01
View user's profile Send private message AIM Address MSN Messenger Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 383
Location: Finland
wow, the example in "Using flat assembler as pure interpreter" was really nice Surprised

i didnt know fasm would be able to do something like that Shocked

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 27 Jan 2006, 01:37
View user's profile Send private message MSN Messenger Reply with quote
chris



Joined: 05 Jan 2006
Posts: 62
Location: China->US->China->?
needless to say, fasm is designed to be a assembler(a translator of assembly language to machine code). However, the power of fasm is far beyond an ordinary assembler, which makes it different. From my point of view, it's more like a scriptable/programmable command interpreter with its emphasis on binary file generation.Smile
Post 27 Jan 2006, 05:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15976
Location: Qo'noS
Quote:
Quote:
more important to explain the things like rept/repeat and equ/= difference
that is explained in the documentation
Yes, of course it is but it seems not to be clear because so many people get tripped up on exactly these things.
Post 27 Jan 2006, 05:41
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
revolution: no rush, this is just the beginning of text, I'm going to covert the preprocessor layer and its separation from the other ones a bit later, after I get interactions between various layers in assembler itself cleared. Actually the thing with preprocessor is much more simple and the single table like that is able to explain the most of it. The layers within assembler itself is a much more delicate concept.

revolution wrote:
Yes, of course it is but it seems not to be clear because so many people get tripped up on exactly these things.

This is more because:
a) people are used to different behavior of other assemblers, where macroinstructions and EQU are the directives of the same layer as any other assembler directives (the only one interpreted layer in such case);
b) they don't read the documentation, with the assumption that they already know what macroinstructions and EQU do, as they used them with other assemblers; or
c) they don't read the documentation; for any other reason why people usually don't read the manuals.

I wrote the fasm's manual to be more like continuous text that has to be read consecutively instead of simple reference, hoping to force this way people to read a bit more instead of just the information on the single feature they're looking for.
Post 27 Jan 2006, 07:51
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7109
Location: Slovakia
Tomasz Grysztar wrote:
I wrote the fasm's manual to be more like continuous text that has to be read consecutively instead of simple reference, hoping to force this way people to read a bit more instead of just the information on the single feature they're looking for.

btw, i noticed that this approach causes problems when anyone gets to "instruction" part, he thinks "i don't need to read instruction reference" and ends, without reading the most important things behind it. I've seen few such cases here.
Post 27 Jan 2006, 09:19
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2468
Location: Bucharest, Romania
vid wrote:
btw, i noticed that this approach causes problems when anyone gets to "instruction" part, he thinks "i don't need to read instruction reference" and ends, without reading the most important things behind it. I've seen few such cases here.

maybe try to put instruction reference in appendix like Nasm doc?
btw: nice guide. definetely help newbies to Fasm understand that it's different from other assemblers.
Post 28 Jan 2006, 11:28
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
Even the x86 instructions section itself is very important, and not reading it causes many problems about syntax, like with the operands for XLAT or MOVS, using segment prefixed adresses, FPU instructions syntax - there are everywhere some small issues, and that section was in fact not written to be really a reference (as for instruction reference you've got the complete Intel or AMD manuals), but primarily to clarify syntax that fasm uses for every single instruction. Even when knowing some general rules, there are still many settings for the instructions that are quite specific and not always conforming to other assemblers. Like the XLAT and string instructions (where I followed the TASM's syntax), or the jumps like:
Code:
jmp pword 0:0    

(in NASM you'd write "dword", here's the difference). And FPU instructions... that's a true mayhem.
Post 28 Jan 2006, 13:35
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: 15976
Location: Qo'noS
Quote:
This is more because:
a) people are used to different behavior of other assemblers, where macroinstructions and EQU are the directives of the same layer as any other assembler directives (the only one interpreted layer in such case);
I think this is exactly why there needs to be an easy to find section with easy to find descriptions, and perhaps even comparisons to others assemblers, in the documentation. Because people are unfamilar with FASM they need somewhere to quickly explain things. Even myself now after some small experience using FASM I still occasionally refer to the manual and find I have trouble locating exactly the section I want. For new comers wanting an overview to start them off it is somewhat daunting to read through many many paragraphs and not be able to find what they need to know. Yes, the information is all there but somewhat buried among the prose.
Quote:
b) they don't read the documentation, with the assumption that they already know what macroinstructions and EQU do, as they used them with other assemblers;
Yes, that is probably true, so help them out a little and get them interested with a quick section on "what is different"
Quote:
or
c) they don't read the documentation; for any other reason why people usually don't read the manuals.
Well, of course, RTFM always applies, bit there is no real way to overcome this problem.
Quote:
I wrote the fasm's manual to be more like continuous text that has to be read consecutively instead of simple reference, hoping to force this way people to read a bit more instead of just the information on the single feature they're looking for.
I see, well in that case you did a great job. But I think that trying to force people to read something is doomed to failure. I think most people just want to write their code not read the novel Smile Hehe, I have never read the 'instruction' section of the FASM manual. I've always used XLATB and MOVSB/MOVSW/MOVSD. Things like "JMP pword 0:0" are not for the faint hearted programmer so most new comers are unlikely to need to know that in a hurry. But even so that is a perfect example for a "differences" section.

Don't get me wrong, I think what you are trying to achive with the documentation is a great thing. An I hope that you understand I am just trying to offer some different perspective from a users point-of-view. For myself and my style of doing new things, I like to "do it" first and if I fail then check the manual on the parts I am having trouble with. How many people here can truthfully claim to read the entire DVD player/TV/whatever manual first before plugging it in and watching something.
Post 28 Jan 2006, 15:39
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
I agree that some table-based reference documentation would make a good addition to the existing one - for the quick reference (though perhaps at price of the completness). I may go no with writing such when I finish what currently pushes me from inside of my head, restlessly awaiting for finally becoming put down in text.
Post 28 Jan 2006, 16:28
View user's profile Send private message Visit poster's website Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 383
Location: Finland
revolution wrote:
For myself and my style of doing new things, I like to "do it" first and if I fail then check the manual on the parts I am having trouble with.


While coding I always have fasm.pfd open so I can just quickly alt+tab and search for some instruction/whatever to look for help Shocked
and its not even rare that I have to open up like 10 of my old sources to remember how to do that and what is the api for this and that etc.


If I'm honest I cant even remember how to define a code/data section so I always copypaste it from win32ax.inc because its always already open due some error while compiling and my mouse(mx1000) does have buttons for copying/pasting Embarassed

ToDo: ; Razz
    read fasm.pdf
    focus on it
    memorize it
    jmp ToDo

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 28 Jan 2006, 16:42
View user's profile Send private message MSN Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
Another thread tangent.

http://developer.amd.com/devtools.aspx
At the bottom of this page it lists NASM and YASM as suggested free assemblers to use.

If you feel as I do, that FASM should be on that list, then make sure to click on the "Contact Us" link at the bottom of the page and voice your opinion to AMD.
Post 29 Jan 2006, 06:11
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2146
Location: Estonia
I hope this reply goes under the section - understanding FASM:

I've done programming in every corner of the CPUs silicon, but the FPU gets me confused. I can accomplish my task finally, but it seems that FASM isn't sure what it expects from me. I can't tell from the errors if the short-form instruction isn't supported or does it just ignore my request for the parameters like st0,st(0),st... I usually got to the st(0..7),st(0..7) solution, if the short form isn't supported (like the FMUL(P)) but there is no easy way to tell where the problem came from.

I don't know if this is what you meant with the mayhem Smile but it really is. I usually couple OllyDBG with my executable to see what the instructions do, because it isn't easy to memorize everything Sad
Post 29 Jan 2006, 10:22
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
Actually the rule is simple (I have taken this from the recent Intel manuals, not looking at other assemblers): only the popping instructions have the short forms. So "fmulp" and "faddp" can be assembled without any operands, while "fadd" and "fmul" need the operands every time - and explaining what those operands should look like is exactly what the sections about instruction are there for.
Post 29 Jan 2006, 10:27
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2146
Location: Estonia
Okey, that makes it clear - sorry I didn't figure out the logic myself. Just there are a lot of different sources on the net Razz

About the draft at the beginning of this thread. Its easy to understand and helpful but maybe too easy reading if you know what I mean Smile Maybe shorter text (with the set-back of more difficult to read text).
Post 29 Jan 2006, 10:55
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6927
Location: Kraków, Poland
Almost finished the part about code resolving - perhaps now it will be time to complicate things even more and introduce preprocessor layer. Wink
Post 29 Jan 2006, 12:43
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2146
Location: Estonia
Erm, I just read it and it really is complicated:
Code:
dd x,y

x = (y-2)*(y+1)/2-2*y
y = x+1

;What does the FASM do first? My best guess is:
;x=0, y=0 then find out if it is correct...
x= (0-2)*(0+1)/2-2*0 = -1
y= 0+1 = 1
;In the next pass:
x= (1-2)*(1+1)/2-2*1 = -3
y= -1+1 = 0
;Another pass?
x= (0-2)*(0+1)/2-2*0 = -1
y= -3+1 = -2
;The 6 is resolved, but:
x= (-2-2)*(-2+1)/2-2*(-2) = 6
y= -1+1 = 0
;Yet another???
x= (0-2)*(0+1)/2-2*0 = -1
y= 6+1 = 7
; Sad
x= (7-2)*(7+1)/2-2*7 = 6
y= -1+1 = 0
; Sad
x= (0-2)*(0+1)/2-2*0 = -1
y= 6+1 = 7
    
Post 29 Jan 2006, 13:53
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.