04-25-2014, 01:27 AM
Does anyone have any experience with MIPS? I've found that the machine code used in minecraft CPUs are often very crude compared to actual architectures. I'm not an expert, but usually they have awkward I/O and never handle strings. Also they lack addresses.
Here is some example (modified) code:
Here is some example (modified) code:
Code:
.text # Begin
.globl main
main:
# Input A
li $v0,5 # read_int syscall code = 5
syscall
move $t0,$v0 # syscall results returned in $v0
# Input B
li $v0,5 # read_int syscall code = 5
syscall
move $t1,$v0 # syscall results returned in $v0
add $t0, $t0, $t1 # A = A + B
# Print sum (integer)
li $v0,1 # print_int syscall code = 1
move $a0, $t0 # int to print must be loaded into $a0
syscall
li $v0,4 # print_string syscall code = 4
la $a0, newline
syscall
li $v0,10 # exit
syscall
# Start .data segment
.data
newline: .asciiz "\n"