View unanswered posts | View active topics It is currently Thu Mar 28, 2024 8:59 am



Reply to topic  [ 8 posts ] 
 Recommendations on cross assemblers for new ISA? 
Author Message

Joined: Mon Dec 28, 2015 11:37 am
Posts: 13
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.


Thu Oct 21, 2021 8:55 am
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1780
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.


Thu Oct 21, 2021 1:11 pm
Profile

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
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


Thu Oct 21, 2021 4:43 pm
Profile

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1780
self-hosting always very attractive!


Thu Oct 21, 2021 5:28 pm
Profile
User avatar

Joined: Tue Jan 15, 2013 5:43 am
Posts: 189
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

_________________
http://LaughtonElectronics.com


Fri Oct 22, 2021 6:22 pm
Profile WWW

Joined: Mon Oct 07, 2019 2:41 am
Posts: 585
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.


Fri Oct 22, 2021 11:00 pm
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
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.

_________________
Robert Finch http://www.finitron.ca


Sat Oct 23, 2021 4:54 am
Profile WWW

Joined: Tue Dec 31, 2013 2:01 am
Posts: 116
Location: Sacramento, CA, United States
SB-assembler version 3 is written in Python3, and provides a method to add support for a new processor.


Sat Oct 30, 2021 12:34 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software