Module 0384: TTP conditional jumps

Tak Auyeung

2023-03-30

Creative Commons License
The work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

1 Description

A conditional jump is a jump instruction, like jmpi and the corresponding register-based instruction jmp, but only conditionally. A conditional jump instruction uses a specific bit in the flags register to determine whether to jump or not.

In general, if x represents one of the flags in the flags register, then the following TTPASM code

   jxi dest

has the same effect as the following equivalent C code:

if (x==1) goto dest;

The English description of jxi dest is as follows:

2 How does it work?

Let’s use jci as a specific example. The microcode of jci configures the processor as follows:

The trick is that PCMux, which is now connected to bit 0 of flags.Q (it is the carry flag), specifies the selection of the mux that outputs to PC.D. This allows the choosing of increment by one (when PCMux==flags.Q[0]) is 0, or to update using *PC (when PCMux==flags.Q[0]) is 1.

This is why the RTL description of jci is as follows:

PC=C ? *PC : PC+1;

In essence, TTP uses one of the bits of the flags register to control the multiplexers that route content to PC.D.

3 What about jnci?

Most architectures support a ‘jump iff a flag is 0’ variant. In RTL, most architectures offer a counterpart jnci to jci that can be described as follows:

PC=(!C) ? *PC : PC+1;

However, such an instruction is really not necessary. The following hypothetical instruction

jnci dest

can be implemented by the following sequence:

jci  cont // continue if C=1
jmpi dest // otherwise go to dest
cont:     // continuation point