2024 FALL ELEC334 Microprocessors Homework 2 - STD
2024 FALL ELEC334 Microprocessors Homework 2 - STD
Ihsan Cicek
Homework 2 Assigned: 22/11/2024 Due: 29/11/2024 17:00
1. (30 pts) Write an ARM Cortex M3 assembly code which determines positive, and negative numbers in
a series of signed 32-bit numbers. The number of elements in the array is defined by variable LENGTH and
the start address of the array with START label. Your code should place the number of negative elements
in register R7, the number of zero elements in register R6 and the number of positive elements in R5.
Show how your code executes step-by-step using line comments.
2. (30 pts) Write an ARM Cortex M3 assembly code that compares two ASCII character strings to
understand which follows the other in alphabetical ordering. Both strings should have the same length as
defined by the LENGTH variable held in R2. The starting addresses of the strings are defined by the START1
and START2 variables. If the string defined by START1 is greater than or equal to the other string, clear the
GREATER variable held in R1; otherwise set it to 0xFFFFFFFF. Show how your code executes step-by-step
using line comments.
Example: After execution of test cases: A R1 = 0x0000000, for B R1 = 0x0000000, for C R1 = 0xFFFFFFF
3. (40 pts) Write an ARM Cortex M3 assembly code that calculates and determines which element in an
array of 32-bit numbers has the largest number of bits set. The length of the series is defined by variable
LENGTH held in R2 and the series starts with the START label. Store the value with the most bits set in the
R1 register. Show how your code executes step-by-step using line comments.