Mips count characters in string

In summary, the conversation discusses how to count characters in a string and display the result in hexadecimal using MIPS programming. The user is reminded to show their work and is asked several questions about their knowledge of MIPS, counting methods, accessing string characters, and displaying hex values. Resources are provided for further learning, but the expert is unable to help with writing the program.
  • #1
keo
1
0
Summary:: Count characterers in a string and display it in hexadecimal

[New user has been reminded to show their work on schoolwork problems]

Hi, how can I do this in MIPS?
Given a string of characters, the program has to count the number of characters in the string, and display it in hexadecimal.
Thank you!
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
1) Do you know how to count In MIPS?

2) Do you know how to look at each character in a string?

3) Do you know what character marks the end of a string?

4) Do you know about integers and how they are stored in memory?

5) If you look at a stored integer 4-bits at a time you can map it to a hex character.

To help here's a bunch of MIPS programming examples and there are many sites online with further examples. From them, you might methods of counting, accessing string characters, and displaying hex values.

Sadly, though we can't help you write your program, we can critique if you give a version and tell us why it's not working.

https://courses.cs.washington.edu/courses/cse378/03wi/lectures/mips-asm-examples.html
 
Last edited:

FAQ: Mips count characters in string

How does the MIPS processor count characters in a string?

The MIPS processor counts characters in a string by using a loop to iterate through each character in the string and incrementing a counter for each character encountered. This counter is then returned as the total number of characters in the string.

What is the MIPS assembly code for counting characters in a string?

The MIPS assembly code for counting characters in a string involves using the lb (load byte) instruction to load each character from memory, and the addi (add immediate) instruction to increment the counter. This is done within a loop until all characters in the string have been processed.

Can the MIPS processor count characters in a string with non-ASCII characters?

Yes, the MIPS processor can count characters in a string with non-ASCII characters. It treats each character as a byte and can handle characters with a value of up to 255.

How does the MIPS processor handle special characters while counting characters in a string?

The MIPS processor handles special characters while counting characters in a string by treating them as regular characters and including them in the count. For example, if the string contains a space or punctuation mark, it will still be counted as a character.

Can the MIPS processor count characters in a string with null terminators?

Yes, the MIPS processor can count characters in a string with null terminators. It will continue to count characters until it encounters a null terminator, which indicates the end of the string. The null terminator will not be included in the character count.

Similar threads

Replies
10
Views
2K
Replies
12
Views
2K
Replies
2
Views
2K
Replies
1
Views
1K
Replies
7
Views
2K
Replies
24
Views
3K
Replies
2
Views
3K
Back
Top