# Print a message only if a number is divisible by 2 or 3. # Written by: Andrew Taylor # Written as a COMP1521 lecture example .text main: # Locals: # - $t0: int n # - $t1: n % 2 # - $t2: n % 3 li $v0, 4 # syscall 4: print_string la $a0, prompt_msg # syscall # printf("Enter a number: "); li $v0, 5 # syscall 5: read_int syscall # move $t0, $v0 # scanf("%d", &n); rem $t1, $t0, 2 # if ((n % 2) beqz $t1, two_three_print # == 0) goto two_three_print; rem $t2, $t0, 3 # if ((n % 3) beqz $t2, two_three_print # == 0) goto two_three_print; b epilogue # goto epilogue; two_three_print: li $v0, 4 # syscall 4: print_string la $a0, two_three_msg # syscall # printf("two-three-ish\n"); epilogue: li $v0, 0 # jr $ra # return 0; .data prompt_msg: .asciiz "Enter a number: " two_three_msg: .asciiz "two-three-ish\n"