%flags now not are a GPR. Now is a internal hidden register. Status stuff like interrupts are now there accessed by special instructions for it. JMP.cc and IF.cc can read arithmetic flags on it. Chaining IFs disappears.
New &renamed instructions :
GET/SET_INT Rn
: Get/Set Interrupt flag (to Enable/Disable interrupts)
GET/SET_SS Rn
: Get/Set Single Step mode (to Enable/Disable single step mode)
GET/CLR_DIVERR Rn
: Get/Clear Division Error flag.
CMP Rd, Rn
: Do comparison, ie SUB Rd, Rn but not sets Rd with the result of subtraction. Only sets %flags
IFXX by IF.cc
: Acts like a prefix instead as proper instructions. Now, not accepts any parameter as CMP sets the flags. Adds one extra cycle to the next instruction.
Assemblers should have an alias for instructions like ADD.cc Rd, Rs, Rn
= IF.cc ADD Rd, Rs, Rn
, or JMP.cc
= IF.cc ADD Rd, Rs, Rn
. Also, IF.cc prefix should have a copy of M and L bits of the prefixed instruction, to allow to be only 2 cycles if it fails.
Example of usage :
Cycle count assuming %r0 = ';' and %r8 being = EXAM_MODE
Old code with the old datapath ,12 instructions -> 4+1+4+1+4+1+3+3+3 = 24 cycles :
IFEQ %r0, ' '
IFEQ %r8, MODE_EXAM
JMP MONITOR_NEW_LADDR
IFEQ %r0, ' '
IFEQ %r8, MODE_STORE
JMP MONITOR_WRITEVAL
IFEQ %r0, '.'
IFEQ %r8, MODE_EXAM ; Only if is in Examination mode
JMP MONITOR_CHMODE_BEXAM ; Changes to block examine mode
IFEQ %r0, ':'
IFEQ %r8, MODE_EXAM ; Only if is in Examination mode
JMP MONITOR_CHMODE_STORE ; Changes to store mode
New code with the new datapath ,12 instructions, -> 3+3+3+2+3+2+3+3 = 22 cycles :
CMP %r0, ' '
JMP.NEQ MONITOR_CHECK_IF_EXAM_MODE
CMP %r8, MODE_EXAM
JMP.EQ MONITOR_NEW_LADDR
CMP %r8, MODE_STORE
JMP.EQ MONITOR_WRITEVAL
MONITOR_CHECK_IF_EXAM_MODE:
CMP %r8, MODE_EXAM
JMP.NEQ MONITOR_END_STUFF
CMP %r0, '.' ; Block Examination command
JMP.EQ MONITOR_CHMODE_BEXAM ; Change to block examine mode
CMP %r0, ';' ; Write data command
JMP.EQ MONITOR_CHMODE_STORE ; hanges to write data mode
MONITOR_END_STUFF: