Adsense

Showing posts with label unconditional program flow control. Show all posts
Showing posts with label unconditional program flow control. Show all posts

Write assembly language code for all type of unconditional program flow control instructions.

;Write assembly language code for all type of unconditional program flow control instructions.
;************************unconditional branch*****************************************
;Table 1: branch instructions with ranges
;==============================================================================
;Branch range           Available instruction                                        
;==============================================================================
;Under +/–254 bytes     B label                                                        
;                       B<cond> label                                                
;Under +/–2 KB          B label                                                            
;Under +/–16 MB         BL label, BX LR                                                    
;Over +/–16 MB          LDR R0, =label    ; Load the address value of label in R0        
;                       BX R0; Branch to address pointed to by R0, or                
;                       BLX R0; Branch to address pointed to by R0 and update LR    
;==============================================================================
        TTL transfer
        AREA Myprog, CODE, READONLY
ENTRY
        EXPORT main
main

        B LOAD_R2        ; B to the label
load_return

;Branch and link with updated value of LR = R14
        BL LOAD_ADD1        ;branch and updated PC link to the LR(R14), return to the next instruction
;***************************by-pass subroutine***************************
LOOP17    B done
;*****************sub-routins********************************************
LOAD_R2
        MOVS R2,#0X04
        LDR R0,=load_return ; psudo load value of label into the R0 for BX instruction
        BX R0                ; unconditional return through branch and exchange

;loop inside the loop
;use of BLX and BL with <Rm>
LOAD_ADD1
        MOV R1,R14            ;Storing the LR(R14) value into R1 for further use
        LDR R2,=load        
        BLX R2                ;Jump to the PC where R2 is pointing and update LR with new value
        LDR R3,=add2
        BLX R3                ;Jump to the PC where R3 is pointing and update LR with new value
        BX R1                ;Return from original location/ return to the line BL LOAD_ADD1
;load subroutine        
load    LDR R6,=0x034        
        LDR R7,=0x235
        BX LR                ; return to the line next to BLX R2
;add subroutine        
add2    ADDS R6, R7, R6
        BX LR                  ; return to the line next to BLX R3
;*****************end of subroutine****************************************
done
        SWI &11
        END

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