Write an Assembly language program titled\"YourLastName_Program1\" that prints o
ID: 3875958 • Letter: W
Question
Write an Assembly language program titled"YourLastName_Program1" that prints out "Hello world", your name, the name of your favorite video game, the name of your favorite film, and the name of your favorite song and the artist(s) who play it. Remember, this course will use the SPIM emulator for MIPS processors. Make sure your programs work on these emulated machines.
Here is the code I have so far. I've figured out the "Hello World" part of the program but I need help figuring out how to print the other 4 strings. Please add on or rewrite my code if necessary, thanks.
# helloworld.s
#
# Print out "Hello World"
.data
msg: .asciiz "Hello World"
.extern foobar 4
.text
.globl main
main: li $v0, 4 # syscall 4 (print_str)
la $a0, msg # argument: string
syscall # print the string
lw $t1, foobar
jr $ra # retrun to caller
Explanation / Answer
Program:-
.data #let processor know we will be submitting data to program now
msg: .asciiz "Hello World,"
insert_Name:
.word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into
Ask_Name:
.asciiz "Please Enter your name " #in unused memory store this string with address Ask_Input
insert_FMovie:
.word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into
Ask_FMovie:
.asciiz "Please Enter your Favourite movie name " #in unused memory store this string with address Ask_Input
insert_FSong:
.word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into
Ask_FSong:
.asciiz "Please Enter your Favourite Song name " #in unused memory store this string with address Ask_Input
insert_Artist:
.word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into
Ask_Artist:
.asciiz "Please Enter Artis name of that song " #in unused memory store this string with address Ask_Input
insert_Namevg:
.word 4 #make a 4 byte (32 bit) space in memory for a word with address insert_into
Ask_Namevg:
.asciiz "Please Enter your Favourate videogame " #in unused memory store this string with address Ask_Input
Tell_message:
.asciiz #in unused memory store this string with address Tell_Output
Tell_name:
.asciiz "My name is : " #in unused memory store this string with address Tell_Output
Tell_namevg:
.asciiz "My favourite video game is : " #in unused memory store this string with address Tell_Output
Tell_fmovie:
.asciiz "My favourite movie is : " #in unused memory store this string with address Tell_Output
Tell_fsong:
.asciiz "My favourite Song is : " #in unused memory store this string with address Tell_Output
Tell_artist:
.asciiz "Artist name of that song is : " #in unused memory store this string with address Tell_Output
.text #enables text input / output
main:
la $a0, Ask_Name #load address Ask_Name from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Name #sets $a0 to point to the space allocated for writing a word
la $a1, insert_Name #gets the length of the space in $a1 so we can't go over the memory limit
li $v0, 8 #load op code for getting a string from the user into register $v0
syscall
la $a0, Ask_Namevg #load address Ask_Namevg from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Namevg #sets $a0 to point to the space allocated for writing a word
la $a1, insert_Namevg #gets the length of the space in $a1 so we can't go over the memory limit
li $v0, 8 #load op code for getting a string from the user into register $v0
syscall
la $a0, Ask_FMovie #load address Ask_FMovie from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_FMovie #sets $a0 to point to the space allocated for writing a word
la $a1, insert_FMovie #gets the length of the space in $a1 so we can't go over the memory limit
li $v0, 8 #load op code for getting a string from the user into register $v0
syscall
la $a0, Ask_FSong #load address Ask_FSong from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_FSong #sets $a0 to point to the space allocated for writing a word
la $a1, insert_FSong #gets the length of the space in $a1 so we can't go over the memory limit
li $v0, 8 #load op code for getting a string from the user into register $v0
syscall
la $a0, Ask_Artist #load address Ask_Artist from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscal l #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Artist #sets $a0 to point to the space allocated for writing a word
la $a1, insert_Artist #gets the length of the space in $a1 so we can't go over the memory limit
li $v0, 8 #load op code for getting a string from the user into register $v0
syscall
la $a0, msg #load address insert_into from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, Tell_name #load address Tell_name from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscal l #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Name #load address insert_name from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, Tell_namevg #load address Tell_namevg from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Namevg #load address insert_Namevg from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, Tell_fmovie #load address Tell_fmovie from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_FMovie #load address insert_FMovie from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, Tell_fsong #load address Tell_fsong from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_FSong #load address insert_FSong from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, Tell_artist #load address Tell_artist from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
la $a0, insert_Artist #load address insert_Artist from memory and store it into arguement register 0
li $v0, 4 #loads the value 4 into register $v0 which is the op code for print string
syscall #reads register $v0 for op code, sees 4 and prints the string located in $a0
li $v0, 10 #loads op code into $v0 to exit program
syscall #reads $v0 and exits program
----------------------------------------------------------------------------------------------------------------------------------------------------------
Output
Please Enter your name
Akash
Please Enter your Favourate videogame
War craft
Please Enter your Favourite movie name
Godzilla
Please Enter your Favourite Song name
7 things
Please Enter Artis name of that song
Miley Cyrus
Hello World,My name is : Akash
My favourite video game is : War craft
My favourite movie is : Godzilla
My favourite Song is : 7 things
Artist name of that song is : Miley Cyrus
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.