I have written this section of code but have hit a problem:
line 37 column 5: "x": operand is of incorrect type
but I have declared it and called it correctly, have I not,? just the same as with the .ascizz data stored at $t1 and $t2
I know that both the programs work as I can run them separate it the just the condition I have placed on line 37 which is some what wrong.
I believe whe problem could be error on the first line of section # third number when li x, 5 5 is used. I believe it's the wrong method of calling the variable x.
I'm new to this and it's probably a simple fix but once I have mastered this i can set any amount of variables i.e x,y,z. Assign numbers to them and apply condition.that's my desired outcome of this little exercise.
.data
prompt1: .asciiz "\n\n Enter firs integer please: "
prompt2: .asciiz "Enter second integer please: "
result: .asciiz "The result is:"
x: .word 60
array1: .space 12 # declare 12 bytes of storage to hold array of 3 integers
.text
main:
#t0 - to hold first integer
#t1 - to hold secon integer
#t2 - to hold sum of $t1 and $t0
# first number
li $v0, 4 # system call to print string asking for input
la $a0, prompt1 # address of string to print
syscall
li $v0, 5 # system call to read integer
syscall
move $t0, $v0 # move the read number stored in $v0 into $t0
#second number
li $v0, 4
la $a0, prompt2
syscall
li $v0, 5
syscall
move $t1, $v0
#thir number
li x, 5
syscall
move $t3, $v0
add $t2,$0,$0
add $t2, $t1, $t0 # add contents of $t0 and $t1 and store in $t2
bge st2, $t3, end # Branch to Label if st2 ≥ x (signed)
# print out contents of $t2
li $2,1 # $v0<-service#1 (print int)
move $4, $t2 # $a0<-$8, move result to $a0
syscall # call to system service
li $v0, 10 #syscall to exit
syscall
end:
la $t0, array1 # load base address of array into register $t0
li $t1, 5 # $t1 = 5 ("load immediate")
sw $t1, ($t0) # first array element set to 5; indirect addressing
li $t1, 13 # $t1 = 13
sw $t1, 4($t0) # second array element set to 13
li $t1, -7 # $t1 = -7
sw $t1, 8($t0) # third array element set to -7
li $v0, 1
move $a0, $t2
syscall