how can i break a String into characters in MIPS assembly,byte by byte.Basicly i want to take a user inputed...












0















.data
str10: .asciiz "Give me a string:n "

.align 2
B: .Space 100
.align 2
C: .Space 100

.text

main:

add $10,$0,$0


StringChanger:
addi $12,$0,100
addi $11,$0,0 #j
addi $13,$0,0 #i
la $a0,str10
li $v0,4
syscall
li $v0,8
la $a0,C
li $a1,100 #arrays length
syscall

la $t0,1($a0)
lb $t1,($t0)
move $v0,$t1
li $v0,4
syscall









share|improve this question

























  • lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

    – Peter Cordes
    Nov 14 '18 at 23:35











  • yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

    – Nick A.a
    Nov 14 '18 at 23:38











  • v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

    – Peter Cordes
    Nov 14 '18 at 23:41











  • thanks for your time but it just prints ''D'' every time

    – Nick A.a
    Nov 14 '18 at 23:57











  • The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

    – Peter Cordes
    Nov 15 '18 at 0:20
















0















.data
str10: .asciiz "Give me a string:n "

.align 2
B: .Space 100
.align 2
C: .Space 100

.text

main:

add $10,$0,$0


StringChanger:
addi $12,$0,100
addi $11,$0,0 #j
addi $13,$0,0 #i
la $a0,str10
li $v0,4
syscall
li $v0,8
la $a0,C
li $a1,100 #arrays length
syscall

la $t0,1($a0)
lb $t1,($t0)
move $v0,$t1
li $v0,4
syscall









share|improve this question

























  • lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

    – Peter Cordes
    Nov 14 '18 at 23:35











  • yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

    – Nick A.a
    Nov 14 '18 at 23:38











  • v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

    – Peter Cordes
    Nov 14 '18 at 23:41











  • thanks for your time but it just prints ''D'' every time

    – Nick A.a
    Nov 14 '18 at 23:57











  • The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

    – Peter Cordes
    Nov 15 '18 at 0:20














0












0








0








.data
str10: .asciiz "Give me a string:n "

.align 2
B: .Space 100
.align 2
C: .Space 100

.text

main:

add $10,$0,$0


StringChanger:
addi $12,$0,100
addi $11,$0,0 #j
addi $13,$0,0 #i
la $a0,str10
li $v0,4
syscall
li $v0,8
la $a0,C
li $a1,100 #arrays length
syscall

la $t0,1($a0)
lb $t1,($t0)
move $v0,$t1
li $v0,4
syscall









share|improve this question
















.data
str10: .asciiz "Give me a string:n "

.align 2
B: .Space 100
.align 2
C: .Space 100

.text

main:

add $10,$0,$0


StringChanger:
addi $12,$0,100
addi $11,$0,0 #j
addi $13,$0,0 #i
la $a0,str10
li $v0,4
syscall
li $v0,8
la $a0,C
li $a1,100 #arrays length
syscall

la $t0,1($a0)
lb $t1,($t0)
move $v0,$t1
li $v0,4
syscall






string assembly mips mars-simulator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 23:40









Peter Cordes

128k18190327




128k18190327










asked Nov 14 '18 at 23:32









Nick A.aNick A.a

11




11













  • lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

    – Peter Cordes
    Nov 14 '18 at 23:35











  • yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

    – Nick A.a
    Nov 14 '18 at 23:38











  • v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

    – Peter Cordes
    Nov 14 '18 at 23:41











  • thanks for your time but it just prints ''D'' every time

    – Nick A.a
    Nov 14 '18 at 23:57











  • The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

    – Peter Cordes
    Nov 15 '18 at 0:20



















  • lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

    – Peter Cordes
    Nov 14 '18 at 23:35











  • yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

    – Nick A.a
    Nov 14 '18 at 23:38











  • v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

    – Peter Cordes
    Nov 14 '18 at 23:41











  • thanks for your time but it just prints ''D'' every time

    – Nick A.a
    Nov 14 '18 at 23:57











  • The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

    – Peter Cordes
    Nov 15 '18 at 0:20

















lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

– Peter Cordes
Nov 14 '18 at 23:35





lb or lbu sign- or zero-extends a byte from memory into a register, and you're already using that. Do that in a loop with an increment to the address. Your code is an unreadable mess because you didn't use code formatting, but I don't see any branch instructions. Obviously you need to loop.

– Peter Cordes
Nov 14 '18 at 23:35













yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

– Nick A.a
Nov 14 '18 at 23:38





yeah sry about the code format ,the thing is that for some reason it prints the whole string not just the 1st character.So i want it to work for 1 first then i will add the loop

– Nick A.a
Nov 14 '18 at 23:38













v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

– Peter Cordes
Nov 14 '18 at 23:41





v0=4 / syscall is print-string. v0=11 / syscall is print character. Read the manual: courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

– Peter Cordes
Nov 14 '18 at 23:41













thanks for your time but it just prints ''D'' every time

– Nick A.a
Nov 14 '18 at 23:57





thanks for your time but it just prints ''D'' every time

– Nick A.a
Nov 14 '18 at 23:57













The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

– Peter Cordes
Nov 15 '18 at 0:20





The syscall takes its arg in $a0, so you need to lbu $a0, C($t0) or something.

– Peter Cordes
Nov 15 '18 at 0:20












0






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',
autoActivateHeartbeat: false,
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%2f53310336%2fhow-can-i-break-a-string-into-characters-in-mips-assembly-byte-by-byte-basicly-i%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310336%2fhow-can-i-break-a-string-into-characters-in-mips-assembly-byte-by-byte-basicly-i%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

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values