News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Designing an Assembler.

Started by Citric, April 14, 2005, 02:32:49 AM

Previous topic - Next topic

Citric

Has anyone sat down and worked out/designed an asm (be it MASM, GoAsm, SolAsm or HLA) Grammer?
or Formal Language specification?

I was looking at a Project to start as a hobby and part of it is an assembler(written in asmembler),
I do not want to reinvent the wheel but i do want to understand it totally so i was looking more
for the language specifcation and/or grammer?

any ideas?

Cheers Adam

MichaelW

I'm not sure if this is what you are looking for, but the MASM 6.0 Programmer's Guide included the BNF grammar for the MASM language in Appendix B. The BNF grammar for the MASM 6.1 language is available here:

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Appendix_B.htm


eschew obfuscation

pbrennick

Hi Citric,
As far as reinventing the wheel goes, I would not be concerned if I were you.  One thing that I am sure of, writing/designing an assembler will leave you with a very 'complete' knowledge of the language.  There probably is no better way to quickly come up to speed and it can be a lot of fun.  Others may have differing opinions and are welcome to voice them here; this is mine and, apparently, yours.

Paul

Citric

Thanks for the encouragement pbrennick.

So far i havent written anything major yet but i think this will be My Project!

:toothy

hopefully i can post something soon!

Citric

This is kinda what i am looking for.

(label:) mnemonic (operand1) (, operand2) (, operand3) ( ; Comment)

bracketed items are optional.

When i think about it if you remove all the fancy stuff, every line in assembler fits into this case.(I think  :wink)

but i also think there are other issues like white space, line and coloumn numbers!

I think this will take more design then i orignally thought!

Adam

Robert Collins

I wonder. Do we really reinvent the wheel or just make it a little bit rounder.

doomsday

Quote from: CitricThis is kinda what i am looking for.

(label:) mnemonic (operand1) (, operand2) (, operand3) ( ; Comment)

bracketed items are optional.

When i think about it if you remove all the fancy stuff, every line in assembler fits into this case.(I think  :wink)

Not far off.  Here's a couple which you might want to think about before you sit down and start writing:
someNumber dd 1234ABCDh      ; no colon after the label
.386               ; directives for the assembler
someEquate EQU 1234
andAnother EQU "Text Equate"

And of course writing/implimenting macros if you intend to support them.

best of luck,
-Brent

Citric

Hi guys

Quote from: Robert Collins on April 20, 2005, 02:40:18 PM
I wonder. Do we really reinvent the wheel or just make it a little bit rounder.

:cheekygreen:

I love it!!

doomsday: i forgot about variable declaration.
               directives, hmmm i think thats fancy stuff for now
               macros, very fancy!!!

i still got more to design and think about before i start writting!!

cheers for the replies!!
Adam

James Ladd

Ill check my books tonight for a yaccable grammar. You could use this to make a start.
Remind me if I dont get back to you too quickly.

BogdanOntanu

You can check the Sol_ASM sourcecode that i have posted here.
It is still simple enough that you can understand it and i does stuff like

label: add eax,7
         dec ecx
         jnz label
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Citric

Quote from: BogdanOntanu on April 21, 2005, 06:24:18 AM
You can check the Sol_ASM sourcecode that i have posted here.
It is still simple enough that you can understand it and i does stuff like

label: add eax,7
dec ecx
jnz label


That actually sounds like a great idea!

Should i get it from thread http://www.masmforum.com/simple/index.php?topic=1218.0 or your home page?

Cheers
Adam

Farabi

I suggest you to take some part from sol asm or fasm than creating it from the beginning. Sol asm is fast and its free, so do fasm if you familiar with it syntax. I saw sol os is looks alike masm and it was good.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

rea

Also visit the win32 asm community there is a section dedicated to this too.

Randall Hyde

Quote from: striker on April 21, 2005, 04:23:54 AM
Ill check my books tonight for a yaccable grammar. You could use this to make a start.
Remind me if I dont get back to you too quickly.

As someone who has been there and done that, let me suggest that you not use the terms "assembler" and "yacc" (or Bison) in the same paragraph.  Yacc is *not* a good development tool for assemblers. Flex/Lex could almost be acceptable (though macros are a bit of a pain to do with them), but Bison is a waste of time. Even if you're doing a *really* fancy assembler like HLA, where there are a bunch of context-free language constructs, Bison/Yacc is not a good tool to use for assemblers.

I believe the OP said he was going to write it in assembly.
That generally implies a recursive-descent predictive parser. And a "Yaccable" grammar is going to take a bit of work to convert to a form that can be processed by a RDP parser.
Cheers,
Randy Hyde

Farabi

Quote from: Citric on April 14, 2005, 02:32:49 AM
Has anyone sat down and worked out/designed an asm (be it MASM, GoAsm, SolAsm or HLA) Grammer?
or Formal Language specification?

I was looking at a Project to start as a hobby and part of it is an assembler(written in asmembler),
I do not want to reinvent the wheel but i do want to understand it totally so i was looking more
for the language specifcation and/or grammer?

any ideas?

Cheers Adam

Hai do you still active. I can give you ,my assembler source code. I will search the file and send it to you, do you still active? I will send you an email.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"