Question: Write an ARM assembly language program CountVowelsOne.s to count how many vowels and how many non-vowels are in the following string. ARM assembly language is

Write an ARM assembly language program CountVowelsOne.s to count how many vowels and how many non-vowels are in the following string.

 "ARM assembly language is important to learn!",0 

Recommendations for writing the program:

  • Put the string in the memory by using DCB.
  • Use R0 to hold the address of a character in the string.
  • Use R1 to be the counter for vowels.
  • Use R2 to be the counter for non-vowels.
  • Build the program, debug if needed.
  • Run the program step by step and see how values are changing in the registers. OR just run the program and see the final result in the register R1 and R2.
  • Make a screenshot to capture the results in your designated registers

Following is code in ARM for counting length of string, you just need to make changes to count vowel and non vowels.

;The semicolon is used to lead an inline documentation ; ;When you write your program, you could have your info at the top document block ;For Example: Your Name, Student Number, what the program is for, and what it does etc. ; ; This program will count the length of a string. ; ;;; Directives PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset ; Linker requires __Vectors to be exported AREA RESET, DATA, READONLY EXPORT __Vectors __Vectors DCD 0x20001000 ; stack pointer value when stack is empty DCD Reset_Handler ; reset vector ALIGN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Byte array/character string ; DCB type declares that memory will be reserved for consecutive bytes ; You can list comma separated byte values, or use "quoted" characters. ; The ,0 at the end null terminates the character string. You could also use "\0". ; The zero value of the null allows you to tell when the string ends. ; ; The DCB directive allocates one or more bytes of memory, and defines the initial ; runtime contents of the memory. ; ; Example ; Unlike C strings, ARM assembler strings are not null-terminated. ; You can construct a null-terminated C string using DCB as follows: ; C_string DCB "C_string",0 ; ;************************************************************************** string1 DCB "Hello world!",0 ; The program ; Linker requires Reset_Handler AREA MYCODE, CODE, READONLY ENTRY EXPORT Reset_Handler Reset_Handler ;;;;;;;;;;User Code Start from the next line;;;;;;;;;;;; LDR R0, = string1 ; Load the address of string1 into the register R0 MOV R1, #0 ; Initialize the counter counting the length of string1 loopCount LDRB R2, [R0] ; Load the character from the address R0 contains CMP R2, #0 BEQ countDone ; If it is zero...remember null terminated... ; You are done with the string. The length is in R1. ADD R0, #1 ; Otherwise, increment index to the next character ADD R1, #1 ; increment the counter for length B loopCount countDone STOP B STOP END ; End of the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!