Ex. No.: 01 Seven Segment Display Interface 04-11-2016
Ex. No.: 01 Seven Segment Display Interface 04-11-2016
Ex. No.: 01 Seven Segment Display Interface 04-11-2016
: 01
04-11-2016
AIM:
To interface a Seven Segment Display and display user defined text.
PROGRAM:
ADDRESS OPCODE
2000
B8 00 00
2003
2005
8E C8
8E D8
2007
200A
200C
200D
2010
2012
2014
2016
2018
2019
201B
201E
201F
2021
2023
2026
2027
2029
202A
202C
202E
LABEL
MNEMONIC
MOVW
AX,0000H
MOVW CS,AX
MOVW DS,AX
MOVW
BA E6 FF
DX,FFE6H
B0 80
MOVB AL,80H
EE
OUTB DX,AL
MOVW
BE 00 21 LOOP4: SI,2100H
B1 05
MOVB CL,05H
COMMENTS
;Initialise
;Segment
Registers
;Configure all
8255
;ports as output
;Initialise
pointer
;Set Count for 5
;groups,
;4
B5 04
LOOP3: MOVB CH,04H
characters/group
;8
B3 08
LOOP2: MOVB BL,08H segments/character
;Get the display
8A 04
MOVB AL,[SI] code
;Increment
46
INCW SI
pointer
D0 C0
LOOP1: ROLB AL,1
;Get 1 data bit
MOVW
BA E2 FF
DX,0FFE2H
;Output bit to
EE
OUTB DX,AL
port B
8A E0
MOVB AH,AL
B0 01
MOVB AL,01H
;Output Clock to
MOVW
BA E4 FF
DX,FFE4H
;Shift Register
EE
OUTB DX,AL
DEC
FE C8
B
AL
OUT
EE
B
DX,AL
MOV
8A C4
B
AL,AH
DEC
FE CB
B
BL
;All bits over ?
75 E9
JNZ LOOP1
;No, Continue
2030
FE CD
DECB CH
2032
75 E0
LOOP2
2034
E8 06 00
DELAY
;Introduce delay
2037
2039
FE C9
75 D7
JNZ
CAL
L
DEC
B
JNZ
;All Characters
;over ?
;No, Continue
CL
LOOP3
203B
E9 CF FF
LOOP4
203E
51
203F
B9 FF FF
2042
E2 FE
JMP
PUS
DELAY: H
MOV
W
LOO
P
2044
2047
2049
204A
2100
2100
2104
2108
210C
2110
CX
;Delay Subroutine
CX,0FFFF
H
$
FF
B9 FF
E2 FE
59
C3
MOVW
CX,0FFFFH
LOOP $
POP CX
RET
FF FF FF FF
C6 86 C7 86
BF
C0
DE 87
BF
92
91 92
92 C8 86 87
DB 0ABH,0F9H,087H,0BFH
;Display Codes
ORG 2100H
table
DB 0FFH,0FFH,0FFH,0FFH
DB 0ABH,0F9H,087H,0BFH
DB 0ABH,0F9H,087H,0BFH
DB 0ABH,0F9H,087H,0BFH
Ex. No.: 02
04-11-2016
AIM:
2013
2000
B0 80
2002
BA E6 FF
2005
EE
2006
BE 38 20
2009
8A 04
200B
BA E0 FF
200E
200F
2010
EE
46
80 C2 02
8A 04
2015
EE
2016
46
2017
80 C2 02
201A
8A 04
201C
EE
201D
46
201E
E8 08 00
2021
81 FE 56 20
2025
75 E2
LABEL
MNEMONIC
COMMENTS
;Initialise
8255
;in Mode 0
;All ports as
o/p
;Load able of
port
;values
;O/p Value at
PortA
AL,[SI]
DL,AL
;O/p Value at
PortB
SI
DL,2
AL,[SI]
DX,AL
;O/p Value at
PortC
SI
DELAY
;Calling Delay
;routine
SI,2056 ;Check for end
CMP H
of
;data
JNZ NEXTST
2027
EB
DD
2029
B9 FF 00
202C
51
202D
2030
B9 FF 03
90
2031
2033
E2 FD
59
2034
2036
2038
E2 F6
C3
2038
10 81 7A
DB
203B
44 44 F0
DB
203E
08 11 E5
DB
2041
44 44 F0
DB
2044
81 10 DA
DB
2047
44 44 F0
DB
204A
11 08 B5
DB
204D
44 44 F0
DB
2050
88 88 00
DB
2053
2056
44 44 F0
00
DB
DB
JMP
MOV
DELAY: W
PUS
DLY5: H
MOV
W
DLY10: NOP
LOO
P
POP
LOO
P
RET
ORG
AGAIN
CX,0FFH ;Delay routine
CX
CX,03FF
H
DLY10
CX
DLY5
2038H
08H,88H,0A4
H
44H,44H,0F0
H
08H,88H,0A4
H
44H,44H,0F0
H
08H,88H,0A4
H
44H,44H,0F0
H
08H,88H,0A4
H
44H,44H,0F0
H
08H,88H,0A4
H
44H,44H,0F0
H
00H
;State 1
;All ambers
ON
;State 2
;All ambers
ON
;State 3
;All ambers
ON
;State 4
;All ambers
ON
;State 5
;All ambers
ON
;Dummy
Ex. No.: 03
04-11-2016
AIM:
To interface 12-bit Analog to Digital Converter.
PROGRAM:
ADDRESS OPCODE
2500
2503
2505
2507
2509
250C
250E
2510
2513
2515
2516
2519
251B
251C
251E
2521
2523
2525
2526
2529
252B
252D
252E
2530
2531
2533
2534
2535
2536
2537
2538
253A
253B
253D
B8
8E
8E
8E
BE
B0
88
BA
B0
EE
BA
B0
EE
8A
B9
D2
0C
EE
B9
E2
B0
EE
B0
EE
B0
EE
90
90
90
90
B0
EE
2B
BA
00 00
C8
D8
C0
00 20
00
04
E6 FF
92
LABEL
MNEMONIC
MOVW
MOVW
MOVW
MOVW
MOVW
MOVB
MOVB
MOVW
MOVB
OUTB
E4 FF CONVERT: MOVW
03
MOVB
OUTB
04
MOVB
02 00
MOVW
C0
ROLB
23
ORB
OUTB
20 00
MOVW
FE
DY: LOOP
01
MOVB
OUTB
03
MOVB
OUTB
00
MOVB
OUTB
NOP
NOP
NOP
NOP
02
MOVB
OUTB
C0
READ: SUBW
E2 FF
MOVW
AX,0000H
CS,AX
DS,AX
ES,AX
SI,2000H
AL,0H
[SI],AL
DX,0FFE6H
AL,92H
DX,AL
DX,0FFE4H
AL,03H
DX,AL
AL,[SI]
CX,02H
AL,CL
AL,23H
DX,AL
CX,20H
DY
AL,01H
DX,AL
AL,03H
DX,AL
AL,00H
DX,AL
COMMENTS
;Initialise Segment
;Registers
AL,02H
DX,AL
AX,AX
DX,0FFE2H
;Enable latches
;for capturing data
25
2540
2541
2543
EC
24 0F
8A E0
INB AL,DX
ANDB AL,0FH
MOVB AH,AL
2545
2548
2549
254B
254E
2550
2555
2557
2559
255B
255D
255F
2561
2564
2566
2568
256A
256C
256F
2571
2573
2575
2577
BA
EC
8B
E8
8A
9A
3C
74
3C
74
EB
FE
80
75
B1
88
EB
80
75
B1
EB
FE
EB
E0 FF
2579
257E
2581
2586
2588
258D
2590
2595
2597
9A
B8
9A
8A
9A
B8
9A
8B
9A
31
00
13
04
52
0F
13
C3
6A
259C
2100
2100
2106
210A
2110
2114
211A
EB B0
0A
4E
4E
20
20
54
D8
2B
0C
A9
2C
06
2D
0F
EF
C1
F9
02
00
0C
AA
F9
04
07
F3
C9
EF
0D
45
4F
20
20
41
00
NEXT:
00 00 FB
08
INCR:
GO:
00
DECR:
DOWN:
MOVW DX,0FFE0H
;in AX Register
INB AL,DX
MOVW BX,AX
CALL DISP
;Display digital value
MOVB CL,[SI]
CALLS 0FB00:00A9H ;Get key for Channel
CMPB AL,2CH
;','-Increment Channel
JE
INCR
CMPB AL,2DH
;'-'-Decrement channel
JE
DECR
JMP NEXT
INCB CL
;Channel increment
CMPB CL,08H
;routine
JNE GO
MOVB CL,00H
MOVB [SI],CL
;Call Convert routine
JMP CONVERT
;for new channel
CMPB CL,00H
;Channel Decrement
JNE DOWN
;routine
MOVB CL,07H
JMP GO
DECB CL
JMP GO
211E
2124
56 41 4C
3D 20 00
55 45 20
DB 56H,41H,4CH,55H,45H,
20H,3DH,20H,00H
Ex. No.: 04
04-11-2016
AIM:
To interface Dual Digital to Analog Converter.
PROGRAM:
ADDRESS
OPCODE
2000
B8
0000
MOVW
AX,0000H
2003
2005
2007
200A
8E C8
8E C0
BA E6 FF
B0 80
MOVW
MOVW
MOVW
MOVB
CS,AX
ES,AX
DX,0FFE6H
AL,80H
200C
200D
EE
9A
OUTB
DX,AL
CALLS 0FB00:0031H
2012
EB 3A
2014
201A
2020
2026
2027
202D
2033
2038
203E
2044
204A
204D
204E
2052
2054
2059
205E
2060
3100 00 FB
LABEL
MNEMONIC
JMP START
COMMENTS
;Initialise
;Segment
;Registers
;Initialise
;all 8255
;ports as o/p
;Newline
;routine
;Display
;message
;string
44 55 41 4C 20 44 MES: DB 'DUAL DAC INTERFACE '
41 43 20 49 4E 54
45 52 46 41 43 45
20
0A 0D 53 20 2D 20
DB 0AH, 0DH, 'S-SQUARE WAVE'
53 51 55 41 52 45
20 57 41 56 45
0A 0D 54 20 2D 20
DB 0AH, 0DH, 'T-TRIANGULAR
WAVE', 0H
54 52 49 41 47 4C
55 41 52 20 57 41
56 45 00
2E
CS
8D 16 14 20
START: LEA DX,@MES
;Display
;message on LCD
8B C2
MOVW AX,DX
;or Console
9A 13 00 00 FB
CALLS 0FB00:0013H
9A A9 00 00 FB GET:
CALLS 0FB00:00A9H
;Wait for user
;entry
3C 53
CMPB AL,53H
;If S, jump to
74 33
JE
SQUARE
;square wave
;generation
;routine
2062
3C 54
CMPB AL,54H
2064
74 02
JE
TRI
2066
EB F1
JMP
GET
;If T, jump to
;triangular
;wave
;generation
;routine
;Wait for valid
;key only
9A
B9
B0
FE
2074
BA E0 FF
MOVW
2077
EE
OUTB
2078
207B
BA E2 FF
EE
MOVW
OUTB
207C
207E
2081
2083
2085
2088
2089
208C
208D
2090
2091
2093
2095
209A
209C
209F
20A0
20A3
31 00 00 FB TRI :
FF 00
RPT1:
00
C0
UP:
E2
B9
8B
FE
F4
FF 00
C1
C8
CALLS
MOVW
MOVB
INCB
0FB00:0031H
CX,0FFH
;Set up Count
AL,00H
;Start from 0
AL
;Increment
;data for +ve
DX,0FFE0H ;going slope
;and output
DX,AL
;at Port A and
;Port B
DX,0FFE2H
DX,AL
LOOP
MOVW
MOVW
DOWN: DECB
UP
CX,0FFH
AX,CX
AL
;Set up Count
;Start from FFh
;Decrement data
;for -ve
BA E0 FF
MOVB DX,0FFE0H ;going slope
;and output
EE
OUTB DX,AL
;at Port A
;and Port B
BA E0 FF
MOVW DX,0FFE0H
EE
OUTB DX,AL
BA E2 FF
MOVW DX,0FFE2H
EE
OUTB DX,AL
E2 F0
LOOP DOWN
E8 D8
JMP RPT1
;Repeat
;continuously
; Square wave generation routine
9A 31 00 00 FB SQUARE: CALLS 0FB00:0031H
B0 FF
RPT2: MOVB AL,0FFH
;Output FFh at
;ports
BA E0 FF
MOVW DX,0FFE0H
EE
OUTB DX,AL
BA E2 FF
MOVW DX,0FFE2H
EE
OUTB DX,AL
20A4
20A7
20A9
B9 00 17
E2 FE
B0 00
MOVW CX,1700H
DLY1: LOOP DLY1
MOVB AL,00H
20AB
20AE
20AF
20B2
20B3
20B6
20B8
BA
EE
BA
EE
B9
E2
EB
MOVW
OUTB
MOVW
OUTB
MOVW
DLY2: LOOP
JMP
E0 FF
E2 FF
00 17
FE
70
DX,0FFE0H
DX,AL
DX,0FFE2H
DX,AL
CX,1700H
DLY2
RPT2
;Delay
;Output 0 at
;ports
;Delay
;Repeat
;continuously
Ex. No.: 05
04-11-2016
AIM:
To interface Music Tone Generator.
PROGRAM:
ADDRESS OPCODE
LABEL
MNEMONIC
2000
B8 00 00
MOV AX,0000H
2003
2005
2007
200A
8E
8B
BA
B0
MOV
MOV
MOV
MOV
200C
200D
EE
9A A9 00 00 FB
2012
B9 00 00
2015
BE 00 25
2018
3C 41
201A
72 F1
201C
201E
3C 50
7F ED
2020
2023
BA E4 FF
2C 41
2025
2027
202A
8A C8
80 F9 00
74 08
202C
46
202D
FE C9
202F
E9 F5 FF
2032
2034
E2 F3
8A 2C
C0
C8
E6 FF
80
COMMENTS
;Initialise
;Segment
;Registers
ES,AX
CX,AX
DX,0FFE6H ;Initialise all
AL,80H
;8255 Ports as
;o/p in Mode 0
OUT DX,AL
GETKEY: CALL FAR 0FB00:00A9H ;Read key
;from ASCII KBD
MOV CX,0000H ;Clear count &
;initialise
MOV SI,2500H ;pointer to frqy
;table
CMP AL,41H
;Check if key
;value
JB GETKEY
;falls bet'n 'A'
;and 'P'
CMP AL,50H
JG GETKEY
;Accept valid
;key only
MOV DX,0FFE4H ;Compute count
SUB AL,41H
;value from
;ASCII keycode
MOV CL,AL
FREQ: CMP CL,00H
JE NEXT
;Increment index
;register
INC SI
;to point to
;proper value
DEC CL
;in frequency
;table
JMP FREQ
LOOP FREQ
NEXT: MOV CH,[SI]
;Load desired
2036
B1 4F
MOV CL,4FH
;frequency
;in CX register
B0 00
EE
203B
90
203C
203D
203E
203F
2040
2041
2043
2045
90
90
90
90
90
FE CD
75 F6
8A 2C
NOP
NOP
NOP
NOP
NOP
DEC CH
JNZ N1
MOV CH,[SI]
2047
F6 D0
NOT AL
2049
204A
EE
90
204B
204C
204D
204E
204F
2050
2052
2054
90
90
90
90
90
FE CD
75 F6
FE C9
NOP
NOP
NOP
NOP
NOP
DEC CH
JNZ N2
DEC CL
2056
2058
75 E0
E9 B2 FF
JNZ NXTPLS
JMP GETKEY
2500
2500
2506
2508
250E
FC
94
74
1C
OUT DX,AL
N2:NOP
E4 D2 C4 B0 A2
80
6A 52 42 3E 27
0F
;Output LOW to
;Port C
;Dummy
;instructions
; for delay
;Get frequency
;to CH
;Output HIGH to
;Port C
;Dummy
;instructions
;for delay
;Repeat process
;according
;to frequency
;Read next key &
;continue
ORG 2500H
DB FCH,E4H,D2H,C4H,B0H,A2H,94H,80H
DB 74H,6AH,52H,42H,3EH,27H,1CH,0FH
Ex. No.: 15
11-11-2016
ELEVATOR
AIM:
To interface Elevator.
PROGRAM:
ADDRESS OPCODE
LABEL
MNEMONIC
2000
2003
2005
2006
BA E6 FF
B0 82
EE
33 C0
MOVW
MOVB
OUTB
XORW
DX,0FFE6H
AL,82H
DX,AL
AX,AX
2008
200A
200C
200F
2010
2013
2014
2016
8A C4
0C F0
BA E0 FF
EE
BA E2 FF
EC
24 0F
3C 0F
LOOP1: MOVB
ORB
MOVW
OUTB
MOVW
LOOP2: INB
ANDB
CMPB
AL,AH
AL,0F0H
DX,0FFE0H
DX,AL
DX,0FFE2H
AL,DX
AL,0FH
AL,0FH
2018
201A
201D
201F
2021
74
BE
D0
73
46
F9
00 00
C8
03
2022
EB F9
2024
2028
8A 84 00 21
3A C4
202A
202C
77 0C
72 21
202E
2032
2035
2036
2038
203B
8A
BA
EE
EB
E8
FE
84 04 21
E0 FF
D0
2B 00
C4
JZ
MOVW
FINDF: RORB
JNC
INCW
JMP
LOOP2
SI,00H
AL,01H
FOUND
SI
FINDF
JA
JB
CLEAR: MOVB
MOVB
OUTB
JMP
GOUP: CALL
INCB
GOUP
GODN
AL,FCLR[SI]
DX,0FFE0H
DX,AL
LOOP1
DELAY
AH
COMMENTS
;Configure 8255
;Port A as o/p,
;Port B as i/p
;Initial stage is
;ground floor
;AH is the floor
;position
;Get request
;If requested
;floor found,
;update pointer
;Else, continue
;search
;Get requesting
;floor code and
;compare with
;current floor
;code
;If needed go UP
;If needed go
;DOWN
;Elevator goes UP
203D
203F
2041
2044
2045
2047
2049
204B
204D
204F
2052
2054
2056
2058
205B
205C
205E
2060
2062
2064
2066
2069
86
0C
BA
EE
24
86
3A
75
EB
E8
FE
86
0C
BA
EE
24
86
3A
75
EB
B9
E2
C4
F0
E0 FF
0F
E0
C4
EB
DF
14 00
CC
E0
F0
E0 FF
0F
C4
C4
EB
C8
00 08
FE
XCHGB AL,AH
ORB AL,0F0H
MOVW DX,0FFE0H
OUTB DX,AL
ANDB AL,0FH
XCHGB AH,AL
CMPB AL,AH
JNZ GOUP
JMP CLEAR
GODN: CALL DELAY
DECB AH
XCHGB AH,AL
ORB AL,0F0H
MOVW DX,0FFE0H
OUTB DX,AL
ANDB AL,0FH
XCHGB AL,AH
CMPB AL,AH
JNZ GODN
JMP CLEAR
DELAY: MOVW CX,0800H
LOOP $
;Elevator goes
;DOWN by one LED
;Delay between
;glow of
;successive LEDs
206B
206E
2070
B9 FF FF
E2 FE
C3
2100
2100
ORG 2100H
00 03 06 09 VALUE1: DB 00H,03H,06H,09H ;Position codes
;for floors
E0 D3 B6 79 VALUE2: DB E0H,D3H,B6H,79H ;Clear code +
;Position code
2104
MOVW CX,0FFFFH
LOOP $
RET
Ex. No.: 16
11-11-2016
STEPPER MOTOR
AIM:
To interface Stepper Motor.
PROGRAM:
ADDRESS
OPCODE
2000
B8 00
2003
8E C8
2005
2007
200A
8E C0
BA E6 FF
B0 80
200C
200D
EE
EB 47
200F
2015
201B
2021
2022
2028
202E
2033
2039
203F
2045
2046
204C
2052
2056
0A
50
54
46
0A
52
43
0A
41
4F
45
0A
43
49
9A
205B
205C
2060
2062
2067
206C
206E
2070
LABEL
00
MOVW AX,0000H
MOVW CS,AX
MOVW ES,AX
MOVW DX,0FFE6H
MOVB AL,80H
0D 53 54 45 50
45 52 20 4D 4F
4F 52 20 49 2F
0D
20
54
0D
4E
43
45
44
49
41
54
4B
0D
4C
53
31
43
4F
45
00
MNEMONIC
4E
49
4F
20
49
57
54
52
4E
2D
43
49
COMMENTS
;Initialise
;Segment
;Registers
;Initialise
;all 8255
;Ports as o/p
OUTB DX,AL
JMP START
; Display Message String
MES: DB 0AH,0DH,'STEPPER MOTOR I/F'
45
45
DB 0AH,0DH,'ENTER DIRECTION'
20
4C
53
DB 0AH,0DH,'A - ANTICLOCKWISE'
20 2D 20
DB 0AH,0DH,'C - CLOCKWISE',00H
43 4B 57
00
00 FB
START:CALLS 0FB00:0031H;New line
;routine
2E
CS
8D 16 10 20
LEA DX,@MES ;Display message
8B C2
MOVW AX,DX
;on LCD or Console
9A 13 00 00 FB
CALLS 0FB00:0013H
9A A9 00 00 FB
GET:CALLS 0FB00:00A9H
;Wait for user entry
3C 41
CMPB AL,41H
;If key ='A',
74 1F
JE
ANTI
;rotate anti;clockwise
3C 43
CMPB AL,43H
;If key = 'C'
2072
2074
74 03
EB F1
JE
JMP
CLO
GET
;rotate clockwise
;Accept valid
;key only
9A
9A
B0
BA
EE
E8
31 00 00 FB
00 00 00 FB
11
E0 FF
1D 00
CLO:CALLS
CALLS
MOVB
MOVW
R1:OUTB
CALL
0FB00:0031H
0FB00:00H
AL,11H ;Output value
DX,0FFE0H ;to Port A
DX,AL
DELAY
;Introduce delay
2089
208B
D0 D8
EB F8
RCRB
JMP
AL,1
R1
;Rotate bits in
;data byte
;right & repeat
9A 31 00 00 FB
9A 00 00 00 FB
B0 11
2099
209C
209D
20A0
20A2
20A4
20A7
20A9
BA
EE
E8
D0
E9
B9
E2
C3
E0 FF
05 00
D0
F7 FF
00 08
FE
ANTI:CALLS 0FB00:0031H
CALLS 0FB00:00H
MOVB AL,11H;Output value
;to Port A
MOVW DX,0FFE0H
R2:OUTB DX,AL
CALL DELAY
RCLB AL,1
;Rotate bits
JMP
R2
;left & repeat
DELAY:MOVW CX,800H
;Delay routine
$ :LOOP $
RET