Adsense

Solution of assembly language code to arrange set of 32 bit data stored from memory location 0x1FFFF104 in ascending order, No. of data elements is stored on memory location 0x1FFFF100.

Solution:

;code prepared by PAILLA RAGHAVENDRA REDDY

        TTL ascending
        AREA Myprog, CODE, READONLY
ENTRY
        EXPORT main
main
        LDR R7,=0x1FFFF100     ; initialize base address to register r7
        LDR R6,=0x00000000     ; inner loop shift value register r6
        LDR R5,=0x00000000    ; outer loop shift value register r5
       
        LDR R1,[R7,R6]        ; fetch first value for loop to the R1
        ADDS R7,R7,#0x04    ; Shift base address
        LSLS R1,R1,#0x02
        SUBS R1,R1,#0x04
       
LAB2    LDR R2, [R7,R5]
        ADDS R6,R6,#0x04
NEXT    LDR R3, [R7,R6]
        CMP R3,R2
        BLO LAB1
        STR R3,[R7,R5]
        STR R2,[R7,R6]
        LDR R2,[R7,R5]
        LDR R3,[R7,R6]
LAB1    ADDS R6,R6,#0x04
        CMP R6,R1
        BLS NEXT
        ADDS R5,R5,#0x04
        MOV R6,R5
        CMP R1,R6
        BEQ done
        CMP R5,R1
        BNE LAB2
done
        SWI &11
        END

Input:

Result:

 

Write assembly and embedded C code to arrange set of 32 bit data stored from memory location 0x1FFFF104 in ascending and descending order, No. of data elements is stored on memory location 0x1FFFF100.

;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.

Memory transfer

 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. 

Arithmetic

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.

Conditional branch

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.

Write a ARM cortex M0+ assembly language code based on arithmatc and logical instructions.

 Problem 1: Implement following code conversions to convert binary no 0x89ABCDEF(32-bits) into a) BCD (64-bits)   b) Gray (32-bits) Problem...