#IfExample.asm # #Program to demonstrate the use of an if statement. # # This example represents the following Java code: # int x = 5, y = 9; # if(x < y) # { # System.out.println("x is less than y."); # } # System.out.println("After if statement."); # where x is $t1 and y is $t2 .data ifOutput: .asciiz "x is less than y.\n" afterIfOutput: .asciiz "After if statement.\n" .text main: li $t1, 5 #initialize x to 5 li $t2, 9 #initialize y to 9 slt $t3, $t1, $t2 beq $t3, $zero, endif li $v0, 4 #print if statement output la $a0, ifOutput syscall endif: li $v0, 4 la $a0, afterIfOutput syscall li $v0, 10 #end the program syscall