# add 17 and 25 then print the result # Written by: Dylan Brotherston # On: 2023-02-12 # # Written as a COMP1521 lecture example # Constant for the magic number of the print integer syscall SYSCALL_PRINT_INT = 1 # Constant for the magic number of the print character syscall SYSCALL_PRINT_CHAR = 11 # Constant for the return value of the main function EXIT_SUCCESS = 0 .text .globl main main: # x in $t0 # y in $t1 # z in $t2 li $t0, 17 # x = 17 li $t1, 25 # y = 25 add $t2, $t1, $t0 # z = x + y # printf("%d", z); move $a0, $t2 # move the result of the addition into the first argument to the syscall, if we are copying the contents of one register to another register we use MOVE li $v0, SYSCALL_PRINT_INT # magic number for the print int syscall ( printf("%d") ) syscall # printf("%c", '\n'); li $a0, '\n' # load the newline character as the first argument to the syscall, as a character is an immediate value we use LI li $v0, SYSCALL_PRINT_CHAR # magic number for the print char syscall ( printf("%c") ) syscall # return 0 li $v0, EXIT_SUCCESS jr $ra