¿Cómo imprimir la suma de 2 números en MIPS?

CorePress2024-01-24  10

Estoy intentando obtener la suma de 2 números pero tengo dificultades. Intenté almacenar valores en v0 e intenté agregarlos usando s0. Pero no funcionó.



------------------------------------

#abajo es un ejemplo

.datos int1: .palabra 23

int2: .palabra 3

resultado: .palabra 0

.globl principal

.texto

principal:

lw$t0, int1

lw$t1, int2

añadir $t2,$t0,$t1

sw $t2, resultado

li $v0, 1 #estas instrucciones se utilizarán para imprimir

lw $a0, resultado

llamada al sistema

CompartirSeguir Respondido

27 de marzo de 2021 a las 7:53

Roshaan Tariq Khan

Roshaan Tariq Khan

1



------------------------------------

.data
A: .word 2 # this is the block to initialize values 
B: .word 4

.text

.globl  main
.ent    main
main:
    lw $t0,A # load value of A in temp register t0 
    lw $t1,B # load value of B in temp register t1
    add $t2,$t0,$t1 # add the value of temp register t0 and t1 then place it in temp register t2
    
    li $v0,10 #
    syscall   # exit the program
.end    main
Compartir SeguirRespondido

27 de marzo de 2021 a las 8:59

Ali Asghar

Ali Asghar

1

Su guía para un futuro mejor - libreflare
Su guía para un futuro mejor - libreflare