Trying to display using the MMIO simulator tool in mars problem (assembly language mips)
up vote
0
down vote
favorite
did some searching and couldn't quite find a definitive answer on this. I'm trying to display a string of text onto the MMIO simulator in assembly language (mars 4.5 ide). So in the code I ask the user to input a string, then I jump to a function that will access the appropriate register to achieve this. Heres my code so far
.data
# Do an inputted string text.
input1: .asciiz "Please enter a string: "
# Make enough space for the array.
array1: .space 101
# Resulting string.
output1 :.asciiz "nInputted string from MMIO: "
.text
# Display the first input and the resulting string.
li $v0, 4
la $a0, input1
syscall
li $v0, 8
la $a0, array1
la $a1, 101
syscall
# Move the address of the first element in a temporary register.
la $t0, ($a0)
# Now store some items on the stack.
addiu $sp, $sp, -12
sw $ra, ($sp)
sw $t0, 4($sp)
# Then call the function to print that output back using a mock syscall
jal print_line
# Restore whats on the stack.
lw $ra, ($sp)
lw $t0, 4($sp)
addiu $sp, $sp, 12
# Terminate the program.
li $v0, 10
syscall
# Define the key_getter function.
print_line:
# Now load some stuff from the stack into this area.
lw $a1, 4($sp)
# Then gather the hard coded memory address of the display terminal
li $a2, 0xffff0000
# At this point, $a1 holds the memory address of the first element in the string.
# And $a2 holds the memory address of the display register for the MMIO.
loop:
#####
display_not_ready:
# Load the word from our display terminal with an offset of 8.
lw $t0, 8($a2)
# Then isolate the bit at the very end.
andi $t0, $t0, 1
# This means if the bit is 1, then the display is ready, if not branch
# until it is ready.
beqz $t0, loop
# Check it the 12th offset is a new line if it is branch to done.
lw $t1, 12($a2)
beq $t1, 10, done
# If we've reached this far then there is a character ready to print.
sw $t1, 12($a2)
# Move to the next character in the array.
addi $a1, $a1, 1
# Then branch back up to loop.
b loop
# Have our done ready.
done:
jr $ra
The problem: Whenever I assemble the code and enter the string, my program gets stuck in an infinite loop around the memory address of "display_not_ready" and beqz $t0, loop.
And it never displays the string to the MMIO simulator in the display field.
Note: After reading a few of the answers on this website, yes I always make sure that the "connect to mips" button is activated. This is not the problem.
assembly mips32 mars
add a comment |
up vote
0
down vote
favorite
did some searching and couldn't quite find a definitive answer on this. I'm trying to display a string of text onto the MMIO simulator in assembly language (mars 4.5 ide). So in the code I ask the user to input a string, then I jump to a function that will access the appropriate register to achieve this. Heres my code so far
.data
# Do an inputted string text.
input1: .asciiz "Please enter a string: "
# Make enough space for the array.
array1: .space 101
# Resulting string.
output1 :.asciiz "nInputted string from MMIO: "
.text
# Display the first input and the resulting string.
li $v0, 4
la $a0, input1
syscall
li $v0, 8
la $a0, array1
la $a1, 101
syscall
# Move the address of the first element in a temporary register.
la $t0, ($a0)
# Now store some items on the stack.
addiu $sp, $sp, -12
sw $ra, ($sp)
sw $t0, 4($sp)
# Then call the function to print that output back using a mock syscall
jal print_line
# Restore whats on the stack.
lw $ra, ($sp)
lw $t0, 4($sp)
addiu $sp, $sp, 12
# Terminate the program.
li $v0, 10
syscall
# Define the key_getter function.
print_line:
# Now load some stuff from the stack into this area.
lw $a1, 4($sp)
# Then gather the hard coded memory address of the display terminal
li $a2, 0xffff0000
# At this point, $a1 holds the memory address of the first element in the string.
# And $a2 holds the memory address of the display register for the MMIO.
loop:
#####
display_not_ready:
# Load the word from our display terminal with an offset of 8.
lw $t0, 8($a2)
# Then isolate the bit at the very end.
andi $t0, $t0, 1
# This means if the bit is 1, then the display is ready, if not branch
# until it is ready.
beqz $t0, loop
# Check it the 12th offset is a new line if it is branch to done.
lw $t1, 12($a2)
beq $t1, 10, done
# If we've reached this far then there is a character ready to print.
sw $t1, 12($a2)
# Move to the next character in the array.
addi $a1, $a1, 1
# Then branch back up to loop.
b loop
# Have our done ready.
done:
jr $ra
The problem: Whenever I assemble the code and enter the string, my program gets stuck in an infinite loop around the memory address of "display_not_ready" and beqz $t0, loop.
And it never displays the string to the MMIO simulator in the display field.
Note: After reading a few of the answers on this website, yes I always make sure that the "connect to mips" button is activated. This is not the problem.
assembly mips32 mars
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction likebeqz
the next instruction is executed before branch is taken (just putnop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).
– Ped7g
Nov 16 at 21:52
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
did some searching and couldn't quite find a definitive answer on this. I'm trying to display a string of text onto the MMIO simulator in assembly language (mars 4.5 ide). So in the code I ask the user to input a string, then I jump to a function that will access the appropriate register to achieve this. Heres my code so far
.data
# Do an inputted string text.
input1: .asciiz "Please enter a string: "
# Make enough space for the array.
array1: .space 101
# Resulting string.
output1 :.asciiz "nInputted string from MMIO: "
.text
# Display the first input and the resulting string.
li $v0, 4
la $a0, input1
syscall
li $v0, 8
la $a0, array1
la $a1, 101
syscall
# Move the address of the first element in a temporary register.
la $t0, ($a0)
# Now store some items on the stack.
addiu $sp, $sp, -12
sw $ra, ($sp)
sw $t0, 4($sp)
# Then call the function to print that output back using a mock syscall
jal print_line
# Restore whats on the stack.
lw $ra, ($sp)
lw $t0, 4($sp)
addiu $sp, $sp, 12
# Terminate the program.
li $v0, 10
syscall
# Define the key_getter function.
print_line:
# Now load some stuff from the stack into this area.
lw $a1, 4($sp)
# Then gather the hard coded memory address of the display terminal
li $a2, 0xffff0000
# At this point, $a1 holds the memory address of the first element in the string.
# And $a2 holds the memory address of the display register for the MMIO.
loop:
#####
display_not_ready:
# Load the word from our display terminal with an offset of 8.
lw $t0, 8($a2)
# Then isolate the bit at the very end.
andi $t0, $t0, 1
# This means if the bit is 1, then the display is ready, if not branch
# until it is ready.
beqz $t0, loop
# Check it the 12th offset is a new line if it is branch to done.
lw $t1, 12($a2)
beq $t1, 10, done
# If we've reached this far then there is a character ready to print.
sw $t1, 12($a2)
# Move to the next character in the array.
addi $a1, $a1, 1
# Then branch back up to loop.
b loop
# Have our done ready.
done:
jr $ra
The problem: Whenever I assemble the code and enter the string, my program gets stuck in an infinite loop around the memory address of "display_not_ready" and beqz $t0, loop.
And it never displays the string to the MMIO simulator in the display field.
Note: After reading a few of the answers on this website, yes I always make sure that the "connect to mips" button is activated. This is not the problem.
assembly mips32 mars
did some searching and couldn't quite find a definitive answer on this. I'm trying to display a string of text onto the MMIO simulator in assembly language (mars 4.5 ide). So in the code I ask the user to input a string, then I jump to a function that will access the appropriate register to achieve this. Heres my code so far
.data
# Do an inputted string text.
input1: .asciiz "Please enter a string: "
# Make enough space for the array.
array1: .space 101
# Resulting string.
output1 :.asciiz "nInputted string from MMIO: "
.text
# Display the first input and the resulting string.
li $v0, 4
la $a0, input1
syscall
li $v0, 8
la $a0, array1
la $a1, 101
syscall
# Move the address of the first element in a temporary register.
la $t0, ($a0)
# Now store some items on the stack.
addiu $sp, $sp, -12
sw $ra, ($sp)
sw $t0, 4($sp)
# Then call the function to print that output back using a mock syscall
jal print_line
# Restore whats on the stack.
lw $ra, ($sp)
lw $t0, 4($sp)
addiu $sp, $sp, 12
# Terminate the program.
li $v0, 10
syscall
# Define the key_getter function.
print_line:
# Now load some stuff from the stack into this area.
lw $a1, 4($sp)
# Then gather the hard coded memory address of the display terminal
li $a2, 0xffff0000
# At this point, $a1 holds the memory address of the first element in the string.
# And $a2 holds the memory address of the display register for the MMIO.
loop:
#####
display_not_ready:
# Load the word from our display terminal with an offset of 8.
lw $t0, 8($a2)
# Then isolate the bit at the very end.
andi $t0, $t0, 1
# This means if the bit is 1, then the display is ready, if not branch
# until it is ready.
beqz $t0, loop
# Check it the 12th offset is a new line if it is branch to done.
lw $t1, 12($a2)
beq $t1, 10, done
# If we've reached this far then there is a character ready to print.
sw $t1, 12($a2)
# Move to the next character in the array.
addi $a1, $a1, 1
# Then branch back up to loop.
b loop
# Have our done ready.
done:
jr $ra
The problem: Whenever I assemble the code and enter the string, my program gets stuck in an infinite loop around the memory address of "display_not_ready" and beqz $t0, loop.
And it never displays the string to the MMIO simulator in the display field.
Note: After reading a few of the answers on this website, yes I always make sure that the "connect to mips" button is activated. This is not the problem.
assembly mips32 mars
assembly mips32 mars
asked Nov 16 at 21:35
Bruthon1
143
143
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction likebeqz
the next instruction is executed before branch is taken (just putnop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).
– Ped7g
Nov 16 at 21:52
add a comment |
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction likebeqz
the next instruction is executed before branch is taken (just putnop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).
– Ped7g
Nov 16 at 21:52
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction like
beqz
the next instruction is executed before branch is taken (just put nop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).– Ped7g
Nov 16 at 21:52
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction like
beqz
the next instruction is executed before branch is taken (just put nop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).– Ped7g
Nov 16 at 21:52
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345732%2ftrying-to-display-using-the-mmio-simulator-tool-in-mars-problem-assembly-langua%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is this running on real MIPS CPU? Then you need to write with delayed branching on mind, i.e. after every branch instruction like
beqz
the next instruction is executed before branch is taken (just putnop
after every branch instruction to be sure the code will work the same time with both delayed branching OFF (simulators support such mode) or ON (real MIPS or simulators configured as real CPU).– Ped7g
Nov 16 at 21:52