Wednesday, August 26, 2020

A mini proposal for RISC-V C externsion instruction encoding

I was looking at the C standard extension (compressed instructions) section in  the RISC-V ISA specification (Volume 1, Unprivileged Spec v. 20191213), and I realize that under a certain condition it is possible to increase the number of compact encodings. Here is how it can be done.

Take the second lowest bit of the program counter and call it the AOP bit. Then get the op field (the lowest two bit of the16-bit  instruction field) and they form a pair. Now here is the new interpretation:

  1. If AOP bit is 0 (in other words, PC is divisible by 4), interpret the op field as before. We have the usual compressed instructions as before.
  2. If AOP bit is 1 (in other words, PC is not divisible by 4), we have two cases: if the op field is not 11, then we have the usual compressed instructions as before. But if the op field is 11, then we have a completely new space to create compressed instructions.

The disadvantage is that the new compressed instruction space can only appear in every other halfword in the instruction stream. But I think it could open up some possibilities, and decoding the AOP/op field should be only slightly more complicated.

I see one possible way is to support certain common instruction pairs, though I can't think of what pairs to encode though.

Thoughts? Post comments here!


Coding in assembly languages - a mini tech biography

I like writing programs in assembly languages. I used to write 6502 codes for Apple II and Commodore 64, dabbled a bit in Z80 coding )on a ZX-81), did a VAX coding once (to modify the Forth source), dabbled in SPARC (Open Firmware), programmed some S/370 stuff for a college course, did a bunch of 680x0 coding on Amiga machines, and some amount of x86 programming on a PC, and more recently did some 65816 coding.

I also read up on various tech specs for various CPUs.

And now my latest focus is now on RISC-V!

So I'm now coding some stuff in it, and run them in an emulator. It's a blast!


Monday, July 15, 2019

My first post...this is a test

Hello!

This is my very first posting on the Blogspot. I'm doing that to get some experience seeing how that works.