Lab Programs Software
Lab Programs Software
Write an ARM assembly language program to copy 32 bit data from code
memory to data memory.
AREA Reset, DATA, READONLY
EXPORT __Vectors
__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN
AREA mycode, CODE, READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0, =SRC
LDR R1, =DST
LDR R3, [R0]
STR R3, [R1]
STOP
B STOP
SRC DCD 8
AREA mydata, DATA, READWRITE
DST DCD 0
END
……………………………………………………………………………………………………………..
EXPORT __Vectors
__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
STOP
B STOP
SRC DCD 8
DST DCD 0
END
……………………………………………………………………………………………………………………
EXPORT __Vectors
__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
UP
SUB R3, #1
BNE UP
STOP
B STOP
SRC DCD 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
DST DCD 0
END
2. B)_ Write an ARM assembly language program to transfer block of ten 32 bit
numbers from one location to another when the source and destination blocks
are overlapping.
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN
AREA mycode,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0,=SRC
MOV R1,#10
MOV R3,#1
LOOP
STR R3,[R0],#4
ADD R3,#1
SUBS R1,#1
BNE LOOP
LDR R0,=SRC
ADD R0,R0,#(SIZE-1)*4
SUB R1,R0,#(OL-1)*4
ADD R1,R1,#(SIZE-1)*4
MOV R3,#10
UP
LDR R4,[R0],#-4
STR R4,[R1],#-4
SUBS R3,#1
BNE UP
STOP
B STOP
SIZE EQU 10
OL EQU 2
AREA myData,DATA,READWRITE
SRC DCD 0
END
………………………………………………………………………………………………………………….
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN
AREA mycode,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0,=SRC
MOV R1,#10
MOV R3,#1
LOOP
STR R3,[R0],#4
ADD R3,#1
SUBS R1,#1
BNE LOOP
LDR R0,=SRC
MOV R5,R0
ADD R0,R0,#(SIZE-1)*4
;SUB R1,R0,#(OL-1)*4
;ADD R1,R1,#(SIZE-1)*4
MOV R3,#5
UP
LDR R6,[R5]
LDR R7,[R0]
STR R7,[R5],#4
STR R6,[R0],#-4
SUBS R3,#1
BNE UP
STOP
B STOP
SIZE EQU 10
;OL EQU 2
AREA myData,DATA,READWRITE
SRC DCD 0
END
LAB 2
LAB NO 2 Solved Exercise:
Write a program to add two 32 bit numbers available in the code memory. Store
the result in the data memory.
EXPORT __Vectors
__Vectors
DCD 0x40001000
DCD Reset_Handler
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
STOP
B STOP
RESULT DCD 0
END
……………………………………………………………………………………………………………….
Reset_Handler
MOV R0, #0
LDR R1, =NUM
MOV R2, #10
LOOP
LDR R3, [R1], #4
ADD R0, R0, R3
SUBS R2, R2, #1
BNE LOOP
Reset_Handler
LDR R1, =NUM1
LDR R2, =NUM2
LDR R3, =RESULT
MOV R4, #4
LOOP
LDR R5, [R1], #4
LDR R6, [R2], #4
ADC R7, R5, R6
STR R7, [R3], #4
SUBS R4, R4, #1
BNE LOOP
STOP
B STOP
STOP
B STOP
LOOP
LDR R5, [R1], #4
LDR R6, [R2], #4
SBC R7, R5, R6
STR R7, [R3], #4
SUBS R4, R4, #1
BNE LOOP
STOP
B STOP
EXTRA PROGRAMS
Write an assembly program to perform addition of 10 natural numbers.
END
……………………………………………………………………………………………………………
LAB 3
LAB NO 3: Solved Exercise
Write an assembly program to multiply two 32 bit numbers.
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors
DCD 0x40001000 ; stack pointer value when stack is empty
DCD Reset_Handler ; reset vector
ALIGN
AREA mycode, CODE, READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
END
Reset_Handler
END
Repeat the above program for BCD multiplication.
Reset_Handler
MOV R0,#VALUEN
MOV R1, #0
MOV R3, #1
LDR R4, =RESULT
VALUEN EQU 10
END
} Return (a);
EXPORT __Vectors
__Vectors
DCD 0x40001000
DCD Reset_Handler
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0, =VALUE1
LOOP
CMP R1, R3
BEQ DONE
BGT GREATER
B LOOP
GREATER
B LOOP
DONE
STOP
B STOP
RESULT DCD 0
END
LAB 4
LAB NO 4: Lab Exercises
EXPORT __Vectors
__Vectors
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0,=NUM
LDR R3,=RESULT
DOWN
ADD R2,#0x30 ; Add 30H to the number, Ascii value of first digit
STRB R2,[R3]
BLS DOWN1
ADD R3,#07
DOWN1
STRB R4,[R3,#01]
RESULT DCD 0
END
EXPORT __Vectors
__Vectors
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
STOP
B STOP
END
EXPORT __Vectors
__Vectors
ALIGN
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R0,#0x29
STOP
B STOP
END