lab6_ex1.asm (717B)
1 .eqv SYS_PRINT_STRING 4 2 .eqv SYS_READ_WORD 5 3 .eqv SYS_EXIT 10 4 5 .data 6 inputmsg: .asciiz "Number: " 7 evenstr: .asciiz "Even number\n" 8 oddstr: .asciiz "Odd number\n" 9 10 .text 11 .globl main 12 13 main: 14 li $v0, SYS_PRINT_STRING 15 la $a0, inputmsg 16 syscall 17 18 li $v0, SYS_READ_WORD 19 syscall 20 21 # Get the LSB 22 andi $t0, $v0, 1 23 beq $t0, 1, odd 24 25 li $v0, SYS_PRINT_STRING 26 la $a0, evenstr 27 syscall 28 j exit 29 30 odd: 31 li $v0, SYS_PRINT_STRING 32 la $a0, oddstr 33 syscall 34 35 exit: 36 li $v0, SYS_EXIT 37 syscall