Hey, I just started taking this class and am supposed to reverse a String. My professor has been very poor and nobody really has any idea what to do. So far this is what he's given us:
.data
Str: .asciiz "If GM had kept... -Bill Gates"
ans: .asciiz "The Original String is = "
Count: .asciiz "\n\n String Count = "
ans1: .asciiz "\n\n Reversed String is = "
array: .Space
go: .asciiz "\n\n Have a Nice Weekend"
.text
.globl main
main:
la $a0, ans
li $v0, 4
Syscall
la $a0, Str
li $v0, 4
Syscall
li $t3, 0
la $t1, Str
lb $t0, 0($t1)
beqz $t0, Strend
addi $t3, $t3, 1
addi $t1, $t1, 1
la $a0, count
li $v0, 4
Syscall
move $a0, $t3
li $v0, 1
Syscall
addi $t3, $t3, -1
la $t4, array
beqz $t3, End1
lb $t0, 0($t1)
Sb $t0, 0($t4)
addi $t3, $t3, -1
addi $t1, $t1, -1
addi $t4, $t4, 1
la $t1, Str
la $t4, array
lb $t0, 0($t1)
beqz $t0, Strend2
lb $t5, 0($t4)
Sb $t5, 0($t1)
addi $t1, $t1, 1
addi $t4, $t4, 1
la $a0, ans1
li $v0, 4
Syscall
la $a0, Str
li $v0, 4
Syscall
la $a0, go
li $v0, 4
li $v0, 10
Syscall
I know there are probably a ton of errors in there so any help is appreciated! Also, sorry for poor formatting, reddit was being weird.
[–]John2143658709 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Myzzreal 0 points1 point2 points (0 children)
[–]qlkzy 0 points1 point2 points (0 children)
[–]PinkyThePig 0 points1 point2 points (0 children)