IFLT (0x9B)


The IFLT instruction is a conditional branch. The branch is successful if the value at the top of the stack is less than zero. This instruction pops the top element from the stack and sends it to the ALU to see if it is negative. If the N flag is set (N=1 means the value is less than 0) then the branch is successful; otherwise the branch fails.

The operand is a two-byte signed offset. If the branch is successful, this offset is added to the byte address at which the IFLT opcode was found and the sum is placed into the PC as the address of the next opcode in the instruction stream. Otherwise, the PC is incremented by two in order to skip past the two-byte operand.

When writing assembly language code, the operand must be a program label within the same method. The assembler calculates the proper offset value.

Interpreter Microcode

The microinstructions are listed in the order in which they are executed; not the order in which they are stored in the control store.

0x09b  SP=MAR=SP-1; rd; goto 0x34
...
0x034  OPC=TOS; goto 0x35
0x035  TOS=MDR; goto 0x37
...
0x037  ALU=OPC; if N goto 0x101 else goto 0x1

then (N = 1)

0x101  OPC=PC-1; fetch; goto 0x2f
...
0x02f  PC=PC+1; fetch; goto 0x30
0x030  H=MBR<<8; goto 0x31
0x031  H=H OR MBRU; goto 0x32
0x032  PC=H+OPC; fetch; goto 0x33
0x033  ALU=0; goto 0x2
...

else (N = 0)

0x001  PC=PC+1; goto 0x40
...
0x040  PC=PC+1; fetch; goto 0x41
0x041  ALU=0; goto 0x2

If you compare this microcode with the code that interprets the IFEQ and the IF_ICMPEQ instructions, you will notice that the 'then" code and the "else" code are exactly the same in all three.

Example Program

//---------------------------------------------
// Demonstrate the IFLT instruction.
//
// 1. Clear Memory
// 2. Assemble this program.
// 3. Reset the computer.
// 4. Click the "Display Words" radio button
//    below the memory display.
// 5. Click the "Run" button.
//
// This program will display the letter 'T' in
// the input/output window indicating that the
// branch succeeded.
//
// If you bipush a non-negative value in the
// first statement, the letter 'F' will be
// displayed indicating that the branch failed.
//---------------------------------------------
.main
    bipush -1
    iflt a
    bipush 'F'
    goto b
a:  bipush 'T'
b:  out
    halt
.end-main