How to get rid of certain characters in a string on mips assembly -
i wondering if explain me how rid of specific characters in string on mips. example, if string "+104367" , want rid of +, , have simply: 104367.
.data str: .asciiz "hello+world" .text main: la $t0, str # la means load address (so load address of str $t0) li $t1, 0 # $t1 counter. set 0 la $t3, 43 # 43 ascii of '+' in dec countchr: lb $t2, 0($t0) # load first byte address in $t0 beqz $t2, end # if $t2 == 0 go label end bne $t2, $t3, proceed # branch if symbol equals 43 (+) la $t4, $t0 # save position proceed: add $t0, 1 # else increment address add $t1, $t1, 1 # , increment counter of course j countchr # loop end: # whatever want here. # remember length of string stored in $t1 # here have position of '+' saved t4
Comments
Post a Comment