Ich habe verwenden geschrieben, aber haben ein Problem getroffen:wie einen vordefinierten ganzzahligen Wert in SPIM Codeabschnitt
Zeile 37 der Spalte 5: „x“: Operand von falschen Typ
aber ich habe erklärte es und nannte es richtig, habe ich nicht ,? Genau wie bei den .ascizz Daten, die bei $t1 and $t2
gespeichert sind, weiß ich, dass beide Programme funktionieren, da ich sie getrennt ausführen kann, nur die Bedingung, die ich in Zeile 37 gesetzt habe, was etwas falsch ist.
Ich glaube, whe Problem könnte Fehler in der ersten Zeile des Abschnitts # dritte Nummer sein, wenn li x, 5 5 verwendet wird. Ich glaube, es ist die falsche Methode, die Variable x aufzurufen.
Ich bin neu und es ist wahrscheinlich eine einfache Lösung, aber sobald ich das gemeistert habe, kann ich eine beliebige Anzahl von Variablen festlegen, d. H. X, y, z. Weisen Sie ihnen Zahlen zu und wenden Sie die Bedingung an. Das ist mein gewünschtes Ergebnis dieser kleinen Übung.
.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