Professional Documents
Culture Documents
INSTITUTE OF TECHNOLOGY
DEPARTMENT OF
ELECTRONICS AND
COMMUNICATION
EC 6513
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL
EC 6513
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL
: ______________________
Register Number
: ______________________
: ______________________
Table of contents :
S. No Date
A
1
2
3
4
5
6
8
B
1
2
3
4
5
6
7
C
1
2
3
4
5
D
1
2
3
4
5
6
7
8
Page No Date of
Mark Signature
Submission
n response to the EU demand. The BIU is independent of the EU and attempts to keep the six bytes queue filled with instruction object codes.
If two or more of these six bytes are empty, then the BIU executes instruction fetch machine
cycles as long as the EU does not have an active request for the bus access pending. If the EU
issues a request for the bus access while the BIU is in the middle of an instruction fetch machine
cycle, then the BIU will complete the instruction fetch machine cycle before honor ing the EU
bus access request. The EU does not use machine cycles; it executes instructions in some number
of clock periods that are not subjected to any type of machine cycles. The only time clock
periods are grouped is clock when the bus control logic wishes to access memory or I/O devices.
8086 / 8088 has an additional pointer into the stack called the BP register. While the SP is
used similar to the stack pointer in other machine
(for pointing to subroutine and interrupt return addresses), the BP register is used to hold
an old stack pointer value, or it can mark a place in the subroutine stack independent of
the SP register. Using the BP register to mark the stack saves the juggling of a single
stack pointer to reference subroutine parameters and addresses. SI and DI are both 16 bits wide and are used by string manipulation instructions and in building some of the
more powerful 8086/8088 data structures and addressing modes. Both the SI and the DI
registers have auto incrementing and auto - decrementing capabilities.
Arithmetic Logic Unit (ALU):
ALU is 16 - bits wide. It can do the following 16 - bits arithmetic operations
(i) Addition
(ii)Subtraction
(iii) Multiplication
(iv) Division
The ALU can also perform logical operations such as
(i) NOT
(ii)AND
(iii) OR
(iv) EXCLUSIVE OR
(v) TEST
Flag Register
The Execution Unit has a 16 - bit flag register which indicates some conditions affected
by the execution of an instruction. Some bits of the flag register control certain operations
of the EU. The flag register in the EU contains nine active flags . Six of the nine flags are
used to indicate some condition produced by an instruction. These condition flags are
also called status flags of 8086/8088 microprocessor. These are the Carry flag, Parity
flag, Auxiliary carry flag, Zero flag, and Sign flag. The other three Control flags are Trap
Flag, Direction Flag and Interrupt flag
Bus Interface Unit (BIU):
The BIU sends out addresses, fetches instructions from memory, reads data from memory
and ports, and writes data to ports and memory. In other words the BIU handles all
transfers of data and addresses on the buses for the execution unit. The BIU has
1. An instruction queue
2. An Instruction pointer
3. Segment registers
Instruction Queue:
To speed up program execution, the BIU fetches as many as 6 insturction bytes ahead of
time from memory. The prefetched instruction bytes are held for the EU in a first - - first out group of register called a queue. The EU decodes an instruction or executes an
instruction which does not require the buses. When the EU is ready for its next
instruction, it simply reads the instruction from the queue in the BIU. Fetching the next
instruction while the current instruction executes, is called pipelining.
Note:
The 8088 microprocessor has only a 4 -byte queue.
Instruction Pointer (IP)
The Instruction Pointer is a 16 - bit register. This register is always used as the effective
memory address, and is added to the Code segment with a displacement of four bits to
obtain the physical address of the opcode. The code segment cannot be changed by the
move instruction. The instruction pointer is incremented after each opcode fetch to point
to the next instruction. Segment Registers The 8086 / 8088 microprocessor has 20 - bit
address lines. All the registers in 8086 / 8088 are 16 - bits in length. Hence to obtain 20 bit addresses from the available 16 - bit registers, all 8086 / 8088 memory addresses are
computed by summing the contents of a segment register and a effective memory
address. The effective memory address is computed via a variety of addressing modes.
The process of adding, to obtain 20 - bit address is as follows:
The selected segment register contents are shifted - left four bits (i.e., the contents are
multiplied by 16 decimal), and then added to the effective memory address to generate
the actual physical address output.
8086 Programs
END
PROGRAM :
ADDRESS
1100
1103
1104
1106
1107
1109
110C
110E
OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
01 C3
ADD
BF 20 15
MOV
89 1D
MOV
CC
INT
OPERAND
SI,1500
BX,AX
BX,AX
DI,1520
[DI],BX
3
OBSERVATION:
INPUT
RESULT:
OUTPUT
COMMENT
END
PROGRAM :
ADDRESS
1100
1103
1104
1106
1107
1109
110C
110E
OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
01 C3
SUB
BF 20 15
MOV
89 1D
MOV
CC
INT
OPERAND
SI,1500
BX,AX
BX,AX
DI,1520
[DI],BX
3
OBSERVATION:
INPUT
RESULT:
OUTPUT
COMMENT
Expt.No:2(A)
Date:
AIM:
To Multiply two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulatar.
2. Multiply the Second Data with the Accumalatar content
3. Store the Result
FLOWCHART:
START
END
PROGRAM :
ADDRESS
1200
1203
1204
1206
1207
1209
120C
120E
120F
1210
1212
OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
F7 E3
MUL
BF 05 15
MOV
89 05
MOV
01 C3
INC
BF 20 15
INC
89 1D
MOV
CC
INT
OPERAND
SI,1500
BX,AX
BX
DI,1505
[DI],AX
DI
DI
[DI],DX
3
OBSERVATION:
INPUT
OUTPUT
COMMENT
RESULT:
Expt.No:2(B)
Date:
AIM:
To Divide two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulatar.
2. Divide the Second Data with the Accumalatar content
3. Store the Result
FLOWCHART
START
END
PROGRAM :
ADDRESS
1300
1303
1306
1309
130B
130E
1310
1311
1313
1314
1316
OPCODE
BA 00 00
B8 FD FF
B9 0F 00
F7 F1
BF 00 15
88 05
47
88 25
47
89 15
CC
MNEMONICS
MOV
MOV
MOV
DIV
MOV
MOV
INC
MOV
INC
MOV
INT
OBSERVATION:
INPUT
OUTPUT
OPERAND
DX,0000
AX,FFFD
CX,000F
CX
DI,1500
[DI],AL
DI
[DI],AH
DI
[DI],DX
3
COMMENTS
RESULT:
Expt.No:3
TO
Date:
LOCATION
AIM:
To write an ALP to Transfer n Datas from one memory location to another.
APPARATUS REQUIRED:
8086 Trainer Kit
ALGORITHM:
1.Intilize the Count value.
2.Load the Acc. algorithm
3.Store the datas to the Destination Address.
4. End The Program.
FLOWCHART :
START
INTILIZE MEMORY
POINTER
TRANSFER TO DESIRED
LOCATION
CL = CL-1
IS
COUN
=
0?
STORE
END
PROGRAM :
ADDRESS
1000
1002
1005
1008
1009
100B
100C
100E
1010
OPCODE MNEMONICS
B1 08
MOV
BE 00 04
MOV
BF 50 14
MOV
AC
LODSB
88 05
MOV
47
INC
FE C9
DEC
75 F8
JNZ
CC
INT
OPERAND
CL,08
SI,1400
DI,1450
[DI],AL
DI
CL
1008
3
OBSERVATION:
INPUT
OUTPUT
COMMENT
RESULT:
Expt.No:4(A)
CODE CONVERSIONS
Date:
(A) ASCII TO HEX CODE:
AIM:
To write an ALP to execute ASCII to HEX code conversion using 8086.
ALGORITHM:
1.
2.
3.
4.
5.
FLOWCHART:
Start
Subtract with 30
No
yes
AL=al-7
If
AL<=1
0
Exit
PROGRAM:
ADDRESS
1100
1102
1104
1106
1108
110A
OPCODE
B0 31
2C 30
3C 10
72 04
74 02
2C 07
MNEMONICS
MOV
SUB
CMP
JB
JZ
SUB
OPERAND
AL,31
AL,30
AL,10
110C
110C
AL,07
110C
CC
INT
COMMENTS
OBSERVATION:
INPUT
ADDRESS
OUTPUT
DATA
ADDRESS
DATA
RESULT:
FLOWCHART:
Start
If
AL<=
Exitthe data
Load al9with
AL=al +07+30
PROGRAM:
ADDRESS
OPCODE
MNEMONICS
OPERA
ND
1100
BO OA
MOV
AL,OA
1102
3C 09
CMP
AL,09
1104
74 04
JZ
110A
1106
72 02
JB
110A
1108
04 07
ADD
AL,07
110A
04 30
ADD
AL,30
110C
CC
INT
COMMENTS
OBSERVATION:
INPUT
ADDRESS
OUTPUT
DATA
ADDRESS
DATA
RESULT:
Expt.No:4 (B)
Date:
AIM:
To write an ALP to find the Largest of the data given in an array.
APPARATUS REQUIRED:
8086 Trainer Kit
ALGORITHM:
1.Intilize the Count value.
2.Get the First data.
3.Compare with the next data.
4. Decrement the count till count becomes zero.
5.Store the lagest of the Data.
FLOW CHART:
START
IS
COUN
T = 0?
END
PROGRAM :
ADDRESS
1000
1003
1005
1006
1008
100A
100B
100D
100F
1011
1013
1015
1018
101A
OPCODE MNEMONICS
BE 00 90
MOV
8A 0C
MOV
46
INC
8A 04
MOV
FE C9
DEC
46
INC
3A 04
CMP
73 02
JMB
8A 04
MOV
FE C9
DEC
75 F5
JNZ
BF 00 95
MOV
88 05
MOV
CCS
INT 3
OPERAND
SI,9000
CL,[SI]
SI
AL,[SI]
CL
SI
AL,[SI]
1011
AL,[SI]
CL
100A
DI, 9500
[DI],AL
OBSERVATION:
INPUT
OUTPUT
COMMENT
RESULT:
Expt.No:5(A)
ARRAY
Date:
AIM:
To write an ALP in 8086 to Add n 16 bit Datas stored in an Array.
APPARATUS REQUIRED:
8086 Trainer Kit.
ALGORITHM:
1.
2.
3.
4.
COUNT
-1 =0?
END
PROGRAM :
ADDRESS
1300
1302
1304
1306
1308
130A
130C
130E
1311
1313
LABEL
LOOP
MNEMONICS
MOV
MOV
MOV
ADD
INC
DEC
JNZ
MOV
MOV
INT
OPERAND
CL, - AL,00
BL,01
AL,BL
BL
CL
LOOP
DI,2000
[DI],AX
3
B1
B2 B3
B4
COMMENT
OBSERVATION:
INPUT
OUT PUT
RESULT:
Expt.No:5(B)
FACTORIAL OF A DATA
Date:
AIM
To write an ALP in 8086 to find the Factorial of the given Data.
APPARATUS REQUIRED:
8086 Trainer Kit.
ALOGORITHMIS:
1. Load the value.
FLOW CHART:
START
IF CL -1 =0?
END
PROGRAM :
ADDRESS
1100
1102
1104
1106
1108
110A
110C
110E
1111
1113
LABEL
LOOP
MNEMONICS
MOV
MOV
MOV
MUL
INC
DEC
JNZ
MOV
MOV
INT 3
OPERAND
CL, 04
AL,01
BL,01
BL
BL
CL
LOOP
DI,2000
[DI],AX
B1
B2 B3
OBSERVATION:
INPUT
OUTPUT
RESULT:
Expt.No:6 (A)
ADDITION OF 3 X 3 MATRIX
Date:
AIM
To write an ALP in 8086 to Add the Data of two 3 x 3 matrix.
B4
COMMENT
APPARATUS REQUIRED:
8086 Trainer Kit.
ALOGORITHMIS:
1.
2.
3.
4.
FLOWCHART :
START
COUNT = COUNT - 01
IF
COUNT
=O?
END
PROGRAM :
ADDRESS
1500
1502
1505
1508
150A
150C
150E
1510
1511
1512
1514
1516
LABEL
LOOP
MNEMONICS
MOV
MOV
MOV
MOV
MOV
ADD
MOV
INC
INC
DEC
JNZ
INT 3
OPERAND
CL, 09
SI,2000
DI,3000
AL,[SI]
BL,[DI]
AL,BL
[DI],AL
DI
SI
CL
LOOP
B1
B2 B3
B4
COMMENT
OBSERVATION:
INPUT -1
INPUT -2
OUTPUT
RESULT:
Expt.No:6(B)
Date:
A WORD
AIM:
To find and replace a word from a string.
ALGORITHM:
1. Load the source and destination index register with starting and the ending
address respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction SCASW with the prefix REP to search
a word from string.
5. If a match is found (z=1), replace the old word with the current word in
destination address. Otherwise, stop.
PROGRAM:
ADDRESS
LABEL
MNEMONICS
MOV
MOV
MOV
MOV
MOV
MOV
CLD
REPLACE
SCASW
JNZ
MOV
MOV
LOOP
MOV
INT 21
OPERAND
AX,DATA
DS, AX
AX,15
SI, OFFSET
CX, COUNT
AX, 00
B1
LOOP
DI, LABEL
[DI],REPLACE
AH,4C
OBSERVATION:
INPUT -1
OUTPUT
RESULT:
Expt.No:7
Date:
AIM:
PASSWORD CHECKING
B2 B3
B4
COMMENT
ALGORITHM:
1.Initialize the Memory Pointer.
2.Store the Required password as our wish.
3.Enter the Password
4.IF the entered Password matches with the Stored Password then the Welcome screen
appears on Display
5.Others wise Wrong Password is displayed on the Screen.
FLOW-DIAGRAM:
STARin a specific
Store Initialize
your Password
the
Memory
Pointer
Enter
Password
Memory AddressTthe
ie.1500
No
IF
Match
es
Yes
LCD displays Correct
Password
PROCEDURE:
STEP: 1
OPCODES
E8 18 01
B5 06
B1 06
MNEMONICS
CALL 111B
MOV CH,06
MOV CL,06
COMMENTS
;Call the LCD initialization
;Initialize the register CH
;Initialize the register CL
1007
100A
100D
100F
1010
1012
BB 00 15
E8 00 00
8A 07
43
FE C9
75 F9
1014
1017
101A
101D
101F
1021
BB 00 15
BE 00 17
E8 00 00
8A 04
3A 07
75 7E
1023
1024
1025
1027
1029
102C
43
46
FE CD
75 F4
E8 00 00
BA 20 FF
INC BX
INC SI
DEC CH
JNE 101D
CALL 102C
MOV DX,FF20
102F
1031
1032
1035
B0 0C
EE
E8 19 01
B0 43
MOV AL,0C
OUT DX,AL
CALL 114E
MOV AL,43
1037
1038
EE
E8 23 01
OUT DX,AL
CALL 115E
103B
103D
103E
1041
B0 4F
EE
E8 1D 01
B052
MOV AL,4F
OUT DX,AL
CALL 115E
MOV AL,52
1043
EE
OUT DX,AL
1044
E8 17 01
CALL 115E
1047
B0 52
MOV AL,52
1049
EE
OUT DX,AL
104A
E8 11 01
CALL 115E
104D
B0 45
MOV AL,45
104F
EE
OUT DX,AL
1050
E8 0B 01
CALL 115E
1053
B0 43
MOV AL,43
1055
EE
OUT DX,AL
1056
E8 05 01
CALL 115E
1059
B0 54
MOV AL,54
105B
EE
OUT DX,AL
105C
E8 FF 00
CALL 115E
105F
E8 80 00
CALL 10E2
1062
B0 01
MOV AL,01
1064
EE
OUT DX,AL
1065
E8 E6 00
CALL 114E
1068
B0 84
MOV AL,84
106A
EE
OUT DX,AL
106B
E8 E0 00
CALL 114E
106E
B0 0C
MOV AL,0C
1070
EE
OUT DX,AL
1071
E8 DA 00
CALL 114E
1074
B0 57
MOV AL,57
1076
EE
OUT DX,AL
1077
E8 E4 00
CALL 115E
107A
B0 45
MOV AL,45
107C
EE
OUT DX,AL
107D
E8 DE 00
CALL 115E
1080
B0 4C
MOV AL,4C
1082
EE
OUT DX,AL
1083
E8 D8 00
CALL 115E
1086
B0 43
MOV AL,43
1088
EE
OUT DX,AL
1089
E8 D2 00
CALL 115E
108C
B0 4F
MOV AL,4F
108E
EE
OUT DX,AL
108F
E8 CC 00
CALL 115E
1092
B0 4D
MOV AL,4D
1094
EE
OUT DX,AL
1095
E8 C6 00
CALL 115E
1098
B0 45
MOV AL,45
109A
EE
OUT DX,AL
109B
E8 C0 00
CALL 115E
109E
E8 C1 FF
CALL 1062
10A1
B0 81
MOV AL,81
10A3
EE
OUT DX,AL
10A4
E8 A7 00
CALL 114E
10A7
B0 0C
MOV AL,0C
10A9
EE
OUT DX,AL
10AA
E8 A1 00
CALL 114E
10AD
B0 57
MOV AL,57
10AF
EE
OUT DX,AL
10B0
E8 AB 00
CALL 115E
10B3
B0 52
MOV AL,52
10B5
EE
OUT DX,AL
10B6
E8 A5 00
CALL 115E
10B9
B0 4F
MOV AL,4F
10BB
EE
OUT DX,AL
10BC
E8 9F 00
CALL 115E
10BF
B0 4E
MOV AL,4E
10C1
EE
OUT DX,AL
10C2
E8 99 00
CALL 115E
10C5
B0 47
MOV AL,47
10C7
EE
OUT DX,AL
10C8
E8 93 00
CALL 115E
10CB
E8 14 00
CALL 10E2
10CE
E8 9D 00
CALL 116E
10D1
E8 9A 00
CALL 116E
10D4
E8 97 00
CALL 116E
10D7
E8 94 00
CALL 116E
10DA
E8 91 00
CALL 116E
10DD
E8 8E 00
CALL 116E
10E0
CD 21
INT 21
10E2
BA 20 FF
MOV DX,FF20
10E5
B0 C7
MOV AL,C7
10E7
EE
OUT DX,AL
10E8
E8 63 00
CALL 114E
10EB
B0 50
MOV AL,50
10ED
EE
OUT DX,AL
10EE
E8 6D 00
CALL 115E
10F1
B0 41
MOV AL,41
10F3
EE
OUT DX,AL
10F4
E8 67 00
CALL 115E
10F7
B0 53
MOV AL,53
10F9
EE
OUT DX,AL
10FA
E8 61 00
CALL 115E
10FD
B0 53
MOV AL,53
10FF
EE
OUT DX,AL
1100
E8 5B 00
CALL 115E
1103
B0 57
MOV AL,57
1105
EE
OUT DX,AL
1106
E8 55 00
CALL 115E
1109
B0 4F
MOV AL,4F
110B
EE
OUT DX,AL
110C
E8 4F 00
CALL 115E
110F
B0 52
MOV AL,52
1111
EE
OUT DX,AL
1112
E8 49 00
CALL 115E
1115
B0 44
MOV AL,44
1117
EE
OUT DX,AL
1118
E8 43 00
CALL 115E
111B
B4 00
MOV AH,00
111D
BA 26 FF
MOV DX,FF26
1120
B0 80
MOV AL,80
1122
EE
OUT DX,AL
1123
BA 20 FF
MOV DX,FF20
1126
B0 38
MOV AL,38
;Function set
1128
EE
OUT DX,AL
1129
E8 22 00
CALL 114E
112C
B0 38
MOV AL,38
112E
EE
OUT DX,AL
112F
E8 1C 00
CALL 114E
1132
B0 38
MOV AL,38
1134
EE
OUT DX,AL
1135
E8 16 00
CALL 114E
1138
B0 0F
MOV AL,0F
113A
EE
OUT DX,AL
113B
E8 10 00
CALL 114E
113E
B0 06
MOV AL,06
1140
EE
OUT DX,AL
1141
E8 0A 00
CALL 114E
1144
B0 01
MOV AL,01
1146
EE
OUT DX,AL
1147
E8 04 00
CALL 114E
114A
E8 01 00
CALL 114E
114D
C3
RET
114E
BA 22 FF
MOV DX,FF22
1151
B0 04
MOV AL,04
1153
EE
OUT DX,AL
1154
B0 00
MOV AL,00
1156
EE
OUT DX,AL
1157
E8 14 00
CALL 116E
115A
BA 20 FF
MOV DX,FF20
115D
C3
RET
115E
BA 22 FF
MOV DX,FF22
1161
B0 05
MOV AL,05
1163
EE
OUT DX,AL
1164
B0 00
MOV AL,00
1166
EE
OUT DX,AL
1167
E8 04 00
CALL 116E
116A
BA 20 FF
MOV DX,FF20
116D
C3
RET
116E
53
PUSH BX
116F
BB FF FF
MOV BX,FFFF
1172
4B
DEC BX
;Decrement BX register
;Function set
;Function set
;Display ON/OFF
;Entry mode
;Clear screen
1173
75 FD
JNE 1172
1175
5B
POP BX
1176
C3
RET
Expt.No:8
Date:
AIM:
To write an ALP for Counter and Time Delay using 8086 Microprocessor.
ALGORITHM:
1. Enter the program into the kit.
2. Connect the PLCK and CLK0 through a wire connector.
3. Now see the output wave form on the OUT0.
PROGRAM:
ADDRESS
1000
1002
1005
1006
OPCODE
B0 36
BA 56 FF
EE
B0 78
MNEMONICS
MOV
MOV
OUT
MOV
OPERAND
AL,36
DX,FF56
DX,AL
AL,78
COMMENTS
1008
100B
100C
100E
100F
RESULT:
BA 50 FF
EE
B0 00
EE
CC
MOV
OUT
MOV
OUT
INT 3
DX,FF50
DX,AL
AL,00
DX,AL
MASAM - PROGRAMS
APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT ADDITION:
.model.small
.data
.code
Start: org 000h
mov ax,06h
mov bx,05h
add ax,bx
int 3
End
OBSERVATION:
INPUT:
DATA1
DATA 2
OUTPUT:
RESULT
APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT SUBTRACTION:
.model.small
.data
.code
Start: org 000h
mov ax,05h
mov bx,03h
sub ax,bx
int 3
End
OBSERVATION:
INPUT:
DATA1
DATA 2
OUTPUT:
RESULT
Expt.No:2(A)
MASAM
Date:
AIM:
To Multiply two16 bit numbers and to store the result using MASAM..
APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT MULTIPICATION
.model.small
.data
.code
Start: org 000h
mov ax,03h
mov bx,04h
mul ax,bx
int 3
End
OBSERVATION:
INPUT:
OUTPUT:
DATA1
DATA 2
RESULT:
Expt.No:2(B)
Date:
AIM:
To Divide two16 bit numbers and to store the result using MASM..
APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT DIVISION:
.model.small
.data
.code
Start: org 000h
mov ax,06h
mov bx,05h
mul ax,bx
int 3
End
OBSERVATION:
INPUT:
OUTPUT:
DATA1
DATA 2
RESULT
Expt.No:3
Date:
AIM:
To perform Logical Operations and store the result using MASM.
APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
PROGRAM:
AND OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,02h
mov bl,04h
and al,bl
int 3
End
OUTPUT:
OR OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,02h
mov bl,04h
or al,bl
int 3
End
OUTPUT:
NOT OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,01h
not al
int 3
End
OUTPUT:
RESULT:
Expt.No:4
BLOCK TRANSFER WITHOUT OVERLAP
USING MASAM
DAte:
AIM:
To Transfer n 16 bit array from one location to another using MASAM..
PROGRAM:
.MODEL SMALL .DATA
Array1 DW 1111h,2222h,3333h,4444h,5555h
Array2 DW 5 DUP (0)
Count DW 0005H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,Array1
LEA DI,Array2
MOV CX,Count
NEXT: MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH,4Ch
INT 21h
END
INPUT
OUTPUT
RESULT
Expt.No:5
Date:
AIM:
To Write an ALP to Verify the Password using MASAM
Software Required:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
Program:
ASSUME CS:CODE,DS:DATA,ES:EXTRA
DATA SEGMENT
STRING1 DB 'MRCET'
STRLEN EQU ($-STRING1)
SANE DB 'STRINGS ARE UNEQUAL$'
SAE DB 'STRINGS ARE EQUAL$'
DATA ENDS
EXTRA SEGMENT
STRING2 DB 'MRCET'
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV SI,OFFSET STRING1
MOV DI,OFFSET STRING2
CLD
MOV CX,STRLEN
REP CMPSB
JZ GO
MOV AH,09H
MOV DX,OFFSET SANE
INT 21H
JMP EXITP
GO: MOV AH,09H
MOV DX,OFFSET SAE
INT 21H
EXITP: INT 03H
CODE ENDS
END START
RESULT
Expt.no:6(A)
Date:
AIM:
Program:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ARRAY DB 0500H,0300H,0001H,0004H,0002H
COUNT DB 05H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
SUB AX,AX
MOV DX,COUNT-1
AGAIN:MOV CX,DX
MOV SI,OFFSET ARRAY
BACK: MOV AX,[SI]
CMP AX,[SI+2]
JBE FORW
XCHG AX,[SI+2]
MOV [SI],AX
FORW: INC SI
INC SI
LOOP BACK
DEC DX
JNZ AGAIN
INT 03H
CODE ENDS
END START
INPUT
OUTPUT
RESULT
Expt.No:6(B)
Date:
AIM:
PROGRAM:
.model.small
.data
.code
Start: org 0000h
Mov DI,1300h
Mov SI,1200h
Mov CL,50h
Mov DL,0ah
Loop1:LODSB
CMP DL,AL
JZ loopz
DEC CL
JNZ loop1
HLT
Loop2:Mov [DI],AL
DEC SI
Mov BX,SI
INC DI
Mov [DI],BL
INC DI
Mov [DI],BL
INPUT
End
OUTPUT
INT 3
RESULT:
Expt.No:7
Date:
AIM:
To perform square operation using MASM.
APPARATUS REQUIRED:
LCALL 00BBh
end
INPUT
OUTPUT
RESULT:
MCS-51 (commonly
referred
to
as 8051)
is
a Harvard
architecture, CISCinstruction set, single chip microcontroller (C) series which was
developed by Intelin 1980 for use in embedded systems
The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer,
etc.) in a single package.
8-bit ALU and Accumulator, 8-bit Registers (one 16-bit register with special move
instructions), 8-bit data bus and 216-bit address bus/program counter/data pointer and
related 8/11/16-bit operations; hence it is mainly an 8-bitmicrocontroller
Boolean processor with 17 instructions, 1-bit accumulator, 32 registers (4 bitaddressable 8-bit) and up to 144 special 1 bit-addressable RAM variables (18 bitaddressable 8-bit)
4 KB of on-chip ROM, with a 16-bit (64 KB) address space (PMEM). Not included on
803X variants
One feature of the 8051 core is the inclusion of a boolean processing engine which
allows bit-level boolean logic operations to be carried out directly and efficiently on select
internal registers and select RAM locations. This feature helped cement the 8051's
popularity in industrial control applications because it reduced code size by as much as
30%. Another feature is the inclusion of four bank selectable working register sets which
greatly reduce the amount of time required to complete an interrupt service routine. With a
single instruction the 8051 can switch register banks as opposed to the time consuming
task of transferring the critical registers to the stack or designated RAM locations. These
registers also allowed the 8051 to quickly perform a context switch.Once a UART, and a
timer if necessary, has been configured, the programmer needs only write a simple interrupt
routine to refill the send shift register whenever the last bit is shifted out by the UART and/or
empty the full receive shift register (copy the data somewhere else). The main program then
performs serial reads and writes simply by reading and writing 8-bit data to stacks.
Memory architecture
The MCS-51 has four distinct types of memory internal RAM, special function registers,
program memory, and external data memory.
Internal RAM (IRAM) is located from address 0 to address 0xFF. IRAM from 0x00 to 0x7F
can be accessed directly. IRAM from 0x80 to 0xFF must be accessed indirectly, using the
@R0 or @R1 syntax, with the address to access loaded in R0 or R1. The 128 bits at IRAM
locations 0x200x2F are bit-addressable.
Special function registers (SFR) are located in the same address space as IRAM, at
addresses 0x80 to 0xFF, and are accessed directly using the same instructions as for the
lower half of IRAM. They cannot be accessed indirectly via @R0 or @R1. 16 of the SFRs
are also bit-addressable.
Program memory (PMEM, though less common in usage than IRAM and XRAM) is up to
64 KB of read-only memory, starting at address 0 in a separate address space. It may be
on- or off-chip, depending on the particular model of chip being used. Program memory is
read-only, though some variants of the 8051 use on-chip flash memory and provide a
method of re-programming the memory in-system or in-application. In addition to code, it is
possible to store read-only data in program memory, accessed by the MOVC A, @DPTR
instruction. Data is fetched from the address specified in the 16-bit special function register
DPTR.
External data memory (XRAM) is a third address space, also starting at address 0. It can
also be on- or off-chip; what makes it "external" is that it must be accessed using the MOVX
(Move eXternal) instruction. Many variants of the 8051 include the standard 256 bytes of
IRAM plus a few KB of XRAM on the chip.
The 8051 is designed as a strict Harvard architecture. The 8051 can only execute code
fetched from program memory. The 8051 does not have any instruction to write to program
memory. Most 8051 systems respect this distinction, and so are unable to download and
directly execute new programs. The strict Harvard architecture has the advantage of making
such systems immune to most forms of malware. Some 8051 systems have (or can be
modified to have) some "dual-mapped" RAM, making them act somewhat more
like Princeton architecture. This (partial) Princeton architecture has the advantage of
making it possible for a Forth boot loader running on the 8051 to write new native code to
RAM and then execute it, leading to faster incremental and interactive programming cycles
than strict Harvard systems.
Registers
The only register on an 8051 that is not memory-mapped is the 16-bit program counter PC.
This specifies the address of the next instruction to execute. Relative branch instructions
supply an 8-bit signed offset which is added to the PC.
8 general-purpose registers R0R7 may be accessed with instructions 1 byte shorter than
others. They are mapped to IRAM between 0x00 and 0x1F. Only 8 bytes of that range are
used at any given time, determined by the two bank select bits in the PSW.
The following registers are memory-mapped into the special function register space:
(0x81) Stack pointer SP. This is an 8-bit register used by subroutine call and return
instructions. The stack grows upward; the SP is incremented before pushing, and
decremented after popping a value.
(0x8283) Data pointer DP. This is a 16-bit register that is used for accessing PMEM
and XRAM.
(0xD0) Program status word PSW. This contains important status flags:
PSW.0: P Parity. Gives the parity (modulo-2 sum of the bits of) the most recent ALU
result.
PSW.1: UD User Defined. For general software use, not otherwise used by hardware.
PSW.2: OV Overflow flag. Set when addition produces a signed overflow.
PSW.3: RS0 Register select 0. The low-order bit of the register bank. Set when banks
at 0x08 or 0x18 are in use.
PSW.4: RS1 Register select 1. The high-order bit of the register bank. Set
when banks at 0x10 or 0x18 are in use.
PSW.5: F0 Flag 0. For general software use, not otherwise used by hardware.
PSW.6: AC auxiliary carry. Set when addition produces a carry from bit 3 to bit 4.
(0xF0) B register. This is used as an extension to the accumulator for multiply and
divide instructions.
256 single bits are directly addressable. These are the 16 IRAM locations from 0x200x2F,
and the 16 special function registers 0x80, 0x88, 0x90, ,0xF8. Any bit of these bytes may
be directly accessed by a variety of logical operations and conditional branches.
Note that the PSW does not contain the common N (negative) and Z (zero) flags. Instead,
because the accumulator is a bit-addressable SFR, it is possible to branch on its most
significant bit directly. There is also an instruction to jump if the accumulator is zero or nonzero.
8051 - PROGRAMS
Expt.No:1(A)
Date:
AIM:
To write an ALP in 8051 to Add two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be added in microcontroller.
3. Add the data and store the sum.
4. Check for the carry and store the carry also.
FLOW CHART:
START
STORE CARRY
END
PROGRAM:
ADDRESS
4100
4103
4104
4105
4106
4107
4108
4109
410A
410C
410E
410F
4110
LABEL
MNEMONICS
MOV
MOVX
MOV
INC
MOVX
ADD
INC
MOVX
MOV
ADDC
INC
MOVX
LCALL
OPERAND
DPTR,#9000
A, @DPTR
R0,A
DPTR
A, @DPTR
A, R0
DPTR
@DPTR,A
A,# 00
A, #00
DPTR
@DPTR, A
00BB
OBSERVATION:
INPUT
RESULT:
OUTPUT
B1
B2 B3
COMMENT
Expt.No:1(B)
Date:
AIM:
To write an ALP in 8051 to Add two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be added in microcontroller.
3. subtract the data and store the sum.
4. Check for the carry and store the carry also.
FLOW CHART:
START
END
PROGRAM :
ADDRESS
4100
4103
4104
4105
4106
4107
4108
4109
4110
LABEL
MNEMONICS
MOV
MOVX
MOV
INC
MOVX
SUB
INC
MOVX
LCALL
OPERAND
DPTR,#9000
A, @DPTR
R0,A
DPTR
A, @DPTR
A, R0
DPTR
@DPTR,A
00BB
OBSERVATION:
INPUT
RESULT:
OUTPUT
B1
B2 B3
COMMENT
Expt.No:2(A)
Date:
AIM:
To write an ALP in 8051 to Multiply two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be multiplied in microcontroller.
3. Multiply two datas and store the quotient and remainder.
4. Check for the carry and store the carry.
FLOW CHART:
START
STORE THEPRODUCT
END
PROGRAM:
ADDRESS
4100
4103
4104
4106
4107
4108
4109
410A
410B
410C
410E
411F
LABEL
MNEMONICS
MOV
MOVX
MOV
INC
MOVX
MUL
INC
MOVX
INC
MOV
MOVX
LCALL
OPERAND
DPTR,#9000
A, @DPTR
F0,A
DPTR
A, @DPTR
AB
DPTR
@DPTR,A
DPTR
A,FO
@DPTR,A
00BB
B1
B2 B3
COMMENT
OBSERVATION:
INPUT
OUTPUT
RESULT:
Expt.No:2(B)
Date:
AIM:
To write an ALP in 8051 to Divide two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be divided in microcontroller.
3. Divide the data and store the Quotient.
4. Store the Remainder also.
FLOW CHART:
START
END
PROGRAM:
ADDRESS
4100
4103
4104
4106
4107
4108
4109
410A
410B
410C
410E
411F
LABEL
MNEMONICS
MOV
MOVX
MOV
INC
MOVX
DIV
INC
MOVX
INC
MOV
MOVX
LCALL
OPERAND
DPTR,#9000
A, @DPTR
F0,A
DPTR
A, @DPTR
AB
DPTR
@DPTR,A
DPTR
A,FO
@DPTR,A
00BB
B1
B2 B3
COMMENT
OBSERVATION:
INPUT
OUTPUT
RESULT:
Expt.No:3
Date:
AIM:
To write an ALP for logical operations using 8051 Microcontroller.
ALGORITHIMS:
1. Initialize the Register A and Register B.
2. Get the datas for performing logical operations in microcontroller.
3. Perform AND,OR and EX-OR operations.
4. For AND multiply the datas.
5. For OR add the datas.
6. Store the datas.
AND PROGRAM:
ADDRESS
9000
9001
9002
MNEMONICS
MOV
MOV
ANL
OPERAND
A,#02
B,#04
AB
9003
LCALL
00BB
COMMENTS
OBSERVATION:
INPUT
ADDRESS
DATA
OUTPUT
ADDRESS
DATA
OR PROGRAM:
ADDRESS
9000
9001
MNEMONICS
MOV
MOV
OPERAND
A,#02
B,#04
COMMENTS
9002
9003
ORL
LCALL
A,B
00BB
OBSERVATION:
INPUT
ADDRESS
DATA
OUTPUT
ADDRESS
DATA
EX-OR:
ADDRESS
9000
9001
9002
9003
MNEMONICS
MOV
MOV
XRL
LCALL
OPERAND
A,#02
B,#04
A,B
00BB
OBSERVATION:
INPUT
ADDRESS
DATA
OUTPUT
ADDRESS
DATA
COMMENTS
RESULT:
Expt.No:4
Date:
(A).1's COMPLEMENT:
AIM:
To write an ALP for 1's complement using 8051 Microcontroller.
ALGORITHIM:
1. Initialize the Accumalator.
2. Get the data to be 1's complemented in microcontroller.
3. Complement the data in the Accumalator.
4. Store the result in the Accumalator .
PROGRAM:
ADDRESS
9000
9001
9002
MNEMONICS
MOV
CPL
LCALL
OPERAND
A,#02
A
00BB
COMMENTS
OUTPUT:
INPUT
OUTPUT
ADDRESS
DATA
ADDRESS
DATA
(B).2's COMPLEMENT:
AIM:
To write an ALP 2's complement using 8051 Microcontroller.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data.
3. Complement the Accumulator and add 01.
4. Store the result in the Accumulator.
PROGRAM:
DATA
ADDRESS
9000
9001
9002
9003
9004
9005
9006
MNEMONICS
MOV
MOV
CPL
ADD
MOV
MOVX
LCALL
OPERAND
DPTR,#9500
A,@DPTR
A
A,#01
DPTR,#9500
@DPTR,A
00BB
COMMENTS
OUTPUT:
INPUT
ADDRESS
OUTPUT
DATA
ADDRESS
DATA
RESULT:
5 CODE CONVERSION
ASCII TO HEXA DECIMAL CONVERSION:
AIM:
To perform ASCII to hexadecimal conversion.
ALGORITHM:
1.
2.
3.
4.
5.
PROGRAM:
ADDRESS
MNEMONICS
OPERAND
9000
MOV
DPTR,#9500
9003
CLR
9004
MOVX
A,@DPTR
9005
SUBB
A,#30
9007
MOV
R1,A
9008
SUBB
A,#0A
900A
JC
9011
900C
CLR
900D
MOV
A,R1
900E
SUBB
A,#07
9010
MOV
R1,A
9011
MOV
A,R1
9012
LCALL
00BB
COMMENTS
OBSERVATION
INPUT
ADDRESS
RESULT:
OUTPUT
DATA
ADDRESS
DATA
INTERFACING
PROGRAMS
Expt.No:1
Date:
DIGITAL CLOCK
AIM:
To write an ALP for Digital Clock.
ALGORITHM:
1.Load the data Hrs,Mins and Sec in Different Memory Registers.
2.Initialize Hr ,Min and Sec.
3.INC Seconds until 59.If it is greater than 59 then the Minute starts incremented by 1 and
the Seconds are initialized to Zero.
4.If minute is greater than 59,then the hour starts incremented by 1 and the Minutes and
Seconds are initialized to Zero.
5.When the hour is greater than 12, then the Seconds and Minutes are initialized to Zero. And
then the Hour is initialized to One.
6. Again the clock starts from
FLOW CHART:
START
Initialize the Memory Pointers for Hr,Min and Sec
Load the data in three Memory
Registers
Initialize Hr
Initialize Min
Loop starts
again
Initialize Sec
Inc Sec
No
If Sec
<=59
Yes
Inc Min
No
If Min
<=59
Inc Hr
If Hr <=
12
Yes
No
Yes
PROGRAM:
ADDRESS
COMMENTS
0000
OPCODES MNEMONICS
E8 B2 00
CALL 00B5
0003
30 30
0005
30 30
0007
0013
31 B3 00
B7
00 B1 00
B5
00 BA 20
FF
B0 0C
XOR
[BX+SI],DH
XOR
[BX+SI],DH
XOR
[BP+DI+B700]
ADD
[BX+DI+B500]
ADD
[BP+SI+FF20]
MOV AL,0C
0015
EE
OUT DX,AL
0016
E8 CF 00
CALL 00E8
0019
BE 00 15
001C
AC
LODSB
001D
2E A2 05
0021
AC
MOV
[0005],AL
LODSB
0022
8A E0
MOV AH,AL
0024
AC
LODSB
0025
2E A2 06
0029
AC
MOV
[0006],AL
LODSB
002A
2E A2 03
002E
AC
MOV
[0003],AL
LODSB
002F
8A E8
MOV CH,AL
0031
AC
LODSB
0032
8A F8
MOV BH,AL
000B
000F
0034
AC
LODSB
0035
8A C8
MOV CL,AL
0037
AC
LODSB
0038
8A D8
MOV BL,AL
003A
EB 19
JMP 0055
003C
90
NOP
003D
0043
2E C6 06
05
2E A0 05
0047
B4 31
0049
004F
2E C6 06
03
B5 30
0051
B7 30
0053
B1 30
0055
E8 B0 00
MOV
Initialize var3(ie.var3 = 0 for the hex value
B[0005],30
30h )
MOV AL,[0005] Move/Store the value of the variable to an
Accum.
MOV AH,31
Initialize the Register AH = 1( ie the hex value
of 31h)
MOV
Initialize the Register AH = 1( ie the hex value
B[0003],31
of 31h)
MOV CH,30
Initialize the Register CH = 0( ie.the hex value
of 30h )
MOV BH,30
Initialize the Register BH = 0( ie.the hex value
of 30h)
MOV CL,30
Initialize the Register CL = 0( ie.the hex value
of 30h)
CALL 0108
Call the part section
0058
B3 30
MOV BL,30
005A
8A C3
MOV AL,BL
005C
EE
OUT DX,AL
005D
E8 98 00
CALL 00F8
0060
E8 A5 00
CALL 0108
0063
FE C3
INC BL
0065
8A C3
MOV AL,BL
0067
EE
OUT DX,AL
0068
E8 8D 00
CALL 00F8
006B
80 FB 39
CMP BL,39
006E
75 F0
JNE 0060
0070
FE C1
INC CL
0072
80 F9 36
CMP CL,36
0075
75 DE
JNE 0055
0077
FE C7
INC BH
0079
80 FF 3A
CMP BH,3A
007C
75 D5
JNE 0053
007E
FE C5
INC CH
0080
80 FD 36
CMP CH,36
0083
75 CC
JNE 0051
0085
2E FE 06
03
FE C4
INC B[0003]
2E 80 3E
03
76 BB
CMP
B[0003],39
JBE 004F
2E C6 06
05
2E 8A 26
06
2E FE 06
06
2E 80 3E
06
76 A3
MOV
B[0005],31
MOV AH,
[0006]
INC B[0006]
00B2
2E C6 06
00
06
MOV
B[0000],00
PUSH ES
00B3
89 CC
MOV SP,CX
00B5
B4 00
MOV AH,00
00B7
BA 26 FF
MOV DX,FF26
00BA
B0 80
MOV AL,80
00BC
EE
OUT DX,AL
00BD
D4
DB 04
00BE
20 FF
AND BH,BH
00C0
B0 38
MOV AL,38
00C2
EE
OUT DX,AL
00C3
E8 03 00
CALL 00C9
00C6
B0 38
MOV AL,38
00C8
EE
OUT DX,AL
008A
008C
0092
0094
009A
009F
00A4
00AA
00AC
INC AH
CMP
B[0006],33
JBE 004F
E8 1C 00
CALL 00E8
00CC
B0 38
MOV AL,38
00CE
EE
OUT DX,AL
00CF
E8 16 00
CALL 00E8
00D2
B0 0F
MOV AL,0F
00D4
EE
OUT DX,AL
00D5
E8 10 00
CALL 00E8
00D8
B0 06
MOV AL,06
00DA
EE
OUT DX,AL
00DB
E8 0A 00
CALL 00E8
00DE
B0 01
MOV AL,01
00E0
EE
OUT DX,AL
00E1
E8 04 00
CALL 00E8
00E4
E8 01 00
CALL 00E8
00E7
C3
RET
00E8
BA 22 FF
MOV DX,FF22
00EB
B0 04
MOV AL,04
00ED
EE
OUT DX,AL
00EE
B0 00
MOV AL,00
00F0
EE
OUT DX,AL
00F1
E8 49 00
CALL 013D
00F4
BA 20 FF
MOV DX,FF20
00F7
C3
RET
00F8
BA 22 FF
MOV DX,FF22
00FB
B0 05
MOV AL,05
00FD
EE
OUT DX,AL
00FE
B0 00
MOV AL,00
0100
EE
OUT DX,AL
0101
E8 39 00
CALL 013D
0104
BA 20 FF
MOV DX,FF20
0107
C3
RET
0108
BA 20 FF
MOV DX,FF20
010B
B0 C0
MOV AL,C0
010D
EE
OUT DX,AL
010E
E8 D7 FF
CALL 00E8
0111
2E A0 05
0115
EE
0116
E8 DF FF
0119
8A C4
MOV AL,AH
011B
EE
OUT DX,AL
011C
E8 D9 FF
CALL 00F8
011F
B0 3A
MOV AL,3A
0121
EE
OUT DX,AL
0122
E8 D3 FF
CALL 00F8
0125
8A C5
MOV AL,CH
0127
EE
OUT DX,AL
0128
E8 CD FF
CALL 00F8
012B
8A C7
MOV AL,BH
012D
EE
OUT DX,AL
012E
E8 C7 FF
CALL 00F8
0131
B0 3A
MOV AL,3A
0133
EE
OUT DX,AL
0134
E8 C1 FF
CALL 00F8
0137
8A C1
MOV AL,CL
0139
EE
OUT DX,AL
013A
E8 BB FF
CALL 00F8
013D
53
PUSH BX
013E
BB FF 3F
MOV BX,3FFF
0141
4B
DEC BX
0142
75 FD
JNE 0141
0144
5B
POP BX
0145
C3
RET
Example : 1
INPUT :
For the clock below 10
1500 -> var3 ---> 30h
1501 -> AH ---> Required time below 10 (ie. from 0 to 9)
1502 -> var4 ---> 30h
1503 -> Assign AH to var1
1504 ->
CH ---> 35h
1505 ->
BH ---> 36h
1506 ->
CL ---> 35h
1507 ->
BL ---> 30h
OUTPUT :
Hours
Var3 AH
0
9
Minutes
CH BH
5 6
Seconds
CL BL
5 0
Example : 2
INPUT :
For the clock Above 10
1500 ->
var3 ---> 31h
1501 -> AH --->Required time above or equal to 10 (ie. from 0 to 2)
1502 ->
var4 = AH + 1
1503 ->
var1 = 39h;
1504 ->
CH ---> 35h
1505 ->
BH ---> 36h
1506 ->
CL ---> 35h
1507 ->
BL ---> 30h
Hours
Var3 AH
1
1
Expt.No: 2
Date:
Minutes
CH BH
5 6
Seconds
CL BL
5 0
OUTPUT :
PROGRAM TO INTERFACE
A) -ANALOG TO DIGITAL CONVERTOR (ADC)
B)-DIGITAL TO ANALOG CONVERTOR ( DAC)
Program (A):
AIM:
s
APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. ADC Interface Board.
3. Power Card.
ALGORITHM:
FLOW CHART:
START
STOP
ZER
O?
RETURN
PROGRAM:
OBSERVATION:
ADDRESS
2E00
LABEL
PGM - A
S. NO
RESULT:
MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
MOV
OUT
CALL
MOV
IN
INT 3
MOV
NOP
NOP
DEC
JNE
RET
OPERAND
DX, FF56
AL, 90
DX, AL
DX, FF54
AL, FF
DX, AL
AL, FF
DX, AL
PGM -A
DX, FF50
AL, DX
B1
CX, 0FFF
CX
LOOP
ANALOG VALUE
DIGITAL VALUE
(volts)
(volts)
B2 B3
COMMENT
Program (B):
AIM:
To Write an ALP to Interface8086 Processor with the Digital to Analog
Convertor (DAC) Interface Board.
APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. DAC Interface Board.
3. Power Card.
PROGRAM:
ADDRESS
3000
LABEL
300C
S. NO
MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
INT 3
OPERAND
DX, FF56
AL, 80
DX,AL
DX, FF52
AL, 00
DX,AL
B1
DIGITAL VALUE
ANALOG VALUE
(volts)
(volts)
OBSERVATION:
B2 B3
COMMENT
Move Central Reg. Addr.
Control Word
Out in Port B
RESULT:
Expt.No: 3
Date:
AIM:
To Write an ALP to Interface8086 Processor with the 8279 Interface Board to Accept a
Key.
APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. Display Interface Board.
ALGORITHM:
FLOW CHART:
START
EVEN ?
STOP
PROGRAM:
ADDRESS
LABEL
LOOP
MNEMONICS
MOV
MOV
OUT
MOV
OUT
MOV
OUT
IN
AND
JE
MOV
IN
AND
INT 3
OPERAND
AL,12
DX,FF52
DX,AL
AL,3E
DX,AL
AL,A0
DX,AL
AL,DX
AL,07
LOOP
DX,FF50
AL,DX
AL,3F
B1
B2 B3
COMMENT
OUTPUT:
INPUT
OUTPUT
RESULT:
Expt.No:4
Date:
AIM:
To Write an ALP to Interface8086 Processor with the 8279 Interface Board to Display a
Character.
APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. Display Interface Board.
FLOW CHART:
START
START
DECREMENT C - REG
CALL DELAY
CHEC
K
ZERO?
CHEC
K
ZERO?
IF
ZERO ?
ADDRESS
LABEL
LOOP 1
MNEMONICS
MOV
MOV
OUT
MOV
OUT
MOV
OUT
MOV
MOV
MOV
OUT
DEC
OPERAND
AL, 12
DX, FF52
DX, AL
AH, AL
DX, AL
AH, AL
DX, AL
AH, 0B
DX, FF50
AL, 00
DX, AL
AH
B1
B2 B3
COMMENT
LOOP 2
JNZ
MOV
MOV
MOV
MOV
OUT
INC
DEC
JNZ
INT 3
LOOP 1
DX, FF50
CL, 06
BX, 2000
AX, [BX]
DX, AL
BX
CL
LOOP 2
PROGRAM:
a b c d e f g h Hexa
Equivalent
OUTPUT :
RESULT:
Expt.No:5
Date:
AIM:
To Write an ALP to Interface8086 Processor with the Stepper Motor Interface Board to
rotate in Forward & Backward Directions and to Control its Speed.
APPARATUS REQUIRED:
FLOWCHART:
START
START
INTILIZE
CALL ROTATE
DECREMENT
CALL DELAY
CALL ROTATE
ZERO
?
CALL DELAY
RETURN
PROGRAM :
ADDRESS
LABEL
ROTATE
MNEMONICS
MOV
MOV
OUT
MOV
MOV
OPERAND
DX, FF26
AL, 80
DX, AL
DX, FF20
AL, 80
B1
B2 B3
COMMENT
DELAY
TABULATION :
OUT
CALL
MOV
OUT
CALL
MOV
OUT
CALL
MOV
OUT
CALL
JMP
MOV
MOV
NOP
NOP
NOP
DX, AL
DELAY
AL, CO
DX, AL
DELAY
AL, E0
DX, AL
DELAY
AL, A0
DX, AL
DELAY
ROTATE
BX, 0010
AX, 00FF
CLOCKWISE
ANTICLOCKWISE
RESULT:
Expt.No:6
Date:
CONTROLLER
AIM:
To Write an ALP to Interface Traffic Light Controller using 8086.
APPARATUS REQUIRED:
1. 8086Trainer Kit
2. Traffic light controller Interface Board.
3. Power Card.
ALGORITHM
1.
2.
3.
4.
5.
ADDRESS
9500
9505
LABEL
LOOP
MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL
OPERAND
DX, FF26
AL, 81
DX, AL
DX, FF20
AL, CC
DX, AL
DX, FF22
AL, 11
DX, AL
9544
DX, FF20
AL, AA
DX, AL
DX, FF22
AL, AA
DX, AL
9555
DX, FF20
AL, 11
DX, AL
DX, FF22
AL, CC
DX, AL
9544
DX, FF20
AL, AA
DX, AL
DX, FF22
AL, AA
DX, AL
9555
B1
B2 B3
COMMENT
CALL DELAY 1
CALL DELAY 2
CALL DELAY 1
CALL DELAY 2
JMP
9505
PROGRAM:
ADDRESS
9544
9554
9555
9565
LABEL
DELAY 1
LOOP 1
LOOP 2
DELAY 2
LOOP 3
LOOP 4
MNEMONICS
MOV
MOV
NOP
NOP
NOP
NOP
DEC
JNZ
DEC
JNZ
RET
MOV
MOV
NOP
NOP
NOP
NOP
DEC
JNZ
DEC
JNZ
RET
OPERAND
BX, 00FF
AL, FF
AL
9549
BX
9547
B1
B2 B3
COMMENT
JUMP LOOP 2
JUMP LOOP 1
BX, 1000
AL, FF
AL
955A
BX
9558
JUMP LOOP 4
JUMP LOOP 3
OUTPUT :
INPUT
OUTPUT
RESULT:
Expt.No:7
Date:
AIM:
To write an ALP for Printer Interfacing through 8255.
ALGORITHM :
1.
2.
3.
4.
FLOW -DIAGRAM :
Start
ssssssss
ssSSST
ART
Initialize the Memory pointer
Yes
No
if al ==
0D
No
Send the character to
printer through 8255 ports
EXIT
PROGRAM :
ADDRESS OPCODES
0000
BA 26 FF
0003
0005
B0 82
EE
0006
0009
000B
BE 00 18
B0 07
BA 24 FF
000E
EE
000F
0012
0014
E8 0A 00
8A 04
3C 0D
0016
75 01
0018
0019
CC
46
001A
EB F3
001C
BA 22 FF
001F
0020
EC
D0 C8
0022
D0 C8
0024
0026
0028
72 F6
8A 04
BA 20 FF
002B
002C
002E
EE
B0 04
BA 24 FF
0031
0032
0033
0034
0036
0037
EE
90
90
B0 05
EE
C3
OBSERVATION:
MNEMONICS
COMMENTS
MOV
Initialize 8255 address
DX,FF26
MOV AL,82
Continuous word for port b & c o\p
OUT DX,AL
Output/Send the value of AL through
the Data ports of 8255
MOV SI, 1800 Starting address for message string
MOV AL,07
strobe high at low and high
MOV
Choosing Port C
DX,FF24
OUT DX,AL
Output the value of AL through Port
C of 8255
CALL 001C
Call one character
MOV AL,[SI] Put to AL
CMP AL,0D
Compare the character with 0D
Jump to a loop to print the character if
JNE 0019
AL doesnt match with 0D.When the
value of AL matches with 0D then loop
gets terminated.
INT3
Stops printing
INC SI
Increment the source index for getting
the next char.
JMP 000F
Again it goes to the loop for getting
another character.
MOV
Choosing Port B
DX,FF22
IN AL,DX
For getting printer status
ROR AL, 1
get two bits to right to get port b
status(busy)
ROR AL, 1
get two bits to right to get port b
status(busy)
JB 001C
wait if busy
MOV AL,[SI] get char from message string
MOV
put the data to printer
DX,FF20
OUT DX,AL
output the value of AL to printer
MOV AL,04
make strobe low to indicate
MOV
byte is loaded
DX,FF24
OUT DX,AL
NOP
Wait for few seconds(ie.delay)
NOP
MOV AL,05
strobe back to high
OUT DX,AL
RET
Return from Procedure or Function
INPUT:
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
41h
42h
43h
44h
45h
46h
47h
48h
49h
0Dh
RESULT:
Expt.No:8
PARALLEL INTERFACE
Date:
AIM:
To write an ALP for Parallel Interface using 8086 Microprocessor.
ALGORITHM:
1. Start the Program.
2. Call for the program.
3. Repeat the steps.
RECEIVER PROGRAM:
ADDRESS
9000
9003
9005
9006
9009
900A
900C
900F
9010
9012
9015
9016
OPCODE
BA 26 FF
B0 9B
EE
BA 24 FF
EC
88 C1
BA 22 FF
EC
88 C3
BA 20 FF
EC
CC
MNEMONICS OPERAND
MOV
DX,FF26
MOV
AL,9B
OUT
DX,AL
MOV
DX,FF24
IN
AL,DX
MOV
CL,AL
MOV
DX,FF22
IN
AL,DX
MOV
BL,AL
MOV
DX,FF20
IN
AL,DX
INT
3
COMMENTS
TRANSMITTER PROGRAM:
ADDRESS
9100
9103
9105
9106
9109
910C
910E
910F
9112
9115
9117
9118
911B
911E
9120
9121
9124
OPCODE
BA 26 FF
B0 80
EE
E8 1C 00
BA 20 FF
B0 FF
EE
E8 13 00
BA 22 FF
B0 22
EE
E8 0A 00
BA 24 FF
B0 33
EE
E8 01 00
CC
MNEMONICS
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
INT
OPERAND
DX,
AL, 80
DX, AL
9125
DX,
AL, FF
DX, AL
9125
DX,
AL, 22
DX, AL
9125
DX,
AL, 33
DX, AL
9125
3
COMMENTS
DELAY:
ADDRESS
9125
9128
9129
912A
912B
912C
912D
912F
OUTPUT:
RESULT:
OPCODE
B9 FF 00
90
90
90
90
49
75 F9
C3
MNEMONICS
MOV
LOOP1:NOP
NOP
NOP
NOP
DEC
JNZ
RET
OPERAND
CX,FF
CX
LOOP1
COMMENTS
INTRODUCTION TO MASM
EDITOR
An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes for
the letters and numbers in successive RAM locations. When you have typed in all of your
programs, you then save the file on a floppy of hard disk. This file is called source file. The next
step is to process the source file with an assembler. In the MASM /TASM assembler, you should
give your source file name the extension, .ASM
ASSEMBLER
An assembler program is used to translate the assembly language mnemonics for instructions to
the corresponding binary codes. When you run the assembler, it reads the source file of your
program the disk, where you saved it after editing on the first pass through the source program
the assembler determines the displacement of named data items, the offset of labels and pails this
information in a symbol table. On the second pass through the source program, the assembler
produces the binary code for each instruction and inserts the offset etc that is calculated during
the first pass. The assembler generates two files on floppy or hard disk. The first file called the
object file is given the extension. OBJ. The object file contains the binary codes for the
instructions and information about the addresses of the instructions. The second file generated by
the assembler is called assembler list file. The list file contains your assembly language
statements, the binary codes for each instructions and the offset for each instruction. In
MASM/TASM assembler, MASM/TASM source file name ASM is used to assemble the file.
Edit source file name LST is used to view the list file, which is generated, when you assemble
the file.
LINKER
A linker is a program used to join several object files into one large object file and convert to an
exe file. The linker produces a link file, which contains the binary codes for all the combined
modules. The linker however doesnt assign absolute addresses to the program, it assigns is said
to be reloadable because it can be put anywhere in memory to be run. In MASM/TASM,
LINK/TLINK source filename is used to link the file.
DEBUGGER
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look at
the contents of registers and memory locations after your program runs. It allows you to change
the contents of register and memory locations after your program runs.
It allows you to change the contents of register and memory locations and return the program. A
debugger also allows you to set a break point at any point in the program. If you inset a
breakpoint the debugger will run the program upto the instruction where the breakpoint is set and
stop execution. You can then examine register and memory contents to see whether the results
are correct at that point. In MASM/TASM, td filename is issued to debug the file.
DEBUGGER FUNCTIONS:
1. Debugger allows looking at the contents of registers and memory locations.
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and then
stop execution of program. At this point, we can examine registry and memory contents at that
point.
5. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8
The DOS -Debugger:
The DOS Debug program is an example of simple debugger that comes with MS-DOS.
Hence it is available on any PC .it was initially designed to give the user the capability to
trace logical errors in executable file.
Below, are summarized the basic DOS - Debugger commands
COMMAND SYNTAX
Assemble A [address]
Compare C range address
Dump D [range]
Enter E address [list]
Fill F range list
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Load L[address] [drive][first sector][number]
Move M range address
END