Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In ARM assembly I need to write a recursive version of the CountLowerCase below. @ Main Program @ print the test string MOV R0, #stdout

In ARM assembly I need to write a recursive version of the 
"CountLowerCase" below. 
 @ Main Program @ print the test string MOV R0, #stdout LDR R1, =TestStringStr SWI SWI_PrStr LDR R1, =TestString SWI SWI_PrStr BL PrintLF @ Count the lower case letters with the iterative function MOV R0, #stdout LDR R1, =CountLowerCaseStr SWI SWI_PrStr LDR R1, =TestString BL CountLowerCase MOV R1, R0 MOV R0, #stdout SWI SWI_PrInt BL PrintLF @ Count the lower case letters with the recursive function MOV R0, #stdout LDR R1, =CountLowerCaseStr SWI SWI_PrStr LDR R1, =TestString BL CountLowerCaseR MOV R1, R0 MOV R0, #stdout SWI SWI_PrInt BL PrintLF SWI SWI_Exit @------------------------------------------------------- PrintLF: /* ------------------------------------------------------- Prints the line feed character ( ) ------------------------------------------------------- Uses: R0 - set to ' ' (SWI_PrChr automatically prints to stdout) ------------------------------------------------------- */ STMFD SP!, {R0, LR} MOV R0, #' ' @ Define the line feed character SWI SWI_PrChr @ Print the character to Stdout LDMFD SP!, {R0, PC} @------------------------------------------------------- CountLowerCase: /* ------------------------------------------------------- Counts number of lower-case letters in a string. (Iterative) ------------------------------------------------------- Uses: R0 - returns number of lower-case letters R1 - address of string to process R2 - character to check for lower-case ------------------------------------------------------- */ STMFD SP!, {R1-R2, LR} MOV R0, #0 @ Initialize counter B CountLowerCaseTest @ Check loop end condition immediately - may be empty string CountLowerCaseLoop: CMP R2, #'a' BLT CountLowerCaseTest CMP R2, #'z' ADDLE R0, R0, #1 CountLowerCaseTest: LDRB R2, [R1], #1 @ Copy character from memory CMP R2, #0 @ At end of string? (NULL terminated) BNE CountLowerCaseLoop _CountLowerCase: LDMFD SP!, {R1-R2, PC} @------------------------------------------------------- CountLowerCaseR: /* ------------------------------------------------------- Counts number of lower-case letters in a string. (Recursive) ------------------------------------------------------- Uses: Uses: R0 - returns number of lower-case letters R1 - address of string to process R2 - character to check for lower-case ------------------------------------------------------- */ @ your code here @------------------------------------------------------- TestStringStr: .asciz "Test String: " CountLowerCaseStr: .asciz "Number of lower case letters: " TestString: .asciz "This is a string." .end 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions