Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ARM assembly Level 1 ---- Extract Alphabetical characters from a String Array and Sort them in ascending order Create your own string array as follows:

ARM assembly

Level 1 ---- Extract Alphabetical characters from a String Array and Sort them in ascending order

  • Create your own string array as follows:

Full name : StarID

Example: Arm Assembly: ab7328cd

  • Extract alphabetical characters from the string array and store them into memory with its first element pointed by R5 (R5=0x40000100)
    • Look at ASCII table to find the ASCII value for different characters.
  • Using the insertion sort algorithm, sort the alphabetical characters stored in the memory pointed by R5 in ascending order (min to max).
    • The sorted characters must be stored in memory with its first element pointed to by R5 and should not contain numeric characters.
    • The program must be able to work for ANY size array

Level 2 ---- Extract numeric characters from the string array and find total sum of the numeric values

Example: Arm Assembly: ab7328cd

The summered value present in above string is 7+3+2+8=20

  • Store the sum of the numeric values present in the string into R4
  • Store the total count of alphabetical characters into R2
  • These calculations must work for ANY size array

Extra info:

Algorithm of Insertion Sort:

Insertion sort arranges numbers of an array in a desired order of descending or ascending. It starts from a position, compares two numbers of the array at a time, exchanges their positions for the desired order and moves down the order until they are sorted.

The idea of an insertion sort is to start at a position of an array (given that there are N elements in the array),

  • Compare the two numbers starting from marker position and the element one position lower than marker position and swap them (if needed) for a desired order.
  • Move down the order and take two numbers for comparison until no swapping is needed or comparison takes place between 2nd and 1st element,
  • Increase the marker and repeat the process until marker exceeds the number of elements in the array.

The array will be completely sorted when marker becomes greater than number of elements present in array (N).

Example: Sort a 5-element (N = 5) array of (41, 60, 20, 71, 49) from minimum to maximum.

First Pass/Time: (compare 1 time since marker starts from 2nd position)

(41, 60, 20, 71, 49) (41, 60, 20, 71, 49) Compare the first 2 elements

-> No Swap since 41 < 60

Second Pass/Time: (marker moves to 3rd position, comparison takes place until no swapping is required or 1st and 2nd element is compared again)

(41, 60, 20, 71, 49) (41, 20, 60, 71, 49) Compare -> Swap since 20< 60

(41, 20, 60, 71, 49) (20, 41, 60, 71, 49) Compare -> Swap since 20 < 41

Note: at this point, 20 becomes 1st element and comparison are stopped.

Third Pass/Time: (marker moves to 4th position, comparison takes place until no swapping is required or 1st and 2nd element is compared again)

(20, 41, 60, 71, 49) (20, 41, 60, 71, 49) Compare -> No swap

Note: at this point, since no swapping is required so comparison is stopped.

Fourth Pass/Time: (marker moves to 5th position, comparison takes place until no swapping is required or 1st and 2nd element is compared again)

(20, 41, 60, 71, 49) (20, 41, 60, 49, 71) Compare -> Swap since 49 < 71

(20, 41, 60, 49, 71) (20, 41, 49, 60, 71) Compare -> Swap since 49 < 60

(20, 41, 49, 60, 71) (20, 41, 49, 60, 71) Compare -> No Swapsince 49 < 60

Note: at this point, since no swapping is required so comparison is stopped.

Also, marker is equal to the number of elements present in the array. Finally, the array is sorted in ascending order, and the sorting algorithm terminates.

Given array = (41, 60, 20, 71, 49) => Sorted array = (20, 41, 49, 60, 71)

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

Finance Led Capitalism Shadow Banking Re Regulation And The Future Of Global Markets

Authors: Robert Guttmann

1st Edition

1137398566, 978-1137398567

More Books

Students also viewed these Finance questions

Question

Can the need for discipline be reduced? If so, how?

Answered: 1 week ago