Added most stack instructions

A project log for Plasma Cortex: open source CPU in VHDL!

This CPU was designed for efficiency and simplicity, while staying an effective and useful design.

dylan-brophyDylan Brophy 08/05/2018 at 23:222 Comments

I needed to re-add the stack instructions to make the CPU work.

As some saw in the HDD crash project log on the #DEXT Meteor project, I lost the VHDL code for the latest version of the Plasma Cortex processor.  That version had most of the instructions already implemented, and the old version I had a backup of did not have all those instructions.  Today I added the four main stack instructions for my CPU:

CALL address
PUSH register
POP  register
ADD  SP, 32 bit constant

You notice no RET instruction?  The Plasma Cortex allows access of all registers the same way, so these are actually valid instructions:

POP  PC ; alias of RET
PUSH PC ; unique instruction
MOV  AX, PC ; another unique instruction

The programmer has full control over the program counter, so the assembler just converts RET instructions to POP PC.

There are no interrupts *yet*, so no IRET or anything like that.  I actually do not plan on having a special return instruction for the Plasma Cortex because I feel it is unneeded.

[edit] Just realized I still need to add these instructions:

MOV [sp+16 bit offset], general purpose register
MOV general purpose register, [sp+16 bit offset]

Those are for the C compiler's local variables.  Those instructions greatly speed up C programs running on the Plasma Cortex.

That's all for now, thanks for reading!!


Ed S wrote 08/09/2018 at 16:14 point

Losing your work is a shock... but are you finding it relatively easy to redo? Is it even coming out a little cleaner the second time?

  Are you sure? yes | no

Dylan Brophy wrote 08/09/2018 at 17:55 point

cleaner the second time!  Ya, hardest part was loosing a game I made...  really sad.

  Are you sure? yes | no