Member Avatar for IndiaofCarl

I have three problems the first one is to count the letters in a string in Assambler in MIPS. the string that should be counted is "My bird is a happy bird and he like to sing"

.data

ANTAL_TAL:
.word       11
TAL_ARRAY:
.word       1, 3, 6, 9, 2, 4, 6, 8, 10, 55, 113
STR_att_omvandla:
.asciiz "My bird is a happy bird and he like to sing"

TAL_1_str: 
.asciiz "Sum of the " 
TAL_2_str:
.asciiz " integer is " 

STRlen_1_str:
.asciiz "\n\nnumber of stringn \""
STRlen_2_str:
.asciiz "\" ar "
STRlen_3_str:
   .asciiz " pices.\n\n"

STRupper_1_str:
.asciiz "If all lowercase letters are capitalized, the string becomes: \""
STRupper_2_str:
.asciiz "\"\n\n"

.text
.globl main

the secound problem I have is to make this code to_upper and I have this code block:

li      $v0, 4
la      $a0, STRupper_1_str
syscall                            # print string

la    $t9, STR_att_omvandla
repeat_chars:
lb    $a0, ($t9)
beq   $a0, $zero, finish_code
jal   till_versal
addi  $t9, $t9, 1
b     repeat_chars                 # loopa igenom strangen

finish_code:
li      $v0, 4
la      $a0, STR_att_omvandla
syscall                            # print string

li      $v0, 4
la      $a0, STRupper_2_str
syscall                            # print string

###--- EXIT
li      $v0, 10                # MARS / SPIM exit
syscall

------------------------------------
the third problem I have is how to make this sentens to Upper case: "My bird is a happy bird and he like to sing" with this code that I have done. 

main:
##---
### heltalsarray_summa
##---
li      $v0, 4
la      $a0, TAL_1_str
syscall                            # print string

lw      $a0, ANTAL_TAL
li      $v0, 1
syscall                            # print integer

li      $v0, 4
la      $a0, TAL_2_str
syscall                            # print string

li      $v0, -1
la      $a0, TAL_ARRAY
lw      $a1, ANTAL_TAL
jal     heltalsarray_summa         # run subroutine

# Print sum
add     $a0, $v0, $zero
li      $v0, 1
syscall                            # print integer (arraysum)

It seems like a difficult question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.