Adsense

Showing posts with label prac4. Show all posts
Showing posts with label prac4. Show all posts

solution of assembly code to find the maximum and minimum from block of 32 bit data stored from memory location 0x1FFFF104, No. of data elements is stored on memory location 0x1FFFF100.

Solution1:

;jigar visani perform the code successfully roll no d19ec120 

              TTL transfer
        AREA Myprog, CODE, READONLY
ENTRY
        EXPORT main
main
        LDR R7,=0X1FFFF100 ; initialize the register R7 with starting address
        LDR R1,[R7,R1]     ; fetch the first value to R1 for counting  
        LSLS R1,R1,#0x02   ; left shift the R1 by 2 position to multiply with 4
        ADDS R7,R7,#0X04   ; add R7= R7+4 to start fetch the data from 0x1FFFF104
        LDR R3,=0X00000000 ; store maximum value
        LDR R4,=0XFFFFFFFF ; store the minimum value
       
COMPARE LDR R5,[R7,R6]    ; fetch first data into R5
        ADDS R6,R6,#0X04  ; Shift R6 to fetch the next word
        CMP R6,R1         ; compare R6 with R1 to continue loop
        BEQ done          ; if R6=R1 than end loop otherwise continue
        CMP R5,R3         ; compare the R5 with R3 to find greater
        BHI GREATER       ; number are unsigned so if R5>R3 than jump to label
back    CMP R5,R4         ; compare R5 with R4 to find minimum number
        BLO LESS          ; if R5<R3 jump to desired location
        B COMPARE         ; unconditional jump to comapre
      
GREATER MOVS R3,R5        ; transfer if R5 is higher than R3
        B back            ; jump to label
       
LESS    MOVS R4,R5        ; transfer if R5 smaller than R4
        B COMPARE         ; jump to label
 
done
        SWI &11
        END

Solutions .........

Please students try different logic. So, i can put some more stuff here.

Write assembly and embedded C code to find the maximum and minimum from 32 bit data stored from memory location 0x1FFFF104, No. of data elements is stored on memory location 0x1FFFF100.

;Write assembly and embedded C code to find the maximum, and minimum  ;from 32 bit data stored from memory location 0x1FFFF104, No. of data ;elements is stored on memory location 0x1FFFF100.

Steps to find the maximum from given set of 32 bit data

 

Step 1:

- Initialize register with the memory location 0x1FFFF100 i.e. R7 for holding base address.

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

- Initialize 0x00000000 to any of the register for holding maximum value i.e. R3.


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 next data (32bit) and store to any register i.e. in R2.

- Fix any of the register to store maximum number from list i.e. in R3

Arithmetic 

Step 5:

Compare content of both registers mentioned above.

Step 6: 

if the content of Data register (R2) is higher than content of maximum no register(R3) than transfer the content of data register(R2) into max register(R3).

Conditional branch

Step 7:

- Repeat steps 3 and 6 also decrease the looping register(R1) 

- Continue up to the value stored in Step 2 i.e. register R1 goes to zero.

 

Repeat above Steps to find the minimum from 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...