COMPUTER SCIENCE AND ENGINEERING DEPARTMENT
UCS617: Microprocessor based Systems Design
LAB ASSIGNMENT-3
ARM Processor
1. Write a program in ARM assembly language to add and subtract two 32-bit numbers using:
i) Direct addressing mode
ii) Indirect addressing mode
area program, code, readonly
entry
main
LDR R0,V1
LDR R1,V2
LDR R2,[R0]
LDR R3,[R1]
ADD R4,R2,R3
area program, data, readonly
V1 DCD &00000030
V2 DCD &00000036
END
iii) Barrel shifter
2. Write a program to perform left and right shift of a number.
3. Write a program to find whether number is even or odd.
4. Write a program to perform Multiplication using addition.
5. Write a program to store Multiplication table of a number.
6. Write a program to perform Division using subtraction.
area program,code,readonly
entry
main
LDR R1,divident
LDR R2,divisor
LDR R4,count
LOOP
ADD R4,#1
SUB R1,R1,R2
CMP R2,R1
BLE LOOP
area program,data,readonly
divident DCD &0000000C
divisor DCD &00000003
count DCD 0
end
7. Write a program to count the number of characters in a given string.
area program,code,readonly
entry
main
LDR R0,=Data
MOV R1,#-1
LOOP
ADD R1,R1,#1
LDRB R2,[R0],#1
CMP R2,#0
BNE LOOP
area program,data,readonly
Data DCB "BUILDING-012345"
end
8. Write a program to find the number of occurrence of a particular character in a string.
area program,code,readonly
entry
main
LDR R0,=Data
MOV R1,#0
LOOP
LDRB R2,[R0],#1
CMP R2,#"A"
BNE DONE
ADD R1,R1,#1
CMP R2,#0
BNE LOOP
area program,data,readonly
Data DCB "AbccAa a"
end
9. Write a program to add two integer strings.
10. Write a program to find the factorial of a number.
area program, code, readonly
entry
main
LDR R0,V1
MOV R1,#1
MOV R2,#1
MOV R3,R1
LOOP
MUL R3,R1,R2
MOV R1,R3
ADD R2,R2,#1
CMP R2,R0
BLE LOOP
area program, data, readonly
V1 DCD 0x00000003
END
11. Write a program to perform 64-bit addition of two 64-bit number.
area program,code,readonly
entry
main
LDR r0,=num1
LDR r1,=num2
LDR r2,num1
LDR r4,num2
LDR r3,[r0,#0x04]
LDR r5,[r1,#0x04]
ADDS r6,r3,r5
ADC r7,r2,r4
LDR r0,=result
SWI &110
area program,data,readonly
value1 DCD &12A3E640,&2F100123
value2 DCD &00101082,&40023F51
result DCD 0
end
12. Write a program to find the largest number in an array.
area program, code, readonly
entry
main
LDR R0,=V1 ;
LDRB R1,[R0] ;
LDR R2,count ;
loop
LDRB R3,[R0],#0x01 ;
CMP R3,R1
MOVGT R1,R3 ;
SUB R2,#0X01 ;
CMP R2,#0X00 ;
BNE loop
area program,data,readonly
count DCD &00000006 ; <---change count depending on length of V1 string
V1 DCB 1,5,2,7,5,9
END
13. Write a program to copy an array.
14. Write a program in ARM assembly language to implement the following equation:
i) ax2+by2
ii) 6(x+y) +2z+4
15. Write a program in ARM assembly language to verify how many bytes are present in a given set which
resemble 0xAC.
16. Write a program in ARM assembly language to count the number of 1s and 0s in a given byte and verify
the result.