How does an assembler work / what are the steps? Im planning to make one.
As of now, I think this is what I'll do:

1. check syntax if correct -> 2. encode -> 3. output

What do you think?

Posted on 2005-05-07 11:08:43 by audioman
Before writing the first instruction you should be decided what is your assembler expected to do.
First define character set allowed in identificators, numbers, operators and their priority.
Second define horizontal structure - fields of a statement, how they are separated, how comments and line continuation will be recognized etc.
Third define vertical structure - block statements and how they will be nested.
Then decide what pseudoinstructions, preprocessing tools and macrolanguage  will be provided and which output formats should be supported.
I recommend you start with the user manual and documentation.
With the clear and fixed concept you'll be able to find all the necessary steps by yourself.
BTW encoding of machine instructions and output together consume mere 10 % of all effort.
Posted on 2005-05-07 13:18:24 by vit$oft
parsing (the act of figuring out what was meant) is always a bit of a hell for a computer ;)
Posted on 2005-05-08 12:26:42 by AmkG
http://webster.cs.ucr.edu/AsmTools/RollYourOwn/

Please start using google and the forum search function more often audioman.
Posted on 2005-05-09 00:39:34 by SpooK
http://www.asmcommunity.net/board/index.php?topic=20863.0

Look at the SolAsm source, mush simpler than HLA2 to read.
Posted on 2005-05-10 22:01:19 by ThoughtCriminal
Or you can read up on the design principles of fasm http://flatassembler.net/docs.php?article=design
Posted on 2005-05-11 23:31:15 by roticv
audioman,

A while back I was thinking about making my own assembler as well, here is the basic flow chart I designed to complement my assembler. I never did get the time to sit down and actually code one, but this might give you a decent idea if you are still interested.

Regards,
Bryant Keller

2 pass assembler outline
Posted on 2005-12-12 23:31:37 by Synfire