Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: Write an ARM assembly language routine to count the number of 1s in a 32-bit word in rO and return the result in

image text in transcribed

image text in transcribed

Exercise 1: Write an ARM assembly language routine to count the number of 1s in a 32-bit word in rO and return the result in r1 code LDR r0, = 0x11AB003F MOV r1,#0x0 MOV r2 , #32 MOVS rO'rO, ROR #1 ADDCS r1,r1,#1 SUBS r2, r2 , #1 BNE OnesCount ;dummy value for r1 :clear ones counter use r2 as the loop counter : Repeat: rotate r0 right set flags ;if carry set increment 1s counter : decrement loop counter ;until all bits tested (11 ones) OnesCount If this was a subroutine Count, the code might be: area test, CODE, readwrite ADR Sp, Stackl LDR r2 ,-0xFFFFFFFF STR r2, [sp] :set up dummy r2 ;dummy data ;call routine ; read result BL MOV r3,rl NOP NOP Count Lab 4 exl ; save r2 and return on the stack STMFD sp!, (r2,lr) MOV r1,#0x0 MOV r2,#4 Count Exercise 1: Write an ARM assembly language routine to count the number of 1s in a 32-bit word in rO and return the result in r1 code LDR r0, = 0x11AB003F MOV r1,#0x0 MOV r2 , #32 MOVS rO'rO, ROR #1 ADDCS r1,r1,#1 SUBS r2, r2 , #1 BNE OnesCount ;dummy value for r1 :clear ones counter use r2 as the loop counter : Repeat: rotate r0 right set flags ;if carry set increment 1s counter : decrement loop counter ;until all bits tested (11 ones) OnesCount If this was a subroutine Count, the code might be: area test, CODE, readwrite ADR Sp, Stackl LDR r2 ,-0xFFFFFFFF STR r2, [sp] :set up dummy r2 ;dummy data ;call routine ; read result BL MOV r3,rl NOP NOP Count Lab 4 exl ; save r2 and return on the stack STMFD sp!, (r2,lr) MOV r1,#0x0 MOV r2,#4 Count

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

More Books

Students also viewed these Databases questions

Question

=+ What is the role of government in bargaining?

Answered: 1 week ago

Question

=+ Who is the negotiation partner at company level?

Answered: 1 week ago