Close

Never too late to change the instruction set

A project log for Kobold K2 - RISC TTL Computer

A 16 bit RISC computer with video display, from just a few TTL and memory chips. Online C compiler and simulator available.

roelhroelh 06/27/2020 at 20:310 Comments

During work on the C compiler it appeared that the instruction set had some problems. Compiling was possible, but sometimes resulted in code that was longer than optimal. (Of course the lack of AND, OR and XOR also can give longer code, but that was accepted from the beginning and I won't change that. Not now :)  ).

The main problems were:

Of course the change must be small, because I will also have to change the hardware prototype and I don't want a lot of rewiring. 

CHANGES

The main change is the introduction of many 3-operand instructions. The second operand is always a register, and when this is register D3, this transforms a ADD in a MOV because D3 is now always zero. A new RISK feature !

The other problems were also addressed. Of course new restrictions appear: Register D3 can not be used to store a value. The number of Z-page addresses goes from 128 to 64, and the result of a shift instruction always goes to D2.

The new features:

Some other new instructions, that were not in the problem list but are quite useful:

The new set needs one extra AND gate. That's an extra IC. Perhaps a few of the other gates can also get a useful function....

SO HERE IT IS

TODO

[ add 2 weeks of changes and debugging ]

DISILLUSIONMENT

After more than two weeks, I could not get this to work. Many opcodes changed, requiring changes at several places. The automatic jump-size detection and associated complexities did not do what I wanted them to do: the programs would not run well on the simulator, so I didn't even dare to change the hardware and test on that.

So I gave up on that. 

Then came a few days that I worked on a simpler form of these changes. I got the assembler and simulator working, but after modifying the hardware I got non-logical behaviour of initialized global variables. Difficult to debug. Or build a debugging tool first ?

Yesterday I decided that it was not worth the trouble. I rolled back all changes from this log.

Except one change: there will now only be 64 zpage variables (instead of 128). Like 64K, 64 globals should be enough for everybody. This leaves us one bit (Instruction bit 7) totally free for later use. So, only 50% of the instruction space is used !

Discussions