Question: Write a PIC24 assembly program!! to count the number of bits being set to 1 in a given data field. Your program should do the

Write a PIC24 assembly program!! to count the number of bits being set to 1 in a given data field.

Your program should do the followings:

- Allocate an 8-bit variable called "count"

- Allocate an 8-bit variable called "len"

- Allocate a space called "id" with enough bytes to hold a studentID. (For example, 001234567 needs 9 bytes, 1 per decimal digit).

- Store YOUR studentID to "id" and set "len" to the correct value. (For example, the above student ID can be saved as: 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07)

- Write a loop to read in the bytes in "id" and count the number of bits being set to 1. (In the example above, for ID 001234567, the total number of bits set to 1 is: 12).

- Save the total number of bits being set to 1 in variable "count"

You must submit the followings:

- source file (.s)

- screenshot of successful result when you assemble your program

- screenshot of final SFR showing all working registers used in the program

- screenshot of Register Files showing "count", "len", "id" and their final values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!