Kartik Takyar 101803618 Jatin Kapoor 101803619 Himanshu Mahajan 101803620 Gaurish Garg 101803621 Aditi Pandey 101803622
Kartik Takyar 101803618 Jatin Kapoor 101803619 Himanshu Mahajan 101803620 Gaurish Garg 101803621 Aditi Pandey 101803622
On
Submitted by:
Submitted to
Assistant Professor
2. Write a program in ARM assembly language to perform left and right shift of a number ......................... 6
8. Write a program to find the number of occurrence of a particular character in a string ........................ 14
11. Write a program to perform 64-bit addition of two 64-bit numbers. .............................................................. 17
14. Write a program in ARM assembly language to implement the following equations ............................... 20
14.1. ax2+bx2 ................................................................................................................................................................................20
14.2. 6(x+y)+2z+4 ......................................................................................................................................................................21
15. Write a program verify how many bytes are present in a given set which resemble 0xAC ................... 22
16. Write a program to count the number of 1s and 0s ina given byte and verify the result ........................ 23
1. Write a program in ARM assembly language to add and subtract two
32-bit numbers using:
AREA PROGRAM,CODE,READONLY
ENTRY
MOV R1, #5
MOV R2, #3
ADDS R3, R1, R2
SUBS R4, R1, R2
END
Output:
R3: 0x00000008
R4: 0x00000002
Screenshot:
Figure 1.1
Page 3 of 23
1.2. Indirect Addressing Mode
Code:
Output:
R5: 0x0000C3A6
R6: 0xFFFFD252
Screenshot:
Figure 1.2
Page 4 of 23
1.3. Barrel Shifting
Code:
Output:
R1: 0x0000000C
R2: 0xFFFFFFFC
Screenshot:
Figure 1.3
Page 5 of 23
2. Write a program in ARM assembly language to perform left and right
shift of a number
Code:
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R1,VALUE1
MOV R3,R1,LSL#0x01
MOV R4,R1,LSR#0x01
AREA program,data,readonly
VALUE1 DCD &00000004
END
Output:
R3: 0x00000008
R4: 0x00000002
Screenshot:
Figure 2.1
Page 6 of 23
3. Write a program to find whether a number is even or odd.
Code:
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R1, =VALUE1
LDR R2, =VALUE2
AND R3, R1, R2
AREA program,data,readonly
VALUE1 EQU 45
VALUE2 EQU 0x000001
END
Output:
R3: 0x00000001
Screenshot:
Figure 3.1
Page 7 of 23
4. Write a program to perform multiplication using addition.
Code:
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R0, =VALUE1
LDR R1, =VALUE2
MOV R2, R0
MOV R3, #0X01
LOOP
ADD R3,R3,#0X01
ADD R0,R0,R2
CMP R1,R3
BNE LOOP
VALUE1 EQU 2
VALUE2 EQU 6
END
Output:
R0: 0x0000000C
Screenshot:
Figure 4.1
Page 8 of 23
5. Write a program to store multiplication table of a number
Code:
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R0, =VALUE1
LDR R1, =VALUE2
MOV R2, #0X0A
MOV R3,R0
LOOP
STR R0,[R1]
ADD R0, R0, R3
SUB R2, R2, #0X01
ADD R1,R1,#0X04
CMP R2, #0X00
BNE LOOP
VALUE1 EQU 3
VALUE2 EQU 0X00000100
END
Output:
[0x00000100]-[0x0003] = 03
[0x00000104]-[0x0007] = 06
[0x00000108]-[0x000A] = 09 …and so on
Screenshot:
Figure 5.1
Page 9 of 23
Figure 5.2
Page 10 of 23
6. Write a program to perform division using subtraction
Code:
area program,code,readonly
entry
main
LDR R0,dividend
LDR R1,divisor
MOV R2,#0x00
MOV R3,R0
LOOP
SUB R3,R3,R1
ADD R2,R2,#0x01
CMP R3,#0x00
BNE LOOP
area program,data,readonly
dividend DCD &0000000A
divisor DCD &00000002
END
Output:
R2: 0x00000005
Page 11 of 23
Screenshot:
Figure 6.1
Page 12 of 23
7. Write a program to count the number of characters in a given string
Code:
Output:
R2: 0x00000007
Screenshot:
Figure 7.1
Page 13 of 23
8. Write a program to find the number of occurrence of a particular
character in a string
Code:
Output:
R1: 0x00000003
Screenshot:
Figure 8.1
Page 14 of 23
9. Write a program to add two integer strings
Code:
Output:
[0x00000000-0x00000003] = 06 08 0A 0C
Screenshot:
Figure 9.1
Page 15 of 23
10.Write a program to find the factorial of a number
Code:
Output:
R2: 0x00000078
Screenshot:
Figure 10.1
Page 16 of 23
11.Write a program to perform 64-bit addition of two 64-bit numbers.
Code:
Output:
[0x0000000 – 0x00000007] = 94 5D 30 FD 90 47 8E 33
Screenshot:
Figure 11.1
Page 17 of 23
12.Write a program to find the largest number in an array.
Code:
Output:
R1: 0x000000009
Screenshot:
Figure 12.1
Page 18 of 23
13.Write a program to copy an array
Code:
Output:
[0x00000000-0x000000009] = 09 08 00 03 00 00 02 05 05 01
Screenshot:
Figure 13.1
Page 19 of 23
14.Write a program in ARM assembly language to implement the following
equations
14.1. ax2+bx2
Code:
Output:
R9: 0x00000034
Screenshot:
Figure 14.1
Page 20 of 23
14.2. 6(x+y)+2z+4
Code:
Output:
R9: 0x0000001C
Screenshot:
Figure 14.2
Page 21 of 23
15.Write a program verify how many bytes are present in a given set which
resemble 0xAC
Code:
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R0,value ; address
MOV R3,#0x0A ; counter 32 bit
LOOP
LDRB R1,[R0],#0x01
CMP R1,#0xAC
ADDEQ R2,R2,#1
SUBS R3,R3,#1
BNE LOOP
AREA PROGRAM,DATA,READONLY
value DCD &0000000E
END
Output:
R2: 0x00000001
Screenshot:
Figure 15.1
Page 22 of 23
16.Write a program to count the number of 1s and 0s ina given byte and
verify the result
Code:
AREA PROGRAM,CODE,READONLY
ENTER
LDR R0,VALUE0
MOV R1,#0X004
MOV R2,#0X00 ;NUMBER 0F 1S
MOV R3,#0X00 ;NUMBER OF 0S
loop
MOVS R0,R0,RRX ;ROTATE RIGHT WITH EXTEND
ADDCC R2,#0X001 ;0S
ADDCS R3,#0X001 ;1S
SUBS R1,R1,#0X001 ;COUNTER
CMP R1,#0X00
BNE loop
AREA PRODRAM,DATA,READONLY
VALUE0 DCD &00000008
END
Output:
R3: 0x00000001
Screenshot:
Figure 16.1
Page 23 of 23