UE18EC305: Using Keil IDE (Assembly Level Programs) Cycle 1: Computer Organization Laboratory (0-0-2-1-1)
UE18EC305: Using Keil IDE (Assembly Level Programs) Cycle 1: Computer Organization Laboratory (0-0-2-1-1)
UE18EC305: Using Keil IDE (Assembly Level Programs) Cycle 1: Computer Organization Laboratory (0-0-2-1-1)
CYCLE 1
1. Write an ALP to find the GCD (Greatest Common Divisor) with conditional execution of ARM
instructions.
3.Write an ALP to find the product of two matrices using with and without MLA ARM instruction.
AREA MAT3MUL, CODE, READWRITE ; name this block of code
ADR R1,ARRY1
ADR R3, RESULT
MOV R0, #3 ; ROW COUNTER
BACK ADR R2,ARRY2
MOV R4, #3 ;COLUMN COUNTER
NEXT MOV R6,#0
MOV R5,#3 ; DOT MULTIPLICATION COUNTER
X LDR R7, [R1], #4
LDR R8, [R2], #12
MLA R6, R7, R8, R6
SUBS R5, R5, #1
BNE X
STR R6, [R3], #4
SUBS R4, R4, #1
SUB R2, R2, #0X20
SUBNE R1, R1, #12
BNE NEXT
SUBS R0,R0,#1
BNE BACK
HERE B HERE
ARRY1 DCD 1,2,3
DCD 4,5,6
DCD 7,8,9
ARRY2 DCD 1,2,3
DCD 1,2,3
DCD 1,2,3
RESULT SPACE 50
END
Output:
6 0c 12
0f 1e 2d
18 30 48
4.Write an ALP to find the convolution of two sequences using with and without MLA ARM
instruction
AREA CONVOLUTION, CODE, READwrite ; name this block of code
ADR R0,SEQ1
ADR R5, RES
MOV R10, #4
MOV R9,#1
; FIRST HALF
BACK MOV R2,#0
ADR R1, SEQ2
MOV R11,R9
BL PROD
STR R2, [R5],#4
ADD R9, R9, #1
MOV R12, R9, LSL #2
ADD R0, R0, R12
SUBS R10,R10, #1
BNE BACK
; SECOND HALF
MOV R10,#3
MOV R12, #4
BACK1 ADR R1, SEQ2
ADR R0, SEQ1+12
MOV R2, #0
ADD R1, R1, R12
MOV R11, R10
BL PROD
STR R2, [R5], #4
ADD R12, R12, #4
SUBS R10, R10, #1
BNE BACK1
EXIT B EXIT
; DOT PRODUCT
PROD LDR R3,[R0],#-4
LDR R4,[R1],#4
MLA R2,R3,R4,R2
SUBS R11,R11,#1
BNE PROD
MOV PC, LR
SEQ1 DCD 1,2,3,4
SEQ2 DCD 5,6,7,8
RES SPACE 100
END
Output: 5,10,28,3c,3d,34,20
5. ALP to demonstrate ARM Thumb modes interworking.
Main
ThumbProg
ADR r0,ARMProg
BX r0
ARMProg
MOV r4,#4
MOV r5,#5
ADD r4,r4,r5
Stop
MOV r0,#0x18 ;
LDR r1,=0x20026 ;
SWI 0x123456:
END