;Write assembly and embedded C code to arrange set of 32 bit data stored from memory location ;0x1FFFF104 in ascending order and descanding, No. of data elements is stored on memory location ;0x1FFFF100.
Steps to arrange block of 32 bit size data in ascending order
Initialize registers
Step 1:
- Initialize register with the memory location 0x1FFFF100 for base address i.e. R7.
- Initialize 0x00000000 to any of the register for holding Shift value i.e. R6. We need to add 0x04
In case, of
Word we need to ADD 0x04
half word ADD 0x02 and
byte ADD 0x01.
Step 2:
- Fetch 32 bit data from next memory location and initialize to any of register for the looping i.e. R1.
- Add 0x04 into base address(0x1FFFF100) to now start fetching from 0x1FFFF104.
Step 3:
- Fetch first data (32bit) and store to any register i.e. in R2.
- Add 0x04 into Shift value register(R6)(content-0x00000000) to now (0x00000004).
Step 4
Fetch second word ans store to another register i.e in R3.
Step 5
- Compare First data (R2) and second data (R3) if data in R2 is greater than the data R3 than continue.
- otherwise change content on related memory locations of R2 and R3. as well after that swap content of R2 and R3 as well.
Step 6
Repeat step 4 and 5 up till entire block scanned.
Step 7:
Start scan block of data again from leaving one location (bcoz max data store at that location).
Step 8
Repeat step 3 to 7.
Repeat above Steps to arrange data in descending for given set of 32 bit data.
Note:
if you are facing any doubt, please ask the query in comment section.
No comments:
Post a Comment