ALP-Embedded Lab
ALP-Embedded Lab
ALP-Embedded Lab
RESULT:
RESULT:
3. Write a ALP to find the number of 0’s and 1’s in a 32 bit data
AREA count01, CODE, READONLY
EXPORT __main
NUM DCD 0x88000099 ; Initialize the number (1000 1000 0000 0000 0000 0000 1001
1001)
__main
MOV R0,#0 ;R0 is counter for 0
MOV R1,#0 ;R1 is counter for 1
MOV R3,#32 ;R3 indicates 32 bit data
LDR R2, NUM
BACK LSRS R2,#1 ;Logical shift right by 1 time
BCS NEXT ;Branch to Next if carry is
set(LSB=1)
ADD R0,R0,#1 ;R3=R1+1 increment 0's counter
B skip ; Jump or branch to label skip
NEXT ADD R1,R1,#1 ;R3=R1+1 increment 1's counter
skip SUB R3,R3,#1 ;R3=R3-1
CMP R3,#0
BNE BACK ;Branch to Label back if z flag not equal
to 1
END
RESULT:
4. Write ALP to determine whether the given 16 bit number is even or
odd
AREA evenodd, CODE, READONLY
EXPORT __main
NUM DCD 0x00000096 ; Initialize the number
__main
LDR R0, NUM
MOV R2, #0xA
LDR R1, NUM
LSRS R0, #1 ; Logical shift Right by 1 time
BCS NEXT ; Branch to Next if Carry is set[LSB=1]
MOV R2,#0x0 ;If the number is EVEN store 0 in R2
B skip
NEXT MOV R2,#0x1 ;If the number is ODD store 1 in R2
skip NOP
END
RESULT:
5. Write a ALP to write DATA into RAM location
AREA Datawrite, CODE, READONLY
EXPORT __main
DATA DCD 0x12345678
__main
LDR R0,DATA ;LOAD DATA INTO R0
LDR R1,=RAMLOC ;LOAD R1 WITH ADDRESS OF DESTINATION
LOCATION
STR R0,[R1]
LDR R2,=RAMLOC1 ;LOAD R2 WITH ADDRESS OF DESTINATION
LOCATION 1
STR R0,[R2]
LDR R3,=RAMLOC2 ;LOAD R3 WITH ADDRESS OF DESTINATION
LOCATION 2
STR R0,[R3]
AREA RAM , DATA, READWRITE
RAMLOC DCD 0
RAMLOC1 DCD 1
RAMLOC2 DCD 2
END
RESULT: