Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

2.

BASIC ARITHMETIC OPERATION AND DATA TRANSFER


AIM:
Write an Assembly language program for 8051 Microcontroller for following program
a) Basic Arithmetic Operations
b) Average of First 5 numbers
c) Data Transferring Programme
TOOLS REQUIRED: PC, Keil µvision5
PROCEDURE:
1. Turn on the computer, create a folder on D drive saved with Register Number.
2. Open Keil uVision5 in desktop, or windows start menu -> all programs->open Keil uVision5.

Creating Project:

3. Go to project ->click on new µVision project -> create a new folder saved with experiment
number within the already existed register number folder in D drive mentioned in step 1, ->
enter the project name -> click on save.
4. Select the device for target -> In devices ->Enter P89C51RD2XX in Search toolbar -> click
on ok -> select No for dialog box message “Copy STARTUP.A51 to project folder and add
files to project”.
(or)
Choose NXP -> to select the device P89C51RD2XX -> click on ok -> select No for Copy
STARTUP.A51 to project folder.

Creating Coding File:


5. Go to file -> click on new->go to save (choose the path to save the file, It is saved within the
name of experiment number folder mentioned in step 3)-> enter a file name with extension
. . .asm->save the file.

Linking the Coding File to Project:


6. Right-click on Source group1 in project bar-> Add existing files to source group1-> choose
the experiment number folder path and select all files in the folder -> select .asm code file
->click on add-> click on close.
7. Write the assembly language program in .asm code file and save it.

Executing the Code File:


8. Right-click on .asm code file->Click on Build target to check the errors (i.e 0-Errors,0-
Warning)
9. Go to debug->Click on Start/Stop Debug Session -> click on ok for dialog box message
“running code size limit 2K” -> and Click on RUN in debug label
10. Observe the output in Register windows, Memory windows, Serial window.

OBSERVATION FORMAT:
LINE/ MNEMONIC OPERAND OPCODE INSTRUCTIO MEMORY PROGRAM IN
LABEL N ADDRESS MEMORY
BYTES
1 ORG 00H
0000 0111 0101
2 MOV 38H, #26H 75 38 26 3 0001 0011 1000
0002 0010 0110
0003 0111 0101
3 MOV 45H, #12H 75 45 12 3 0004 0100 0101
0005 0001 0010
0006 1110 0101
4 MOV A 38H E5 38 2
0007 0011 1000
0008 1000 0101
5 MOV B 45H 85 45 F0 3 0009 0100 0101
000A 1111 0000
000B 0010 0000
6 ADD A, B 20 F0 2
000C 1111 0000
000D 1111 0101
7 MOV 40H, A F5 40 2
000E 0100 0000
8
000F 0111 0101
9 MOV 37H, #22H 75 31 22 3 0010 0011 0111
0011 0001 0010
0012 0111 0101
10 MOV 39H, #05H 75 39 05 3 0013 0011 1001
0014 0000 0101
0015 1110 0101
11 MOVA 37H E5 87 2
0016 0011 1001
0017 1000 0101
12 MOV B 39H 85 39 F0 3 0018 0011 1001
0019 1111 0000
001A 1001 0101
13 SUBB A, B 95 F0 2
001B 1111 0000
001C 1111 0101
14 MOV 32H, A F5 32 2
001D 0011 0010
15
001E 0111 0101
16 MOV 31H, #22H 75 31 22 3 001F 0011 0001
0020 0010 0010
0021 0111 0101
17 MOV 35H, #09H 75 35 09 3 0022 0011 0101
0023 0000 1001
0024 1111 0101
18 MOV A 31H E5 31 2
0025 0011 0001
0026 1000 0101
19 MOV B 35H 85 35 F0 3 0027 0111 0101
0028 1111 0000

20 MUL A, B A4 1 0029 1010 0100

002A 1111 0101


21 MOV 47H, A F5 47 2
002B 0100 0100
002C 1000 0101
22 MOV 48H, B 85 F0 48 3 002D 1111 0000
002E 0100 1000

23

002F 0111 0101


24 MOV 52H, #A 75 52 A 3 0030 0101 0010
0031 1010
0032 0111 0101
25 MOV 54H, #02H 75 54 02 3 0033 0101 0100
0034 0000 0010
0035 1110 0101
26 MOV A 52H E5 52 2
0036 0101 0010
0037 1000 0101
27 MOV B 54H 85 54 F0 3 0038 0101 0100
0039 1111 0000

28 DIV AB 1 003A 1000 0100

003B 1111 0101


29 MOV 50H, A F5 50 2
003C 0101 000
003D 1000 0101
30 MOV 55H, B 85 F0 55 3 003E 1111 0000
003F 0101 0101

31 END
b) Average of First 5 numbers
LINE/ MEMORY PROGRAM IN
MNEM0NIC OPERAND OPCODE INSTRUCTION
LABEL ADDRESS MEMORY

1 ORG 00H

0000 0111 1000


2 MOV R0, #05H 78 05 2
0001 0000 0101
0002 1000 1000
3 MOV B R0 88 F0 2
0003 1010 0000
0004 0111 0100
4 MOV A #00H 74 00 2
0005 0000 0000
5/
ADD A, B 28 1 0006 0010 1000
BACK
0007 1101 1000
6 DJNZ R0, BACK D8 FD 2
0008 1111 1101

7 DIV AB 84 1 0009 1000 0100

000A 1111 0101


8 MOV 38H, A F5 38 2
000B 0011 1000
000C 1000 0101
9 MOV 39H, B 85 F0 39 3 000D 1111 0000
000E 0011 1001

10 END

c)Data transfer program


LINE/ INSTRUCTION MEMORY PROGRM IN
MNEMONIC OPERAND OPCODE
LABEL BYTES ADDRESS MEMORY

1 ORG 00H

0000 0111 1000


2 MOV R0, #40H 78 40 2
0001 0100 0000

0002 0111 1001


3 MOV R1, #60H 79 60 2
0003 0110 0000

0004 0111 1010


4 MOV R2, #06H 7A 06 2
0005 0000 0110

5/
MOV A @R0 E6 1 0006 1110 0110
BACK

6 MOV @R1, A F7 1 0007 1111 0111

7 INC R0 08 1 0008 0000 1000

8 INC R1 09 1 0009 0000 1001

9/ 000A 1110 1111


DJNZ R2 DF FA 2
BACK 000B 1111 1010

10 END

You might also like