Shop OBEX P1 Docs P2 Docs Learn Events
is there a stand alone assembler? (or any advice on how to write one) — Parallax Forums

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

b.p.m.b.p.m. Posts: 59
edited 2009-01-26 00:20 in Propeller 1
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

Comments

  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 03:59
    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.b.p.m. Posts: 59
    edited 2009-01-25 04:19
    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
  • AleAle Posts: 2,363
    edited 2009-01-25 07:17
    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!
  • heaterheater Posts: 3,370
    edited 2009-01-25 12:15
    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.
  • propMakerpropMaker Posts: 65
    edited 2009-01-25 14:38
    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.
  • propMakerpropMaker Posts: 65
    edited 2009-01-25 14:40
    Get the book from here (free). compilers.iecc.com/crenshaw/
  • hippyhippy Posts: 1,981
    edited 2009-01-25 15:02
    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.
  • AleAle Posts: 2,363
    edited 2009-01-25 15:15
    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.b.p.m. Posts: 59
    edited 2009-01-25 19:23
    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
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-01-26 00:20
    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 smile.gif

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

    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz
Sign In or Register to comment.