Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is problem: 1 . Counting Occurrences in ARM Assembly Objective: o Write an ARM assembly program to count the occurrences of bytes from data

This is problem:
1. Counting Occurrences in ARM Assembly
Objective:
o Write an ARM assembly program to count the occurrences of bytes from data2 within data1.
o Utilize the provided base addresses for data1(0x10000000- X0) and data2(0x20000000- X1).
Requirements:
Data Initialization:
o data 1-12342468370249366170
o data 2-34353637
o Declare two arrays, data1 and data2, with the provided values.
o Use the base addresses 0x10000000 for data1 and 0x20000000 for data2.
Counting Occurrences:
o Use the base addresses of data1 and data2 to store the data.
o Count the occurrences of each byte from data2 within data1 totally.
o Store the total number of occurrences in X5 register.
Comments and Documentation:
o Provide clear comments and documentation explaining each section of your code.
o Include information about the data structure and any design decisions.
This is solution:
// Initialize data values
MOVZ X0,0x1000, LSL 16// In X0, make the array's main address
MOVZ X1,0x2000, LSL 16// In X1, make the array's main address
MOVZ X2, #0// Set the counter in X2
MOVZ X17, #4// In X17, set the loop counter for the outer loop
MOVZ X18, #10// In X18, set the loop counter for the outer loop
// Load data into registers
MOVZ X6,0x3435// Load data to X6
MOVZ X7,0x3637// Load data to X7
STURH X6,[X0]// At the address in X0, store X6
STURH X7,[X0, #2]// At the address in X0+2, store X7
// Enter more data into the registers.
MOVZ X8,0x1234// Load data to X8
MOVZ X9,0x2468// Load data to X9
MOVZ X10,0x3702// Load data to X10
MOVZ X11,0x4936// Load data to X11
MOVZ X12,0x6170// Load data to X12
STURH X8,[X1]// At the address in X1, store X8
STURH X9,[X1, #2]// At the address in X1+2, store X9
STURH X10,[X1, #4]// At the address in X1+4, store X10
STURH X11,[X1, #6]// At the address in X1+6, store X11
STURH X12,[X1, #8]// At the address in X1+8, store X12
// Comparing the arrays' components using an outer loop
LOOP1: LDURB X3,[X0]//Put a byte into X3 from the location in X0
ADDI X0, X0, #1// Increase X0's address
// Inner loop to compare elements of the arrays
LOOP2: LDURB X4,[X1]//Put a byte into X4 from the location in X1
ADDI X1, X1, #1// Increase X1's address
SUB X5, X3, X4// Keep the value in X5 after subtracting X4 from X3
CBNZ X5, NotInc // If the outcome is not zero, do not increase X2
ADDI X2, X2, #1// Increase the X2 counter
NotInc:
SUBI X18, X18, #1// Reduce the X18 inner loop counter.
CBNZ X18, LOOP2// Repeat the loop if the inner loop counter is not zero
// Reset variables for the next iteration of the outer loop
MOVZ X1,0x2000, LSL 16// Reset the second array in X1 base address
MOVZ X18, #10// In X18, reset the inner loop counter
SUBI X17, X17, #1// Reduce the X17 outer loop counter
CBNZ X17, LOOP1// Repeat the loop if the outer loop counter is not zero
Now, solve this problem for this given datas:
o data 1-2527283031333436373940424345
o data 2-3031323334353637

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

Students also viewed these Databases questions