Professional Documents
Culture Documents
AIM:
To write an Assembly Language Program (ALP) for 16 bit Arithmetic operations using 8086.
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
ALGORITHM:
(i)16-bit addition:
2
3
(iii)Multiplication of 16-bit numbers:
4
TABULATION:
INPUT OUTPUT
1100 1200
1101 1201
1102
1103
INPUT OUTPUT
1100 1200
1101 1201
1102
1103
5
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)
COMMANDS
ADDRESS MNEMONICS OP-CODE
MOVE
ACCUMULATOR
1007 MOV [1200],AX A3,00,12 CONTENT TO
MEMORY
SUBTRACT
1003 SUB AX[1102] 2B,06,02,11 MEMORY CONTENT
WITH
ACCUMULATOR
MOVE
1007 MOV [1200],AX A3,00,12 ACCUMULATOR
CONTENT TO
MEMORY
6
TABULATION
INPUT OUTPUT
1100 1200
1101 1201
1102 1202
1103 1203
7
C-MULTIPLICATION OF TWO 16-BIT NUMBERS
MOVE
1007 MOV [1200],DX 87,16,00,12 ACCUMULATOR
CONTENT TO AX
REGISTER
100E HLT F4
STOP
8
TABULATION
INPUT OUTPUT
1100 1200
1101 1201
1102 1202
1103 1203
9
D-DIVISION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS
1000 MOV AX[1100] A1,00,11 MOVE THE DATA
TO
ACCUMULATOR
1003 DIV[1102]
F7,36,02,11 DIVIDE MEMORY
CONTENT
WITH
ACCUMULATOR
1007 MOV [1200],DX 87,16,00,12 MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER
100B
MOV[1202],AX A3,02,12 MOVE CONTENT
OF AX
REGISTER TO
MEMORY
100E HLT F4 STOP
10
TABULATION
INPUT OUTPUT
1100 1200
1101 1201
1102 1202
1103 1203
1104 1204
1105
1106
1107
11
E-DOUBLE PRECISION ADDITION
ADDRESS MNEMONICS OP-CODE COMMANDS
MOVE THE DATA
TO
ACCUMULATOR
1000 MOV AX,[1100] A1,00,11
ADD MEMORY
CONTENT WITH
ACCUMULATOR
1003 ADD AX,[1104] 03,06,04,11
MOVE DATA IN
MEMORY
1007 MOV [1200],AX A3,00,12 TO ACCUMULATOR
MOVE
ACCUMULATOR
VALUE TO
MEMORY
100A MOV AX,[1102] A1,02,11
ADD
ACCUMULATOR
VALUE WITH
100D ADC AX,[1106] 13,06,06,11 CARRY
MOVE
ACCUMULATOR
VALUE TO
1011 MOV[1202],AH A3,02,12 MEMORY
MOVE HIGHER
VALUE TO
1014 LAHF 9F MEMORY
MOVE
ACCUMULATOR
VALUE TO
1015 MOV[1204],AH 88,26,04,12 MEMORY
12
TABULATION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1200
1101 1201
1102 1202
1103 1203
1104
1105
1106
1107
13
F-DOUBLE PRECISION SUBTRACTION
SUBTRACT MEMORY
CONTENT WITH
ACCUMULATOR
1003 SUB AX,[1104] 2B,06,04,11
RESULT:
Thus an Assembly Language Program (ALP) for 16 bit Arithmetic operations using
8086 has been written and executed successfully.
14
15
1.2 ARITHMETIC OPERATIONS USING MASM SOFTWARE
AIM:
To perform arithmetic operations such as addition, subtraction, multiplication division
operations using MASM software.
APPARATUS:
SL.NO ITEM
1. PC
2. Keyboard
3 MASM SOFTWARE
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
0PR1 EQU 98H
0PR2 EQU 49H
SUM DW 01 DUP(00)
SUBT DW 01 DUP(00)
PROD DW 01 DUP(00)
DWS DW 01 DUP(00)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV BL,0PR2
XOR AL,AL
MOV AL,0PR1
ADD AL,BL
16
17
DAA
MOV BYTE PTR SUM,AL
JNC MSB0
INC [SUM+1]
MSB0:XOR AL,AL
MOV AL,0PR1
SUB AL,BL
DAS
MOV BYTE PTR SUBT,AL
JNB MSB1
INC [SUBT+1]
MSB1:XOR AL,AL
MOV AL,0PR1
MUL BL
MOV WORD PTR PROD,AX
XOR AH,AH
MOV AL,0PR1
DIV BL
MOV WORD PTR DWS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
RESULT:
18
19
1.3 BASIC LOGICAL OPERATIONS
AIM:
To write an Assembly Language Program (ALP) for 16 bit logical operations using 8086
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
ALGORITHM:
20
TABULATION
INPUT OUTPUT
1001 1400
1002 1401
INPUT OUTPUT
1200 1400
1201 1401
1004
1005
21
PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)
A-ONE’S COMPLEMENT OF A 16-BIT NUMBERS
22
TABULATION
INPUT OUTPUT
1001
1002
1004
1005
23
C- SETTING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESS MNEMONICS OP-CODE COMMANDS
1000 MOV AX ,0000 B8,00,00 CLEAR
ACCUMULATOR
RESULT:
Thus an Assembly Language Program (ALP) for 16 bit logical operations using 8086 has been
written and executed successfully.
24
25
2. MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To convert a given Move a data block without overlap
.
ALGORITHM:
1. Initialize the memory location to the data pointer.
2. Increment B register.
3. Increment accumulator by 1 and adjust it to decimal every time.
4. Compare the given decimal number with accumulator value.
5. When both matches, the equivalent hexadecimal value is in B register.
6. Store the resultant in memory location.
PROGRAM:
RESULT:
The program to Move a data block without overlap has been written and executed
successfully.
26
TABULATION
BCD TO HEXADECIMAL:
INPUT OUTPUT
1100 1101
27
3. CODE CONVERSION, DECIMAL ARITHMETIC AND
MATRIX OPERATIONS
AIM:
To write an Assembly Language Program (ALP) for Code conversion, decimal arithmetic and
Matrix operations using 8086.
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
PROGRAM:
BCD TO HEXADECIMAL:
101D HLT F4
28
TABULATION
HEXADECIMAL TO BCD:
INPUT OUTPUT
1100 1101
1102
29
HEXADECIMAL TO BCD:
1031 HLT F4
30
ASCII TO HEXADECIMAL
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1400
1101 1401
1102
31
ASCII TO HEXADECIMAL
1008 CLD FC
32
HEXADECIMAL TO ASCII
INPUT OUTPUT
1100 1400
1101 1401
33
HEXADECIMAL TO ASCII
1008 CLD FC
1021 STOSB AA
1037 STOSB AA
34
MATRIX OPERATIONS
INPUT OUTPUT
2000 3000
2001 3001
2002 3002
2003 3003
3000
3001
3002
3003
35
MATRIX OPERATIONS
1013 INC DI 47
1014 INC SI 46
1019 HLT F4
36
BCD ADDITION
INPUT OUTPUT
1100 1104
1101 1105
1102 1106
1103
37
BCD ADDITION
100E DAA 27
1015 DAA 27
1022 HLT F4
38
BCD SUBTRACTION
INPUT OUTPUT
1100 1104
1101 1105
1102 1106
1103
39
BCD SUBTRACTION
100E DAS 2F
1015 DAS 2F
1022 HLT F4
RESULT:
40
41
4.1 SORTING AND SEARCHING
AIM:
To write an Assembly Language Program (ALP) for sorting and searching operations using
8086.
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
ALGORITHM:
42
43
b) Place all the elements of an array in the consecutive memory locations.
c) Fetch the first element from the memory location and load it in the accumulator.
d) Initialize a counter (register) with the total number of elements in an array.
e) Decrement the counter by 1.
f) Increment the memory pointer to point to the next element.
g) Compare the accumulator content with the memory content (next element).
h) If the accumulator content is larger, then move the memory content (largest
element) to the accumulator. Else continue.
i) Decrement the counter by 1.
j) Repeat steps e to h until the counter reaches zero.
k) Store the result (accumulator content) in the specified memory location.
l) Stop the program.
44
TABULATION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1200 1200
1201 1201
1202 1202
1203 1203
1204 1204
45
PROGRAM:
46
DESCENDING ORDER OF AN ARRAY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
47
DESCENDING ORDER OF AN ARRAY
48
LARGEST NUMBER IN AN ARRAY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
49
LARGEST NUMBER IN AN ARRAY
50
SEARCH A NUMBER IN AN ARRAY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
51
SEARCH A NUMBER IN AN ARRAY
RESULT:
Thus an Assembly Language Program (ALP) for sorting and searching operations using 8086 has
been written and executed successfully.
52
53
4.2 STRING MANIPULATION
AIM:
To write an Assembly Language Program (ALP) for string manipulation operations using
8086
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
ALGORITHM:
54
STRING PRIMITIVE
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
STRING MANIPULATION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
55
PROGRAM:
56
LENGTH OF STRING
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
57
C-CALCULATING THE LENGTH OF STRING
RESULT:
Thus an Assembly Language Program (ALP) for string manipulation operations using
8086 has been written and executed successfully.
58
59
4.3 SORTING IN DESCENDING ORDER USING MASM
AIM:
To write the program using MASM software for sorting the numbers in descending order and verify
the output.
APPARATUS:
SL.NO ITEM
1. PC
2. Keyboard
3 MASM SOFTWARE
ALGORITHM:
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 02H,19H,25H,53H
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
60
61
AGAIN 1:MOV AX,[SI]
CMP AX,[SI+2]
JNL PR1
XCHG [SI+2],AX
XCHG [SI],AX
PR1:ADD SI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START
RESULT:
Thus an program using MASM software for sorting the numbers in descending order
and verify the output has been written and executed successfully
62
63
4.4 LARGEST NUMBER IN AN ARRAY USING MASM SOFTWARE
AIM:
ALGORITHM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 23H,56H,45H,52H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV CL,COUNT
MOV AL,[SI]
AGAIN:CMP AL,[SI+1]
JNL NEXT
MOV AL,[SI+1]
NEXT:INC SI
DEC CL
JNZ AGAIN
MOV [SI],AL
64
65
MOV AH,4CH
INT 21H
CODE ENDS
END START
RESULT:
Thus to find the largest number in an array using MASM software has been written
and executed successfully.
66
67
5. PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE
AIM:
To write an MASM program for password checking, print RAM size and system date using MASM
software.
APPARATUS REQUIRED:
SL.NO ITEM
1. PC
2. Keyboard
3 MASM SOFTWARE
PROGRAM:
; PASSWORD CHECKING
DATA SEGMENT
PASSWORD DB 'MASM1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $'
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,00
UP1:
MOV AH,08H
INT 21H
CMP AL,0DH
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H
INT 21H
68
69
INC SI
JMP UP1
DOWN:
MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
.DATA
MSG DB 'MEMORY SIZE IN KILO BYTES='
ASCRES DB 4 DUP(?),'HEX',0CH,0AH,'$'
DUP(?),'HEX',0CH,0AH,'$'
RES DW ?
HEXCODE DB '0123456789ABCDEF'
.CODE
HEX_ASC PROC
MOV DL,10H
MOV AH,0
MOV BX,0
DIV DL
MOV BL,AL
MOV DH,HEXCODE[BX]
MOV BL,AH
MOV DL,HEXCODE[BX]
RET
HEX_ASC ENDP
MAIN:
MOV AX,@DATA
MOV DS,AX
INT 12H
MOV RES,AX
MOV AL, BYTE PTR RES
CALL HEX_ASC
70
71
MOV ASCRES+2,DH
MOV ASCRES+3,DL
MOV AL,BYTE PTR RES+1
CALL HEX_ASC
MOV ASCRES,DH
MOV ASCRES+1,DL
MOV DX,OFFSET MSG
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
ALIGN 16
END MAIN
SYSTEM DATE
Display month/day/year.
.MODEL small
.STACK 100h
.DATA
mess1 DB 10, 13, 'Today is $' ; 10=LF, 13=CR
.CODE
Today PROC
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET mess1 ; Move string to DX
MOV AH, 09h; 09h call to display string (DX > AH > DOS)
INT 21H; Send to DOS
; CX year, DH month, DL day
MOV AH, 2AH; Get the date (appendix D)
INT 21H; Send to DOS
PUSH CX; Move year to the stack
MOV CX, 0; Clear CX
MOV CL, DL
PUSH CX; Move day to stack
MOV CL, DH; Move month > CL
PUSH CX; Move month to stack
MOV DH, 0; Clear DH
72
73
ADD CX, 1; Add one to counter
MOV DX, 0; Clear the remainder
CMP AX, 0; Compare quotient to zero
JNE dividem; If quoient is not zero, go to "dividem:"
divdispm:
POP DX; Remove top of stack into DX
ADD DL, 30h; ADD 30h (2) to DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
LOOP divdispm; If more to do, divdispm again
; LOOP subtracts 1 from CX. If non-zero, loop.
MOV DL, '/'; Character to display goes in DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
; ************************** DISPLAY DAY ************************
; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0; Clear DX
POP AX; Remove day from stack into AX
MOV CX, 0; Initialize the counter
MOV BX, 10; Set up the divisor
divided:
DIV BX; Divide (will be word sized)
PUSH DX; Save remainder to stack
; LOOP subtracts 1 from CX. If non-zero, loop
MOV DL, '/'; Character to display goes in DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
74
75
MOV AH, 4ch; Send return code to AH
INT 21H; Send return code to DOS to exit.
Today ENDP; End procedure
END Today; End code. Start using "Today" procedure.
MVI A, 80H: Initialize 8255, port A and port B
OUT 83H (CR): in output mode
START: MVI A, 09H
OUT 80H (PA): Send data on PA to glow R1 and R2
MVI A, 24H
OUT 81H (PB): Send data on PB to glow G3 and G4
MVI C, 28H: Load multiplier count (40ıο) for delay
CALL DELAY: Call delay subroutine
MVI A, 12H
OUT (81H) PA: Send data on Port A to glow Y1 and Y2
OUT (81H) PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10ıο) for delay
CALL: DELAY: Call delay subroutine
MVI A, 24H
OUT (80H) PA: Send data on port A to glow G1 and G2
MVI A, 09H
OUT (81H) PB: Send data on port B to glow R3 and R4
MVI C, 28H: Load multiplier count (40ıο) for delay
CALL DELAY: Call delay subroutine
MVI A, 12H
OUT PA: Send data on port A to glow Y1 and Y2
OUT PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10ıο) for delay
CALL DELAY: Call delay subroutine
JMP START
Delay Subroutine:
DELAY: LXI D, Count: Load count to give 0.5 sec delay
BACK: DCX D: Decrement counter
MOV A, D
ORA E: Check whether count is 0
JNZ BACK: If not zero, repeat
DCR C: Check if multiplier zero, otherwise repeat
JNZ DELAY
RET: Return to main program
RESULT:
Thus an MASM program for password checking, print RAM size and system date
using MASM software
76
77
6. COUNTERS AND TIME DELAY
AIM:
To write an Assembly Language Program (ALP) for string manipulation operations using
8086.
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
ALGORITHM:
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
.MODEL SMALL
.DATA
MSGIN DB 'Enter delay duration (0-50): $'
MSG1 DB 'This is Microprocessor!$'
DELAYTIME DW 0000H
CODE
MOV DX,@DATA
MOV DS,DX
LEA DX,MSGIN
MOV AH,09H
INT 21H
IN1:
MOV AH,01H
INT 21H
CMP AL,0DH ;
JE NXT
SUB AL,30H
MOV DL,AL
MOV AX,BX
78
79
MOV CL,0AH
MUL CL
MOV BX,AX
AND DX,00FFH
ADD BX,DX
MOV DELAYTIME,BX
LOOP IN1
NXT:MOV CX,DELAYTIME
MOV DL,10
MOV AH,02H
INT 21H
LEA SI,MSG1
LP: PUSH DX
MOV DL,[SI]
Jnz repe
CMP DL,'$'
JE NXT2
MOV AH,02H
INT 21H
ADD SI,1
POP DX
MOV DI,DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2: MOV AH,4CH
INT 21H
END
RESULT:
Thus an MASM program for Counters and Time Delay using MASM software has been written and
executed successfully.
80
81
7. TRAFFIC LIGHT CONTROL
AIM
To write an assembly language program to interface traffic light controller with 8086 using
8255.
APPARATUS REQUIRED
2. Power chord,
4. 26 channel bus
ALGORITHM
1. Find the control word for 8255 and data corresponding to the given condition’s and load
this data in to the memory location.
2. Get the number of conditions in the C-register.
3. Move the control word to accumulator and place in 8255.
4. Move the first data to accumulator and place in port-A.
5. Move the next data to accumulator and place in port-B.
6. Move the next data to accumulator and place in port-C.
7. Call the delay routine.
8. Decrement the C-register. If C=’0’ then go to next step else go to step 3.
9. Go to step 1 and Stop
82
83
TRAFFIC CONTROL DIAGRAM:
THEORY:
The 8086 micro processor announced by Intel in 1978 was Intel„s first 16-bit micro
processor and the first in the family it is sub-divided into two principle units. The
execution unit EU, including the ALU eight 160bit general register, a 16-bit flag
register and register unit. The bus interface unit, includes an address for adder
calculation for 16-bit segment register a 16-bit instruction pointer {ip}6 bytes
instruction queue and bus control logic, The 8086 chip has 40-pins including 16data
pin and 20 address pins, the 8086 microprocessor is used in various applications. In
our program use 8086 in traffic light controller using 8086 LCD display
PROCEDURE:
1. Enter the program
2. Execute the program
3. Check the output.
84
85
PROGRAM
MEMORY
ADDRESS LABEL MNEMONICS OP CODE
MOV
1000 START: BX,1100H BB 00 11
MOV
1003 CX,000CH B9 00 0C
1006 MOV AL,[BX] 8A 07
OUT
1008 CONTRL,AL E6 0F
100A INC BX 43
100B NEXT: MOV AL,[BX] 8A 07
100D OUT
PORTA,AL E6 0C
100F INC BX 43
1010 MOV AL,[BX] 8A 07
OUT
1012 PORTB,AL E6 0D
1014 INC BX 43
1017 MOV AL,[BX] 8A 07
OUT
1019 PORTC,AL E6 0E
101B CALL DELAY E8 07 00
101E INC BX 43
1021 LOOP NEXT: E2 ED
1023 JMP START EB DF
1024 DELAY: PUSH CX 51
MOV
1025 CX,0005H B9 00 05
MOV
1028 REPEAT: DX,0FFFFH BA FF FF
103B LOOP2: DEC DX 4A
103C JNZ LOOP2 75 FD
LOOP
103E REPEAT E2 F8
103F POP CX 59
1040 RET C3
INPUT DATA
1100 80, 84, 2E, 4C
1104 84, 9D, 90, 93
1107 2B, 10, 64, 27, 12
86
87
PORT A [ {D0 - D20}………0 - OFF & 1 – ON ]
D8 D7 D6 D5 D4 D3 D2 D1
POSITION 1 1 0 0 0 0 1 0 0 84H
POSITION 2 1 0 0 0 0 1 0 0 84H
POSITION 3 1 0 0 1 0 0 1 1 93H
POSITION 4 0 1 1 0 0 1 0 0 64H
POSITION 1 0 1 0 0 1 1 0 0 4CH
POSITION 2 1 0 0 1 0 0 0 0 90H
POSITION 3 0 0 0 1 0 0 0 0 10H
POSITION 4 0 0 0 1 0 0 1 0 12H
RESULT:
Thus an program for traffic light controller by interfacing with 8086 microprocessor has been written
and executed successfully
88
89
8. STEPPER MOTOR CONTROL
AIM:
APPARATUS REQUIRED:
2. Keyboard 1
3. Power chord 1
4. Stepper motor 1
6. 50 Channel Bus
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the
next. Stepper Motors are used very wisely in position control systems like printers, disk drives,
process control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles
has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets
induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a
permanent magnet with one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to run
the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise
stepping can be obtained.
In this scheme, any two adjacent stator windings are energized. The switching scheme is
shown in the table given below. This scheme produces more torque.
90
91
ANTICLOCKWISE CLOCKWISE
P 1 1 P 1 2 1
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
The 74138 chip is used for generating the address decoding logic to generate the device
select pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the
stepper motor driving circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore, the interface
circuitry that generates the driving pulses uses silicon Darlington pair transistors. The inputs for
the interface circuit are TTL pulses generated under software control using the Microcontroller
Kit. The TTL levels of pulse sequence from the data bus are translated to high voltage output
pulses using a buffer 7407 with open collector.
92
93
PROGRAM:
94
95
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED
100F INC D1 47
RESULT:
Thus an assembly language program to interface stepper motor with 8086 has
been written and executed successfully.
96
97
9. DIGITAL CLOCK
AIM:
To write an Assembly Language Program (ALP) to display the Computer’s real-time clock on
the screen as in digital clock.
APPARATUS REQUIRED:
2. PC 1
THEORY:
CLOCK DISPLAY:
Every PC is equipped with a real-time clock operated by a small battery. Even when the computer is
switched off, this clock continues to function to maintain the clock in its CMOS registers. When the
PC is on, the Operating System software reads this clock and stores the value in memory. User
programs can access this data. The OS software provides facilities for the programmer to read this
clock value using Software Interrupts. The IBM PC system BIOS also provides interrupt services to
access this real time clock. The BIOS services provide the hours, minutes and seconds in CPU
registers as BCD data. Hence they can be converted easily into ASCII value for displaying on screen
ALGORITHM:
a) Initialize data segment to hold the clock data as hours, minutes and seconds.
b) Display a message on screen for the user.
c) Call the procedure to get the time from PC’s real-time clock using BIOS interrupt.
d) Call the procedure to convert the clock data into ASCII and display it on the screen.
e) Check for user key press using BIOS interrupt service.
f) If no key is pressed continue updating the clock on screen.
g) If a key is pressed terminate the program.
a) Use Function 02 in Interrupt 1Ah service to read the PC’s real-time clock. This function
returns hours in CH, minutes in CL and seconds in DH registers.
b) Divide each of these registers by 10h to separate the BCD digits.
98
99
c) Convert each separated digit into ASCII by adding 30h with it.
d) Store each digit in the appropriate location in the memory.
e) Return from the procedure.
Procedure ShowTime:
a) Use BIOS interrupt 10h function 02h to set video cursor at desired location on the screen.
b) Use DOS interrupt 21h function 09h to display the stored clock data from Data segment
memory as a string terminated by ‘$’.
c) Call a procedure to delay for few milliseconds doing nothing.
d) Return from the procedure.
Procedure Delay:
PROGRAM:
.MODEL SMALL
.STACK
.DATA
MESSAGE DB 0AH,0DH
MESSAGE1 DB 0AH,0DH
PROMPT DB “TIMER::”
HOURS1 DB 0
HOURS2 DB 0
SEPERATOR1 DB “:”
MINUTES1 DB 0
MINUTES2 DB 0
SEPERATOR2 DB “:”
SECONDS1 DB 0
SECONDS2 DB 0
LAST DB ‘$’
DIVISOR DB 10H
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AH,09H
LEA DX,MESSAGE
INT 21H
AGAIN:CALL GETTIME
CALL SHOWTIME
MOV AH,01H
100
101
INT 16H
JZ AGAIN
MOV AH,04CH
INT 21H
GET TIME PROC
MOV AH,02H
INT 1AH
MOV AL,CH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV HOURS1,AL
MOV HOURS2,AH
XOR AX,AX
MOV AL,CL
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV MINUTES1,AL
MOV MINUTES2,AH
XOR AX,AX
MOV AL,DH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV SECONDS1,AL
MOV SECONDS2,AH
RET
GET TIME ENDP
SHOW TIME PROC
MOV AH,02H
MOV BH,0
MOV DH,20D
MOV DL,10D
INT 10H
MOV AH,09H
LEA DX,PROMPT
INT 21H
CALL DELAY
RET
SHOW TIME ENDP
DELAY PROC
PUSH CX
MOV CX,0FFFH
IDLE:NOP
NOP
NOP
NOP
102
103
LOOP IDLE OUT
POP CX
RET
DELAY ENP
END
RESULT:
Thus an Assembly Language Program (ALP) to display the Computer’s real-time
clock on the screen as in digital clock has been written and executed successfully.
104
105
10. KEYBOARD AND DISPLAY
AIM:
APPARATUS REQUIRED:
2. Keyboard 1
3. Power chord 1
4. 50 channel bus 3
5. 8279 kit 1
ALGORITHM:
ROLLING DIAPLAY
106
107
READ A KEY:
IN AL,C2
1003 LOOP: E4 C2
1007 JZ LOOP 74 FA
100D IN AL,C0 E4 C0
1011 HLT F4
108
109
ROLLING DISPLAY (DISPLAY MESSAGE IS HELP US)
SUB PROGARM:
110
111
LOOK-UP TABLE
ADDRESS DATA
1200 FF,FF,FF,FF
1204 FF,FF,FF,FF
1208 98,68,7C,C8
120C FF,1C,29,FF
RESULT:
Thus to perform interfacing and programming for Key board and Display has been written and
executed successfully.
112
113
11.1 SERIAL INTERFACE
AIM:
APPARATUS REQUIRED:
2. Keyboard 1
3. Power chord 1
4. VXT parallel bus 1
5. Interface board 8251 1
6. Serial connection cable RS232
ALGORITHM:
114
TABULATION
INPUT OUTPUT
1015 1250
115
PROGRAM
TRANSMITTER PROGRAM
INTERUPT
1018 INT 02 CD 02
RECEIVER PROGRAM
OP-
ADDRESS MNEMONICS COMMANDS
CODE
INTERUPT
1200 IN AL,C0 E4 C0
RESULT:
Thus to perform serial communication using 8251 has been written and
executed successfully.
116
117
11.2 PARALLEL INTERFACE
AIM:
To interface programmable peripheral interface 8255 with 8086 and study its characteristics
in mode0
APPARATUS REQUIRED:
1. 8086 p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
THEORY:
I/O MODES:
Control Word:
118
119
MODE 0 – SIMPLE I/O MODE:
This mode provides simple I/O operations for each of the three ports and is suitable
for synchronous data transfer. In this mode, all the ports can be configured either as input or output
port.
PROGRAM:
1007 IN AL,C0 E4 C0
100B HLT F4
120
121
MODE 0 STROBED I/O MODE:
PROGRAM:
1004 IN AL,C0 E4 C0
1006 OUT C2 AL E6 C2
1008 HLT F4
RESULT:
Thus to interface programmable peripheral interface 8255 with 8086 and study
its characteristics in mode0 has been written and executed successfully.
122
123
12. A/D AND D/A INTERFACE AND WAVEFORM GENERATION
AIM:
To write an Assembly Language Program (ALP) to interface ADC and DAC using 8086
microprocessor.
APPARATUS REQUIRED:
2. Keyboard 1
3 Power chord 1
4. ADC kit 1
5. Multimeter 1
6. DAC kit 1
7. 50 channel Bus 2
8. CRO 1
9. CRO probe 1
THEORY:
ADC-0809 A/D card is an 8bit analog to digital converter with 8 channel multiplexer and
microprocessor compatible control logic. The heart of the car is ADC-0809 monolithic C-MOS
device. Its conversion time is 100 micro sec. it eliminates the need for external zero and full scale
adjustment. The card selects one of the eight unipolar inputs by using the address decoder. ADC-0809
uses successive approximation as conversion techniques. Input is latched to the decoder on the low to
high transition of the address latch enable signal. The conversion starts on the falling edge of the start
of conversion signal. During the process end of conversion signal goes low otherwise it remains high.
Digital output can be read from ADC making output enable signal high.
124
125
Circuit description:
The data line of ADC-0809 d0 to d7 is connected to port-A as input port. SOC is connected to PC0 as
output port; EOC is connected to PC4 as input port & ALE is connected to PC1 as output port. All
eight inputs of 0-5 volts ADC-0809 analog with external clock, external EOC, external SOC signals
are brought to 26 pin connector. A clock input of a specified frequency is required for the operation of
ADC-0809. A counter 74LS93 has been used for this purpose.
Hardware installation:
Connect ADC-0809 interfacing module to 8255-I of 8086 trainer kit through 26 pin FRC
cable.
Be sure about the direction of the cable i.e. pin NO.1 of module should be connected to pin
NO.1 of 8255 connector.
Connect +5v, GND from the trainer kit (+5v & GND signals are available in the 25 & 26 pin
of FRC 8255-I connector)
A digital number can be converted to an analog voltage by selectively adding voltage which is
proportional to the weight of each binary digit. The module finds a great use in feedback system, like
output of a channel is fed to a control circuit to contain output in the form of signal is observed at an
oscilloscope or for a hard copy fed to an X-Y Recorder/X-T Recorder. Different wave forms can be
generated by using this DAC-0800 module.
Circuit description:
Port A & port B are connected to channel 1 and channel 2 respectively. A reference voltage of 8V is
generated using 723 and is given to verify points of the DAC 0800. The standard output voltage will
be 7.98V when FF is outputted and will be 0v when 00 is outputted. The output of DAC-0800 is fed
to the operational amplifier to get the final output as X out and Y out. Several interesting waveforms
can be generated and observed on oscilloscope.
Hardware installation:
126
127
ALGORITHM:
128
TABULATION
129
3) GENERATION OF TRAINGULAR WAVE
a) Start the program.
b) Load the value in the accumulator.
c) Increment the BL register.
d) Jump on no zero.
e) Decrement the BL register.
f) Jump on no carry.
g) Return.
h) Store the output in the required memory location.
i) Stop the program.
PROGRAM:
COMMANDS
ADDRESS LABEL MNEMONICS OP-CODE
MOVE DATA TO
1000 MOV AL,03 B0,03
ACCUMULATOR
MOVE THE
1002 OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1004 MOV AL,23 B0,23
ACCUMULATOR
MOVE THE
1006 OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1008 MOV AL,03 B0,03
ACCUMULATOR
MOVE THE
100A OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
100C MOV AL,01 B0,01
ACCUMULATOR
130
131
MOVE THE
100E OUT D0,AL E6,D0 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1010 MOV AL,00 B0,00
ACCUMULATOR
MOVE THE
1012 OUT D0,AL E6,D0 CONTENT OF AL
TO OUTPUT PORT
MOVE THE
1014 LOOP IN AL,E0 E4,E0 CONTENT OF
INPUT PORT TO AL
PERFORM AND
1016 AND AL,01 24,01 OPERATION WITH
AL AND DATA
COMPARE THE
1018 CMP AL,01 3C,01 VALUE OF AL
WITH DATA
101A JNZ LOOP 75,F8 JUMP ON NO ZERO
MOVE THE
101C IN AL,C0 E4,C0 CONTENT OF
INPUT PORT TO AL
MOVE THE DATA
101E MOV BX,1100 BB,00,11
TO BX
MOVE THE
1021 MOV[BX],AL 88,07 CONTENT OF AL
TO BX
STOP
1023 HLT F4
132
SAWTOOTH WAVE
133
DIGITAL TO ANALOG CONVERTER
134
SQUARE WAVE
135
GENERATION OF SQUARE WAVE
136
TRAINGULAR WAVE
137
GENERATION OF TRAINGULAR WAVE
RESULT:
Thus an Assembly Language Program (ALP) to interface ADC and DAC using 8086 microprocessor
ha sbeen written and executed successfully
138
ADDITION OF TWO 8-BIT NUMBERS
INPUT OUTPUT
6102 6500
6104
139
13. BASIC ARITHMETIC AND LOGICAL OPERATIONS
AIM
To write an assembly language program to add the two 8-bit numbers using microcontroller
instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Add the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 3F
6103 ADD A, #data2 24, 29
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to add the two 8-bit numbers using
microcontroller instruction set has been written and executed successfully.
140
SUBTRACTION OF TWO 8-BIT NUMBERS
INPUT OUTPUT
6102 6500
6104
141
13.2 SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to subtract the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Subtract the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 59
6103 SUBB A, #data2 94, 28
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE
RESULT:
142
MULTIPLICATION OF TWO 8-BIT
INPUT OUTPUT
6102 6500
6105 6501
143
13.3 MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to multiply the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,#data2 75, F0, 02
6106 MUL AB A4
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to multiply the two 8-bit numbers using microcontroller
instruction set has been written and executed successfully.
144
DIVISION OF TWO 8-BIT NUMBERS
INPUT OUTPUT
6102 6500
6105 6501
145
13.4 DIVISION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to divide the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The remainder of the result is in B-register.
6. The quotient of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 08
6103 MOV B,#data2 75, F0, 02
6106 DIV AB 84
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to divide the two 8-bit numbers using microcontroller
instruction set has been written and executed successfully
146
SETTING BITS IN AN 8 BIT NUMBER
INPUT OUTPUT
6101 6500
6103
147
13.5 SETTING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ORL A, #data2 44, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to find the Setting bits an 8-bit number using
microcontroller instruction set has been written and executed successfully
148
MASKING BITS IN AN 8 BIT NUMBER
INPUT OUTPUT
6101 6500
6103
149
13.6 MASKING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Masking bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform AND operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ANL A, #data2 54, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to find the Masking bits an 8-bit number
using microcontroller instruction sethas been written and executed successfully.
150
1 ‘s and 2’s COMPLEMENT OF A NUMBER
INPUT OUTPUT
6101 6500
6501
151
14. SQUARE AND CUBE PROGRAM, FIND 2’s COMPLEMENT OF A NUMBER
AIM
To write an assembly language program to find the 1’s and 2’s complement of an 8-bit
number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
2. Move the data to Accumulator.
3. Complement the accumulator.
4. Move the one’s complement output to the memory 6500H.
5. Add 01H with accumulator.
6. Move the two’s complement output to the memory 6501H.
7.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data 74, CC
6102 CPL A F4
6103 MOV DPTR, #6500H 90, 65, 00
6106 MOVX @DPTR, A F0
6107 INC A 04
610A INC DPTR A3
610B MOVX @DPTR, A F0
610C LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to find the 1’s and 2’s complement of an 8-bit
number using microcontroller instruction set has been written and executed successfully.
152
SQUARE OF A 8-BIT NUMBER
INPUT OUTPUT
6102 6500
6501
153
14.2 SQUARE OF A 8-BIT NUMBER USING 8051
AIM
To write an assembly language program to find two the square of a8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,A F5, F0
6105 MUL AB A4
6106 MOV DPTR, #6500H 90, 65, 00
6109 MOVX @DPTR, A F0
610A INC DPTR A3
610B MOV A, B E5, F0
610D MOVX @DPTR, A F0
610E LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to find the square of an 8-bit number using
microcontroller instruction set has been written and executed successfully.
154
CUBE OF A 8-BIT NUMBER
INPUT OUTPUT
6102 6500
6501
155
14.3 CUBE OF A 8-BIT NUMBER USING 8051
AIM
To write an assembly language program to find the cube of a 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,A F5, F0
6105 MOV R0, A F8
6106 MUL AB A4
6107 MOV F0,R0 A8, F0
6109 MUL AB A4
610A MOV DPTR, #6500H 90, 65, 00
610D MOVX @DPTR, A F0
610E INC DPTR A3
6110 MOV A, B E5, F0
6112 MOVX @DPTR, A F0
6113 LOOP SJMP LOOP 80, FE
156
157
RESULT:
Thus an assembly language program to find the cube of an 8-bit number using
microcontroller instruction set has been written and executed successfully.
158
UNPACKED BCD TO ASCII
INPUT OUTPUT
6101 6500
159
15. UNPACKED BCD TO ASCII
AIM
To write an assembly language program to convert unpacked BCD to ASCII code using 8051.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 02
6102 ORL A, #30 44, 30
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
RESULT:
Thus an assembly language program to convert the Unpacked BCD to ASCII thas been
written and executed successfully.
160