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.










share|improve this question






















  • 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















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.










share|improve this question






















  • 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?