Close

Log#32 : This little Least Significant Bit

A project log for YASEP News archives

A backup of the blog before the host erases it. A good opportunity to review the development, twists and turns of this ISA !

yann-guidon-ygdesYann Guidon / YGDES 04/09/2020 at 03:020 Comments

By whygee on Sunday 8 May 2011, 23:25 - Architecture
(update : 2011/05/11)


I've been wondering since march of this year if the Least Significant Bit
(LSB) of the Next Instruction Pointer (NIP or NPC) could be better used than
now.

The YASEP instructions are 16-bits aligned and the instruction addresses have their LSB cleared by convention. This bit is usually wasted in word-aligned byte-oriented computer architectures.

In the current YASEP architecture, this LSB holds the carry flag of ADD/SUB operations. It is the only status flag that I couldn't get rid of with the usual architectural tricks. As a reminder, instructions can check 3 conditions : register is cleared, has its LSB cleared (odd/even) or MSB (sign) cleared. Every condition can be negated and a 4th condition serves as "always" or "reserved" case. Reading the LSB and MSB is easy, checking for a cleared register is more costly. In some implementation, the register set has "shadow" bits with precomputed/cached "register is clear" bits. But otherwise, no dirty trick is employed.

The Carry bit is less easy to handle : it's a dynamic result that can't be reconstructed from the 16 or 32 bits of the registers. It is not possible to restore it after a thread switch. It can't be added to the "condition cache" because it will have to be saved and restored (16 more bits to save ? Bleh...)

Here come the latest changes :

  1. Breakpointing / tracing / debugging : inject a "1" in the LSB and you can see where the pointer is used.
  2. Safety : for example if the stack is corrupted, there is a chance that the LSB will be set and trigger the trap

In future iterations, this bit could be used for something else more pertinent
(such as a second instruction memory bank selector) so it must be carefully
handled by programers now.


20200409:

I was still undecided ... That damned carry bit is still a pebble in my shoe but this log is now moot : these days, the data and program memory space must be separate and the instruction pointers address 16-bit aligned words, not bytes.

Discussions