hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
720 stars 56 forks source link

Instruction size vs #bits #43

Closed aslak3 closed 1 year ago

aslak3 commented 4 years ago

My little FPGA processor that I'm working on has 16 bit wide instructions but it can address individual bytes. This mostly works with "#bits 8" but it causes some confusion eg the instructions stream should always consist of 16 bit word quantities. Maybe there needs to be two quantities, the addressable width and the instruction width? The instruction width would influence the width of the outputted data.

All in all, this project is terrific and I look forward to seeing it progress!

I'm hoping I can have a crack at another output format, a VHDL array, instead of being lazy and munging another output format with perl or similar. But I need to learn some Rust first.....

pol-rivero commented 4 years ago

This is the same issue as I had in #39 . It's easy to find a workaround, but I hope the upcoming rewrite gives us a native way to solve this.

aslak3 commented 4 years ago

My bad, somehow I missed your issue #39. I'll close this.

In general "#bits 8" works but it will be confusing when working with any processor that can byte address but uses a different instruction width, like the 68K. Or my own creation. It also breaks output formats, eg. MIF.

hlorenzi commented 4 years ago

Hmmm, I think this time it's a bit different from #39 since this issue doesn't deal with banks.

Is the only problem here messing with the output format? I think we can fix that by creating some new output options to deal with things like instruction width.

Now, usually, the assembler itself doesn't care about instruction width -- it only needs to know the addressable width to calculate label addresses. Do you think there is something else missing here? Is it a problem if the assembler doesn't care about instruction width? What do you think?

aslak3 commented 4 years ago

The two issues are:

  1. Error checking on output size does not operate the way it should, ie. you can create instructions which are a multiples of the #bits value, which is not also a multiple of the instruction width.
  2. The output formats are wrong, eg MIF will have the wrong WIDTH field.

I can live with 1, though of course it's not ideal. To overcome 2 I'm currently using hexstr output and feeding it through my own perl based MIF generator using -p, which is how I found out that errors do not go in stderr.

hlorenzi commented 1 year ago

I'll probably add new format-specific options to the MIF output to overcome this limitation in the future!