#include <iostream>
int main() {
int a = 5;
int b = 7;
int c = a + b;
std::cout << "Sum: " << c << std::endl;
return 0;
}
.data
a: .word 5
b: .word 7
c: .word 0
newline: .asciiz "\n"
prompt: .asciiz "Sum: "
.text
main:
lw $t0, a # Load a into $t0
lw $t1, b # Load b into $t1
add $t2, $t0, $t1 # Add $t0 and $t1, store result in $t2
la $a0, prompt # Load address of prompt into $a0
li $v0, 4 # System call for print_str
syscall
move $a0, $t2 # Move $t2 (sum) to $a0
li $v0, 1 # System call for print_int
syscall
la $a0, newline # Load address of newline into $a0
li $v0, 4 # System call for print_str
syscall
li $v0, 10 # System call for exit
syscall