LMM Assembler
Ale
Posts: 2,363
Hei,
well, after stating that I am working of a LMM (large memory model), I decided that without chicken there is no egg, so
Here I present my incarnation of a LMM assembler.
It generates a listing output (with error if any) and a binary image suitable to be loaded by (an egg!) a kernel that I still need to write.
As a proof of concept this works, but it is only that, an assembler. To work, this needs a preprocessor and the kernel
from the pLMMAss/dist directory run:
java -jar pLMMAss.jar <input_filename>
It generates input_filename.bin and input_filename.lst
It is a modification of the compiler included with pPropellerSim and as it is programmed in java, it is multiplatform (only tested in Mac OS 10.5 now).
The file lmm_ej.asm has a preview of how this intermediate file has to be written. LMMPreprocessor.java (/src) has a list of recognized (not yet) mnemonics, but includes a description of the planned ones.
As usual, GPL v2 code, full sources (at this point it is a bit crude, welcome to the world of LMM).
Enjoy
Edit: New version, Apr 2nd 2008 is here.
Post Edited (Ale) : 4/3/2008 11:14:59 AM GMT
well, after stating that I am working of a LMM (large memory model), I decided that without chicken there is no egg, so
Here I present my incarnation of a LMM assembler.
It generates a listing output (with error if any) and a binary image suitable to be loaded by (an egg!) a kernel that I still need to write.
As a proof of concept this works, but it is only that, an assembler. To work, this needs a preprocessor and the kernel
from the pLMMAss/dist directory run:
java -jar pLMMAss.jar <input_filename>
It generates input_filename.bin and input_filename.lst
It is a modification of the compiler included with pPropellerSim and as it is programmed in java, it is multiplatform (only tested in Mac OS 10.5 now).
The file lmm_ej.asm has a preview of how this intermediate file has to be written. LMMPreprocessor.java (/src) has a list of recognized (not yet) mnemonics, but includes a description of the planned ones.
As usual, GPL v2 code, full sources (at this point it is a bit crude, welcome to the world of LMM).
Enjoy
Edit: New version, Apr 2nd 2008 is here.
Post Edited (Ale) : 4/3/2008 11:14:59 AM GMT
zip
220K
Comments
What do you use for downloading the binary output on a Mac?
- You load a cog with the kernel, and the kernel executes the binary that this compiler produces, how ?, well I thought in having it reside in an external SRAM that is also used for stack and variables. It can be double cached to HUB RAM and COGs RAM, or just reside in HUB RAM.
Maybe something like PropDOS can be used to jettison both the kernel and the binary. It Is something I did not completely think, because, as a matter of fact, I wanted to test it thoroughly with the simulator (because, there is no spin involved).
I'll now develop the kernel and see how it works. How fast all routines make it, due to the huge overhead that this approach has.
Short answer, you do not download it directly.
edit: I still plan to make the programmer in pPropellerSim work as soon as I can work-out some bugs.
I have a working kernel, I'll post it tonight.
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
I've got a version of the Python download script that I hacked to work on the Mac. I'll dig it out if you need it Mike.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Prop Room Robotics - my web store for Roomba spare parts in the UK
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
A Python download script for the Mac would be useful. Thanks.
OK, here it is. It's something I was playing with a few months ago, it's hard coded for a particular file: "lmm_001.binary", and I think someone did a much improved python loader since then. However this does work, and at least gives a clue on how to modify the better script.
It was this line that I added in replacement of the generic POSIX line. Worked for me, but it may be that you need to look through /dev for a different driver if it doesn't do the trick for you.
return [noparse][[/noparse]"/dev/tty.usbserial-A3000O6p"]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Prop Room Robotics - my web store for Roomba spare parts in the UK
Post Edited (CardboardGuru) : 11/30/2007 10:09:29 AM GMT
I did not do a GUI front end for the LMM assembler on purpose, I thought that as everyone was desperate to have command line compilers that will be the best... well, we are here to learn.
A small update: I'm working in parallel with the kernel and the assembler. If (not that big IF) I can put some hours today and tomorrow, a kernel should emerge. I got some Ideas from Bill's kernel, and added some of my own. I hope it performs well. (I do not believe in the 25 % penalty of IC kernel, I think it is closer to 200%, we will see).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
After months of thoughts and some more coding, a new LMM Assembler is underway. There are many changes, not only operational but also at code3 level to what was posted here some time ago.
Before I explain the features let me tell you my approach. I wanted an assembler that can produce a RAM/EEPROM image that can be loaded to the propeller directly and also that can produce a binary that can be loaded and executed by a LMM VM/kernel.
To that effect a special mechanism was added, i.e. sections: there are three HUB, COG and LMM. They only affect symbols. inside a HUB section all symbols are 15 bits long, in a LMM they are 31 bits long and in a COG section only 9 bits long. COG sections make all symbols aligned to long and HUB sections make them byte aligned. In a LMM section, well I'm in a bit of a dilemma, jumps have to be long aligned, but the rest can be byte aligned... This needs a bit more of work/thought.
Features:
- Include files
- sections
- alignment to powers of two
- long/word/byte/strings with multiple data per line
- arithmetic expressions
- global symbols inside COG sections
- COG section auto-FIT
- Simple GUI front end when not used as command line tool
- programmed in java, GPL'd v2 code.
coming soon.
I wrote this to gather some comments on the implementation for LMM sections and so on.
I'll distribute this in the pPropellerSim project page by sourceforge.
Ale
I'd also try and create some scheme whereby every symbol in a Cog is offset from that Cog's ORG 0 even if above $1F0, there are some cases where the offset between two faraway symbols is needed. Maybe treat the whole of memory as if Hub then work out what the symnbol value is where it's used.
I think the most complex thing is going to be working out what any symbol's address is, whether it's an absolute address or an offset from some specific base. For example, @symbol used in Spin is offset from the object's base ( $0010 for top-most object ).
For LMM alignment I'd use byte as that's most flexible, although it does depend a lot on which type of LMM being used. Having at least one line macro's (#DEFINE ) allows the LMM opcodes to have the required bit alignment shifts specified to suit whatever alignment the LMM interpreter implements.
There are other sections worth considering; STACK where each symbol definition is an incremented address above the previous ( handy for overlaying Cog registers ), and SPIN if you want to allow Spin bytecode to be used.
symbols in COG sections are offset to the beginning of the section. ORG is not used at the beginning of a section.
Spin byte code use is not a big deal. Bigger deal is to compile spin, but the bytecodes with names taken from the interpreter is very simple.
That is why I came up with sections. Asm has to be aligned and addresses are to longs. Any address is in the 9 bit range. But constants can be larger, for that a global symbol (defined with .global, or in a HUB section) seemed more attractive.
I wanted to be as compatible with parallax's as possible, but there are some peculiarities that complicate things.
I'll test it today a bit more and If it is ready I'll post it. (I want to compile something and download it to the propeller, that will be fun!)
I'll see the other points.
thanks hippy
Finally I was able to sort of meet some of the goals above stated. Multi-line comments, macros and conditional compiling are not to be tested/used because... they are not implemented
The example file (example.lmmpasm) was used as a test of different features.
Comments are as usual welcome.
The file can be found at the top of this thread. Old compiler is not available anymore (I did not erase it, just it is not posted, if you nedit please, let me know).
As usual a full source tree from netbeans ide. executable is in /dist directory in form of a jar file.
Have fun