PDA

View Full Version : is there a stand alone assembler? (or any advice on how to write one)



b.p.m.
01-25-2009, 10:46 AM
hi everyone,
i remember reading on the forum that somebody was working on
a propeller based assembler. it's my dream to write assembly
programs right on my demo board without having to run to the PC
every five seconds when coding. does anyone have any information
on this? i'm trying to teach myself prop assembler so that i might
be able to write my own assembler with an editor and sd based OS.
so far i've finished deSilva's fantastic machine code tutorial. i learned alot
from it.
speaking of which, deSilva, if you're out there or anyone else who
might know, when is your much anticipated assembly book coming
out! i'm ready to place my order.

thanks,
blake

p.s. i think it was a Steven who said he started work on a prop based
assembler.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson

Post Edited (b.p.m.) : 1/25/2009 5:13:31 AM GMT

J. A. Streich
01-25-2009, 10:59 AM
I believe Chip has been working towards this goal in his "free time". I don't know the status of the project...

b.p.m.
01-25-2009, 11:19 AM
hey again,
quick question: does anybody have advice or ideas that would help me
write my own assembler in spin?

thanks again
blake

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson

Post Edited (b.p.m.) : 1/25/2009 5:00:44 AM GMT

Ale
01-25-2009, 02:17 PM
If you know how to read java, I'd recommend you have a look at pPropellerSim in sourceforge.org/projects/ppropellersim

The class org.pacito.propeller.Compiler is the one that implements the compiling.

Writing an assembler is far easier than it seems if you think of it this way (There are other approaches).

Two pass assembling.

1st Pass: symbol capture and sizing (easy because all instructions are 32 bits). Unknown opcodes, bad syntax, duplicated symbols can be catched here.
2nd Pass: Assembly compilation. Symbol table is ready so any not found symbol is an error. Here you catch invalid format for instructions, operands out of range.

In the second pass you output the compiled code directly.

The most critical part is to take a line and to extract every possible bit out of it: label condition opcode arg1, arg2 (if any) effects (if any). Once you wrote such a line parsing algorithm, the rest is a piece of cake. Start there.

If you need any more help just chime!

heater
01-25-2009, 07:15 PM
As Ale says an assembler can be fairly simple thing.

Problem comes if you want to make it assemble source code that is compatible with the Propeller tool.
Dealing with all the complexity (and quirks) of expressions used in constant definitions etc gets quite laborious.
Best not to think about that for a Prop hosted assembler.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

propMaker
01-25-2009, 09:38 PM
Here are some compiler/interpretter projects I've been working on. And an ebook on writing compilers, might give you some ideas. My files are the same as the books, just translated to spin.

I'm running on a protoboard with vga and keyboard.

propMaker
01-25-2009, 09:40 PM
Get the book from here (free). compilers.iecc.com/crenshaw/ (http://compilers.iecc.com/crenshaw/)

hippy
01-25-2009, 10:02 PM
An assembler is far easier to write than a full compiler but there's still a lot in common and quite a bit of work to do.

I would suggest writing a PC-based assembler and then porting that to Spin. Decide what the specification is for your assembler and write code to be reasonably easy to port, so don't rely on malloc if using C or strings if using Basic, stick with byte, word and long arrays, no structures no user defined types etc.

I'm not sure how useful an on-chip Native Assembler would be to a wider community but a well featured LMM Assembler is something which I think would have an appeal.

Ale
01-25-2009, 10:15 PM
I'm with hippy. I'd have a look at what propMaker has, it seems that your job may have been made shorter.

b.p.m.
01-26-2009, 02:23 AM
hey guys,
first thanks for the quick replies to my query. i agree with ale that a two pass
approach is the most straight forward (that's what i was thinking). i think my
first version will be very no-frills; literals will be values only (no expressions)
and all labels will global (i'll figure out how to handle local labels later),etc.
propMaker, thanks for the great material; i'll be all over it for awhile.
ale, i'll take a look at pPropellerSim but to be honest i have trouble wrapping
my mind around Java
i'll no doubt be back with all sorts of questions in the weeks ahead.

thanks,
blake

p.s. i wrote my first assembly on a General Electric 115 back in '74. it worked
with punch cards and had a iron core memory for the boot program.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson

Cluso99
01-26-2009, 07:20 AM
Suggest you read the threads on homespun and bstc (both full blown compilers for PC and PC/Mac/Linus) - see the link "prop Tools" in my signature for a link to their threads.There is a lot of discussion and advice contained in them. And go for it http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index (http://forums.parallax.com/showthread.php?p=778427)
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)