PDA

View Full Version : Esercizio Assembler (SPIM)


Kuntz87
03-04-2007, 16:48
TRACCIA:

Eseguire un programma che prenda in input un nome e riscriva su terminale video un messaggio di saluto con il nome della persona accodato alla fine del messaggio

Esempio
OUTPUT: Come ti chiami?
INPUT: Brad Pit
OUTPUT: Seee mo sullo spim ce mette mano pure Brad Pit

SVOLGIMENTO:


.text
.globl main

main:

li $v0, 4 #stampa di una stringa
la $a0, stringauno #caricamento stringa da stampare
syscall #stampa stringauno

li $v0, 8 #lettura di una stringa
la $a0, buffer
li $a1, 100
syscall #legge un nome

li $v0, 4 #stampa di una stringa
la $a0, risposta #caricamento stringa da stampare
syscall #stampa "Bread Pitt"

li $v0, 4 #stampa di una stringa
la $a0, rispostadue #caricamento stringa da stampare
syscall

li $v0, 10 #exit
syscall #termina programma




.data

stringauno:

.asciiz "Come ti chiami? "

risposta:

.asciiz "Bread Pitt"

buffer:

.space 100

rispostadue:

.asciiz "See mo sullo SPIM ce mette mano pure Bread Pitt"



MI DITE SE E' GIUSTO?

grazie

Capua
03-04-2007, 17:18
a vederlo a occhio sembrerebbe giusto...ma non potresti provarlo sul simulatore spim?

Kuntz87
03-04-2007, 18:00
ho installato pcspim ma non riesco a farlo funzionare

Kuntz87
03-04-2007, 18:35
PUOI DIRMI SE E' GIUSTO ANCHE QUESTO? E' L'ULTIMO
NEL LINK C'è LA TRACCIA(E' LA NUMERO 2)

http://it.geocities.com/fliberat/arch2/marzo1.htm




.text
.globl main

main:


lw $t2,x

verifica:

rem $t3,$t2,10

beqz $t3,end

add $t2,$t2,1

j verifica

end:

add $t0,$t2,1
sw $t0,y
la $t1,y
break



.data

x: .word 38
y: .word 0