Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello , I need the code of the assingment in a way that Leg V 8 visual Simulator would understood. Assignment Content Counting Occurrences in

Hello , I need the code of the assingment in a way that Leg V8 visual Simulator would understood.
Assignment Content
Counting Occurrences in ARM Assembly
Objective:
Write an ARM assembly program to count the occurrences of bytes from data2 within data1.
Utilize the provided base addresses for data1(0x10000000- X0) and data2(0x20000000- X1).
Requirements:
Data Initialization:
data 1-2527283031333436373940424345
data 2-3031323334353637
Declare two arrays, data1 and data2, with the provided values.
Use the base addresses 0x10000000 for data1 and 0x20000000 for data2.
Counting Occurrences:
Use the base addresses of data1 and data2 to store the data.
Count the occurrences of each byte from data2 within data1 totally.
Store the total number of occurrences in X5 register.
Comments and Documentation:
Provide clear comments and documentation explaining each section of your code.
Include information about the data structure and any design decisions.
I have this code but this doesn't work on Leg V8, it gives so many errors(unsupported instructions like this)
.data
datal: .byte 125,27,28,30,31,33,34,36,37,39,40,42,43,45
data2: .byte 30,31,32,33,34,35,36,37
.text
.global main
main:
// Initialize registers
mov x0, #0// Index for data1
mov x1, #0// Index for data2
mov x2, #0// Counter for occurrences
ldr x3,=datal // Load base address of datal
ldr x4,=data2// Load base address of data2
check_next_byte:
ldrb w6,[x4, x1]// Load byte from data2 at index x1
ldrb w7,[x3, x0]// Load byte from datal at index x0
cmp w6, w7// Compare bytes
bne not_match // If not equal, skip incrementing counter
add x2, x2, #1// Increment counter if bytes match
not_match:
add x0, x0, #1// Move to next byte in datal
cmp x0, #14// Compare if reached end of datal
b.eq end_loop // If yes, exit loop
add x1, x1, #1// Move to next byte in data2
cmp x1, #7// Compare if reached end of data2
b.eq end_loop // If yes, exit loop
b check_next_byte // Continue looping
end_loop:
// Store the total number of occurrences in register x5
mov x5, x2
// Exit
b exit
exit:
// End of program
mov x7, #93// System call code for exit
svc #0// Perform system call
So please give final code that supports on Leg V8 simulator and working properly

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