AnyCPU
http://anycpu.org/forum/

Recommendations on cross assemblers for new ISA?
http://anycpu.org/forum/viewtopic.php?f=3&t=863
Page 1 of 1

Author:  spiff [ Thu Oct 21, 2021 8:55 am ]
Post subject:  Recommendations on cross assemblers for new ISA?

Hi,
Is there any recommendations for a cross assembler when you are developing a new ISA?
Many have created their own processor, what is their starting point for making an assembler for this system?
The cross assembler need obviously to be open source.

My side project is an 8-bit system (emulator) looking similair to the 65xx. I looking for a simple, easy way to start generating code. I probably like the assembler to be coded in C but let this thread be open to any recommendation.

Did a search but failed to find an old topic about this.

Author:  BigEd [ Thu Oct 21, 2021 1:11 pm ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

In the case of OPC, @revaldinho rustled up an assembler in python. Several times.

As the idea was to keep code to a single printed page, it is terse, but of course it can be reformatted. Using a language with nice strings and regular expressions, and which allows evaluation of strings as expressions, can be a help.
https://github.com/revaldinho/opc/blob/ ... opc5asm.py

There's also a cheap-and-cheerful assembler in easy6502, and in Norbert Landsteiner's emulator work:
https://www.masswerk.at/6502/assembler.html
https://github.com/skilldrick/easy6502

These are in JavaScript, so the same facilities are there as in python.

Naturally, everything can be done in C, especially with helpful libraries.

Author:  robinsonb5 [ Thu Oct 21, 2021 4:43 pm ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

I wrote my own assembler and linker for 832 because I wanted to be able to "relax" references to their shorted possible form without having to tangle with the complexity of GCC or LLVM. It also supports constructor / destructor tables and weak linkage.

It's open source, written in C and lightweight enough to build and run on an Amiga! (Not particularly useful in itself, but bodes well for eventual self-hosting.)
Feel free to use it as a starting point, for inspiration, or just as an example of what *not* to do! :D https://github.com/robinsonb5/EightThir ... aster/832a

Author:  BigEd [ Thu Oct 21, 2021 5:28 pm ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

self-hosting always very attractive!

Author:  Dr Jefyll [ Fri Oct 22, 2021 6:22 pm ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

spiff wrote:
The cross assembler need obviously to be open source.
Hmm... when you say this, do you mean open source is the only acceptable option for you? Or do you mean you don't expect that a closed-source assembler would support a new ISA?

FWIW, there's at least one closed-source assembler that does support new ISAs. On 6502.org, Garth Wilson wrote...
Quote:
I use the C32 (Cross 32) assembler, originally from Universal Cross Assemblers in Canada, but now sold by Data Sync Engineering, at http://www.datasynceng.com/c32doc.htm . It's also available at http://www.mpeforth.com/cross32.htm . It won't do your 64-bit stuff, but up to 32-bit, it comes with the files to assemble for dozens of different processors, and gives you the information to make up the files for a new processor, including one of your own design. Supposedly it's about a 40-hour project to do that. If you go through with it, you'll have a really nice macro assembler.


Dunno if this'll be helpful for you. I bought Cross32 years ago (and paid about $100, as I recall). I was a bit disappointed that macros can't be nested. (And I never tried altering Cross32 to support a new ISA.)

-- Jeff

Author:  oldben [ Fri Oct 22, 2021 11:00 pm ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

Quote:
My side project is an 8-bit system (emulator) looking similair to the 65xx. I looking for a simple, easy way to start generating code. I probably like the assembler to be coded in C but let this thread be open to any recommendation.

The older dos shareware or the C -users group may have a table driven cross assembler.
The problem is C is no longer really able to compile the old 16 bit stuff.
C is so messed up now that it hard even to know just what will compile in the 64bit world.
If you do write your own assembler keep the source code as simple as posible
in language constructs so can port the code for self compiling.
Code:
top:
ptr = ptr + 1
ch=*ptr
if (ch = NULL) goto out
 if (ch == WHAT ) { do that thing(); goto top:}
 
out:

rather than
while(ch=++*ptr && ch== WHAT) do that thing()
 

Assume 32Kb for the assembler
if self hosting and 16Kb for a simple dos.
48Kb for a compiler.

Author:  robfinch [ Sat Oct 23, 2021 4:54 am ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

There is vasm. http://www.compilers.de/vbcc.html

It is supposed to be portable to other architectures with a little bit of work. I believe it has support for 8-bit processors like the 6502 and 6809.
I have used it for the PowerPC but I have not tried modifying it. It can generate linkable files which are linked with vlink. It also has potentially a C compiler.

Author:  barrym95838 [ Sat Oct 30, 2021 12:34 am ]
Post subject:  Re: Recommendations on cross assemblers for new ISA?

SB-assembler version 3 is written in Python3, and provides a method to add support for a new processor.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/