MIPS on qtspim. Add two string entries to the following code. one string should
ID: 3751373 • Letter: M
Question
MIPS on qtspim. Add two string entries to the following code. one string should be namefield and another shouldbe last name field. no input required
.data
limit: .word 50
space: .asciiz " "
newline: .asciiz " "
tab_space: .asciiz " "
msg_01: .asciiz "A sample MIPS Code "
msg_02: .asciiz "here write what this program does "
msg_03: .asciiz " End of program ! "
.text
.globl main
main: la $a0, msg_01
li $v0, 4
syscall
la $a0, msg_02
li $v0, 4
syscall
lw $a0, limit
la $a1, space
loop: beq $0,$a0, exit
addi $a0, $a0, -1
li $v0, 1
syscall
move $t0,$a0
move $a0, $a1
li $v0, 4
syscall
move $a0, $t0
j loop
exit: la $a0, msg_03
li $v0, 4
syscall
li $v0, 10
syscall
Explanation / Answer
Here as you asked to asked to interduce 2 string variable of name and lastname ,these are initialized
as char array of size 30 each .
programme will ask for first name and last name in the begining and will store it in respective variables.
These variable can be used anytime in the programme
-comment if you want anything else from this code
Codes:
.data
firstname: .space 30 #strings is initialized with 29 char ,1 char for
lastname: .space 30 #strings is initialized with 29 char ,1 char for
limit: .word 50
space: .asciiz " "
newline: .asciiz " "
tab_space: .asciiz " "
msg_01: .asciiz "A sample MIPS Code "
msg_02: .asciiz "here write what this program does "
msg_03: .asciiz " End of program ! "
.text
.globl main
main:
# added code
la $a0 firstname #it load the address of the "firstname" variable into $a0
li $v0 8
syscall
la $a0 lastname #it load the address of the "firstname" variable into $a0
li $v0 8
syscall
#####
la $a0, msg_01
li $v0, 4
syscall
#print firstname lastname from preveouly stored variable
la $a0 firstname
li $v0 4
syscall
la $a0 lastname
li $v0 4
syscall
#
la $a0, msg_02
li $v0, 4
syscall
lw $a0, limit
la $a1, space
loop: beq $0,$a0, exit
addi $a0, $a0, -1
li $v0, 1
syscall
move $t0,$a0
move $a0, $a1
li $v0, 4
syscall
move $a0, $t0
j loop
exit: la $a0, msg_03
li $v0, 4
syscall
li $v0, 10
syscall
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.