| | |
Help with modifying strings
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 6
Reputation:
Solved Threads: 0
I am taking a class in Assembly this semester and am currently at a loss. The first two projects I found easy enough but now we are working with strings. I have a basic skeleton for the program that gets input.
This succeeds in getting the input and writing it back to the screen. I just need to do a few modifications to the string that is entered. If the user enters nothing then the program exits. Any letters entered are reversed, upper to lower case and vice versa. I know that the difference in a letter's upper and lower case is 0x20, and 0x0a is the hex for a new line(user just typed enter) but I cannot figure out how to use this and the entered string to achieve the desired result. I asked the professor for help and he just told me the differnce is 0x20 hex, make sure the only things to change case are letters, and a new line is 0x0a. I already know all this, it is just the actual conversion that is giving me problems. Any help or hints in the right direction would be appreciated. I feel like I need to navigate the string one byte(character) at a time, and pass each character to a chg subroutine, but I haven't been able to get anything to work
Thank you for your time
PS, the assembly I am coding in is MIPS but I am sure that I can use other assembly code or tips and modify it as needed for my processor.
Assembly Syntax (Toggle Plain Text)
.data strbuf: .space 80 # Buffer for string being flipped ann: .ascii "Welcome to UpLo\n" .asciiz "Type a sentence and I will swap upper/lower case\n" prompt: .asciiz "New sentence (just return to exit): " .text # Main Program # main: li $v0,4 # Announce myself with a message la $a0,ann # on the terminal. syscall loop: li $v0,4 # Prompt for a new sentence la $a0,prompt syscall jal readstr # Read the string jal chgcase # Flip upper/lower case jal wrtstr # Write the result b loop done: # Get here when all done. li $v0,10 # "exit" syscall syscall readstr: li $v0,8 la $a0,strbuf li $a1,80 syscall jr $ra wrtstr: li $v0,4 la $a0,strbuf syscall jr $ra chgxit: jr $ra
This succeeds in getting the input and writing it back to the screen. I just need to do a few modifications to the string that is entered. If the user enters nothing then the program exits. Any letters entered are reversed, upper to lower case and vice versa. I know that the difference in a letter's upper and lower case is 0x20, and 0x0a is the hex for a new line(user just typed enter) but I cannot figure out how to use this and the entered string to achieve the desired result. I asked the professor for help and he just told me the differnce is 0x20 hex, make sure the only things to change case are letters, and a new line is 0x0a. I already know all this, it is just the actual conversion that is giving me problems. Any help or hints in the right direction would be appreciated. I feel like I need to navigate the string one byte(character) at a time, and pass each character to a chg subroutine, but I haven't been able to get anything to work
Thank you for your time
PS, the assembly I am coding in is MIPS but I am sure that I can use other assembly code or tips and modify it as needed for my processor.
![]() |
Similar Threads
- Tutorial: User Input: Strings and Numbers [C++] (C++)
- Modifying this random word program (Python)
- Splitting String (Python)
- modifying text file (Python)
- problem in modifying data in a binary file (C++)
- assignment help [fstream, on modifying a record in a file] (C++)
- modifying an exe (C)
Other Threads in the Assembly Forum
- Previous Thread: new to assembly
- Next Thread: Teach yourself assembly??
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop nohau osdevelopment print program range read remainder shape string text theory tsr x86






