Está en la página 1de 31

BHARAT INSTITUTE OF ENGINEERING AND

TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY AND
MICROPROCESSORS
INTERFACING
MANUAL
BHARAT INSTITUTE
OFLAB
ENGINEERING
AND
8086
MICROPROCESSOR
TECHNOLOGY

BHARAT INSTITUTE OF ENGINEERING AND


III-II ECE
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND
TECHNOLOGY
BHARAT INSTITUTE OF ENGINEERING AND

INDEX
S. No.

NAME OF THE EXPERIMENT

PAGE
NO.

INTRODUCTION TO 8086

PIN DIAGRAM OF 8086

ARCHITECTURE OF 8086

ARITHMETIC OPERATIONS USING 8086 TRAINER KIT

11

SHIFT OPERATIONS USING 8086 TRAINER KIT

13

ROTATE OPERATIONS USING 8086 TRAINER KIT

14

INTRODUCTION TO MASM

15

PROCEDURE FOR STARTING MASM

17

MASM PROGRAMS:
9

LENGTH OF THE STRING

18

10

INSERTION OF A CHARACTER IN A STRING

19

11

DELETION OF A CHARACTER IN A STRING

20

12

MOVE A BLOCK OF STRING

21

13

SEARCHING A CHARACTER OF THE STRING

22

14

REVERSE OF A STRING & CHECK PALINDROME

23

15

PACKED BCD TO UNPACKED BCD

24

16

BCD TO ASCII

25

17

PASSWORD

26

18

SORTING OF AN ARRAY IN ASCENDING ORDER

27

SORTING OF AN ARRAY IN DESCENDING ORDER

28

19

INTERFACING PROGRAMS USING 8086


20

STEPPER MOTOR INTERFACE

29

21

DUAL 8BIT D/A INTERFACE

30

22

ADC(8BIT A/D) INTERFACE

31

INTRODUCTION:

AT-8086A is a High performance trainer and development kit with latest


devices and versatile software. It is an excellent learning tool for 8086 learners and
development system for 8086 based applications.

This manual provides all the necessary information for the installation,
operation, and troubleshooting and routine maintenance of AT8086A.

The salient features of AT8086A are as follows:

AT-8086A operates at 3.159 Mhz clock

Static RAM-76C256 is providing user RAM of 32K bytes

27C256 is programmed with monitor program of 32k bytes

AT-89C2051 controller handles the inter face between 8086 & pc


keyboard

4 Line*20 Character LCD provided with back light to display

Designed and engineered to integrate user applications conveniently at


a minimum cost.

SPECIFICATIONS:

CPU
Memory

Intel 8086 operating at 3.159 MHz clock


EPROM:
Provide up to 32k bytes using 27c256.
RAM:

Serial I/O

Provide up to 32k bytes of CMOS


Static RAM Using 76c256 provision to
Battery backs the entire System RAM.

One RS-232c compatible interface using


USART-8251A with programmable baud
Rates Through the 8253 Programmable
Timer.
4

Interrupts

8086 has 2 Interrupts (NMI, INTR).


The NMI is directly connected to the
Switch (NMI).
INTR is used for Interrupt controller
(8259) Operation.
One Interrupt of 8259 is connected to
Switch (IR0)

PC-Keyboard

It is 108 PC-Keyboard Consist of Functional


And alphanumeric keys. By using this
Keys the user can enter the
Program easily.

LCD Display

4 line 20 character alpha numeric LCD


Display with back Light facility.

Bus Signals

I/O signals

All address, data and control signals are


Terminated in a 50-pin FRC Header for user
expansion.
2 * PPI (8255) signals are terminated in two
26-pin FRC Headers and the pin out is
Compatible with our range of Educational
interface modules. Timer lines are also
Terminated in berg strip header.

Power supply: +5V@1A, +/-12V and is provided externally.


About 8086 CPU:
The Intel 8086 high performance 16-bit CPU is available in three clock rates:
5, 8 and 10 MHz. The CPU is implemented in N-Channel, depletion load, silicon gate
technology (HMOS-III), and packaged in a 40-pin CERDIP or plastic package. The
8086 operate in both single processor and multiple processor configurations to
achieve high performance levels.
5

The following pin function descriptions are for 8086 systems in either
minimum or maximum mode. The ``Local Bus'' in these descriptions is the direct
multiplexed bus interface connection to the 8086 (without regard to additional bus
buffers).

The following pin function descriptions are for the 8086 in minimum mode
(i.e., MN/MX e VCC). Only the pin functions, which are unique to minimum mode,
are described; all other pin functions are as described above.

ARITHMETIC OPERATIONS USING 8086 TRAINER KIT

10

Program to Perform 16-Bit Arithmetic Operations:ADDITION:


MOV AX,1234H
MOV BX,1111H
ADD AX,BX
INT 25

SUBTRACTION:
MOV AX,1234H
MOV BX,1111H
SUB AX,BX
INT 25

MULTIPLICATION:
MOV AX,1234H
MOV BX,1111H
MUL BX
INT 25

DIVISION:
MOV AX,1234H
MOV BX,1000H
DIV BX
INT 25
Program to Perform 8-Bit Arithmetic Operations:-

11

ADDITION:
MOV AL,12H
MOV BL,11H
ADD AL,BL
INT 25

SUBTRACTION:
MOV AL,12H
MOV BL,11H
SUB AL,BL
INT 25

MULTIPLICATION:
MOV AL,12H
MOV BL,11H
MUL BL
INT 25

DIVISION:
MOV AL,12H
MOV BL,02H
DIV BL
INT 25
Program to Perform SHIFT Operations:ARITHMETIC SHIFT RIGHT (SAR):

12

MOV AX,A123H
MOV CL,02
SAR AX,CL
INT 25
ARITHMETIC SHIFT LEFT (SAL):
MOV AX,A123H
MOV CL,02
SAL AX,CL
INT 25
LOGICAL SHIFT RIGHT (SHR):
MOV AX,A123H
MOV CL,02
SHR AX,CL
INT 25
LOGICAL SHIFT LEFT (SHL):
MOV AX,A123H
MOV CL,02
SHL AX,CL
INT 25

Program to Perform ROTATE Operations:ROTATE RIGHT WITHOUT CARRY (ROR):


MOV AX,FF12H
MOV CL,02
13

ROR AX,CL
INT 25

ROTATE LEFT WITHOUT CARRY (ROL):


MOV AX,FF12H
MOV CL,02
ROL AX,CL
INT 25

ROTATE RIGHT THROUGH CARRY (RCR):


MOV AX,FF12H
MOV CL,02
RCR AX,CL
INT 25

ROTATE LEFT THROUGH CARRY (RCL):


MOV AX,FF12H
MOV CL,02
RCL AX,CL
INT 25

INTRODUCTION TO MASM:
DOS Text Editor- edit
Microsofts EDIT editor is a very simple and user friendly editor. EDIT is a pure text editor,
which means all the characters are represented in ASCII code. To start, just type in the edit
command followed by the file name:
A\>edit filename.asm

14

then a blue screen will appear.


Format of Assembly Instructions:
General Format:
[label:] mnemonic [operand [,operand]] [;comment]
Fields in an instruction can be separated by spaces or tabs. In general, text is case insensitive
(upper or lower case). Upper case is often used to emphasize instructional points.
Field
Description
Can appear anywhere in the code segment.
It should be on a line by itself to simplify future modifications.
Label
Must be terminated with a colon. :
Must be unique.
Helpful Hint: Do not use the word LOOP as a label for the assembler confuses this
with the loop instruction.
Mnemonic
The instruction itself e.g. MOV
The object of the instruction.
The number of operands required depends on the instruction.
If two operands are required then separate them with a comma and whatever space
delimeter you want. E.g. Use the tab key, or enter a number of spaces.
Operand(s)
e.g. mov ax,data
mov is the instruction,
ax is the destination operand,
data is the source operand.
Comment
Can appear anywhere in the file. Can start anywhere on the line.
Must begin with a semicolon. ;
Assembler Directives:
Assembler Directives are an entirely different set of objects. Directives are non-operational
instructions, the main purpose of which is to guide the assembling process of the assembler.
There are a few categories of directives.
1. Memory Allocation
Directive
DB
DW
DD
DQ
DT

Description
Reserves space in one Byte (1 byte) units.
Reserves space in one Word (2 byte) units.
Reserves space in one Double (4 byte) units.
Reserves space in one Quad (8 byte) units.
Reserves space in one Ten (10 byte) units.

2. Use these directives in data allocation statements.


The general format is:
15

3. [variable_name] data_type [nit [,init]]


4.
Where:
o
variable_name is the programmers choice
data_type is one of: DB, DW, DD, DQ, DT
init can be a numeric, string or DUP expression.
A DUP expression takes the form:*
#_of_elements DUP(list of values)
e.g.
zeroes DB 10 DUP(00) ; associate zero_vals with a string of 10 zero bytes.
Assemble, Link and Execute an Assembly Program :
To call the MASM assembler to assemble and link a program:
Either type:
C:\Work Area>masm filename.asm;
C:\Work Area>link filename.obj;
To run the file enter the filename after it has been assembled and linked.

PROCEDURE FOR STARTING MASM


1.
2.
3.
4.
5.

Press START button on windows desktop.


Press RUN
Enter CMD and Press ENTER
Type CD\ or CD.. and Press ENTER
Enter the Drive name in which MASM software is loaded followed by colon (Ex: D:) and

press Enter
6. Then Type CD MASM and press ENTER
7. Then Type EDIT and press Enter
8. A window will open where the ASM program has to be written. Save the program in the
format XXX.ASM in MASM folder itself or a location which can be easily remembered.
16

9. After saving the program then EXIT


10. Type MASM XXX.ASM; and press Enter and check for errors and warnings. If any
errors or warnings type EDIT XXX.ASM and press Enter and make necessary changes
in the program
11. Type LINK XXX.OBJ; and Press Enter
12. Type DEBUG XXX.EXE and press Enter which will displays -
13. Type U and press Enter in order to get the memory locations and the instructions stored
in it
14. Our program starts at an offset address 0010 so the instruction has to be loaded with
0010. For that TYPE R IP and press Enter and it shows the content of instruction
pointer.
Type 0010 and press Enter which will change the contents of IP
15. To execute the program in single step mode type T and press Enter. It sets the Trap Flag.
16. Proceed till the HLT instruction is executed (Keep on typing T and Enter)
17. Now to check the memory location press D <Offset Starting Address> <Offset End
Address>
18. In order to EXIT press Q and Press Enter
19. In order to exit MASM Type EXIT and press Enter.

MASM PROGRAMS:

LENGTH OF THE STRING


ASSUME CS:CODE,DS:DATA
DATA SEGMENT
STRING DB "HELLO"
LEN DB ?
RESULT DB 01H DUP(?)
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV ES,AX
17

MOV CL,00H
MOV BL,00H
MOV SI,OFFSET STRING
MOV DI,OFFSET RESULT
BACK: MOV AL,[SI]
CMP AL,BL
JE NEXT
INC SI
INC CL
JMP BACK
NEXT: MOV [DI],CL
MOV AH,4CH
CODE ENDS
END

INSERTION OF A CHARACTER IN A STRING


ASSUME CS:CODE, DS:DATA, ES:EXTRA
DATA SEGMENT
STR DB "MIRO"
COUNT DB 05H
POS DB 03H
INS DB "C"
DATA ENDS
EXTRA SEGMENT
STR1 DB 05 DUP(?)
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV DL,INS
18

MOV CL,COUNT
MOV BL,POS
BACK: MOV AL,06
SUB AL,CL
CMP AL,BL
JE NEXT
CLD
MOVSB
DEC CL
JNZ BACK
JMP EXIT
NEXT: MOV AL,DL
STOSB
MOV DL,AL
DEC CL
JNZ BACK
EXIT: INT 21H
CODE ENDS
END START

DELETE A CHARACTER IN A STRING


ASSUME CS:CODE,DS:DATA,ES:EXTRA
DATA SEGMENT
STR DB "MICRO"
COUNT DB 05H
POS DB 04H
DEL DB ?
DATA ENDS
EXTRA SEGMENT
STOR DB 05 DUP(?)
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
XOR AX,AX
MOV CL,COUNT
MOV BL,POS
19

BACK: MOV AL,06


SUB AL,CL
CMP AL,BL
JE NEXT
CLD
MOVSB
DEC CL
JNZ BACK
JMP EXIT
NEXT: LODSB
MOV DL,AL
DEC CL
JNZ BACK
EXIT: MOV DEL,DL
INT 21H
CODE ENDS
END START

MOVE A BLOCK OF A STRING


ASSUME DS:DATA, CS:CODE, ES:EXTRA
DATA SEGMENT
LIST DB 48H, 57H, 34H, 33H, 32H
COUNT EQU 05
DATA ENDS
EXTRA SEGMENT
RESULT DW 01H DUP(22H)
EXTRA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV CX,COUNT
CLD
MOV SI,OFFSET LIST
MOV DI,OFFSET RESULT
AGAIN: MOV AL,[SI]
MOVSB
DEC DI
MOV BL,[DI]
INC DI
LOOP AGAIN
20

MOV AH,4CH
CODE ENDS
END

SEARCHING A CHARACTER OF THE STRING


ASSUME CS:CODE,DS:DATA
DATA SEGMENT
STR DB "L"
SEARCH DB "IALH"
COUNT EQU 04H
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV ES,AX
XOR AX,AX
MOV CX,COUNT
MOV DI,OFFSET SEARCH
MOV AL,STR
SCAN1: SCASB
JZ FINISH
INC BL
LOOP SCAN1
FINISH:
MOV AH,4CH
CODE ENDS
END

21

REVERSE OF THE STRING & CHECK PALINDROME


ASSUME CS:CODE,DS:DATA,ES:EXTRA
DATA SEGMENT
WORDS DB 'POT TOP'
LENTH EQU 07H
DATA ENDS
REVER DB 07H DUP(?)
EXTRA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
XOR AX,AX
XOR DX,DX
MOV SI,OFFSET WORDS
MOV DI,OFFSET REVER
ADD DI,LENTH-1
MOV CX,LENTH
BACK: MOV AL,[SI]
XCHG AL,ES:[DI]
INC SI
DEC DI
LOOP BACK
MOV CX,LENTH
MOV SI,OFFSET WORDS
MOV DI,OFFSET REVER
22

CLD
REPE CMPSB
JNZ NEXT
INC DX
NEXT: MOV AH,4CH
CODE ENDS
END

PACKED BCD TO UNPACKED BCD


ASSUME CS:CODE,DS:DATA
DATA SEGMENT
BCD_NUM EQU 79H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV CL,COUNT
MOV AL,BCD_NUM
MOV AH,AL
AND AL,0FH
AND AH,0F0H
ROL AH,CL
MOV AH,4CH
CODE ENDS
END

23

BCD TO ASCII
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
BCD_NUM EQU 79H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV CL,COUNT
MOV AL,BCD_NUM
MOV AH,AL
AND AL,0FH
AND AH,0F0H
ROL AH,CL
OR AL,30H
OR AH,30H
MOV AH,4CH
CODE ENDS
END

24

PASSWORD
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
PASWRD DB 'HARI'
LENTH EQU 04H
DATA ENDS
EXTRA SEGMENT
INWRD DB 'HARI'
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
XOR AX,AX
XOR DX,DX
MOV SI,OFFSET PASWRD
MOV DI,OFFSET INWRD
MOV CX,LENTH
CLD
REPE CMPSB
JNZ GO
INC DX
GO: INT 3H
CODE ENDS
END START

25

SORTING OF AN ARRAY IN ASCENDING ORDER


ASSUME CS:CODE, DS:DATA
DATA SEGMENT
LIST DW 5312H, 4102H, 3711H, 2915H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX
MOV SI,OFFSET LIST
AGAIN1: MOV AX,[SI]
CMP AX,[SI+2]
JL PR1
XCHG [SI+2],AX
XCHG [SI],AX
PR1: ADD SI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
CODE ENDS
END

26

SORTING OF AN ARRAY IN DESCENDING ORDER


ASSUME CS:CODE, DS:DATA
DATA SEGMENT
LIST DW 1234H, 2345H, 3214H, 4121H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX
MOV SI,OFFSET LIST
AGAIN1: MOV AX,[SI]
CMP AX,[SI+2]
JAE PR1
XCHG [SI+2],AX
XCHG [SI],AX
PR1: ADD SI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
CODE ENDS
END

INTERFACING PROGRAMS:
27

*PROGRAM FOR STEPPER MOTOR INTERFACE *


CODE SEGMENT
ASSUME CS:CODE,DS:CODE,SS:CODE,ES:CODE
CMDB8255 EQU 27H
PAB8255 EQU 21H
PBB8255 EQU 23H
PCB8255 EQU 25H
;CLOCK WISE 05H,06H,0AH,09H
;ANTI CLOCK WISE 09H,0AH,06H,05H
ORG 400H
MOV AL,80H;PORTS AS O/P
OUT CMDB8255,AL
MOV AL,0FFH
OUT PAB8255,AL
START: MOV AL,05H
OUT PAB8255,AL
CALL DELAY
MOV AL,06H
OUT PAB8255,AL
CALL DELAY
MOV AL,0AH
OUT PAB8255,AL
CALL DELAY
MOV AL,09H
OUT PAB8255,AL
CALL DELAY
JMP START
DELAY:
MOV CX,05FFH
LP: DEC CX
JZ
EXT ; LP1
JMP LP
EXT: RET
CODE ENDS
END
*PROGRAM FOR DUAL 8BIT D/A INTERFACE *
CODE SEGMENT
28

ASSUME CS:CODE,DS:CODE,SS:CODE,ES:CODE
CMD8255B EQU 27H
PAB8255 EQU 21H ; FIRST DAC INPUT
PBB8255 EQU 23H ; SECOND DAC INPUT
ORG 400H
MOV AL,80H; Initialize
OUT CMD8255B,AL;PORTS A,B,C
;AS O/P
LP1: MOV AL,00H ;INITIAL VALUE
LP2: OUT PBB8255,AL
OUT PAB8255,AL;OUTPUT AL
INC AL
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CMP AL,0E0H ;COMPARE WITH UPPER
JZ
LP1
;LIMIT
JMP LP2
CODE ENDS
END

*PROGRAM FOR ADC(8BIT A/D) INTERFACE *


CODE SEGMENT
ASSUME CS:CODE,DS:CODE,SS:CODE,ES:CODE

29

KBINT EQU 22H


DISINT EQU 23H
CMD8255B EQU 27H
PAB8255 EQU 21H
PBB8255 EQU 23H
PCB8255 EQU 25H
DSPBUF EQU 9E00H
ORG 400H
MOV AL,92H; Initialize port A & B as
OUT CMD8255B,AL; I/p & C as i/p
LP2:
MOV AL,07H
OUT PCB8255,AL ; Select 7th channel
OR AL,18H
OUT PCB8255,AL ; Set start of conversion
AND AL,0E7H ; Reset SOC bit(pulse)
NOP
OUT PCB8255,AL
NOP
NOP
LP1:

;
;
;
;
;
;
;
;
;
;
;
;

IN AL,PBB8255 ; Wait for EOC(end of


AND AL,01H ; conversion)
JZ
LP1
IN
AL,PCB8255
OR AL,20H
OUT PCB8255,AL; Set output enable
NOP
NOP
IN
AL,PAB8255; Read ADC output
MOV DL,AL
; Store temporarily in DL
MOV SI,OFFSET RESMES+8000H
MOV DI,DSPBUF; Move result message
MOV CX,08H; into display buffer
REP MOVSW
MOV AL,DL
MOV CL,04H
; Get the upper nibble
SHR AL,CL
CALL
ASCII
MOV DI,DSPBUF+0EH
30

;
;
;
;
;
;
;
;

MOV [DI],AL

MOV AL,DL
AND AL,0FH
CALL
ASCII
MOV DI,DSPBUF+0FH
MOV [DI],AL
INT DISINT
JMP LP2; Be in an infinite loop
;RESMES:
;
DB 'Digital O/P : 00'
;ASCII:
;
ADD AL,30H ; If no. < 0AH,add 30H
;
CMP AL,3AH
;
JC
RET1
;
ADD AL,07H; If no. >= 0AH,add 37H
;RET1:
;
RET
CODE ENDS
END

31

También podría gustarte