porting vasm to a new CPU

category: code [glöplog]
I need to make an assembler for a CPU which currently has none, and I've been thinking about porting vasm to it, but I'm not sure if it's a good idea. Does anyone have any experience with this? Is there another project like vasm that I could use instead?

(Also, no, I'm not going to write one from scratch, I'm too lazy to make a good parser with proper error messages etc., and I'll probably need those.)
added on the 2019-10-05 16:15:36 by porocyon porocyon
The alternative would be GNU binutils, but vasm is likely to be easier.

I didn't add new CPUs to it (yet), but did add extra opcodes to existing CPUs.

If you don't need a completely new syntax parser (that is, your assembler has roughly a format of OPCODE ARG1, ARG2, ARG3), you don't need too much work to get it going, I think.

The documentation (http://sun.hasenbraten.de/vasm/release/vasm_26.html#Interface) explains how to add a new CPU, and Frank Wille will be happy to help (I hope? or maybe I'm annoying him with bugreports, but he did help me with whatever I needed in vasm so far).
I first thought of binutils too, but looking at the diff for adding RISC-V support, I decided that it's too much effort. (Though having binutils would be nice, because it works well, and I'm also (too) used to that toolchain.)

So I guess I'll go for vasm, but I'm not sure how well it's able to deal with the instruction set, because the latter is "slightly" insane.
added on the 2019-10-06 17:09:57 by porocyon porocyon
Hi, you may want to check the license terms on VASM, it is not really open source in the usual sense, it is just distributed in source form.

This archive may be redistributed without modifications and used for non-commercial purposes.

Of course this may not affect you if you don't plan on redistributing your version :-)
added on the 2019-10-06 17:35:44 by hmn hmn
Frank would likely accept your patches, though.
added on the 2019-10-06 21:12:40 by xeron xeron
Yeah, Frank Wille is actually quite responsive when you have questions or inquiries, so also feel free to talk to him directly.

He not only fixed some bugs I reported, but actually added some features I requested to both vasm and vlink, so I could switch Free Pascal to use vasm and vlink as default assembler and linker for m68k-amiga and m68k-atari, and have it as an option for powerpc-morphos and powerpc-amiga.
added on the 2019-10-06 22:50:09 by Charlie Charlie
for now I'd just need it within my group, so I guess that'd be fine. But maybe after the demo is released, it'd be nice if the assembler could be included in homebrew devkits, but WinterMute etc. might not be able to redistribute it.
added on the 2019-10-06 23:32:39 by porocyon porocyon
Do I remember this correctly that you can distribute your own patches for vasm but not the modified binary itself?
added on the 2019-10-07 08:00:50 by El Topo El Topo
They will happily upstream the patches anyway.
El Topo: that's true, but I don't know if distributing the binaries yourself (modified or otherwise) is allowed, because that's what's done with devkitPro: they distribute binary packages (using pacman) of the compilers etc. for various platforms. (And the only toolchain worth mentioning for the platform I'm working with, is a devkitPro one, so it'd make sense to contribute to it as well.)
added on the 2019-10-07 14:32:25 by porocyon porocyon
I recall there being a table based assembler called tasm that was easy to expand (not to be confused with other assemblers called tasm)
added on the 2019-10-07 16:05:41 by sol_hsa sol_hsa
sol_hsa: that's not exactly easy to find, then
added on the 2019-10-08 08:34:58 by porocyon porocyon
added on the 2019-10-08 08:49:13 by sol_hsa sol_hsa
It is not that hard actually: http://www.cpcalive.com/docs/TASMMAN.HTM
Based on a quick google trip I think I may be thinking of the telemark assembler which isn't open source or free, so, sorry about that.

Making one shouldn't be that hard... =)
added on the 2019-10-08 08:57:02 by sol_hsa sol_hsa
I know it isn't that hard, but I'm too lazy to make my own parser, and add enough features to it to be "usable" enough
added on the 2019-10-08 11:11:49 by porocyon porocyon