Kevin_P23
asked on
Reading a string in MIPS assembly language
I am very new to writing in assembly.
My question is, if there is are bunch of characters entered in by the user, and I only want to access one character at a time, would the following code work for me? (The effect I hope to acheive would be similar to getchar() in C)
-----------
abcdefg
-----------
#code to read each letter, one at a time
buffer: .space 1
...
la $a0, buffer
li $a1, 1
li $v0, 8
syscall
So the first time I use this code, "a" will be read, and next "b", and so forth. I am assigning a high value because this solution is needed very soon.
My question is, if there is are bunch of characters entered in by the user, and I only want to access one character at a time, would the following code work for me? (The effect I hope to acheive would be similar to getchar() in C)
-----------
abcdefg
-----------
#code to read each letter, one at a time
buffer: .space 1
...
la $a0, buffer
li $a1, 1
li $v0, 8
syscall
So the first time I use this code, "a" will be read, and next "b", and so forth. I am assigning a high value because this solution is needed very soon.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.