HW#3 Solution
HW#3 Solution
HW#3 Solution
Subject: Microprocessors II
Write the required assembly code to program the I/O printer ports so that
printing your first and last name on the output port.
SOL :-
MOV AL,[SI]
MOV DX,4000h ; set DX to address of port 0
OUT DX,AL ; output and transfer the char to port 0
MOV BX, 0Fh ; to make the Strobe active for 16 CLK cycles
(delay for STB duration)
Repeat: DEC BX
JNZ Repeat
MOV AL,01h ; STB = ‘1’ (disable the strobe signal)
OUT DX,AL
INC SI
DEC CL
JNZ POLL_BUSY
DONE: HLT
Q3) It is required to repeatedly generate the following timing signal using the
timer/counter chip 82C54 that is connected to an 8086-based
microprocessor. Consider the starting address of the 82C54 chip is 70h,
and its clock frequency is 1 HZ. Write down the required program to
perform this task.
SOL :-
Counter
Counter 11 CLK1 (1 Hz)
A1 Count = 22
Count Gate1
Mode 00
Mode
OUT1 total out for
one cycle
####
𝐑𝐃 CLK2 (1 Hz)
Counter
Counter 22
Count == 15
Count 15 Gate2
Mode
Mode 00
#####
𝐖𝐑 OUT2
####
𝐂𝐒
Determine the control word of each counter:
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RW/W1 RW/W0 M2 M1 M0 BCD
0 0 0 1 0 0 0 1 Counter 0
= 11 h
0 1 0 1 0 0 0 1 Counter 1
= 51 h
1 0 0 1 0 0 0 1 Counter 2
= 91 h
MOV DX,70h
MOV AL,10h ; Initialize counter0 with 0010h
OUT DX,AL
MOV DX,71h
MOV AL,02h ; Initialize counter1 with 0020h
OUT DX,AL
MOV DX,72h
MOV AL,15h ; Initialize counter2 with 15h
OUT DX,AL
Minimum-mode of 8086
with memory-mapped I/O ports
###
CS 2
SOL :-
a)
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 1 0 0 1 0
D7 = 1 for enable .
D6 D5 = 0 0 & D2 = 0 for mode 0 .
D4 = 1 for port A as input .
D1 = 1 for port B as input .
D3 & D0 for port C as output .
Control word = 92 h
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
Port A :
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0
Port B :
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0
Port C :
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0
Control Register :
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0
Port A address = 00408 h
Port B address = 0040A h
Port C address = 0040C h
Control Register = 0040E h
To address the upper and lower banks, a one (1-to-2) address decoder is required
to select one SRAM out of two chips from each bank-group.
Address Range
Start address is 07000h, and the capacity is 1 MB, then the No. of address lines (N)
required to access all locations
A22 A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
•
•
•
0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1
###
M / 𝐈𝐎 Decoder Address Lines ######
𝐁𝐋𝐄
v A22 & A21 are decoded with the control signal M/IO to select memory
v A20 is the input of the 1 -to- 2 address decoder to select/enable one
SRAM chip from the upper group (bank0) and one SRAM chip from the
lower group (bank1)
A21
A22
• (D15 – D8) from high bank as needed with control signals (RD & HWR)
• (D7 – D0) from lower bank as needed with control signals (RD & LWR)
Bank 0 8 bits
A19 – A0 D0 – D7
#####
𝐖𝐄
SRAM 0
####
𝐎𝐄 (256K * 8-bit)
Low - byte
###
𝐂𝐄
16
Bank 0
A19 – A0 D0 – D7
8 bits
#####
𝐖𝐄
SRAM 1
####
𝐎𝐄 (256K * 8-bit)
High - byte
###
𝐂𝐄
....0
𝑪𝑺 16 bits
Q0
A20 Address ....1
𝑪𝑺
Decoder Q1 D15 – D0
Bank 1
8 bits
A19 – A0 D0 – D7
#####
𝐖𝐄
SRAM 2
####
𝐎𝐄 (256K * 8-bit)
Low - byte
###
𝐂𝐄
16
Bank 1
A19 – A0 D0 – D7
#####
𝐖𝐄 8 bits
SRAM 3
####
𝐎𝐄 (256K * 8-bit)
High - byte
###
𝐂𝐄