Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Reversing a string in MIPS
New Posts  All Forums:Forum Nav:

Reversing a string in MIPS

post #1 of 3
Thread Starter 
Trying to get this program to work but I can't figure out why I keep getting an error. The program is suppose to take an entry of 11 characters, then output the reversed input. The error is as below.
Quote:
Runtime exception at 0x00400034: store address not aligned on word boundary 0x7fffeffb

The code for the program is below. I also need to store the final reversed string into 'revstr'. I am just having trouble with the reversal.
Code:
.data 
str: .space 12
revstr: .space 12
prompt: .asciiz "Enter in string, max 11 characters: "
.text
main:
        
        la      $a0, prompt     #calling opening prompt
        li      $v0, 4
        syscall

        li $v0, 8
        la $a0, str
        li $a1, 12
        syscall

        li $t0, 0
        subu $sp, $sp, 1
        sw $t0, ($sp)
        li $t1, 0

bump1:
        lbu $t0, str($t1)
        beqz $t0, stend
        subu $sp, $sp, 4
        sw $t0, ($sp)
        addu $t1, $t1, 1
        j bump1
        
stend: li $t1, 0

populate:
        lw $t0, ($sp)
        addu $sp, $sp, 4
        beqz $t0, done
        sb $t0, str($t1)
        addu $t1, $t1, 1
        j populate
        
done: 
        li $v0, 4
        la $a1, str
        syscall
        li $v0, 10
        syscall
post #2 of 3
line 18
4 bytes not 1
Code:
subu $sp, $sp, 4
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
Core I7
(13 items)
 
  
CPUMotherboardGraphicsRAM
I7 920 rev. D0 @ 4.26Ghz EVGA X58 SLI EVGA GTX 285 OCZ XMP 3x2Gb (pc3 12800) 
Hard DriveOptical DriveOSMonitor
Western Digital Caviar Black 640Gb x 2 LG GH22LS30 openSuse 12.1 x64 HP F2105 
PowerCase
CORSAIR 850TX Cooler Master ATCS 840 
  hide details  
Reply
post #3 of 3
Thread Starter 
Ha yea I saw that right after I posted, should of corrected myself.

Can't say I am a big fan of learning assembly language. Thanks tom.slick
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Reversing a string in MIPS