IMMEDIATE OPERANDS Immediates are numerical constants They appear often in code, so there are special instructions for them Otherwise, need more instructions to fetch them from the memory. Add immediate addi ss0, $s1, -10(in MPS f=g-10 where MIPs registers ss0, Ssl are associated with c variables f, g Syntax similar to add instruction, except that last argument is a number instead of a register No subtract immediate instruction
▪ Immediates are numerical constants. ▪They appear often in code, so there are special instructions for them. ▪ Otherwise, need more instructions to fetch them from the memory. ▪Add Immediate: addi $s0,$s1,-10 (in MIPS) f = g - 10 (in C) where MIPS registers $s0,$s1 are associated with C variables f, g. ▪Syntax similar to add instruction, except that last argument is a number instead of a register. ▪No subtract immediate instruction 16
THE CONSTANT ZERO MIPS register 0(Zero) is the constant 0 Cannot be overwritten Useful for common operations E. g, move between registers add $t2, Ssl, Zero
▪MIPS register 0 ($zero) is the constant 0 ▪ Cannot be overwritten ▪Useful for common operations ▪ E.g., move between registers add $t2, $s1, $zero 17
OVERELOW ARITHINTETIC Recall: Overflow occurs when there is a mistake in arithmetic due to the limited precision in computers Example(4-bit unsigned numbers) 1111 +0011 10010 But we don' t have room for 5-bit solution so the solution would be 0010, which is +2, and"wrong
▪Recall: Overflow occurs when there is a “mistake” in arithmetic due to the limited precision in computers. ▪Example (4-bit unsigned numbers): 15 1111 + 3 + 0011 18 10010 ▪But we don’t have room for 5-bit solution, so the solution would be 0010, which is +2, and “wrong”. 18