Bonus Assignment - console

PHOTO EMBED

Tue May 02 2023 15:49:44 GMT+0000 (Coordinated Universal Time)

Saved by @ahmed_salam21

# MIPS Lab Bonus Assignment 
# using console

.data
message: .asciiz "Enter an integer: "
mult4: .asciiz "The number is a multiple of 4."
mult6: .asciiz "The number is a multiple of 6."
notmult: .asciiz "The number is not a multiple of 4 or 6."

.text

  li $v0, 4 # Print prompt message
  la $a0, message
  syscall

  li $v0, 5 # Read integer input
  syscall
  move $t0, $v0 # Store input in $t0

  li $t1, 4 # Check if input is a multiple of 4
  div $t0, $t1
  mfhi $t2
  beqz $t2, MULT4

  li $t1, 6 # Check if input is a multiple of 6
  div $t0, $t1
  mfhi $t2
  beqz $t2, MULT6

  # Input is not a multiple of 4 or 6
  li $v0, 4 # Print not a multiple message
  la $a0, notmult
  syscall
  j EXIT

MULT4:
  li $v0, 4 # Print multiple of 4 message
  la $a0, mult4
  syscall
  j EXIT

MULT6:
  li $v0, 4 # Print multiple of 6 message
  la $a0, mult6
  syscall

EXIT:
  li $v0, 10 # Exit program
  syscall
content_copyCOPY