For the following MIPS pseudoinstructions please implement t
For the following MIPS pseudo-instructions, please implement them using generic MIPS instructions (those can be directly mapped into machine language format).
li $v0, 4
move $t1, $v0
sge $t2, $t1, $t3
bge $t2, $t1, Label
Solution
Arithmetic Instructions
Control Structures
Branches
Jumps
Subroutine Calls
subroutine call: \"jump and link\" instruction
subroutine return: \"jump register\" instruction
Note: return address stored in register $ra; if subroutine will call other subroutines, or is recursive, return address should be copied from $ra onto stack to preserve it, since jal always places return address in this register and hence will overwrite previous value
System Calls and I/O (SPIM Simulator)
The following table lists the possible syscall services.
1
2
3
4
5
6
7
8
9
10
| Service | Code in $v0 | Arguments | Results | 
|---|---|---|---|
| print_int | 1 | $a0 = integer to be printed | |
| print_float | 2 | $f12 = float to be printed | |
| print_double | 3 | $f12 = double to be printed | |
| print_string | 4 | $a0 = address of string in memory | |
| read_int | 5 | integer returned in $v0 | |
| read_float | 6 | float returned in $v0 | |
| read_double | 7 | double returned in $v0 | |
| read_string | 8 | $a0 = memory address of string input buffer $a1 = length of string buffer (n) | |
| sbrk | 9 | $a0 = amount | address in $v0 | 
| exit | 10 | 


