Question: Write an ARMv 8 assembly function ( using Linaro Toolchain ) named count _ wd that finds the number of three - letter words in

Write an ARMv8 assembly function (using Linaro Toolchain) named count_wd that finds the number of three-letter words in a given sentence. The base address of the input sentence (C-String) is passed using register X1 and the number of three letter words is returned using register X0. Write an assembly program (main) to test the assembly function. Create a static character array (C-String) for the input sentence which is stored in the data section of the assembly code and the base address is passed to the function. The user's input sentence will be in correct format without errors and will not have punctuation marks. The maximum size of the input sentence is 63 characters. Store the returned value (number of three-letter words) from the function in register X20. Assume all the registers are used by the main (caller) program to store some data before calling the function. Assemble, test, and simulate the assembly code using DS-5 simulator. Do not upload the entire DS-5 project. Only upload the assembly file (.S file) from the DS-5 project. Comment your assembly code.
Example Assembly code (string_code.S) that shows how to store and read strings:
/* This assembly code simply loads the lower case alphabets from the below */
/* static array (str 1) and converts the alphabets to a upper case alphabets */
/* and stores the upper case alphabets in static array (str 2)*/
.data // data section
.type str1,%object // defining object str1
.size str1,4// string 1
.type str2,%object // defining object str2
.size str2,4// string 2
str1:
.asciz "abc\0"// char values as string
str2:
.byte 0,0,0,0// null char values
.text // program section
.global main // main
.arch armv8-a+fp+simd // processor type
.type main, %function // main function
main:
ADR X9, str1// Load the array address to X9
ADR X10, str2// Load the array address to X10
LDURB W19,[X9, #0]// Load the first char from string 1
SUB W19, W19, #32// Convert to upper case
STURB W19,[X10, #0]// Store the upper case alphabet to string 2
LDURB W19,[X9, #1]// Load the second char from string 1
SUB W19, W19, #32// Convert to upper case
STURB W19,[X10, #1]// Store the upper case alphabet to string 2
LDURB W19,[X9, #2]// Load the third char from string 1
SUB W19, W19, #32// Convert to upper case
STURB W19,[X10, #2]// Store the upper case alphabet to string 2
LDURB W19,[X9, #3]// Load the null from string 1
STURB W19,[X10, #3]// Store the null to string 2
NOP
Write an ARMv 8 assembly function ( using Linaro

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 Programming Questions!