Documente Academic
Documente Profesional
Documente Cultură
SYSTEM SPECIFICATION:
PROCESSORS:
MEMORY:
EPROM: 16K bytes of EPROM loaded with monitor expandable to 1024 bytes using
27256.
RAM: 16K bytes of CMOS RAM expandable to 256K bytes using 6264/62256
INPUT/OUTPUT:
BUS: All address, data and control signals (ttl competitor) avoidable at edge
connector as per multi bus. The kit has own resident bus
POWER SUPPLY:5V, 2.5A for kit, +12, -12, 250mA for CRT +24/21V for
EPROM programmer.
CPU: 8086 is a 16 bit microprocessor and has 16 data lines and 20 address lines. The
lower 16 address lines are multiplexed with 16 data lines. Hence it becomes necessary
to latch the address lines. This is done by using 74LS373. we have used this kit in
maximum mode (MN/MX input held logically low) NMI input is connected to VCT
INT key.
CO-PROCESSOR 8087: The co-processor monitor instructions fetched by the host
processor and recognizes certain of these as its own executes them.
INPUT/OUTPUT PROCESSOR 8089: The 8086 and 8088 are designed to be used
with 8089 in high performance input./output applications. 8089 resembles a
microprocessor with two DMA channels and an instruction set specifically tailored
for input/output operations. 8089 can serve i/o device directly. In addition, it can
transfer data from memory to memory and from i/o to i/o device.
BUS ARBITERS: 8289 is a bus arbiter that controls the access of a processor to a
multi master system resource (typically memory) that is shared by two or more
microprocessor (master).
MEMORY: 16KB of EPROM and 16KB of CMOS RAM has been provided with
20-biit address of 8086, a total of 1MB of memory can be addressed with the address
slots as 00000 to FFFFF.
I/O DEVICES:
8279: 8279 is a general purpose programmable keyboard and display device designed
for use with 8086 microprocessor.
8255: 8255 is a programmable peripheral interface (PPI) designed use with 8086
microprocessor. This basically acts as a general purpose i/o component to interface
peripherals equipments to the system bus.
8253: This chip is a programmable interval timer/counter and can be used for the
generation of accurate time delay. It has got three independent 16 bit counters each
having a count rate of up to 2MHz.
DISPLAY: Eight digits of seven segment display has been provided on the trainer
kit.
Algorithm:-
Start
SI ← 0200
AL ← [SI]
SI ← [SI] +1
BL ← [SI]
AL ← AL+BL
SI ← [SI] +1
[SI] ← AL
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202 Result
Result table:-
Memory Location Data
0200 56 H
0201 42 H
0202 98 H
Program:-
Algorithm:-
Start
SI ← 0200
AL ← [SI]
SI ← [SI] +1
BL ← [SI]
AL ← AL - BL
SI ← [SI] +1
[SI] ← AL
Stop
Reference table:-
Result table:-
Memory Location Data
0200 56 H
0201 42 H
0202 14 H
Algorithm:-
Start
SI ← 0200
AL ← [SI]
SI ← [SI] +1
BL ← [SI]
AL ← AL*BL
SI ← [SI] +1
[SI] ← AL
SI ← [SI] +1
[SI] ← AH
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
0203 Result
Result table:-
Program:-
Algorithm:-
Start
SI ← 0200
AL ← [SI]
SI ← [SI] +1
BL ← [SI]
AL ← AL ÷ BL
SI ← [SI] +1
[SI] ← AL
SI ← [SI] +1
[SI] ← AH
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Data2
0202
0203 Result
Result table:-
Memory Location Data
0200 20 H
0201 11 H
0202 01 H
0203 0F H
Program:-
Algorithm:-
Start
SI ← 0400
AX ← [SI]
SI ← [SI] +1
SI ← [SI] +1
BX ← [SI]
AX ← AX+BX
SI ← [SI] +1
SI ← [SI] +1
[SI] ← AX
Stop
Reference table:-
0403
0404 Result
0405
Result table:-
0404 8C H
0405 E9 H
Result:-
AX= 56F4 H, BX= 9298 H
AX + BX= E98C H;
Program:-
Algorithm:-
Start
SI ← 0400
AX ← [SI]
SI ← [SI] +1
SI ← [SI] +1
BX ← [SI]
AX ← AX-BX
SI ← [SI] +1
SI ← [SI] +1
[SI] ← AX
Stop
Reference table:-
Result table:-
Result: -
AX= D3A2 H, BX= BC41 H.
AX-BX= 1761 H;
Program:-
Algorithm:-
Start
SI ← 0400
AX ← [SI]
SI ← SI+1
SI ← SI+1
BX ← [SI]
AX ←AX*BX
SI ← SI+1
SI ←SI+1
[SI] ← AX
SI ← SI+1
SI ←SI+1
[SI] ← AX
Stop
Reference table:-
Result table:-
Program:-
Algorithm:-
Start
SI ← 0400
AX ← [SI]
SI ← SI+1
SI ← SI+1
BX ← [SI]
AX ←AX÷BX
SI ← SI+1
SI ←SI+1
[SI] ← AX
Stop
Reference table:-
Result table:-
0404 06 H
0405 00 H
0406 5C
0407 0B
Quotient: AX = 0006 H,
Remainder: DX = 0B5C H.
Program:-
Algorithm:-
Start
SI ← 0200
AL ← [SI]
SI ← [SI] +1
BL ← [SI]
AL ← AL+BL
DECIMAL ADJUST AFTER ADDITION[IF THE RESULT
IS GREATER THAN 09 OR 90,ADD 06 OR 60 TO THE
LOWER NIBBLE OR HIGHER NIBBLE OF AL]
SI ← [SI] +1
[SI] ← AL
Stop
Reference table:-
Memory Location Data
0500 Data1
0501 Data2
0502 Result
Result table:-
Memory Location Data
0500 87
0501 63
0502 50
Aim: - To write an assembly language program to add two 8 bit BCD numbers.
Program:-
ALGORITHM:
START
SI 0200
AL [SI]
SI SI+1
BL [SI]
AL AL+BL
ASCII ADJUST AFTER ADDITION
SI SI+1
[SI] AL
STOP
REFERENCE TABLE:
0500 DATA1(AL)
0501 DATA2(BL)
0502 RESULT(AL)
0503 RESULT(BL)
RESULT TABLE:
0500 36
0501 34
0502 00
0503 01
Program:
MOV SI,0500
MOV AL,[SI]
INC SI
MOV BL,[SI]
ADD AL,BL
AAA
INC SI
MOV [SI],AL
INC SI
MOV [SI],AH
HLT
ALGORITHM:
START
SI 0200
AL [SI]
CL 04
AL AL+ [SI+01]
SI SI+1
CL CL-1
JNZ Jumps to program address 0107 until CL is not zero
[SI] AL
STOP
RESULT TABLE:
MULTIBYTE ADDITION
PROGRAM:
Algorithm:-
Start
SI ← 0200
AL ← [SI]
AL ← AL ‘
SI ← [SI] +1
[SI] ← AL
Stop
Reference table:-
Result table:-
Result: - AL= AD
After complementing AL= 52;
Program:-
Algorithm:-
Start
SI ← 0600
AL ← [SI]
AL ← AL+1
SI ← [SI] +1
[SI] ← AL
Stop
Reference table:-
Memory Location Data
0600 Data1
0601 Data2
Result table:-
Memory Location Data
0600 FD H
0601 03 H
Result: - AL= AD
After complementing AL= 52;
Program:-
Algorithm:-
Start
SI ← 0600
AL ← [SI]
BL ← AL
BL ← BL+1
L1: AL ← AL*BL
BL ← BL+1
If ZF = 1 continue, else jump to L1.
SI ← SI+1
[SI] ← AL
Stop
Reference table:-
Memory Location Data
0600 Data1
0601 Data2
Result table:-
Memory Location Data
0600 05 H
0601 78 H
Result: - AL= 05 H.
Factorial of AL= 78 H;
Factorial of a given Number
Program:-
Algorithm:-
Start
SUBROUTINE PROGRAM : ( L1: CL ← AL
CL ← CL-1
L2: AL ← AL*Cl
CL ← CL-1
If ZF =1 Continue, Else Jump to L2.
Return to Called Location.)
MAIN PROGRAM : SI ← 0400
AL ← [SI]
SI ← SI+1
BL ← [SI]
DL ← AL
AL ← AL-BL
Call SUBROUTINE PROGRAM
AL ↔ DL
DL ↔AL
Call SUBROUTINE PROGRAM
AL ↔ BL
BL ↔ AL
AL ← AL*DL
AL ↔ BL
AL ← AL/BL
SI ← SI+1
[SI] ← AL
Stop
n
COMPUTE Cr
Program:-
MOV CL, AL
DEC CL
MUL CL
DEC CL
JNZ 0104
RET
MOV SI, 0400
MOV AL, [SI]
INC SI
MOV BL,[SI]
MOV DL, AL
SUB AL, BL
CALL 0100
XCHG AL, DL
CALL 0100
XCHG AL, BL
CALL 0100
MUL DL
XCHG AL, BL
DIV BL
INC SI
MOV [SI], AL
HLT
Reference table:-
Memory Location Data
0400 Data1
0401 Data2
0402 Result
Result table:-
Memory Location Data
0400 05 H
0401 03 H
0402 0A H
Ascending Order
Aim: - To write an assembly language program Sort given numbers in ascending
order.
Program:-
Result table:-
Memory Location Output Data
0200 08H
0201 34H
0202 57H
0203 86H
0204 91H
Algorithm:-
Start
DX ← 0003
L1: DI ← 0200
CX ← 0003
L2: AL ← [DI]
Compare AL, [DI+01]
If AL > [DI+01] Then jump to L3, else continue.
AL ↔ [DI+01]
[DI] ← AL
L3: DI ← DI+1
Loop: Jump to L2 if CX ≠ 0, else continue.
DX ← DX+1
CX ← DX
Loop: Jump to L1 if CX ≠ 0, else continue.
Stop
Descending Order
Aim: - To write an assembly language program Sort given numbers in Descending
order.
Program:-
Result table:-
Memory Location Output Data
0200 91H
0201 86H
0202 57H
0203 34H
0204 29H
Algorithm:-
Start
SI ← 0200
AL ← [SI]
CL ← 08
L1: Rotate the bits of AL to right once.
If CF is set continue, else jump to L2.
BL ← BL+1
L2: If CX=0 continue, else jump to L1.
Stop
Reference table:-
Memory Location Data
0200 Data1
Result table:-
Memory Location Data
0200 56 H
Result: - AL= 56 H.
Numbers of ones in AL are in BL: 04
MOV SI,0200
MOV AL,[SI]
MOV CL, 08
L1: RCR AL, 1
JNC L2
INC BL
L2: LOOP L1
HLT
Assembly Language Program:-
Algorithm:-
Start
SI ←0200
CX ←0008
DI ←0220
Clear direction flag
Prefix of MOVSB repeat MOVSB until CL=0 or ZF≠0.
Move byte or word from one string to another.
Stop
Reference table:-
Result table:-
Aim: - To write an assembly language program to Move block of data using string
instructions.
Program:-
MOV SI,0200
MOV CX,0008
MOV DI ,0220
CLD
REPZ
MOVSB
HLT
Algorithm:-
Start
SI ← 0200
CX ← 000A
AL ← [SI]
L1: AL ← [0200]
BL ← BL+1
AL ← AL*BL
SI ← SI+1
[SI] ← AL
If CL=0 continue, else jump to L1.
Stop
Reference table:-
Program:-
MOV SI,0200
MOV CX,000A
MOV AL,[SI]
INC BL
MUL BL
INC SI
MOV [SI],AL
LOOP 0108
HLT
Assembly Language Program:-
Reference table:-
Result table:-
Binary to Gray
Program:-
MOV SI, 0200
MOV AL, [SI]
MOV BL, AL
SHR BL, 1
XOR AL,BL
INC SI
MOV [SI], AL
HLT
Algorithm:-
Start
SI ← 0200
AL ← [SI]
BL ← AL
L1: Shift bits of BL to Right.
AL ← BL
CL ← CL+1
If CL=0 continue, else jump to L1.
SI ← SI+1
[SI] ←AL
Stop
Reference table:-
Memory Location Data
0200 Data1
0201 Result
Result table:-
Gray to Binary
Program:-
MOV SI,0200
MOV CL,08
MOV AL,[SI]
MOV BL,AL
L1: SHR BL,1
XOR AL,BL
DEC CL
JNZ L1
INC SI
MOV [SI], AL
HLT
Algorithm:-
Start
SI ← 0200
DI ← 0300
CX ← 0005
DX ← 0000
L2: AL ← [SI]
BL ← [DI]
Compare AL with BL.
If AL = BL jump to L1, else continue.
DX ← DX+1
L1: SI ←SI+1
DI ←DI+1
If CX =0 continue else jump to L2
Stop
Reference table:-
Program:-
MOV SI,0200
MOV DI,0300
MOV CX,0005
MOV DX,0000
L2: MOV AL,[SI]
MOV BL, [DI]
CMP AL, BL
JE L1
INC DX
L1: INC SI
INC DI
LOOP L2
HLT
Assembly Language Program:-
Algorithm:-
Start
SI ← 0200
CX ← 0004
DI ← 0403
L1: AL ← [SI]
[DI] ← AL
SI ←SI+1
DI ←DI-1
If CX =0 continue else jump to L1
Stop
Input table:-
Result table:-
Reverse a String
Program:-
MOV SI,0200
MOV CX,0004
MOV DI,0403
INC SI
DEC DI
LOOP L1
HLT
START
SI 0200
AX [SI]
AX AX*AX
BX 03
AX AX*BX
BX AX
AX [SI]
DX 02
AX AX*DX
BX BX-AX
BX BX+04
AX BX
BX 05
AX AX/BX
SI SI+1
SI SI+1
[SI] AX
SI SI+1
SI SI+1
[SI] DX
STOP
EVALUATION OF EXPRESSION
PROGRAM:
REFERENCE TABLE:
RESULT TABLE:
8051
Micro
Controller
programs
8051 microcontroller
When you use the Keil µVision, the project development cycle is
roughly the same as it is for any other software development
project.
Create a project, select the target chip from the device
database, and configure the tool settings.
Create source files in C or assembly.
Build your application with the project manager.
Correct errors in source files.
Test the linked application.
µVision IDE
The µVision IDE combines project management, a rich-
featured editor with interactive error correction, option setup, make
facility, and on-line help. Use µVision to create your source files and
organize them into a project that defines your target application.
µVision automatically compiles, assembles, and links your
embedded application and provides a single focal point for your
development efforts.
Source files are created by the µVision IDE and are passed to
the C51 Compiler or A51 Macro Assembler. The compiler and
assembler process source files and create relocatable object files.
The Keil C51 Compiler is a full ANSI implementation of the C
programming language that supports all standard features of the C
language. In addition, numerous features for direct support of the
8051 architecture have been added. The Keil A51 macro assembler
supports the complete instruction set of the 8051 and all
derivatives.
Start µVision
Create a Project File
To create a new project file select from the µVision menu:
Project – New Project- This opens a standard Windows dialog that
asks you for the new project file name. Use a separate folder for
each project. µVision creates a new project file with the name
NAME.UV2 which contains a default target and file group name. You
can see these names in the Project Workspace – Files.
Select a Device
You may create a new source file with the menu option File –
New. This opens an empty editor window where you can enter your
source code. µVision enables the C color syntax highlighting when
you save your file with the dialog File – Save As… under a filename
with the extension *.asm. We are saving our example file under the
name MAIN.asm.
Once you have created your source file you can add this file
to your project. µVision offers several ways to add source files to a
project. For example, you can select the file group in the Project
Workspace – Files page and click with the right mouse key to open a
local menu. The option Add Files opens the standard files dialog.
Select the file MAIN.asm you have just created.
The STARTUP.A51 file is the startup code for the most 8051 CPU
variants. The startup code clears the data memory and initializes
hardware and reentrant stack pointers. In addition, some 8051
derivatives require a CPU initialization code that needs to match the
configuration of your hardware design.
µVision lets you set options for your target hardware. The dialog
Options for Target opens via the toolbar icon or via the Project -
Options for Target menu item. In the Target tab you specify all
relevant parameters of your target hardware and the on-chip
components of the device you have selected. The following are the
settings for our example are shown.
The following table describes the options of the Target dialog:
Typical, the tool settings under Options – Target are all you need to
start a new application. You may translate all source files and line
the application with a click on the Build Target toolbar icon. When
you build an application with syntax errors, µVision will display
errors and warning messages in the Output Window – Build page. A
double click on a message line opens the source file on the correct
location in a µVision editor window.
The Project - Options dialog pages let you set all the tool options. All
options are saved in the µVision project file Via the local menu in
the Project Workspace – Files you may set different options for a file
group or even a single file. In this case you may have an additional
Properties page and only dialog pages that are related to the
selected item.
Dialog Description
Page
Target Specify the hardware of your application.
Output Define the output files of the tool chain and allows you to start user
programs after the build process.
Listing Specify all listing files generated by the tool chain.
C51, CX51 Set C51 Compiler specific tool options like code optimization or
variable allocation.
A51, AX51 Set Assembler specific tool options like macro processing.
BL51 Define the location of memory classes and segments. Typical you will
Locate enable Use Memory Layout from Target Dialog as shown below to get
LX51 Loca automatic settings.
te
BL51 Misc Other linker related settings like Warning or memory Reserve
LX51 Misc directive.
Debug Settings for the µVision Debugger.
Properties File information and special options for files and groups.
AIM: To write a program for LED Blinking for LEDs those are connected to port-1
PROGRAM:
ORG 0000h
back : Mov a,#55h
Mov p1,a
Lcall delay
Mov a,#0AAh
Mov p1,a
Lcall delay
Sjmp back
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to Toggle all bits of port-P1
PROGRAM:
ORG 0000h
Back : Mov a,#0FFh
Mov p1,a
Lcall delay
Mov a,#0FEh
Mov p1,a
Lcall delay
Sjmp Back
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to get a byte of data from p0 and
Send it to p1
PROGRAM:
ORG 0000h
Mov R0,#55h
Mov P0,R0
Mov P1,P0
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to transmit ‘A’ serially at 9600
baud rate
PROGRAM:
ORG 0000h
Mov TMOD, #20h
Mov SCON, #50h
Mov TH1, #-3h
Setb TR1
Again: Mov SBUF, #’A’
Here : Jnb TI,Here
clr TI
sjmp Again
end
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to transmit ‘ECE’ serially at 4800
baud rate
PROGRAM:
ORG 000h
Mov TMOD,#20h
Mov SCON,#50h
Mov TH1,#-6h
Setb TR1
Again: Mov A,#'E'
Acall trans
Mov A,#'C'
Acall trans
Mov A,#'E'
Acall trans
Mov A,#' '
Acall trans
Sjmp Again
Trans : Mov Sbuf,A
Here : Jnb TI,Here
Clr TI
RET
End
OUTPUT:
AIM: Write a program for 8051 Micro-Controller to receive data serially at 9600
baud rate
PROGRAM:
ORG 000h
Mov TMOD,#20h
Mov SCON,#50h
Mov TH1,#-3h
Setb TR1
Here : Jnb Ri,Here
Mov A,Sbuf
Mov P1,A
Clr Ri
Sjmp Here
End
OUTPUT: