Reputation: 1
.data
prompt_input: .asciiz "Enter value for "
prompt_output: .asciiz "Result: "
newline: .asciiz "\n"
.equation1: .asciiz "(A NAND B) NOR C"
.equation2: .asciiz "(A XOR B) AND C"
.equation3: .asciiz "(A * B) DIV C"
.equation4: .asciiz "(A MOD B) + C"
.text
.globl main
main:
# Display menu to the user
li $v0,4
la $a0,equation_menu
syscall
# Prompt user for equation choice
li $v0,5
syscall
move $t0,$v0 # Store user's choice
# Depending on user's choice, execute corresponding equation
beq $t0,1,equation1
beq $t0,2,equation2
beq $t0,3,equation3
beq $t0,4,equation4
# Invalid choice, exit
li $v0,10
syscall
equation1:
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t1,$v0 # Store A
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t2,$v0 # Store B
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t3,$v0 # Store C
# Calculate (A NAND B) NOR C
nor $t4,$t1,$t2 # NAND operation
nor $t5,$t4,$t3 # NOR operation
# Display result
li $v0,4
la $a0,prompt_output
syscall
move $a0,$t5
li $v0,1
syscall
j exit
equation2:
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t4,$v0 # Store A
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t5,$v0 # Store B
li $v0,4
la $a0,prompt_input
syscall
li $v0,5
syscall
move $t6,$v0 # Store C
# Calculate (A XOR B) AND C
xor $t7,$t4,$t5 # XOR operation
and $s0,$t7,$t6 # AND operation
# Display result
li $v0,4
la $a0,prompt_output
syscall
move $a0,$s0
li $v0,1
syscall
j exit
equation3:
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t1, $v0 # Store A
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t2, $v0 # Store B
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t3, $v0 # Store C
# Calculate (A * B) / C
mul $t4, $t1, $t2 # Multiplication operation
div $t5, $t4, $t3 # Division operation
# Display result
li $v0, 4
la $a0, prompt_output
syscall
move $a0, $t5
li $v0, 1
syscall
j exit
equation4:
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t1, $v0 # Store A
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t2, $v0 # Store B
li $v0, 4
la $a0, prompt_input
syscall
li $v0, 5
syscall
move $t3, $v0 # Store C
# Calculate (A MOD B) + C
div $t4, $t1, $t2 # Modulo operation
mfhi $t5
add $t5, $t5, $t3 # Addition operation
# Display result
li $v0, 4
la $a0, prompt_output
syscall
move $a0, $t5
li $v0, 1
syscall
j exit
exit:
# Exit program
li $v0,10
syscall
when i run this program, it displays the error "Instruction references undefined symbol at 0x00400028" and this "0x00400028] 0x3c010000 lui $1, 0 [equation_menu] ; 6: la $a0,equation_menu"
I tried many ways like changing asciiz into asciz, adding main and deleting spaces but nothing works.
Upvotes: 0
Views: 21