You are on page 1of 4

18MHC205J MICROCONTROLLERS AND EMBEDDED SYSTEMS Exercise 8

EXERCISE 8
DATE:08-04-2021 REG NO:RA1811038010037

AIM:

● To write an assembly language program to perform division operation

● To write an assembly language program to determine the sum of N- number


using ARM Sim.

APPARATUS REQUIRED:

PC with ARM Sim

PROGRAM TO PERFORM DIVISION OPERATION:

Address Label Mnemonic Opcode Comments


00001000 E3A0100A Value of input to R1
MOV R1, #dividend
00001004 E3A02002 Value of input to R2
MOV R2, #divisor
00001008 E3A00000 Value of input to R0
MOV R0, #00
0000100C E0411002 R1=R1-R2
LOOP SUB R1, R1, R2
00001010 E2800001 R0=R0+1
ADD R0, R0, #01
00001014 E1510002 Compare R1 with R2
CMP R1, R2
00001018 5AFFFFFB Branch if it is positive or
BPL LOOP zero
0000101C EF000011 Halt
SWI 0x11

INPUT: R1 = 10 R2 = 2

OUTPUT: Value and Status of all modified registers:

R0 = 5

R1 = 0

R2 = 2

R15(pc) = 70656

DEPARTMENT OF MECHATRONICS - SRM IST


18MHC205J MICROCONTROLLERS AND EMBEDDED SYSTEMS Exercise 8

Negative(N) = 1

Zero(z) = 0

Carry(C) = 0

Overflow(V) = 0

PROGRAM TO DETERMINE SUM OF N NUMBERS:

Address Label Mnemonic Opcode Comments


00001000 E3A00014 Value of input to R1
MOV R0,#INPUT
00001004 E1A01000 Move R1 value to R0
MOV R1,R0
00001008 E2400001 R1=R1-1
SUB R0,R0,#01
0000100 E0812000 R2=R1-R0
LOOP ADD R2,R1,R0
C
00001010 E1A01002 Move R2 to R1
MOV R1,R2
00001014 E2400001 R0=R0-01
SUB R0,R0,#01
00001018 E3500000 Compare
CMP R0, #00
0000101 1AFFFFFA Branch if not equal to
BNE LOOP
C
00001020 EF000011 Halt
SWI 0X11

INPUT: R0 = 20

OUTPUT: Value and Status of all modified registers:

R0 = 0

R1 = 210

R2 = 210

R15(pc) = 70656

DEPARTMENT OF MECHATRONICS - SRM IST


18MHC205J MICROCONTROLLERS AND EMBEDDED SYSTEMS Exercise 8

Negative(N) = 0

Zero(z) = 1

Carry(C) = 1

Overflow(V) = 0

Screenshot:

DEPARTMENT OF MECHATRONICS - SRM IST


18MHC205J MICROCONTROLLERS AND EMBEDDED SYSTEMS Exercise 8

Maximum Marks
Evaluation component
Marks obtained
Program 2

Flowchart 3

Calculation 3

Screenshot of execution 2

Signature of Faculty with


date

RESULT:

Thus, the assembly language program to perform division operation and to determine the sume
of N numbers was written, executed and verified using using ARM Sim.

DEPARTMENT OF MECHATRONICS - SRM IST

You might also like