Professional Documents
Culture Documents
ADD R5 R3 R1
BRN R5 3 If the contents of R5 is
less than 0, then skip the
SUB R2 R2 R5
next two instructions and
SUB R1 R2 R1 go straight to the LD
LD R5 R2 instruction.
Note: conditional branches usually not too far away, so we can use immediate relative addressing.
Status Bits for Branch Control
V
C Branch V
C Function
N Control
N Unit
Z
Z
PL JB BC
From part of Figure 10-15, page 457
Exercise: Can you draw the circuit to output these status bits from the ALU?
Some Possible Branch Instructions
For the instructions on this and the next slide, assume that the operands in the registers are treated as signed
integers in 2’s complement representation.
For above instructions, set FS to 0000 so that the output of the Function Unit is its
input A (see Table 10-4, page 443).
Branch if zero BZ Z == 1
Branch if not zero BNZ Z == 0
Branch if negative BN N == 1
For above instructions, set FS to 0101 so that the output of the Function Unit is A-B
(see Table 10-4, page 443).
Branch if greater BG ( N + V ) + Z == 0
Branch if greater or equal BGE N + V == 0
Branch if less BL N + V == 1
Branch if less or equal BLE ( N + V ) + Z == 1
SP SP – 1 PC M[SP]
M[SP] PC SP SP + 1
PC effective address of sub-routine
Typically, Instruction Set Architectures have a JML (Jump and Link) instruction that is used for making procedure call,
and a JMR (Jump Register) instruction to return from a procedure call. See Table 12-1, page 540.
How does a Stack work?
• Stack is a part of the memory
• A register $SP keeps the pointer (address) of the top of the stack
• In Push operation, $SP is decremented, and the data to be put into
the top of the stack is written into the memory at the location
specified by the new $SP
• In Pop operation, the contents of the memory at location specified
by $SP is read, and $SP is incremented.
Stack grows
100 100
Say, the top of the stack is currently at 101. Now, register $SP contains 102.
In other words, register $SP contains 101. Register R1 contains 000011.
100 100
(-1)s2e-127 x (1.f)
1 8 23
s e f
IEEE Standard
Floating Point Example
10101101001110010000000000000000
010110102 = 90