Adsense

Write KL25Z ARM cortex M0+ code to transfer data with in the processor (register to register)

 Assembly code

; Write assembly code to trasfer the data with in the processor
;------------------------------------------------------------------
; Targeted instructions are of mainly four type
; 1. Data transfer Register to Rregister
; 2. data transfer Register to Rregister with all flags get affected
; 3. Immediate data into register with flags get affected
; 4. Special register to register and vice versa
;---------------------------------------------------------------------
        TTL transfer
        AREA Myprog, CODE, READONLY

ENTRY
        EXPORT main
main

        LDR R1,=0x25    ; Load R1 with 0x25
        LDR R2,=0x23    ; Load R2 with 0x23
        MOV R7,R1        ; Mov content of R7 to R1
        MOVS R3,R2        ; Mov content of R2 to R3
        MOVS R4,#0x02    ; Mov immediate 8 bit data 0x22 to R4
        MRS R5,MSP        ; Save specical purpose register APSR's content into R5

        ADDS R5,R5,#0x01; Increse main stack pointer value stored in R5 by 1
        MSR MSP, R5        ; Load content of thr R5 into APSR
done
        SWI &11            ; Call system interrupt to end the program
        END

 Result:


 Embedded C code

#include "MKL25Z4.h"

int main(void)
{
volatile char a = 0x06, c=0x00;
volatile short int    d= 0x00;
c= a;
d = c;
return 0 ;
}

Result:

No comments:

Post a Comment

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