Professional Documents
Culture Documents
Microprocessor
Laboratory Experiments Manual
Using MicroTalk-8086 and MDA-8086 Trainers
Golam Mostafa
Ahsanullah University of Science and Technology
Preface
Dear Readers,
First of all, you must say that you wish to learn ‘things’. And only then, we may tell you
something like: “Look for the things that work and play with them”. This is one of the
proven methods of ‘Self Learning’.
This book is prepared for those who are willing to learn things by doing themselves.
Take an experiment and “follow” every step. Be patient and keep waiting until you are
rewarded with a result.
Now, you have an experiment, which works. Repeatedly study and practice every step
of the experiment. You will soon discover the reason for having a particular step
included in the experiment. Try to build the experiment in your own way. Execute the
program and monitor the result.
Good Luck!
Golam Mostafa
Segun Bagicha, Dhaka
6/1/2009
Contents
Experiment – 1A Familiarization with the Components Organization and the Operating
Procedures of the MicroTalk-8086 Trainer 1/Expt-1A
Experiment – 1B Familiarization with the Organization and the Operating Procedures of the
MDA-8086 Trainer 1/Expt-1B.
Experiment – 5A Familiarization with the Procedures of Interfacing a Text Mode LCD Panel
with MicroTalk-8086 Trainer. 1/Expt-5A
Experiment – 5B Familiarization with the Procedures of Programming the Text Mode LCD
Panel of the MDA-8086 Trainer. 1/Expt-
i
Experiment – 8 Task-8.1 [BINary-to-BCD]
Conversion of Tw-digit BINary Number (range: 00h – 63h) into BCD Number
by Counting Method. 1/Expt-8
Task-8.2
[BINary-to-BCD]
Conversion of n-bit BINary Number into equivalent BCD Number by Horner
Method (Fast Method) 2/Expt-8
Experiment – 11A Study of the Asynchronous Serial Communication Link Between IBMPC and
MicroTalk-8086 Trainer. 1/Expt-11A
Experiment – 11B Study of the Asynchronous Serial Communication Link Between IBMPC and
MDA-8086 Trainer. 1/Expt-11B
ii
Experiment – 8
Converting BINary Number into Equivalent BCD
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-8.1
Converting Two-digit BINary number (range: 00h – 63h) into equivalent BCD number (range:
00 – 99) using Counting Method (Slow Process).
1. Draw Input/Out Data Structure. Keep Input BIN at location 03010h and the Output BCD at
location 04010h.
2. Convert the following conversion Pseudo Codes into 8086 ASM codes and save as:
bin2bcdc..asm.
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
START: nop
L1: Bring BINary ah-register from location 03010h
mov al, 00h ; IPBCD
L2: add al, 01h
If ((al3 – al0) > 9)
Goto L6
L3: dec ah
jnz L2
L4: mov BYTE PTR [bx+1010h], al ; BCD result at location: 04010h
L5: hlt
L6: add al, 06h
jmp L3
MYCODE ENDS
END START
4. Assemble the above program and down load it.
7. Open memory location 04010h and we must see 37 (the desired BCD number).
8. Enter different values for the input Binary and check that the program produces correct BCD
numbers.
1/Expt-8
Task-8.2
Converting 4-digit BINary number (range: (0000h – FFFFh) into equivalent BCD number
(range: 0000h – 065535) using Horner Method (Fast Process).
1. Review the following Horner Rule foe conversion.
BIN = b15b14, ………………………., b1b0
= b15x215 + b14 x 214 +, …………….., +b1 x 21 + b0 x20
= (……….(b15)2 + b14) 2 +, ………………………, + b1 ) 2 + b0
BCD = (……….(b15)2 + b14) 2 +, ……………………., + b1 ) 2 + b0
= (……….(IPBCD x 2 + b15) 2 + b14) 2 +,………………..+ b1 ) 2 + b0
where: IPBCD = Initial Partial BCD = 000000
2. Computation Philosophy
a. Extract b15 and compute: (IPBCD x 2 + b15) → IPBCD
b. Carry out Step-a, for all the bits of the input BINary number.
3. Draw DSM-based Data Structure for the Input/Output numbers.
3. Draw the following Register-based Data Structure for the Input/Output Numbers.
15 0 23 (Six BCD Digits) 0
4. Convert the following Pseudo Codes into ASM codes. Save as: bcd2binh.asm. Download
and execute it. The DSM locations: 04011h and 04010h would contain the Binary number.
L1: 000000 → cl, bh, bl (IPBCD)
mov si, WORD PTR [di+10h] ; getting the input BINary from DSM
mov ah, 10h ; number of bits in the input Binary number
L2: ; Extrcat b15
rcl si, 01h ; b15 is in C-bit
call BCDC ; BCD Computation
L3: dec ah
Jnz L2 ; extract next bit (b14, …….b0)
L4: mov BYTE PTR [di+1012h], cl
Mov WORD PTR [di+1010h], bx ; BCD at locations: 04012, 04011, 04010
L5: hlt
BCDC:
mov al, bl
adc al, al
daa
mov bl, al
mov al, bh
adc al, al
daa
mov bh, al
mov al, cl
adc al, al
daa
mov cl, al
ret
2/Expt-8
3/Expt-8
Experiment – 1B
Familiarization with Components Organization and the Operating
Procedures of the MDA-8086 Microprocessor Learning System
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Procedures:
1. Collect the MDA-8086 trainer from the lab attendant.
2. Open the top cover of the trainer.
3. Look at the PCB (Printed Circuit Board) of the trainer and the component layout of Fig-1B.8.
4. Now, on the PCB, locate the circuit designation U1. This is the 8086 microprocessor chip.
5. Look very carefully on the top of the U1-chip and you will find the inscription ‘8086’.
6. Locate the keyboard on the trainer. The keyboard interface circuitry is there but is not
obvious.
7. Locate the following output devices on the PCB of the trainer.
a. The LCD unit. The interface controller of the LCD device is built-in within the LCD panel.
b. The 7-segment display device, which has the circuit designation – FND in Fig-1B.8. This is
a common-anode type display device. Let us agree to call it by the symbolic name CA7SD
(Common Anode 7-Segment Display Device). A CA-type display device is opposite to CC-
type display device. The interface controller for this device is the chip, U29 (8255).
c. The LED assembly, LED11-LED13. The interface controller for these LEDs is the chip, U29.
8. Locate the RAM chips U9, U10 on the PCB. Bit capacity of each RAM is: 32x1024x8.
9. Locate the EPROM chips U7 and U8 on the PCB. These chips contain the Monitor Program of
the MDA-8086 trainer. Bit capacity of each EPROM is: 32x1024x8.
1/Expt-1B
Task-1.2 Familiarization with the Hardware Block Diagram of MDA-8086
There are many more interface controllers on the PCB of the MDA-8086, which we could not
describe in Task-1B.1. The following Hardware Block Diagram of Fig-1B.1 contains the total IO
scenario of the trainer. For complete circuit diagram, consult user manual for MDA-8086 trainer.
KBIC : 74244 :U24 CPU : 8086 : U1 LCDIC LCD
NMI RES CS/
G0 STP C D E F
D7-D0 D15-D8
CS/
+ REG 8 9 A B
RS : 01h
D7-D0 D7-D0
- DA 4 5 6 7 16 Characters x 2 Lines
DR:01h IR
: AD 0 1 2 3
546 SR
Users Interface Controller 20h, 22h, CON10
CS/ DR
24h, 26h
CA7SD
PAR:19h
CS/ SIO: 8251:U14 TTL <----> RS232 : U15 CON: DB9
PB0-PB3 PBR:1Bh D15-D8 CS/
D 9600 Bd
LED11-LED14 TxTTL TTL TxRS
PCR:1Dh
PB4-PB7 DAC PIO:8255 D7-D0 D7-D0
9600 Bd
Step. Motor Int. U33 CR:1 Fh RxTTL TTL RxRS
U29
DR: 08h RxRDY
LM:U38 0V 0V
P8 ADC:U31 CS/
D7-D0 D7-D0 SR: 0Ah
PA:18h CR: 0Ah TxRDY
8x8 TxC,RxC
PB:1Ah
Common Cathode CLK for 9600 Bd
Type Bi-color PC:1Ch
LED Array CR:1Eh
CS/ CK0 PCLK: 2.4576MHz
PIO: 8255:U30 TC-0:09h GT0 +5V
D15-D8
+5V OT0
DIP2 D7-D0
P6 GATE1
Vin CS/ CK1
VR2
TC-1:0Bh GT1 0V
DAC:U33 D7-D0 D7-D0 PUT: OT1
TH1 U41 GATE2
CK2
DR:18h :8253 TC-2:0Dh GT2 0V
OT2
0V MIC CR:18h CR:0Fh
A,M-IO/,BHE/
Sx/ Sy/ 0V
Mem/Port Decoder : U16
GM: 547: 11/03:3 Hrs
2/Expt-1B
Task-1B.3 Getting Familiar with Keyboard Layout of MDA-8086 Trainer
MON RES
G0 STP C D E F
+ REG 8 9 A B
- DA 4 5 6 7
: AD 0 1 2 3
546
Figure-1B.2: keyboard Layout of MDA-8086 Learning System
The 26 keys of the keypad may be classified into the following categories:
A: CPU Control Key
1. RES (system RESet) : When this key is pressed down and then released, the 8086 is reset and
starts from the cold state. The PC looks for a valid instruction at memory location: FFFF
(CS):0000 (IP) = FFFF0h. Activation of the RES key displays the following message on the LCD
monitor. Note that the jumper at P1 must be set to ‘Local Monitor (the left side)’ position.
MDE – 8086 kit ! !
Midas 335-0964/5
2. MON (Monitor) /NMI (Non Maskable Interrupt): When pressed, the CPU is immediately
interrupted
B: Command Keys
1. AD (set memory ADdress) : This command key allows the user to set the 20-bit address of a
memory location in the format of [Segment:Offset]. Press this key and we will see the
following message on the LCD with the cursor blinking at the Segment Field.
Seg. Oset data
xxxx yyyy zz
a. ‘Seg.’ stands for ‘Memory Segment’, ‘Oset’ stands for ‘Memory Offset’ and ‘data’ refers to the 8-bit
content of the memory location, xxxx:yyyy.
b. Now, we can set the ‘Segment’ part of our desired memory location. Let us assume that we wish to
examine the content of the memory location F000h (F000:0000) of the ROM area of Fig-11.1. We may
use the data keys (0 to F) to change the segment into: F000h.
c. Now is the turn to change the ‘Offset’. Press [:] key.
2. : (set the Offset) : This key allows editing the Offset part of a memory location. When this is
pressed, the cursor moves to the Offset Field. And now, the user can use the data keys to set
the offset to the desired value.
3. DA (update address and allow Data entry) : This key brings cursor to the Data Field. Now, the
user may use the data key (0 to F) to enter new data (assume that the present memory location
is a RAM location).
4. + (increment by One) : This key allows moving to the next memory location.
5. - (decrement by One): This key allows moving in the previous memory location.
6. GO (GO to the beginning point of the program to be executed): This key allows executing a
program.
7. REG (examing and changing REGister contents): This key allows checking and editing the
content of the internal registers of the 8086.
8. STP (Single STep): This key allows executing one instruction at a time.
C: Data Keys
Keys with labels: 0, 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are the hexadecimal data keys.
3/Expt-1B
Task-1B.4 Familiarization with the Operation of MDA-8086 Trainer by Blinking
Character 3 on the CA7SDD.
Brief Theory: The CA7SDD is connected with the 8086 CPU as per diagram depicted in Fig-1B.3.
8086 : U1 8255 : U29 CA7SD
a CA +5V
Port-A
PA7-PA0
CS/ 19h f b
D15-D8 D7-D0
g
e c
CR: 1Fh
(1)
(3) d p
ah al
MLoc Content Comment
(3)
PC = CS:IP
Program Codes CSM
(2) xxxxx TDELAY
(4) 01000
RAM: U9, U10
548
To show character 3 on CA7SD (output device), we need to send code B0h (1011 0000) into Port-A
register of U29. B0h is the 8-bit CA-code for character 3 (see Fig-1.4 for the internal structure of
CA7SD). To blank (nothing) the output device, we need to send code FFh into Port-A. After
sending B0h, we need to wait for sometimes (Time Delay) so that the character 3 remains visible
for a while. Likewise, after sending code for blank, we also need to insert some time delay so that
the display remains OFF for sometimes. To blink 3 on the CA7SD, we may follow the steps:
A. Use keyboard and store data B0h (CA-code for 3) at memory location 03010h (0000:3010) of
the DSM of Fig-1B.3. Keep data FFh (CA-code for) Blank) at memory location 03011h.
B. Use keyboard and store Program Codes into the memory locations of the CSM of Fig-1B.3.
The programs read the data for character 3 from DSM and send it to Port-A register. As a
result, 3 appear on CA7SDD. The program inserts time delay. After that the data for blank
is sent to Port-A to show nothing on the CA7SDD.
C. Now, let us carry out the following:
1. Power up the MDA-8086 trainer.
2. Carry out the steps of Table-A to enter data into memory locations of DSM.
3. Carry out the steps of Table-B to enter Program Codes into memory locations of CSM.
Table-A
Entry of Common Anode Code for Character 3 and Blank
Sn: Press Key LCD Display Remarks
1 RES MDE8086 Kit V9.5 The trainer is ready to accept valid command
Midas 935-0964/5
2 AD Seg. Oset Data The 20-bit address of an arbitrary memory location is opened in
xxxx yyyy zz the format of: ‘Segment: Offset’. The present content of the
memory location has also appeared in the data field.
3 0000 Seg. Oset Data The segment part of the 20-bit address is set to 0000h. This is
0000 yyyy zz actually 00000h (the right most digit is understood to be 0).
Now, set the offset part of the 20-bit address.
4/Expt-1B
4 : Seg. Oset Data The cursor has moved to the offset field and is blinking. Use the
0000 yyyy _ zz data keys (0 to F) to set the value of the offset.
5 3010 Seg. Oset Data The 20-bit address, 03010 (0000:3010) is entered. Now, deposit
0000 3010 _ zz the cacode data (B0h) for character ‘3’.
6 DA Seg. Oset Data The cursor has moved at the data field. Now, use data keys (0 to
0000 3010 zz _ 9) to deposit the cacode, B0h at the indicated memory Location.
7 B0 Seg. Oset Data The data value B0h is deposited at location, 0000:3010. Now,
0000 3010 B0 _ deposit cacode (FFh) for the ‘blank’ character at the memory
location, 0000:3010.
8 + Seg. Oset Data The next memory location is opened. Enter data, FFh at the
0000 3011 zz _ indicated memory location using the data keys (0 to 9). To move
to the previous memory location, use the ‘ – ‘ command.
9 FF Seg. Oset Data The CA-code for blank is entered at memory location: 03011
0000 3011 FF _
10 RESET MDE8086 Kit V9.5 The trainer is ready to accept valid command
Midas 935-0964/5
Table-B
Enter the Machine Codes of the following Program starting at location: 01000h (0000:1000)
Label: Mem. Loc Assembly Codes Machine Codes Meaning
START: 0000:1000 – nop 90
L1: 0000:1001 - mov ax, 0000h B8 00 00 ; 00000h = Base Add.of Data Seg.
mov ds, ax 8E D8 ; 00000h = Base Add of Stack Seg.
mov ax, 0000h B8 00 00 ; Stack Pointer Reg. set to: 08FFEh
mov ss, ax 8E D0 ; Control Byte to set PAR as output
mov sp, 8FFEh BC FE 8F
L3: 0000:101F - mov al, BYTE PTR ds:[bx+11h] 8A 47 11 ; reading cacode for ‘blank’
out PARU((19h), al E6 19 ; sending cacode of ‘blank’ to PAR
mov cx, 0FFFFh B9 FF FF ; Insert Time Delay
HERE2: 0000:1027 - loop HERE2 E2 FE
4. Carry out the steps of Table-C to execute the above program of Table-B.
Table-C
Program Execution: Carry Out the following steps:
Sn: Press Key LCD Display Remarks
1 RESET MDE8086 Kit V9.5 The trainer is ready
Midas 935-0964/5
2 AD Seg. Ost Data The cursor blinks at the segment field. Use data keys to set the
xxxx yyyy zz segment at: 0000h.
3 : Seg. Ost Data The cursor blinks at the offset field. Use data key to set the
0000 yyyy _ zz address at : 1000h
4 GO Statring Address Program has been executed. Character ‘3’ should blink.
0000:1000
5/Expt-1B
Task-1B.5 Familiarization with Internal Structure of CA 7-Segment Display Device
a
ca 7 ca
10 9 8 7 6
g f ca a b f b
10 g 6
e c
d
4 p
2
5 p(5) f(9) e(1) d(2) c(4) b(6) a(7)
e d ca c p g(10)
1 2 3 4 5
(a) Physical View (b) Internal LED Structure (c) Electrical Equivalent
Figure-1B.4: Structure of Common Anode Type 7-Segment Display Device
Task-1B.6 Enter appropriate data at the appropriate memory locations of DSM to blink
character A on the CA7SD. Make CA-code for A looking at the diagram of Fig-1B.3.
6/Expt-1B
(e) Save the screen (what you have typed in the screen) with the file name of: P1B.asm.
Save the file as: c:\mda8086\P1B.asm
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save As...’ from the menu using the arrow keys.
3. Now type the file name: P1B.asm and then press Enter key.
(f) Type the following lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT para public ‘code’ ; declaring logical segment
ASSUME cs:MYCODE
ORG 1000h
(g) Type the following assembler statements at the end of your assembly program.
MYCODE ENDS
END START
(h) Update your file (P1B.asm) in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save’ from the menu using the arrow keys.
3. Now press Enter key.
(i) Now leave the screen and come back to the DOS prompt in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Exit’ from the menu using the arrow keys.
3. Now press Enter key.
(j) Type cls and press Enter key for clearing up the screen.
(k) Now, convert the source codes of your program c:\mda8086\P1B.asm into machine
codes in the following ways: This is known as assembling.
The Procedures:
1. Type MASM at the cursor position of the DOS prompt. Press Enter key.
2. Type P1B.asm (assembly) and press Enter key
3. Type P1B.obj (object) and then Press Enter key
4. Type P1B.lst (list) and press Enter key.
5. Press Enter key
(l) You are back to the DOS prompt. Your assembly program has already been converted
into machine codes and the codes have been saved in the path: c:\mda8086\P1B.lst.
Show the error messages to the teacher if any. Remember that there should not be any
error in the program. If there are errors, take help from the teacher to correct these
errors and then and go to Step-k. After error free assembling go to Step-m.
(m) Open the P1B.lst file in the following ways to see its contents:
The Procedures:
1. Type ‘EDIT’ at the DOS prompt. And then press Enter key.
2. Press Alt key and then press Enter key.
3. Choose ‘Open...’ from the menu using the arrow keys. Press Enter key.
4. Use ‘tab’ key and ‘arrow’ key to choose the file, P1B.lst from the menu. Press Enter.
5. Now the machine codes of your program are in the screen.
(n) Look at the machine codes of your program on the screen. Compare these codes with
the machine codes of Table-B of Task-1B.4. Write down the codes where they differ.
(o) Look for the jumper ‘P1’ (Fig-1B.5) or switch ‘KIT/PC’ of the MDA-8086 trainer. Bring
the jumper at the ‘Local Monitor’ or KIT position.
7/Expt-1B
Jumper Position
P1 at: Serial Monitor
GND +5V
Jumper Position
at: Local Monitor
538
8/Expt-1B
4. Power down and Power up the MDA-8086 trainer. Press the RESET key of the trainer to
get the prompt message on the screen of the IBMPC.
* * 8086 Monitor 9.5 * *
* * Midas 335-0964/5 * *
8086> _
5. To bring the IBMPC into DOS mode, press Alt and hold and then press X key. And then
press the Enter key.
6. The IBM-PC in the path: c:\mda8086> _
7. Now, convert the P1B.obj (object) file into P1B.abs (absolute) file for onward transmission
to the trainer. Type LOD186 at the cursor position of the DOS prompt. And then press
Enter key. Answer as follows:
(a) Type T1B.obj
(b) Type c:\mda8086\P1B.abs
(c) press Enter key
The conversion is completed with the message LOAD COMPLETED and the PC comes to the
following DOS path:
9/Expt-1B
Task-1B.12 Introduction to MDA-8086 Trainer
The MDA-8086 is a 16-bit microprocessor learning system using Intel’s 8086 architecture. The
trainer has been designed, developed and built by the ‘MIDAS Engineering Co. of South Korea.
The Address:
Original Manufacturer: ACE TechnoV, 906 19-7-22,
Kuro-Gu, Seoul,
South Korea.
Fax: (02) 2109-5968. Web: www.midaseng.com.
10/Expt-1B
Task-1B.14 Software Features of MDA-8086
A: Resident Monitor Program
1. Allows data entry, edit into RAM locations [Word operations are not available]
2. Allows Program Execution
3. Allows data entry, edit into Registers locations
4. Allows Debugging a Faulty Program (Single Stepping)
5. Does not contain any data conversion algorithms like:
BCD-to-Binary, Binary-to-BCD, Multiplication, Division, BCD-to-ASCII
B: Serial Monitor Program
Allows downloading program/data codes from the IMB-PC to the MDA-8086
C: Example Programs
A disk accompanying the trainer contains a good number of example programs.
Taks-1B.15 Memory Space and Port Space Organization of MDA-8086
FFFFF
FFFF FFFE
ROM
F0000
EFFFF
Useable after Decoding
10000 (00)26 IO CON10
0FFFF (00)24 IO CON10
Reserved (00)22 IO CON10
User-3
Extra Segment
RAM
05000
04FFF Space for
03000 Data Segment
02FFF Space for
01000 Code Segment
00FFF (00)12 8259: DR
Scratch Pad (00)11 SPEAKER: DR (00)10 8259: CR
00F00 (00)0F 8253: CR
00EFF (00)0D 8253: TC-2
Data Structure (00)0B 8252: TC-1 (00)0A 8251: CR/SR
00400 (00)09 8253: TC-0 (00)08 8251 : DR
003FF
Interrupt (00)05 (00)04 LCDDR
Vvector Table (00)03 (00)02 LCDSR
00000 (00)01 KBD DR/FR (00)00 LCDIR
545 545
11/Expt-1B
Task-1B.16 Component Layout of MDA-8086
12/Expt-1B
Figure-1B.8: Component Layout Diagram of the MDA-8086 System
Task-1.17 Schematics of the MDA-8086 Learning System
13/Expt-1B
14/Expt-1B
15/Expt-1B
16/Expt-1B
17/Expt-1B
18/Expt-1B
Experiment – 1B
Familiarization with Components Organization and the Operating
Procedures of the MDA-8086 Microprocessor Learning System
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Procedures:
1. Collect the MDA-8086 trainer from the lab attendant.
2. Open the top cover of the trainer.
3. Look at the PCB (Printed Circuit Board) of the trainer and the component layout of Fig-1B.8.
4. Now, on the PCB, locate the circuit designation U1. This is the 8086 microprocessor chip.
5. Look very carefully on the top of the U1-chip and you will find the inscription ‘8086’.
6. Locate the keyboard on the trainer. The keyboard interface circuitry is there but is not
obvious.
7. Locate the following output devices on the PCB of the trainer.
a. The LCD unit. The interface controller of the LCD device is built-in within the LCD panel.
b. The 7-segment display device, which has the circuit designation – FND in Fig-1B.8. This is
a common-anode type display device. Let us agree to call it by the symbolic name CA7SD
(Common Anode 7-Segment Display Device). A CA-type display device is opposite to CC-
type display device. The interface controller for this device is the chip, U29 (8255).
c. The LED assembly, LED11-LED13. The interface controller for these LEDs is the chip, U29.
8. Locate the RAM chips U9, U10 on the PCB. Bit capacity of each RAM is: 32x1024x8.
9. Locate the EPROM chips U7 and U8 on the PCB. These chips contain the Monitor Program of
the MDA-8086 trainer. Bit capacity of each EPROM is: 32x1024x8.
431
Task-1.2 Familiarization with the Hardware Block Diagram of MDA-8086
There are many more interface controllers on the PCB of the MDA-8086, which we could not
describe in Task-1B.1. The following Hardware Block Diagram of Fig-1B.1 contains the total IO
scenario of the trainer. For complete circuit diagram, consult user manual for MDA-8086 trainer.
KBIC : 74244 :U24 CPU : 8086 : U1 LCDIC LCD
NMI RES CS/
G0 STP C D E F
D7-D0 D15-D8
CS/
+ REG 8 9 A B
RS : 01h
D7-D0 D7-D0
- DA 4 5 6 7 16 Characters x 2 Lines
DR:01h IR
: AD 0 1 2 3
546 SR
Users Interface Controller 20h, 22h, CON10
CS/ DR
24h, 26h
CA7SD
PAR:19h
CS/ SIO: 8251:U14 TTL <----> RS232 : U15 CON: DB9
PB0-PB3 PBR:1Bh D15-D8 CS/
D 9600 Bd
LED11-LED14 TxTTL TTL TxRS
PCR:1Dh
PB4-PB7 DAC PIO:8255 D7-D0 D7-D0
9600 Bd
Step. Motor Int. U33 CR:1 Fh RxTTL TTL RxRS
U29
DR: 08h RxRDY
LM:U38 0V 0V
P8 ADC:U31 CS/
D7-D0 D7-D0 SR: 0Ah
PA:18h CR: 0Ah TxRDY
8x8 TxC,RxC
PB:1Ah
Common Cathode CLK for 9600 Bd
Type Bi-color PC:1Ch
LED Array CR:1Eh
CS/ CK0 PCLK: 2.4576MHz
PIO: 8255:U30 TC-0:09h GT0 +5V
D15-D8
+5V OT0
DIP2 D7-D0
P6 GATE1
Vin CS/ CK1
VR2
TC-1:0Bh GT1 0V
DAC:U33 D7-D0 D7-D0 PUT: OT1
TH1 U41 GATE2
CK2
DR:18h :8253 TC-2:0Dh GT2 0V
OT2
0V MIC CR:18h CR:0Fh
A,M-IO/,BHE/
Sx/ Sy/ 0V
Mem/Port Decoder : U16
GM: 547: 11/03:3 Hrs
G0 STP C D E F
+ REG 8 9 A B
- DA 4 5 6 7
: AD 0 1 2 3
546
Figure-1B.2: keyboard Layout of MDA-8086 Learning System
The 26 keys of the keypad may be classified into the following categories:
A: CPU Control Key
1. RES (system RESet) : When this key is pressed down and then released, the 8086 is reset and
starts from the cold state. The PC looks for a valid instruction at memory location: FFFF
(CS):0000 (IP) = FFFF0h. Activation of the RES key displays the following message on the LCD
monitor. Note that the jumper at P1 must be set to ‘Local Monitor (the left side)’ position.
MDE – 8086 kit ! !
Midas 335-0964/5
2. MON (Monitor) /NMI (Non Maskable Interrupt): When pressed, the CPU is immediately
interrupted
B: Command Keys
1. AD (set memory ADdress) : This command key allows the user to set the 20-bit address of a
memory location in the format of [Segment:Offset]. Press this key and we will see the
following message on the LCD with the cursor blinking at the Segment Field.
Seg. Oset data
xxxx yyyy zz
a. ‘Seg.’ stands for ‘Memory Segment’, ‘Oset’ stands for ‘Memory Offset’ and ‘data’ refers to the 8-bit
content of the memory location, xxxx:yyyy.
b. Now, we can set the ‘Segment’ part of our desired memory location. Let us assume that we wish to
examine the content of the memory location F000h (F000:0000) of the ROM area of Fig-11.1. We may
use the data keys (0 to F) to change the segment into: F000h.
c. Now is the turn to change the ‘Offset’. Press [:] key.
2. : (set the Offset) : This key allows editing the Offset part of a memory location. When this is
pressed, the cursor moves to the Offset Field. And now, the user can use the data keys to set
the offset to the desired value.
3. DA (update address and allow Data entry) : This key brings cursor to the Data Field. Now, the
user may use the data key (0 to F) to enter new data (assume that the present memory location
is a RAM location).
4. + (increment by One) : This key allows moving to the next memory location.
5. - (decrement by One): This key allows moving in the previous memory location.
6. GO (GO to the beginning point of the program to be executed): This key allows executing a
program.
7. REG (examing and changing REGister contents): This key allows checking and editing the
content of the internal registers of the 8086.
8. STP (Single STep): This key allows executing one instruction at a time.
C: Data Keys
Keys with labels: 0, 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are the hexadecimal data keys.
433
Task-1B.4 Familiarization with the Operation of MDA-8086 Trainer by Blinking
Character 3 on the CA7SDD.
Brief Theory: The CA7SDD is connected with the 8086 CPU as per diagram depicted in Fig-1B.3.
8086 : U1 8255 : U29 CA7SD
a CA +5V
Port-A
PA7-PA0
CS/ 19h f b
D15-D8 D7-D0
g
e c
CR: 1Fh
(1)
(3) d p
ah al
MLoc Content Comment
(3)
PC = CS:IP
Program Codes CSM
(2) xxxxx TDELAY
(4) 01000
RAM: U9, U10
548
To show character 3 on CA7SD (output device), we need to send code B0h (1011 0000) into Port-A
register of U29. B0h is the 8-bit CA-code for character 3 (see Fig-1.4 for the internal structure of
CA7SD). To blank (nothing) the output device, we need to send code FFh into Port-A. After
sending B0h, we need to wait for sometimes (Time Delay) so that the character 3 remains visible
for a while. Likewise, after sending code for blank, we also need to insert some time delay so that
the display remains OFF for sometimes. To blink 3 on the CA7SD, we may follow the steps:
A. Use keyboard and store data B0h (CA-code for 3) at memory location 03010h (0000:3010) of
the DSM of Fig-1B.3. Keep data FFh (CA-code for) Blank) at memory location 03011h.
B. Use keyboard and store Program Codes into the memory locations of the CSM of Fig-1B.3.
The programs read the data for character 3 from DSM and send it to Port-A register. As a
result, 3 appear on CA7SDD. The program inserts time delay. After that the data for blank
is sent to Port-A to show nothing on the CA7SDD.
C. Now, let us carry out the following:
1. Power up the MDA-8086 trainer.
2. Carry out the steps of Table-A to enter data into memory locations of DSM.
3. Carry out the steps of Table-B to enter Program Codes into memory locations of CSM.
Table-A
Entry of Common Anode Code for Character 3 and Blank
Sn: Press Key LCD Display Remarks
1 RES MDE8086 Kit V9.5 The trainer is ready to accept valid command
Midas 935-0964/5
2 AD Seg. Oset Data The 20-bit address of an arbitrary memory location is opened in
xxxx yyyy zz the format of: ‘Segment: Offset’. The present content of the
memory location has also appeared in the data field.
3 0000 Seg. Oset Data The segment part of the 20-bit address is set to 0000h. This is
0000 yyyy zz actually 00000h (the right most digit is understood to be 0).
Now, set the offset part of the 20-bit address.
434
4 : Seg. Oset Data The cursor has moved to the offset field and is blinking. Use the
0000 yyyy _ zz data keys (0 to F) to set the value of the offset.
5 3010 Seg. Oset Data The 20-bit address, 03010 (0000:3010) is entered. Now, deposit
0000 3010 _ zz the cacode data (B0h) for character ‘3’.
6 DA Seg. Oset Data The cursor has moved at the data field. Now, use data keys (0 to
0000 3010 zz _ 9) to deposit the cacode, B0h at the indicated memory Location.
7 B0 Seg. Oset Data The data value B0h is deposited at location, 0000:3010. Now,
0000 3010 B0 _ deposit cacode (FFh) for the ‘blank’ character at the memory
location, 0000:3010.
8 + Seg. Oset Data The next memory location is opened. Enter data, FFh at the
0000 3011 zz _ indicated memory location using the data keys (0 to 9). To move
to the previous memory location, use the ‘ – ‘ command.
9 FF Seg. Oset Data The CA-code for blank is entered at memory location: 03011
0000 3011 FF _
10 RESET MDE8086 Kit V9.5 The trainer is ready to accept valid command
Midas 935-0964/5
Table-B
Enter the Machine Codes of the following Program starting at location: 01000h (0000:1000)
Label: Mem. Loc Assembly Codes Machine Codes Meaning
START: 0000:1000 – nop 90
L1: 0000:1001 - mov ax, 0000h B8 00 00 ; 00000h = Base Add.of Data Seg.
mov ds, ax 8E D8 ; 00000h = Base Add of Stack Seg.
mov ax, 0000h B8 00 00 ; Stack Pointer Reg. set to: 08FFEh
mov ss, ax 8E D0 ; Control Byte to set PAR as output
mov sp, 8FFEh BC FE 8F
L3: 0000:101F - mov al, BYTE PTR ds:[bx+11h] 8A 47 11 ; reading cacode for ‘blank’
out PARU((19h), al E6 19 ; sending cacode of ‘blank’ to PAR
mov cx, 0FFFFh B9 FF FF ; Insert Time Delay
HERE2: 0000:1027 - loop HERE2 E2 FE
4. Carry out the steps of Table-C to execute the above program of Table-B.
Table-C
Program Execution: Carry Out the following steps:
Sn: Press Key LCD Display Remarks
1 RESET MDE8086 Kit V9.5 The trainer is ready
Midas 935-0964/5
2 AD Seg. Ost Data The cursor blinks at the segment field. Use data keys to set the
xxxx yyyy zz segment at: 0000h.
3 : Seg. Ost Data The cursor blinks at the offset field. Use data key to set the
0000 yyyy _ zz address at : 1000h
4 GO Statring Address Program has been executed. Character ‘3’ should blink.
0000:1000
435
Task-1B.5 Familiarization with Internal Structure of CA 7-Segment Display Device
a
ca 7 ca
10 9 8 7 6
g f ca a b f b
10 g 6
e c
d
4 p
2
5 p(5) f(9) e(1) d(2) c(4) b(6) a(7)
e d ca c p g(10)
1 2 3 4 5
(a) Physical View (b) Internal LED Structure (c) Electrical Equivalent
Figure-1B.4: Structure of Common Anode Type 7-Segment Display Device
Task-1B.6 Enter appropriate data at the appropriate memory locations of DSM to blink
character A on the CA7SD. Make CA-code for A looking at the diagram of Fig-1B.3.
436
(e) Save the screen (what you have typed in the screen) with the file name of: P1B.asm.
Save the file as: c:\mda8086\P1B.asm
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save As...’ from the menu using the arrow keys.
3. Now type the file name: P1B.asm and then press Enter key.
(f) Type the following lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT para public ‘code’ ; declaring logical segment
ASSUME cs:MYCODE
ORG 1000h
(g) Type the following assembler statements at the end of your assembly program.
MYCODE ENDS
END START
(h) Update your file (P1B.asm) in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save’ from the menu using the arrow keys.
3. Now press Enter key.
(i) Now leave the screen and come back to the DOS prompt in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Exit’ from the menu using the arrow keys.
3. Now press Enter key.
(j) Type cls and press Enter key for clearing up the screen.
(k) Now, convert the source codes of your program c:\mda8086\P1B.asm into machine
codes in the following ways: This is known as assembling.
The Procedures:
1. Type MASM at the cursor position of the DOS prompt. Press Enter key.
2. Type P1B.asm (assembly) and press Enter key
3. Type P1B.obj (object) and then Press Enter key
4. Type P1B.lst (list) and press Enter key.
5. Press Enter key
(l) You are back to the DOS prompt. Your assembly program has already been converted
into machine codes and the codes have been saved in the path: c:\mda8086\P1B.lst.
Show the error messages to the teacher if any. Remember that there should not be any
error in the program. If there are errors, take help from the teacher to correct these
errors and then and go to Step-k. After error free assembling go to Step-m.
(m) Open the P1B.lst file in the following ways to see its contents:
The Procedures:
1. Type ‘EDIT’ at the DOS prompt. And then press Enter key.
2. Press Alt key and then press Enter key.
3. Choose ‘Open...’ from the menu using the arrow keys. Press Enter key.
4. Use ‘tab’ key and ‘arrow’ key to choose the file, P1B.lst from the menu. Press Enter.
5. Now the machine codes of your program are in the screen.
(n) Look at the machine codes of your program on the screen. Compare these codes with
the machine codes of Table-B of Task-1B.4. Write down the codes where they differ.
(o) Look for the jumper ‘P1’ (Fig-1B.5) or switch ‘KIT/PC’ of the MDA-8086 trainer. Bring
the jumper at the ‘Local Monitor’ or KIT position.
437
Jumper Position
P1 at: Serial Monitor
GND +5V
Jumper Position
at: Local Monitor
538
438
4. Power down and Power up the MDA-8086 trainer. Press the RESET key of the trainer to
get the prompt message on the screen of the IBMPC.
* * 8086 Monitor 9.5 * *
* * Midas 335-0964/5 * *
8086> _
5. To bring the IBMPC into DOS mode, press Alt and hold and then press X key. And then
press the Enter key.
6. The IBM-PC in the path: c:\mda8086> _
7. Now, convert the P1B.obj (object) file into P1B.abs (absolute) file for onward transmission
to the trainer. Type LOD186 at the cursor position of the DOS prompt. And then press
Enter key. Answer as follows:
(a) Type T1B.obj
(b) Type c:\mda8086\P1B.abs
(c) press Enter key
The conversion is completed with the message LOAD COMPLETED and the PC comes to the
following DOS path:
440
Task-1B.14 Software Features of MDA-8086
A: Resident Monitor Program
1. Allows data entry, edit into RAM locations [Word operations are not available]
2. Allows Program Execution
3. Allows data entry, edit into Registers locations
4. Allows Debugging a Faulty Program (Single Stepping)
5. Does not contain any data conversion algorithms like:
BCD-to-Binary, Binary-to-BCD, Multiplication, Division, BCD-to-ASCII
B: Serial Monitor Program
Allows downloading program/data codes from the IMB-PC to the MDA-8086
C: Example Programs
A disk accompanying the trainer contains a good number of example programs.
Taks-1B.15 Memory Space and Port Space Organization of MDA-8086
FFFFF
FFFF FFFE
ROM
F0000
EFFFF
Useable after Decoding
10000 (00)26 IO CON10
0FFFF (00)24 IO CON10
Reserved (00)22 IO CON10
User-3
Extra Segment
RAM
05000
04FFF Space for
03000 Data Segment
02FFF Space for
01000 Code Segment
00FFF (00)12 8259: DR
Scratch Pad (00)11 SPEAKER: DR (00)10 8259: CR
00F00 (00)0F 8253: CR
00EFF (00)0D 8253: TC-2
Data Structure (00)0B 8252: TC-1 (00)0A 8251: CR/SR
00400 (00)09 8253: TC-0 (00)08 8251 : DR
003FF
Interrupt (00)05 (00)04 LCDDR
Vvector Table (00)03 (00)02 LCDSR
00000 (00)01 KBD DR/FR (00)00 LCDIR
545 545
441
Task-1B.16 Component Layout of MDA-8086
442
Figure-1B.8: Component Layout Diagram of the MDA-8086 System
Task-1.17 Schematics of the MDA-8086 Learning System
443
444
445
446
447
448
Experiment – 2
Familiarization with Assembly Instructions of 8086 Microprocessors
by Adding Two 8-bit Unsigned Hexadecimal Numbers
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-2.1 Theory
When two 8-bit unsigned numbers are added, there may be a generation of carry, which is
automatically stored into the C-bit (Carry Bit) of the flag register of the 8086. For example:
addition of the numbers FFh and 10h produces the result ‘1 0Fh’. The upper part of the result is
‘Single Bit’, which is accommodated by the C-bit and the lower part ( 8-bit) of the result is in the
al-register.
Task-2.2 Data Structure
A data structure clearly indicates the storage locations (memory locations or register locations) of
the input data (input numbers) and the output data (result). A detailed and cleaned data
structure helps a lot for writing error-free assembly instructions for the solution of a problem.
The data structure for our present addition problem is given below in Fig-2.1. Here, we have
assumed that:
i. The input numbers can have the range: 00h - FFh
ii. The 1st number (data1) is available via memory location 03010h and the 2nd number is available
via memory location 03011h.
iii. The Lower part of the result in memory location 04000h and the Upper part (accumulated carries)
of the result is in location 04001h.
Expanded Data Segment Memory(DSM)
FFFFF = F000:FFFF
Output
03012 = 0000:3012
03011 = 0000:3011 Data2=F7
03010 = 0000:3010 Data1= 21 Inputs
03001 = 0000:3001
03000 =0000:3000
00000 = 0000:0000
608
Figure-2.1 : Memory Based Data Structure for Adding Two Unsigned Hexadecimal Numbers
1/Expt-2
Task-2.3 Pseudo Code for Addition
START: nop
L1: Initialize based address of DSM
Initialize initial value for the bx-pointer to point locations in DSM
0000h → dsr
3000h → bx
L2: Read data1 (say 21h) from the memory location 03010h of DSM
Read data2 (say F7h) from the memory location 03011h of DSM
al ← (03010h)
ah ← (03011h)
L3: Add the two numbers that have read from external memory locations
al + ah → c, al ; result is C-bit and al-register
L4: If (C-bit = LH)
Gto L7 and save result as 01XX in locations 04000h and 04001h.
L5: C-bit = LL, Save result as 00XX in locations 04000h and 04001h.
al → 04000h ; lower 8-bit of result
00h → 04001h ; the C-bit as 00h
L6: Halt
L7: al → 04000h ; lower 8-bit of result
01h → 04001h ; the C-bit as 01h
Goto L6
L1:
Initialize:
Based Addr of DSM
Pointer Register
L2:
(03010) --> al
(03011) --> ah
L3:
al + ah --> c, al
L4:
Y L 7:
Carry = 1
?
al ---- > 04000h
L5: N
01 –Æ 04001h
al --- > 04000h
00 –Æ 04001h
L6:
Halt
2/Expt-2
Task-2.5 Write 8086 Assembly Codes for the Pseudo Codes of Task-2.3
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
START: nop
L1: mov ax, 0000h ; dsr cannot be directly loaded
mov ds, ax
mov bx, 3000h
L2: mov al, BYTE PTR ds:{bx+10h} ; data1 is read
mov ah, BYTE PTR ds:{bx+11h] ; data2 is read
L3: add al, ah ; result in : c, al
L4: jc L7 ; jump to L7 if carri bit = LH
L5: mov BYTE PTR ds:[bx+0100h], al ; lower 8-bit of result
mov BYTE PTR ds:[bx+0101h], 00h ; no carry; so 00h is saved
L6: hlt
L7: mov BYTE PTR ds:[bx+0100h}, al ; lower 8-bit of result
mov BYTE PTR ds:[bx+0101h], 01h ; there is carry; so save 01h
jmp L6
MYCODE ENDS
END START
Task-2.6 Assembling, Downloading, Executing and Seeing Results for Codes of Task-2.5
1. Open DOS screen in the path MTK8086 (or MDA8086) and type the assembly codes of Task-2.5.
2. Save the source codes as: P2.asm
3. Exit the DOS screen.
4. Assemble the program P2.asm to create the following files:
i. P2.obj
ii. P2.lst
5. After error free assembly, open the text file P2.lst file and get familiar with what it contains. The list
(lst) file allows us to find the sources of errors when the file P2.asm is not correctly assembled.
6. Close the P2.lst file.
7. Create P2.abs file by processing the P2.obj file with the help of LOD186.
8. Open the text file P2.abs to get familiar with its format. You will get familiar with the structure of this
file in Chapter-7. The P2.abs file contains the binary codes of the file P2.obj along with some other
information. The P2.abs file is the only text (ASCII) format that can be transmitted form the IBMPC to
the RAM of the trainer using the COM1 port of the IBMPC.
9. Download the P2.abs file from the IBMPC to the trainer starting at RAM location 0000:1000. For
downloading procedures, see Experiment-1A for Microtalk-8086 and Experiment-1B for MDA-8086.
10. After downloading, enter the input data1 and data2 into the specified memory locations of the DSM
of Fig-2.1. See relevant steps of Experiment-1A or 1B to open memory locations and enter the data.
11. Execute the downloaded program.
12 Open the output memory locations of the DSM to see the result.
Task-2.7 Validity Check of Program P2.asm
Check that the program P2.asm provides correct results for the following pair of input numbers:
i. FFh and FFh ii. CDh and 25h iii. 00h and 00h iv. 01h and 00h
3/Expt-2
Task-2.8 Adding Three 8-bit Unsigned Numbers
578bc
Entry
START:
L1:
(03010) --> al
(03011) --> ah
(03012h) --> dl
L2:
al + ah --> c, al
L3:
Y L8:
Carry = 1
?
L3A: N 01h ----> 04001h
L4 :
al + dl ---> c , al
L5:
Y L 9:
Carry = 1
L5A: ?
N 01h+(04001h)--->04001h
L6:
L7:
Halt
Procedures:
1. Draw memory based data structure for the input/output data of the Flow Chart of Fig-2.3.
2. Convert the Flow Chart of Fig2.3 into Pseudo Codes.
3. Convert the Flow Chart of Fig2.3 into 8086 assembly codes. And save as P2B.asm
4. Assemble the P2B.asm to get P2B.obj, P2B.lst files.
5. Process P2B.obj file to get P2B.abs file.
6. Download P2B.abs file into the trainer.
7. Enter three 8-biitnumbers into the specified input memory locations of the DSM
8. Execute the program at the address specified by the ORG directive in the P2B.asm program.
9. Open the output memory locations of the DSM and check that they contain correct result for the
given input numbers.
4/Expt-2
Experiment – 3
Familiarization with Assembly Instructions of 8086 Microprocessors
by Multiplying Two 8-bit Unsigned Hex Numbers by Repetitive Additions
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-3.1 Theory
In unsigned number system, all bits of a given binary number carry positive positional values. In
signed number system, the MS-bit of the given number bears negative positional values and all
other bits carry positive positional values. In 80x86 architectures, the negative numbers are
represented using 2’s compliment form and follows different ways while performing
multiplication process on unsigned and signed numbers. In this experiment, we will be focusing
on the multiplication of unsigned binary numbers.
The two 8-bit unsigned numbers data1 and data2 could be multiplied together in two ways,
which are:
i. Using the mul instruction of the 8086 like:
mov al, data1
mov bl, data2
mul bl
ii. By Repetitive Addition Process (RAP) like:
Multiplier (MLPR) = data1
Multiplicand (MPLC) = data2
Product = add MLPC with initial partial result (IPR = 00h) cumulatively
for as many times as the MLPR is.
We intend to practice RAP method for multiplication in order to get familiar with the basic
instructions that the MPU carry out to multiply numbers. In practical application, while dealing
with large numbers (For example: computing Cost from Product Rate and Weight in Chapter-7),
we will be using the mul instruction.
Expanded Data Segment Memory(DSM)
Task-3.2 Data Structure FFFFF = F000:FFFF
Let us assume that we have the following
two numbers to multiply. Memory Location Content Table
03012 = 0000:3012
03011 = 0000:3011 MLPC
03010 = 0000:3010 MLPR Inputs
00000 = 0000:0000
12
1/Expt-2
Task-3.3 Pseudo Code for Addition
START: nop
L1: Initialize based address of DSM
Initialize initial value for the bx-pointer to point locations in DSM
0000h → dsr
3000h → bx
L2: Read MLPR and keep in al-register
Read MLPC and save in ah-register
al ← (03010h) ; al = MLPR
ah ← (03011h) ; ah = MLPC
cl ← 00h (IPR = 00)
00h → ch (Ccounter)
L3: cl + MLPC → C, cl ; multiplication process begins on RPA method.
L4: if (Carry = 1)
Goto L9
L5: MLPR- 01h → MLPR
L6: if (MLPR !=0)
Goto L3
L7: Result Lower Byte (Rlbyte) → 04000h
Result Upper Byte (Rubyte) → 04001h
L8: halt
L9: Ccounter + 01h → Ccounter
Goto L5
Task-3.4 Draw Flow Chart for the above Pseudo Codes and show it to the teacher.
Task-3.5 Write 8086 assembly codes in your Lab Khata for the above pseudo codes and show
to the teacher.
Task-3.6 Carry out the following steps:
a. Save the assembly codes as P3.asm with ORG at 2500h.
b. Assemble P3.asm to get P3.obj and P3.lst files.
c. Process p3.obj file to get p3.abs file.
d. Download P3.abs file into the RAM of the trainer.
e. Enter the MLPR and MLPC into the specified memory location of the DSM using the
keyboard of the trainer.
f. Execute the downloaded program.
g. Open the output memory locations and check that they contain correct result for the given
numbers.
h. Check the validity of the program P3.asm by giving different numbers for the MLPR and
MLPC.
Task-3.7 Check that the execution of the following codes (P3B.asm) provide the same result
as has been provided by the program P3.asm.
2/Expt-2
3/Expt-2
Experiment – 4
Familiarization with the Procedures of Programming the 8255 PIO Controller
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-3.2 Get Familiar with the Bus-structured Diagram of 8255 PIO Controller
See Fig-4.3 (b) of this book.
If you are using MicroTalk-8086 trainer, then performs the Tasks-3.3 to 3.6. If you are
using MDA-8086 trainer, then start from Task-3.7.
PCR: 3604h
A A PBR: 3602h
PB7
D7- D0 D LED15
LED0
PA0
CR
3606h
1/Expt-2
L7: Read result from the DSM of experiment-2.
mov cx, BYTE PTR [bx+0100h]
L8: Send the lower byte of into PAR
Send the upper byte of result into PAB
mov al, cl
mov dx, PAR
out dx, al
mov al, ch
mov dx, PBR
out dx, al
L9: hlt
3. Assemble the program P4.asm and then download the P4.abs file.
4. Enter 45h and FCh as input numbers via the memory locations of the DSM of Experiment-2.
5. Execute the program and check that the LEDs show correct result.
6. Check the functionality of the program giving various sets of input numbers.
Task-3.6 Detect a Particular Bit (PC0 for LH) via PCR and then Blink PA0 for 10 Times
1. Use a telephone hook up wire and connect PC0 at LL.
2. Open file P4B.asm and save as P4C.asm
5. Read PCR
6. If (PC0 != LH)
Goto Step-5
2/Expt-2
Task-3.7 8255 Programming using MDA-8086 Trainer
The following 8086-8255-CA7SDD interface circuit of Fig-4.2 has been taken and redrawn from
the MDA-8086 manual.
A .M-IO/ 06 CS/
A2 08 A1
A1 09 A0
PCR (1Dh)
RST 35 RST
+5V 26 Vcc
0V 07 GND
CR (1Fh)
+5V
538
START: nop
L1: Set direction of fixed port PAR as output. Consult Section-4.2 (a) of
this book for Control Byte.
mov al, 80h
Out CR, al
mov ah, 07h ; Counter for 7 time blink
L2: mov al, CA5 ; declare CA5 (Common Anode Code of 5) by EQU
out PAR, al
call TDEL ; Insert time delay to see the character
L4: dec ah
jnz L2
3/Expt-2
L5: mov bx, 0400h ; blinking done; now going to prompt
mov WORD PTR [bx], 0000h
mov WORD PTR [bx+02h], 0F000h
jmp DWORD PTR [bx] ; control transfers at F000:0000= F0000h
TDEL: mov cx, 0FFFFh
ADEC: loop ADEC
ret
MYCODE ENDS
END START
Task-3.9 Draw Flow Chart for the ASM Codes of Section-3.8 and show it to the teacher.
Task-3.10 Ignite the LED, G00 of the following interface circuit of Fig-4.3.
[About Dot Matrix LED] Let us have a look on the component side of the MDA-8086 trainer and we find
that there is an 8-by-8 ‘Dot Matrix LED (DOTLED)’. Each dot of the device contains two separate common
cathode type ‘Light Emitting Diodes’ of RED and GREEN colors. This two-diode structure has been
depicted in Fig-42.1. Thus there are in total 64 LEDs. These diodes are connected across rows and columns
in such a way so that a user program can access a single LED.
GM:624: 04/04 Col7
Col0
10 14 12 22
PC7 PC 0
1C h
A A PA: 18h
R ow7
PB7 25 R70 R77
D7-D0 D PA7 37 G70 G77
RD/ R/
WR/ W/
M-IO/ IO/ PB: 1Ah
CS/
CR R ow0
PB0 18 R00 R07
1Eh PA0 4 G00 G07
Solution:
L1: Set directions of the IO lines of Port-A, B and C as outputs [Cbyte (80h) → CR (1Eh)]
L2: All columns are OFF except Coolumn-0 [ 01h → Port-C]
L3: All port lines of Port-A, B are at LH except PA0 [ FFh → Port-B; FEh → Port-A]
L4: Done
4/Expt-2
5/Expt-2
Ahsanullah University of Science and Technology (AUST)
Dhaka-1212: Bangladesh
Recommended Course Outline
8086 Microprocessor, Interfacing and System Design
Faculty: Golam Mostafa, B.Sc.Engg (EE-BUET), M.Sc.Engg (CSE-BUET), PTrng (UK, USA), EX-BCIC, GEC and Schlumberger, Assoc Prof. AUST
Week Lecture Topics Quiz Lab Works using
MicroTalk-8086 and MDA-8086
1–4 1 – 12 Chapter - 1: Fundamental Concepts 1 Experiment – 1A, 1B
(12) (a) Basic Tasks of a MPU and Building Blocks of a MPU-based System; Experiment – 2
(b) RAM Structure, Data Read from a RAM Location, Development of Pseudo Code and Experiment - 3
Assembly Code to accomplish Data Read/Write Operation with Memory Locations.
(c) Use of Data Structure, Pseudo Code, Flow Chart and ASM (assembly) Instructions to Program Selected Exercises from Ch-1
8086 for: (i) Adding two 8-bit Hexadecimal Numbers, (ii) for Multiplying two 8-bit
Hexadecimal Numbers by Repetitive Additions;
(d) Data Read/Write Operations with Fixed and Variable Ports.
5 13 - 15 Chapter - 2: Architecture 1 Experiments: Same as Above
(3) (a) Physical Pin Diagram, Pin Classification, Bus-structured Diagram. Selected Exercises from Ch-2
(b) Internal Register Set, Function of Flag Register.
(c) Memory Organization showing ODD/EVN Banks, Truth table of RD/, WR/, M-IO/, BHHE/, A0.
6 16 - 18 Chapter – 3: Instruction Set 1 Experiments: Same as Above
(3) (a) Definitions and Classifications of Instructions, Addressing Modes. Selected Exercises from Ch-3
(b) Various Format of JMP and CALL Instructions.
7- 8 19 - 24 Chapter – 4: IO Controller Programming 1 Experiment – 4
(6) (a) Parallel IO Programming using 8255, LCD Display System and Programming. Experiment – 5A
(b) Keyboard and CC7SDD Programming using 8279, Serial IO Programming using 8251 Selected Exercises from Ch-4
9 25 - 27 Chapter – 4: Interrupt Structure 1 Experiment – 6A, 6B
(3) (a) Meaning of Interrupting the CPU, Events that occur during Interrupt, Interrupt Pins of 8086, IPD Selected Exercises from Ch-5
(b) Conditions to be satisfied before Interrupt, Use of ITC code to Know Beginning Address of ISR.
(c) Use of SSM and SP to save/retrieve Exit Data during Interrupt, RET and IRET Instructions.
10 - 11 28 - 33 Chapter – 6: Data Conversion Algorithm 1 Experiment – 7
(6) (a) 2s-Complemet Code, BCD2BIN Conversion by (i) Counting Rule (ii) by Horner Rule. Experiment – 8, 9
(b) BIN2BCD Conversion by (i) Counting Rule (ii) by Horner Rule. Selected Exercises from Ch-8
(c) Rules to Adjust Incorrect BCD, daa Instruction
12 34 - 36 Chapter – 7: System Design (8086 Based Digital Weighing Machine: DWM) 1 Experiment - 10A, 10B
(3) (a) Block Diagram of an 8086-based DWM, Weight Acquisition, Multiplexed ADC, Rate Acquisition Selected Exercises from Ch-7
(b) Cost Computation Flow Chart, 16-bit x 16-bit Multiplication
13– 14 37 - 42 Chapter – 8: Microcontroller 1 Experiment – 10A
(6) (a) Definition of MCU, Physical Pin of 89S51, Block Diagram showing Internal Resources Experiment – 10B
(b) Block Diagram of Port-mode, Mixed-mode and Bus-mode Operation Selected Exercises from Ch-8
(c) Instruction Set, Block Diagram of 8051-based (i) DWM (ii) RTC, (iii) CARMET , (iv) PENERMET
Text Book : 8086/Microprocessor/Interfacing and System Design/using MicroTalk-8086 MPU Learning/Dev. System/ By: Golam Mostafa
Reference Book : Microprocessors/Interfacing/ By: Douglas V. Hall: McGraw-Hill Book Company
Lab Book : 8086 Microprocessor/Laboratory Experiments Manual/ using MicroTalk-8086 and MDA-8086 Trainers/ : By: Golam Mostafa
Experiment – 5A
Familiarization with the Procedures of Interfacing
the Text Mode LCD Panel with MicroTalk-8086 Trainer
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-5A.1 Familiarization with the Architecture and Working Principles of Text LCD Panel
See Section-4.4 (a) of this book.
Task-5A.2 Familiarization with the Instruction Set of 2-Line LCD Panel
See Section-4.4 (c) of this book.
Task-5A.3 Familiarization with the Connection of LCD Panel with MicroTalk-8086 Trainer
A LCD panel can be interfaced with the 8086 buses using the existing hardware of the MicroTalk-
8086 trainer. The connection diagram is shown below in Fig-5A.1. The base address for the
registers of the LCD is taken from the decoded SEP2/-pin of the MicroTalk-8086 trainer. The
SEP2/-pin assumes LL-state for any 16-bit even port address that is chosen from the band 3E00h
– 3FFEh and is asserted on the 8086 bus.
DP10 DP1F
D7
D6
D5
D4
D3
D2
D1
15
16
9
8
7
1
AD7 +5
AD6
AD5
AD4 T o See at Dark
AD3
AD2
AD1
AD0
A2
A1
0V R1:1k5 Viewing Angle
+5V
0V
0V
+5V 6
0V 5
SEP2/: 3E00h - 4
0V 3 Y2/ 13 2
3
RD/ 2 Y1/ 14 1
WR/ 1 Y0/ 15
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
1/Expt-5A
Operational Truth Table-1:
Function 8086 Instruction Signal Activities
WR/ RD/ E A2 A1
Write into Instruction Register: LCDIR (3E00h) out LCDIR, al 0 1 1 0 0
Read from Status Register: LCDSR (3E04h) in al, LCDSR 1 0 1 1 0
Write into Data Register: LCDDR (3E02h) out LCDDR, al 0 1 1 0 1
From the above operational truth table, we can easily verify that the addresses assigned to the
registers are indeed correct! When the address bits A2A1 = 00, the Instruction Register (because
D-I/=LL) is selected for write (because R-W/=LL) operation. The decoder has been designed in
such way so that the E-pin of the LCD assumes LH-state while the 8086 asserts LL signal on its
WR/-pin during the execution of the out LCDIR, al instruction.
Similarly, when the address bits A2A1=10, the Status Register is selected for read (because R-W/
= LH) operation. For address bits A2A1=01, the LCDDR register is selected for write operation.
2/Expt-5A
Task-5A.5 Show the following Message on the Center of the LCD Panel
***Chittagong***
Assemble the following program (P5A5.asm), download it and then execute. The LCD should show the
message. Before sending any data to LCD, we must insert some fixed time delay by calling the BUSY
subroutine. The Time Delay is required to allow the LCD for digesting the last data byte written into it.
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
LCDIR EQU 3E00h
LCDSR EQU 3E04h
LCDDR EQU 3E02h
START: nop
L3: mov si, OFFSET MSG ; knowing how far the message Chittagong is!
mov bx, 0000h ; pointing the 1st character (C) of the message
MYCODE ENDS
END START
3/Expt-5A
Task-5A.6 Instruction Set of LCD
4/Expt-5A
Experiment – 5B
Familiarization with the Procedures of Programming
the Text Mode LCD Panel using MDA-8086 Trainer
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-5B.1 Familiarization with the Architecture and Working Principles of Text LCD Panel
See Section-4.4 (a) of this book.
A2 4 D-I/
A1 5 R -W /
+5V 2 Vdd
Viewing
VA1 Angle 3 VL
10k
0V 1 Vss DP1F DPF
1/Expt-2
Task-5B.4 Display Character A at DP0 Position of Top Line of the LCD
Convert the following Text Codes into ASM code. Save the program as P5B4.asm. Assemble the program,
download it and execute it. Check that the LCD shows the desired character.
1. Initialize the LCD Panel by the codes of Section-4.4 (d) of this book.
2. Set the cursor position at DP0 of Top Line by sending Cbyte-7 [see Instruction Set at Section-4.4 (c)].
3. Collect ASCII code of A from Section-4.4 (e) of this book and send it into LCDDR.
5. The character A should appear on the LCD.
Task-5B.5 Show the following Message on the Center of the LCD Panel
***Ahsanullah***
***University***
Convert the following pseudo codes into ASM codes and save as P5B5.asm. Assemble the program,
download it and then execute. The LCD should show the message. Before sending data to LCD call TDEL.
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
START: nop
L1: Initialize the LCD
L2: Set the Cursor Position at DP0 of Top Line
L3: Get the OFFSET of the MSG1 (***Ahsanullah***) into bx-register
Get the displacement of the characters if MSG1 into si-register.
mov bx, OFFSET MSG1
mov si, 0000h ; displacement of the 1st character of MSG1
st
L4: Collect the ASCII code of 1 character from MSG1 and send it to LCD
mov dl, BYTE PTR cs:[bx+si] ; MSG1 is in the current Code Segment
L5: Check that the character so read is not the end-of-MSG1 character
cmp al, 00h
jz L6 ; end-of-MSG1 character
call BUSY ; to see that LCD is ready
mov al, dl
mov LCDDR, al
inc si ; ready to read next character of MSG1
jmp L4
L6: Set the Cursor Position at DP0 of Bottom Line
L7: mov bx, OFFSET MSG2
mov si, 0000h ; displacement of the 1st character of MSG1
st
L8: Collect the ASCII code of 1 character from MSG2 and send it to LCD
mov dl, BYTE PTR cs:[bx+si] ; MSG1 is in the current Code Segment
L9: cmp al, 00h
jz L10 ; end-of-MSG2 character
call BUSY ; to see that LCD is ready
mov al, dl
mov LCDDR, al
inc si ; ready to read next character of MSG1
jmp L7
L10: hlt
MSG1 DB ‘***Ahsanullah***’, 00h ; 00h marks the end of MSG1
MSG2 DB ‘***University***’, 00h
TDEL: mov cx, 00FFh ; fixed time delay given to LCD to digest the last
ADEC: lopp ADEC ; character written inti it.
ret
MYCODE ENDS
END START
2/Expt-2
3/Expt-2
Experiment – 6A
Familiarization with the Functionality Check
Of the NMI-interrupt of 8086 using MicroTalk-8086 Trainer
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-6A.1
Get familiar with the following circuit, which will be used for functional check of the NMI-
interrupt of the 8086 microprocessor.
U2 : 8086 U23: 8255 LED15… ...LED8
31 INTA/
PBR:3602h
+5V K2 18 8
CS/
INTR
+5V K1 17 NMI B B
PAR:3600h
R1
R2
8
CR:3606h
0V
LED7…...LED0
MPU PIO
1406x : GM: 1/2008
Task-6A.2
1. Write ASM code for the following Main Line Program (MLP). Save it as: mlpnmi.asm
2. Download it into the code area starting at 01000h of the MicroTalk-8086 and test it.
MLP = To blink LED15-LED8 of Fig-6A.1 continuously.
START1: nop
ML1: Cbyte → CR ; to set direction of PBR, PAR as output
ML2: Ignite LED15-LED0
Insert Time Delay by calling the SUT TDEL1
ML3: Extinguish LED15-LED8
Insert Time Delay by calling TDEL1
ML4: Goto ML1 ; repeat the cycle
TDEL1: load cx-register with FFFFh
Keep decrementing until cx = 0
Return from SUR
Task-6A.3
1. Reset the trainer.
2. Write ASM codes for the following ISRNMI (Interrupt Subroutine due to NMI Interrupt).
Save it as: isrnmi.asm
1/Expt-6A
3. Download it starting into the code area of MicroTalk-8086 starting at 02000h.
ISRNMI = To blink LED0 only for 7 times.
START2: nop
ISR1: set direction of PAR and PBR by sending Cbyte into CR
Mov ah, 07h ; counter of 7
ISR2: LH → LED0
Call TDEL2
ISR3: LL → LED0
Call TDEL2
ISR4: dec ah
Jnz ISR2
; ISR5: iret ; return from interrupt subroutine
hlt
TDEL2: mov cx, 0FFFFh
AGND2: Loop AGND2 ; again decrement
ret
Task-6A.4
1. Reset the trainer002E q
2. Write the following ASM lines at the top of the MLP under the label START1. These ASM
codes establish the link between the ISRNMI address and the ITC code of NMI-interrupt.
mov bx, 0000h
mov WORD PTR [bx+08h], 2000h ; Offset part of the ISRNMI address
mov WORD PTR [bx+0Ah], 0000h ; Segment part of the ISRNMI address
3. Reassemble the MLP. Down load the corresponding absolute file into MicroTalk-8086.
Task-6A.5
1. Reset the trainer.
2. Insert the following ASM lines at the top of the ISRNMI under the label START2. These lines
will reset the ‘Interrupting Device’. The interrupting device generates the IRQ-signal for
NMI-interrupt (Taks-6A.6).
mov dx, 0000h
in al, dx
3. Remove the comment directive (;) from the label ISR5 and keep the hlt instruction under comment.
3. Reassemble ISRNMI and download it.
Task-6A.6
1. Execute the MLP at 01000h by using the DOP key of the trainer.
2. Observe that the LED15-LED0 is blinking.
3. Take a telephone hookup wire (Jumper Wire) and insert its one end at J6-3 (KIRQ-pin).
Insert the 2nd end at J2-19 (NMI-pin). This wire will carry short pulse as an interrupt signal at
the NMI-pin of the 8086. The pulse will be generated when a key is pressed down on the key
pad of the trainer.
4. Gently hit a key on the keyboard of the trainer. Notice that LED15-LED8 is not blinking.
5. Observe that LED0 blinks for 7 times.
6. Observe that the MLP has resumed after a while.
7. Repeat the process by pressing any key on the keyboard of the trainer.
2/Expt-6A
3/Expt-6A
Experiment – 6B
Familiarization with the Functionality Check
Of the NMI-interrupt of 8086 using MDA-8086 Trainer
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-6A.1
Get familiar with the following circuit, which will be used for functional check of the NMI-
interrupt of the 8086 microprocessor.
8086 : U1 8255 : U29 CA7SD
A2 08 A1 PB0
MON
Key
A1 09 A0 0V
RST 35 RST
+5V 26 Vcc
0V 07 GND
CR (1Fh)
+5V
538
1/Expt-6B
Task-6A.3
1. Reset the trainer.
2. Write ASM codes for the following ISRNMI (Interrupt Subroutine due to NMI Interrupt).
Save it as: isrnmi.asm
3. Download it starting into the code area of MDA-8086 starting at 02000h.
ISRNMI = To blink LED11 only for 7 times.
START2: nop
ISR1: set direction of PAR and PBR by sending Cbyte into CR
Mov ah, 07h ; counter of 7
ISR2: LH → LED11
Call TDEL2
ISR3: LL → LED11
Call TDEL2
ISR4: dec ah
Jnz ISR2
; ISR5: iret ; return from interrupt subroutine
hlt
TDEL2: mov cx, 0FFFFh
AGND2: Loop AGND2 ; again decrement
ret
Task-6A.4
1. Reset the trainer.
2. Write the following ASM lines at the top of the MLP under the label START1. These ASM
codes establish the link between the ISRNMI address and the ITC code of NMI-interrupt.
mov bx, 0000h
mov WORD PTR [bx+08h], 2000h ; Offset part of the ISRNMI address
mov WORD PTR [bx+0Ah], 0000h ; Segment part of the ISRNMI address
3. Reassemble the MLP. Down load the corresponding absolute file into MDA-8086 trainer.
Task-6A.5
1. Reset the trainer.
2. Remove the comment directive (;) from the label ISR5 and keep the hlt instruction under comment.
3. Reassemble ISRNMI and download it.
Task-6A.6
1. Execute the MLP at 01000h (0000:1000) by using the GO key of the trainer.
2. Observe that the character 3 is blinking.
3. Gently press the MON-key of the trainer. This key applies a LH-signal on the NMI-pin of the
8086 (see Fig-6B.a). The pulse will be generated when a key is pressed down on the key pad
of the trainer.
4. Observe that the character 3 is not blinking.
5. Observe that LED11 blinks for 7 times.
6. Observe that the MLP has resumed after a while. If not, then multiple interrupts have
occurred due to de-bouncing of the MON-key.
7. Repeat the process by pressing any key on the keyboard of the trainer.
2/Expt-6B
3/Expt-6B
Experiment – 7
Converting BCD Number into Equivalent Binary
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-7.1
Converting Two-digit BCD number (range: 00 – 99) into equivalent BINary number (range: 00h
– 63h) using Counting Method (Slow Process).
1. Draw Input/Out Data Structure. Keep Input BCD at location 03010h and the Output Binary
at location 04010h.
2. Convert the following conversion Pseudo Codes into 8086 ASM codes and save as:
bcd2binc.asm.
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
START: nop
L1: Bring BCD into ah-register
Extract UPF
Mov al, 00h ; IPR1 = 00h
While (UPF !=0)
IPR1 + UPW → IPR1
L2: Bring BCD into ah-register
Extrcat TPF
Mov cl, 00h ; IPR2 = 00h
While (TPF !=0)
IPR2 + TPW → IPR2
L3: Binary = (IPR1 + IPR2) → 04010h
L4: halt
MYCODE ENDS
3. Assemble and down load the absolute program.
4. Enter the input BCD number as: 23 at location 03010h
5. Execute the program.
6. Open memory location 04010h and we must see 17.
7. Enter different values for the BCD and check that the program produces correct Binary.
8. If your are using the MicroTalk-8086 trainer, then insert additional codes at label L4 to see
only the data part of the following on the CC7SD as follows (download bcd2bin7.abs):
Input BCD at: DP0DP1
Output Binary at: DP6DP7
9. If you are using MDA-8086 trainer, then insert ASM codes at label L4 to see the following
message on the LCD panel as follows (download bcd2binl.abs):
Input BCD: DPE DPF positions of Line-1
Output BCD: DPE DPF positions of Line-2
1/Expt-7
Task-7.2
Converting 4-digit BCD number (range: (0000 – 9999) into equivalent BINary number (range:
0000h – 270Fh) using Horner Method (Fast Process).
1. Review the following Horner Rule foe conversion.
BCD = d3d2d1d0
= d3x103 + d2 x 102 + d1 x 101 + d0 x100
= (((d3)10 + d2) 10 + d1 ) 10 + d0
bx = BCD dx = IPBIN
538
4. Convert the following Pseudo Codes into ASM codes. Save as: bcd2binh.asm. Download
and execute it. The DSM locations: 04011h and 04010h would contain the Binary number.
L1: 0000h → dx (IPBIN)
mov bh, BYTE PTR [di+11h] ; getting the input BCD from DSM
L2: ; Extrcat d3
mov cl, 04h
shr bh, cl
call BINC ; Binary Computation
L3: mov bh, BYTE PTR [di+11h]
and bh, 0Fh ; getting d2
call BINC
L4: mov bh, BYTE PTR [di+10h]
mov cl, 04h
shr bh, cl ; getting d1
call BINC
L5: mov bh, BYTE PTR [di+10h]
And bh, 0Fh ; getting d0
call BINC
L6: mov WORD PTR [di+1010h], dx ; BINary number at: 04011, 04010
BINC:
mov ax, 000Ah
mul dx ; result at: dx, ax = 00, ax
mov dl, bh
add dx, ax
ret
2/Expt-7
Familiarization with the Architecture and Working Principles of Text LCD Panel
See Section-4.4 (a) of this book.
Task-5A.2 Familiarization with the Instruction Set of 2-Line LCD Panel
See Section-4.4 (c) of this book.
Task-5A.3 Familiarization with the Connection of LCD Panel with MicroTalk-8086 Trainer
A LCD panel can be interfaced with the 8086 buses using the existing hardware of the MicroTalk-
8086 trainer. The connection diagram is shown below in Fig-5A.1. The base address for the
registers of the LCD is taken from the decoded SEP2/-pin of the MicroTalk-8086 trainer. The
SEP2/-pin assumes LL-state for any 16-bit even port address that is chosen from the band 3E00h
– 3FFEh and is asserted on the 8086 bus.
3/Expt-7
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
From the above operational truth table, we can easily verify that the addresses assigned to the
registers are indeed correct! When the address bits A2A1 = 00, the Instruction Register (because
D-I/=LL) is selected for write (because R-W/=LL) operation. The decoder has been designed in
such way so that the E-pin of the LCD assumes LH-state while the 8086 asserts LL signal on its
WR/-pin during the execution of the out LCDIR, al instruction.
Similarly, when the address bits A2A1=10, the Status Register is selected for read (because R-W/
= LH) operation. For address bits A2A1=01, the LCDDR register is selected for write operation.
4/Expt-7
KJ: loop KJ
ret
Task-5A.5 Show the following Message on the Center of the LCD Panel
***Chittagong***
Assemble the following program (P5A5.asm), download it and then execute. The LCD should show the
message. Before sending any data to LCD, we must insert some fixed time delay by calling the BUSY
subroutine. The Time Delay is required to allow the LCD for digesting the last data byte written into it.
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h
LCDIR EQU 3E00h
LCDSR EQU 3E04h
LCDDR EQU 3E02h
START: nop
L3: mov si, OFFSET MSG ; knowing how far the message Chittagong is!
mov bx, 0000h ; pointing the 1st character (C) of the message
5/Expt-7
; send Cbyte4 (18h) into LCDIR
; send Cbyte5 (38h) into LCDIR
MYCODE ENDS
END START
Task-5A.6 Instruction Set of LCD
6/Expt-7
Experiment – 1A
Familiarization with Components Organization and the Operating
Procedures of the MicroTalk-8086 Microprocessor Learning/Dev. System
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put
Tick Mark (√ ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Procedures:
1. Collect the MicroTalk- 8086 trainer from the lab attendant.
2. Open the top cover of the trainer.
3. Look at the PCB (Printed Circuit Board) of the trainer for component layout (Task-1.13).
4. Now, on the PCB, locate the circuit designation U2. This is the 8086 microprocessor chip.
5. Look very carefully on the top of the U2-chip and you will find the inscription ‘8086’.
6. Locate the keyboard on the trainer. The keyboard interface controller is the chip, U24 (8279).
7. Locate the following output devices on the PCB of the trainer.
a. The LED15-LRD8, LED7-LED0. The interface controller of the LCD devices is U23 (8255).
b. The 7-segment display device, which has the circuit designation, DP0-DP15. These are of
common cathode type display devices. Let us agree to call it by the symbolic name
CC7SD. The interface controller for these devices is U24 (8279).
c. The 8x8 Bicolor dot matrix LED, DOT1. The interface controller is the chip U30 (8255).
8. Locate the RAM chips U11, U12 on the PCB. Bit capacity of each RAM is: 32x1024x8 (32Kbyte)
9. Locate the EPROM chips U9 and U10 on the PCB. These chips contain the Monitor Program
of the MicroTalk-8086 trainer. Bit capacity of each EPROM is: 32x1024x8.
1/Expt-1
Task-1.2 Familiarization with the Hardware Block Diagram of MicroTalk-8086
There are many more interface controllers on the PCB of the MicroTalk--8086, which we could
not describe in Task-1.1. The following Hardware Block Diagram of Fig-1.1 contains the total IO
scenario of the trainer. Complete schematics are attached at the end of this experiment.
609:GM:03-04
J6 J10 J5 J8
RS <-->TTL
U18, U19
6.144 MHz RxT TxT SMI
U29 J7
J6
CKG Display
22h-27h (20h)IR0 RxRDY PA PB PC PA PB PC
RST Addr Field Data Field
(21h)IR1 TxE 3000-31FE
CK RDY 1000-1FFE 2000-2FFE 3600-37FE 3800-39FE
DP0 DP2 DP4 DP6 DP8
CS/
ADC CS/ ADC CS/ ADC CS/ ADC CS/ ADC DP1 DP3 DP5 DP7
J5 J5
2/Expt-1
Task-1.3 Getting Familiar with Keyboard Layout of MicroTalk-8086 Trainer
Study the following template for the keyboard of the MicroTalk-8086 trainer. Also, give a quick
glance on the descriptions that relate to the functions of these keys.
D E F
DNLD
DOP EXA FRW
A B C
F2
AUT BKW CHG
7 8 9
F3
EXW EXB FLR
4 5 6
F4
CS PC FB
1 2 3
F5
IP AX AL
0 BKS
RST RST
PRT S/S
608
The 24 keys of the keypad may be classified into the following categories:
2. AUT (AUTo Increment): Command to enter data into memory locations on auto
incrementing the address field.
4. DNLD (DowN LoaD): Command the CPU to automatically initialize the ‘ROM-Based’
serial link routine prior to down loading the program code/data from the IBM-PC.
3/Expt-1
5. PC (Program Counter): Command to enter the starting address of the 1st instruction of user
program, which is to be single stepped. Also, this key works as a ‘home key’ to bring the
display showing the address of the instruction to be single stepped.
6. EXB (Examine Byte data): Command to examine/edit the content of one memory location.
8. FRW (FoRWard): Command to examine the contents of the next memory locations or next
Register or the next Port.
9. BKW (BacKWard): Command to examine the contents of the previous memory locations
or next Register or the next Port.
10. CHG (ChanGe): Command to alter the contents of memory locations or Registers or Ports.
11. PRT (PORT): Command to examine the content of a Port location (yet to be implemented)
12. FLR (FLag Register): Command to examine the contents of the flag register in hex format.
13. FB (Flag register in Bit form): Command to examine the contents of flag register in bit
format.
14. CS (Code Segment): Command to examine the content of the Code Segment Register. FRW
key should be used to examine the contents of the DS, ES and SS registers.
15. IP (Instruction Pointer): Command to examine the content of the Instruction Pointer
Register. FRW key should be used to examine the contents of the DI, SI, SP and BP
registers.
16. AX (AX register): Command to examine the content of the AX register, FRW key should be
used to examine the contents of the BX, CX, DX registers.
17. AL (AL register): Command to examine the contents of the AL register. FRW key should
be used to examine the contents of the AH, BL, BH, CL, CH, DL, DH registers.
18. BKS (BacKSpace): Command to correct typing mistakes in the address and the data field.
S/S (Single Step): Command the CPU to execute only one instruction during the single
stepping mode.
19. F2, F3, F4, F5 (Function Keys): Actions to be defined by the user.
C: Data Keys
Keys with labels: 0, 1,2,3,4,5,6,7,8,9,A, B,C,D,E,F are the hexadecimal data keys.
4/Expt-1
Task-1.4 Familiarization with the Operation of MicroTalk-8086 Trainer by Adding
Two Numbers.
In this task, we will learn the operation of the MicroTalk-8086 trainer. The learning involves:
1. Getting familiar with the ‘4’ memory segments, which the CPU uses during the execution of a
program. These are: (a) Code Segment Memory (CSM), (b) Data Segment memory (DSM) (c) Extra
Segment Memory (ESM) and (d) Stack Segment Memory (ESM). See Fig-1.3 (a) below.
2. Getting familiar with the procedures of entering program code/data into memory (RAM) locations.
3. Getting familiar with the procedures of executing a program, the code/data of which has already
been stored into memory (RAM) locations.
4. An example program will be taken to demonstrate the practice of the above steps.
5. The program is:
“Adding two 8-bit numbers and show the result on the ‘LED7 – LED0’ of the trainer.”
Procedures:
1. Assume that we have two numbers to add and these are: 2Ch and 47h. The expected result is:
73h (0111 0011). The input data must be kept in the ‘Data Segment Memory (DSM)’ of Fig-1.3
(b).
2. Let us use the keyboard of the trainer and deposit these two numbers into two memory
locations of the ‘Data Segment Memory (DSM)’. The particulars of the DSM are:
a. The Base Address is: 00000h
b. The Beginning Address of DSM is: 03000h
c. The offset (how far) of the beginning address of DSM from the Base Address is: 3000hs.
ALl Four Memory Segments of User-1 Expanded Data Segment Memory(DSM)
(0 8F FF = 0000:8FFF) FFFFF = F 000:FFFF
CSM Beginning
03001 = 0000: 3001
03000 =0000:3000
Address
01000 = 0000 : 1000) Base Addres
00000 = 0000: 0000
45
Figure-1.3 (a): Four Memory Segments Figure-1.3 (b): The Enlarged View of the DSM of Fig-1,3 (a)
3. Power on the trainer and then press the RST key. The display should show: 8086 CPU
4. Use the keypad of the trainer and deposit the input data 21h and F7h at the indicated memory
locations of the DSM of Fig-1.3 (b). The procedures of data entry are given in the next page.
a. Data1 (2Ch) will be kept at memory location: 03010h (0000:0310).
b. Data2 (47h) will be kept at memory location: 03011h (0000:0311)
5/Expt-1
Table-A
Procedures to Enter 21h and F7h into Memory Locations 03010h and 03011h
Sn. Press Key 7Seg Display Remarks
1 RST 8086 CPU Trainer is ready
2 EXA - - - - - Ad Address Field is opened to accept 20-bit memory address
3 030 030 - - Ad Three digits are entered for the Address Field
4 5 0305 – Ad Next digit but ‘Wrong’ for the memory address. (Typing Error)
5 BKS 030 - - Ad Typing error is corrected.
6 10 03010 Ad 20-bit address is entered. Now, the CPU is waiting to know if
Byte or Word examine is requested
7 EXB 03010 XX Display shows the 8-bit data of memory location: 03010h
8 CHG 03010 - - Data field is ready to accept new data
9 2C 03010 2C The data 2Ch has been stored in location: 03010h
10 FRW 03011 XX Address field shows the content of the next memory location
11 CHG 03011 - - Data field is ready to accept new data
12 47 03011 47 Data 47h has been deposited at location: 03011h
13 RST 8086 CPU Data entry done. The data are in the specified RAM locations.
5. Now, we need a program, which will bring the input numbers from DSM into the internal
registers of the 8086 for addition. The result will be shown on the LED7-LED0 of the trainer.
The result will also be deposited at memory locations 04000h of the DSM. Let us assume that
we have this program, which is listed below in Table-B.
Table-B
Label: Memory Assembly Instructions Machine Meaning
Location Codes
START: 01000 - nop - 90 ; must be here for the
L1: (0000:1001) - mov bx, 3000h - BB 00 30 ; bx Register is a pointer
mov al, BYTE PTR [bx+10h] 8A 47 10 ; 2Ch comes into CPU
mov ah, BYTE PTR [bx+11h] 8A 67 11 ; 44h comes into CPU
L2: 0100A - add al, ah 02 C4 ; data are added
L3: 0100C - mov BYTE PTR [bx+1000h], al 88 87 00 10 ; result is stored in DSM
L4: 01010 - mov ah, al - 8A E0 ; result is sent to LEDs
mov al, 80h B0 80
mov dx, 3606h BA 06 36
out dx, al EE
L5: 01018 - mov al, ah - 8A C4
mov dx, 3600h BA 00 36
out dx, al EE
L6: 0101E - hlt - F4 ; CPU is halted
6. Now enter the machine codes of the above Table-B in the ‘Code Segment Memory (CSM)’ of
Fig-1.4 of the next page. Note that:
a. The 1st byte of our program is ‘90’ and it must be stored at memory location: 01000 (0000:1000). The
1st byte of an instruction is known as ‘Operation Code’ or ‘Opcode’.
b. The next byte of our program is at label L2 and it is BB. The code will be stored in location 01001.
The operand part of this instruction has the data 00 and 30 and they would be stored in locations
01002 and 01003 respectively.
c. The next byte of our program is 8A it must be stored at memory location: 0000:1004. And so on….
6/Expt-1
d. Follow the steps of Table-A to enter the Machine Codes of the program of Table-B into CSM part of
memory. This time use the ‘AUT’ command to open the address field. In AUT mode, the data field
will automatically be opened and the address field would also be advance automatically.
Expanded Code Segment Memory(CSM)
FFFFF = F000:FFFF
01003 = 0000:1003 30
01002 = 0000:1002 00 Operand
01001 = 0000:1001 BB Opcode
Beginning 01000 = 0000:1000 90 Opcode
Address of CSM
00000 = 0000:0000
Base Addres
46
9. It is hoped that the program of Table-B has been executed correctly. Let us look for the result:
a. Look at the LED assembly of the trainer. The LED assembly should have the following ON/OFF
conditions: [‘Black Fill’ means ‘LH’ and ‘No Fill’ means ‘LL’].
LED Assemly
LED15 LED8
LED7 LED0
608
b. Reset the trainer. Open the memory location: 04000h of the DSM of Fig-1.3 (b). We will find
a data value of 73h. To open a memory location, follow the steps of Table-A.
7/Expt-1
Task-1.5 Execute the program of Table-B for the following set of data. Check that the LEDs
indicate the correct results and the memory location 04000h also contain the correct result.
Data1 Data2 Expected Result LED Status (LED7-LED0) Memory Content (03012h)
ABh 10h BBh 1011 1011 BBh
67h 89h F0h 1111 0000 F0h
FF FF 01FE 1111 1110 FE (01 is missing!)
CR (3606h)
PA R (3600h)
LD7
al ah
03012 73 ALU
03011 47
03010 2C
al
D LD0
D
03000
Result
8/Expt-1
The procedures:
1. Type cd \ and then press enter key. The screen shows: c:>_
2. Type d: and then press enter key. The screen shows: d:>_
3. Type cd mtk8086 and then press enter key. The screen shows: d:\mtk8086>_
4. Press Alt-key and then hit Enter-key to enlarge the screen.
(c) Type EDIT at the cursor position of the above DOS prompt. Press Enter key. As a result,
a screen appears called DOS Screen will appear.
(d) Type only the labels and the assembly instructions of Table-B of Task-1.4.
(e) Save the screen (what you have typed in the screen) with the file name of: P14.asm.
Save the file as: d:\mtk8086\P14.asm
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save As...’ from the menu using the arrow keys.
3. Now type the file name: P14.asm and then press Enter key.
(f) Type the following 3 lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT
ASSUME cs: MYCODE
ORG 1000h
(g) Type the following assembler statements at the end of your assembly program.
MYCODE ENDS
END START
(h) Update your file (P14.asm) in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save’ from the menu using the arrow keys.
3. Now press Enter key.
(i) Now leave the screen and come back to the DOS prompt in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Exit’ from the menu using the arrow keys and then press Enter key.
(j) Type cls and press Enter key for clearing up the screen.
(k) Now, convert the source codes of your program d:\mtk8086\P14.asm into machine
codes in the following ways: This is known as assembling.
The Procedures:
1. Type MASM at the cursor position of the DOS prompt. Press Enter key.
2. Type P14.asm (assembly) and press Enter key
3. Type P14.obj (object) and then Press Enter key
4. Type P14.lst (list) and press Enter key.
5. Press Enter key
(l) You are back to the DOS prompt. Your assembly program has already been converted
into machine codes and has been saved in the path: d:\mtk8086\P14.lst. Show the error
messages (if any) to the teacher. Remember that there should not be any error in the
program. If there are errors, take help from teacher and correct these and go to Step-k.
(m) Open the P14.lst file in the following ways to see its contents:
The Procedures:
1. Type ‘EDIT’ at the DOS prompt. And then press Enter key.
2. Press Alt key and then press Enter key.
3. Choose ‘Open...’ from the menu using the arrow keys. Press Enter key.
9/Expt-1
4. Use ‘tab’ key and ‘arrow’ key to choose the file, P14.lst from the menu. Press Enter.
5. Now the machine codes of your program are in the screen and they look like:
MYCODE SEGMENT
ASSUME cs:MYCODE
1000 ORG 1000h
(n) Pick up the machine codes of your program from the screen. Compare these codes with
the machine codes of Table-B of Task-1.4. Write down the codes where they differ.
(o) Power OFF and then ON of the MicroTalk-8086 trainer and then press the RST key.
(p) The 7-segmnet display of the trainer shows the following prompt message:
8086 CPU
(q) Use keyboard of the trainer and enter the machine codes of Step-n (P14.lst) in the CSM
starting at memory location. 0000:1000. Take help of the lab teacher to know the ways
of entering the differing codes in the CSM.
(r) Enter the data 2Ch at RAM location 0000:3010 and 47h at RAM location 0000:3011 of the
data segment memory.
(s) Execute the program at location: 0000:1000
(t) Observe that the LED7 – LED0 show the correct result of 73h (0111 0011).
(u) The Task-1.7 is well done.
Task-1.8 In this Task, we will transfer the machine codes of the Step-n of Task-1.7 from the
IBM-PC to the CSM of the MicroTalk-8086 trainer. This method is known as Down Loading. To
do it, we will be using the COM1 port of the IBM-PC. This method saves a lot of time while
developing a large program. We do not need to enter the data and codes manually in the
memory locations. The procedures are:
1. Power down the MicroTalk-8086 trainer. Connect the serial cable of the trainer with the
COM1 port of the IBM-PC.
2. Bring the IBM-PC in WIN98/WINXP mode.
3. Check that the MTK86COM1 interface is present in the Start menu and then goto Step-4.
Otherwise, install it from the MTK8086 folder. MTK86COM1 allows transferring Intel-Hex
formatted file from IBMPC into the RAM space of MicroTalk-8086 trainer.
10/Expt-1
4. Power up the MicroTalk-8086 trainer.
5. From the Start menu locate the MTK86COM1 interface and execute it. The following GUI
interface will appear on the screen.
10. Exit the screen and come to the DOS prompt of: d:\mtk8086> _
11. Go to the MTK86COM1 interface and follow the menu to transfer the P14.abs file.
12. Reset the MicroTalk--8086 trainer.
13 Enter 2Ch and 47h at memory location 03010h and 03011h of the DSM.
14 Execute at 0000:1000 using the DOP command of the trainer.
15 The LED7-LED0 will show the result.
11/Expt-1
Task-1.9 Down load the file U248279.abs and then execute it at: 0000:1000. Observe that the
CC7SD devices of the trainer shows: 0,1,2,3,4,5,6,7,8,9,A, B,C,D,E,F,0,1,2............
Taks-1.10 Structure of an Intel-Hex Formatted Frame
: 10 C100 00 003E9032002116101E110133C10ACD19 D4
(a) (b) (c) (d) (e)----------------------------> (f)
There are six fields in an Intel-Hex formatted frame as is shown above. The
meanings of these fields are given below:
2. The characters are received on software handshake basis. The trainer send
an acknowledgment code (06H) after receiving each character, The IBMPC
will send the next after getting the ACK code. If the ACK code is not
available within the timeout time, the IBMPC will terminate the
transmission session.
3. The trainer receives the data of caption (b) and computes the following
information:
Total information bytes as contained in the caption (e)
Total data bytes in the frame as contained in (b) to (f)
4. The trainer keeps receiving all the data bytes in a frame. The ASCII
codes of the received characters are shown at the DP0DP1 positions of the
trainer. After receiving a frame, the trainer does the following:
a. The ASCII codes of the frame are save in: 6080H –
b. The ASCII codes are converted to HEX and saved in: 60C0H-.
c. The CHKSUM is recomputed from the converted Hex and is
compared with the received CHKSUM as contained in the
caption (f)
d. If the CHKSUM agrees, the trainer saves the Hex data
stating at the address as contained in the caption (c).
e. The trainer then sends the ACK code to the IBMPC.
f. The cycle repeats with the reception and process of the
next data frames.
12/Expt-1
Task-1.11 Introduction to MicroTalk-8086 Trainer
The MicroTalk-8086 is a 16-bit ‘Microprocessor Learning/Development System’ based on Intel’s
8086 architecture. The trainer has been designed, developed and built in ‘Bangladesh’ by
‘Karighar Research and Development Center’ by a one-man team headed by ‘Golam Mostafa (the
author)’ during the period: 1992 – 2004. The author greatly acknowledges the hard labor and the
patience of ‘M. A. Sarker (author’s ex-student)’ for the preparation of the PCB under the Orcad-
EDA environment and the accumulation of the logistic support. The Address:
Manufacturer:
Karighar Research and Development Center
2/801: Eastern Morshed Apartment, 16/1-2, Segun Bagicha
Dhaka-1000, Bangladesh, Phone: 7161846, 01726-341559
Hardware Features:
A. Central Processing Unit Subsystem
1. 8086 Microprocessor running in Minimum Mode
2. ROM-based Composite Memories and Port Decoder
B. Memory Subsystem
1. 64 Kbytes of EPROM 2. 64 Kbytes of RAM
C: Interrupt Structure Subsystem
8259-Based 8-Channel Interrupt Priority Controller with Option for Cascading
D: Input/Output Subsystem
1. Keyboard: 8279 Based Keypad containing 24 keys. It Supports:
i. Data Lines, Scan Lines are available at Edge Connectors for further Interfacing
ii. Unused Row/Col Lines of the Keyboard are at the Edges for adding extra keys
2. Display: 7-Segment CC-type Display Unit containing 16 Digits
3. Parallel IO: a: Onboard 8255PIO, which interfaces:
i. 16 LED suitable for monitoring input/output data in Binary form
ii. Driver Electronics for Phase Stepper Motor
iii. The Port Lines are at the Edges Connectors for Data Input/Output
b. Onboard 82535PIO, which drives an 8x8 Bi-color Dot Matrix Led
4. Serial IO: 8251A-Based RS232 Serial Port. It is:
i. Interfaced with IBM-PC by a DB9 connector.
ii. Signals are available at the Edge Connector
5. ADC: ADC0804-Based Analog-to-Digital Converter.
6. DAC: AD558-Based Digital-to-Analog Converter.
7. Timer: 8253-Based 3-Channel Programmable Timer/Counter. All 9 Signals are at the Edges.
8. Prototyping: a. Edges (Edge Connectors. It supports). It supports:
i. The availability of all the signals that may be required to design a system
ii. Acceptance of Hookup Wiring for Circuit Experiments
b. 5.5” x 2.5” Bread Board
Software Features:
A: Resident Monitor Program
1. Powerful and Comprehensive Resident Monitor Program
2. Auto/Manual Data Entry for both Byte/Word Operations
3. Program Execution Capability
4. Forward/Backward/Change/Backspace Facilities
5. Byte/Word Examine/Edit Capability
6. Single Instruction Execution Capability for Program Debugging.
7. Registers Contents can be Examined and Changed.
13/Expt-1
8. Flag Register Contents can be Examined in Bit-form and Hex-form.
9. ROM-Based Test Routine for all the Onboard Peripheral Controllers
10. A good number of Ready Made Stand alone routines
11. A good number of Subroutines to Facilitate System Design
12. ROM-Based Data Conversion Algorithms like:
i. BCD-to-Binary Conversion (BCD2BIN) ii. Binary-to-BCD Conversion (BIN2BCD)
iii. Binary Multiplication BMULT) iv. Binary Division (BDIV)
v. BCD-to-Common-cathode Code (BCD2CC) vi. CCcode-to-BCD Conversion (CC2BCD)
vii. Scan Code-to-CCcode Conversion (SC2CC)
13. Complete Software that Converts the MicroTalk-8086 into a Digital Weighing Machine (DWM)
14. Serial Communication Link to down load Intel-Hex frames from IBMPC into the Trainer.
ROM
FFFF:0000 Start Up Location Can be Used
after
Decoding
F0000
4000
EFFFF 3FFE
Useable after Decoding Can be Decoded at
10000 Used SEP2 ( J1-5)
0FFFF after 3E00
Decoding
Reserved 3DFE
User-3
Decoded at
4x 2KByres SEP1 ( J1-6)
3C00
0D000 3BFE
0CFFF Decoded at
User-2
SEP0 ( J1-7)
Reserved 3A00
4x 4KByres 39FE
Shadow
09000 3806 CR of 8255: U30
3804 PC of 8255: U30
08000 Space for 3802 PB of 8255:U30
3800 PA of 8255:U30
07000 Stack Segment 37FE
Shadow
06000 Space for 3605 CR of 8255: U23
3604 PC of 8255: U23
User-1
14/Expt-1
Task-1.13 Component Layout of MicroTalk-8086
15/Expt-1
Figure-1.7: Component Layout Diagram of the MDA-8086 System
Task-1.14 Schematics of the MDA-8086 Learning System
16/Expt-1
Figure-1.8: CPU Subsystem
17/Expt-1
Figure-1.9: Composite Memory and Port Subsystem
18/Expt-1
Figure-110: Memory Subsystem
Print: P19_Expt1A.doc
DB[0:7]
U25
19 S[0:7]
1 2OE
U24 1OE DP1 DP2 DP4 DP5 DP6 DP7
DP0 DP3
D0 12 24 DB7 DB7 17 3 S7 S7 6 S7 6 S7 6 S7 6 S7 6 S7 6 S7 6 S7 6
D1 13 DB0 QA3 25 DB6 DB6 15 A8 Y8 5 S6 S6 p S6 1 p S6 1 p S6 p S6 p S6 p S6 1 p S6 1 p
1 1 1 1
D2 14 DB1 QA2 26 DB5 DB5 13 A7 Y7 7 S5 S5 g S5 2 g S5 2 g S5 g S5 2 g S5 2 g S5 2 g S5 2 g
2 2
D3 15 DB2 QA1 27 DB4 DB4 11 A6 Y6 9 S4 S4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f
4
D4 16 DB3 QA0 DB3 8 A5 Y5 12 S3 S3 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e
5
D5 17 DB4 28 DB3 DB2 6 A4 Y4 14 S2 S2 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d
7
D6 18 DB5 QB3 29 DB2 DB1 4 A3 Y3 16 S1 S1 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c
9
D7 19 DB6
DB7
QB2 30
QB1 31
DB1 DB0
DB0
2 A2
A1
Y2
Y1
18 S0 S0 10 b
a
. S0 10 b
a
. S0 10 b
a
. S0 10 b
a
. S0 10 b
a
. S0 10 b
a
. S0 10 b
a
. S0 10 b
a
.
cc cc cc cc cc cc cc cc
A1 21 QB0 74LS244 U27 S7SEGCC S7SEGCC S7SEGCC S7SEGCC S7SEGCC
S7SEGCC S7SEGCC S7SEGCC
A0 32 1 15 cc0
SL0 33 2 A Y0 14 cc1 3 3 3 3 3 3 3 3
SL1 34 3 B Y1 13 cc2 cc0 cc1 cc2 cc3 cc4 cc5 cc6 cc7
SL2 35 VCC C Y2 12 cc3 cc[0:7]
SL3 6 Y3 11 cc4
23 4 G1 Y4 10 cc5
BD 4 5 G2A Y5 9 cc6 DP8 DP9 DP10 DP11 DP12 DP13 DP14 DP15
IRQ G2B Y6 7 cc7 S7 S7 6 S7 6 S7 6 S7 S7 6 S7 6 S7 6
6 6
74LS138 Y7 S6 p S6 1 p S6 1 p S6 1 p S6 1 p S6 1 p S6 1 p S6 1 p
1
KIRQ U28 S5 g S5 2 g S5 2 g S5 2 g S5 2 g S5 2 g S5 2 g S5 2 g
2
3.072MHz PCLK 3 SL0 1 15 cc8 S4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f S4 4 f
4
CLK SL1 2 A Y0 14 cc9 S3 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e S3 5 e
5
37 SL2 3 B Y1 13 cc10 S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d S2 7 d
IORC/ 10 CN/ST SL3 C Y2 12 cc11 S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c S1 9 c
RESET 9 RD 6 Y3 11 cc12 S0 10 b . S0 10 b . S0 10 b . S0 10 b . S0 10 b . S0 10 b . S0 10 b
a
. S0 10 b .
36 RESET 4 G1 Y4 10 cc13 a a a a a a
cc cc
a
cc cc cc cc cc cc
AIOWC/ 11 SHFT 5 G2A Y5 9 cc14 S7SEGCC S7SEGCC S7SEGCC S7SEGCC S7SEGCC S7SEGCC S7SEGCC S7SEGCC
CS8279 22 WR G2B Y6 7 cc15
CS 74LS138 Y7 3 3 3 3 3 3 3 3
U26 cc8 cc9 cc10 cc11 cc12 cc13 cc14 cc15
7 KC7 cc[8:15]
5 Y7 9 KC6
4 G2B Y6 10 KC5
6 G2A Y5 11 KC4
VCC G1 Y4 12
3 Y3 13
2 C Y2 14
1 B Y1 15
38 KR0 74LS138 A Y0 K10 K11 K12 K13
RL0
39
RL1
1 DNLD D/DOP E/EXA F/FRW
RL2 K20 K21 K22 K23
2
RL3
5 F2 A/AUT B/BKW C/CHG
RL4 K30 K31 K32 K33
6
RL5 7/EXW 8/EXB 9/FLR
7 F3
RL6 K40 K41 K42 K43
8 KR7
RL7
F4 4/CS 5/PC 6/FB
0/PRT
RST1 BKS-S/S RST2
RES/
19/Expt-1
Figure-1.11: Keyboard and Display Subsystem
20/Expt-1
Figure-1.12: LED Assembly and Stepper Motor Interface Subsystem
21/Expt-1
Figure-1.13: Bicolor 8x8 Dot Matrix LED Display Subsystem
22/Expt-1
Figure-1.14: Serial Communication Subsystem
23/Expt-1
Figure-1.15: IPC, ADC, DAC and Timer Subsystem
24/Expt-1
Figure-1.16: Power Supply Subsystem
25/Expt-1
8086
Microprocessor
Laboratory Experiments Manual
Using MicroTalk-8086 and MDA-8086 Trainers
Golam Mostafa
Ahsanullah University of Science and Technology
Experiment – 10A
Conversion and Operation of MicroTalk-8086 Trainer
into a Digital Weighing Machine (DWM)
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-10A.1: [Aim of the Experiment] To get familiar with the procedures of converting the
MicroTalk-8086 microprocessor trainer into a Digital Weighing Machine (DWM).
Task-10A.2: [Converting the MicroTalk- 8086 Trainer into DWM] Let us carry out the following
steps to convert the MicroTalk-8086 trainer into a DWM (Digital Weighing Machine).
1. Look into the following block diagram of Fig-71.1, which could be used to represent the
MicroTalk-8086 based DWM. Load cell is shown in fig-71.2. Amplifier is shown in elsewhere.
713-04
CC7S Type Display of
MicroTalk-8086 Tr ainer
Load Cell Breadboard Weight Field Rate Field
Weight
+ Sense (Blue)
+ Excitation (Green) +5V
+ Output (Red) +
Output 20mV / 20Kg. Wt.
+ Output (White) -
- Excitation (Black) -5V
- Sense (Yello)
Load Cell
GM: loadcellcircuit323: 15/12/01: 714-04
Figure-71.2: Pictorial View of Load Cell Figure-71.3: Electrical Circuit of the Load Cell
1/Expt-10A
2. Assume that the ‘Load Cell’ is connected (Practically it is not connected). We will be
performing the load cell exercises in Experiment-7.2.
3. Also assume that the ‘Breadboard, the Instrument Amplifier (See Fig-72.1) and the ADC (See
Fig-72.2) are also present (Practically they not connected).
4a. Assume that the Load Cell has produced a signal of 12.37mV corresponding to 12.370kg of
loads. This signal has been amplified and digitized to upBCD format by the ADC. Also
assume that the WTupBCD (Weight as Unpacked BCD as: 01, 02, 03, 07 for 12.37 Kg) signals
have been acquired via the interface controller U23 (8255) and are saved into the following
four memory locations (Fig-71.4) of Table-T7 of the ‘DWM Data Structure (Fig-71.11).
For the weight of 12.370Kg, we have:
(05050) = 01 for 10kg
(05051) = 02 for 2kg
(05052) = 03 for 300 gm
(05053) = 07 for 70gm
05053 UpBCD Wt: 1/100 Goods
05052 UpBCD Wt: 1/10 upBCD
05051 UpBCD Wt: 1 T7
Wt
05050 UpBCD Wt: 10
6 We assume that the MicroTalk-8086 trainer contains the product cost computation routine
(See Fig-74.1) and it has already computed the cost by multiplying the weight and rate. Let us
assume that the COSTBCD (product Cost in Packed BCD Format) has been saved in the
specified memory locations of Fig-71.9. The COSTCC (Product Cost in CC-code Format) has
also been saved in the specified memory locations of Fig-7.10.
For the product cost of : Tk 345.74 (rate of Tk 27.95/kg x weight of 12.370kg), we have:
(05025) = 03 for Tk 0300
(05026) = 45 for Tk 45
(05027) = 74 for Paisa 74
05027 pBC D: 1/10, 1/100 Cost
05026 pBC D: 10, 1 BCD
05025 pBC D: 1000, 100 Field
Figure-71.9: Table Containing BCD Cost
For the product cost of : Tk 345.74 (rate of Tk 27.95/kg x weight of 12.370kg), we have:
(0500A) = 3F for digit-0
(0500B) = 4F for digit-3
(0500C) = 66 for digit-4
(0500D) = 6D for digit-5
(0500E) = 07 for digit7
(0500F) = 66 for digit-4
3/Expt-10A
GM:04/04: 632
COS T : 0 0 0 0 . 0 0
ASCII for 1/10 Wt
ASCII for .
Field
ASCII for 1 ASCII Table: T4
LCD Display
ASCII for 10 T4b
ASCII for :
5 93
05038 ASCII for W DP10
05037 ASCII for Blank
ASCII for Blank
DPF W : 1 2 . 3 7 0 R : _ _ . _ _
ASCII for 1/100
ASCII for 1/10
ASCII for . DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A DP1B DP1C DP1D DP1E DP1F
ASCII for 1
ASCII for 10 Cost
ASCII for 100
ASCII for 1000 Field
ASCII for : T4a
ASCII for T
ASCII for S
ASCII for O
0502A ASCII for C
05029 ASCII for Blank
05028 ASCII for Blank DP0
05027 pBCD: 1/10, 1/100 Cost
05026 pBCD: 10, 1
7-Segment
Field
Table: T3
and LCD
05024 Rate
05023 pBCD: 1/10, 1/100
05022 pBCD: 10, 1 Field
05021 pBCD: 1/10, 1/100 Wt
05020 pBCD: 10, 1 Field
0501F upBCD: X0 :1/ 100 DP15
upBCD: X0 : 1/10 Cost
upBCD: X0 : 1
upBCD: X0 : 10 Field
upBCD Table: T2
Task-10A.3: [Operating the MicroTalk-8086 as DWM: p713.asm] We may follow the steps as
outlined below: Take a hookup wire and short: J6-3(KIRQ) and J6-11 (IR2).
1 Connect the IBM-PC and the MicroTalk- 8086 trainer using the serial cable of COM1 port.
Apply power to the IBM-PC and the Microtalk-8086 trainer.
2 Now open the file p713.asm program from the path: c:\mtk8086\p713.asm. This is the
program, which converts the MicroTalk-8086 trainer into a DWM.
3 Assembly the program p713.asm. Convert it to p713.abs and down load into MicroTalk-8086.
4 Execute the downloaded program starting at location: 01000 (0000:1000).
5 Observe that the following message (Fig-71.12) appears at the 7-segment panel of the trainer.
715-04 CC7S Type Display of
MicroTalk-8086 Trainer
Weight Field Rate Field
DP1 DP3 D P6 D P8
D P0 D P2 DP4 DP5 DP7
1 2. 3 7 0 0 0. 0 0
0 0 0 0. 0 0
D P9 D P11 DP13 D P15
DP10 DP12 DP14
Cost Field
D P1 D P3 D P6 D P8
D P0 D P2 D P4 D P5 D P7
1 2. 3 7 0 _ _. _ _
0 0 0 0. 0 0
D P9 D P11 D P13 D P15
D P10 D P12 D P14
Cost Field
Figure-71.13: 7-Segment Display Panel after Pressing the Rate Entry Key ‘E’
5/Expt-10A
8 Enter the product rate of Tk 27.95 by pressing down the digits: 2 7 9 and 5. When the entry of
all the 4-digits are done, the display appears as Fig-7.14 which shows the Cost of the product.
715-04 CC7S Type Display of
MicroTalk-8086 Trainer
Weight Field Rate Field
1 2. 3 7 0 2 7. 9 5
0 3 4 5. 7 4
DP9 DP11 DP13 DP15
DP10 DP12 DP14
Cost Field
6/Expt-10A
Task-10A.5: Complete Code Listing for DWM Program: P713.asm
MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h ; 0000:1000
START: nop
L1: ; init to enter Rate Data from keyboard
mov di, 5000h
mov BYTE PTR [di+48h], 05h ; cursor position
mov BYTE PTR [di+49h], 04h ; 4-digits to print
mov BYTE PTR [di+4Ah], 08h ; cursor type _
; 8259 initialization
;call far ptr F000:0890
mov bx, 504Ch
mov WORD PTR [bx], 0890h
mov WORD PTR [bx+02h], 0F000h
call DWORD PTR [bx] ; IR2 for KIRQ enabled
sti ; 8086's interrupt is enabled
; vector set for int 22h for KIRQ at: ; 0000:2000h ; 00088h
mov ax, 0000h
mov es, ax
mov bx, 0000h
mov WORD PTR es:[bx+88h], OFFSET INT22; 2000h
mov WORD PTR es:[bx+8Ah], SEG INT22; 0000h ; correct
; 8279 initialization
mov al, 08h ; 16-digit
mov dx, 0002h ; poit at CR of 8279
out dx, al
mov al, 34h ; clock scaling
out dx, al
call far ptr BIN2BCD ; convert BIN Cost to BCD Cost by Horner Rule
7/Expt-10A
call far ptr BCD2CC
8/Expt-10A
BIN2BCD PROC FAR
LV1: mov bx, 5000h ; converting 32-bit BIN2BCD by Horner Rule
mov di, WORD PTR [bx+4Eh] ; di=upper 16-bit of BINCOST
mov si, WORD PTR [bx+4Ch];si=lower 16-bit (di, si) = 32-BIT BINCOST
mov WORD PTR [bx+4Eh], 0000h
mov WORD PTR [bx+4Ch], 0000h;(0504F,0504E,0504D,0504C)=00000000
; initial 8-digit BCDCOST)
mov bx, 0000h ; converting 32-bit BIN2BCD using Horner Rule
mov cx, 0000h; (cx,bx) = 00000000 = initial partial BCDCOST
mov ah, 20h ; number of rotation
mov al, 00h ; result: (ch,cl,bh,bl)
LV2: rcl si, 01h
rcl di, 01h
jc LV7
mov al, bl
add al, al
LV2a: daa
mov bl, al
LV3: mov al, bh
adc al, al
daa
mov bh, al
LV4: mov al, cl
adc al, al
daa
mov cl, al
LV5: mov al, ch
adc al, al
daa
mov ch, al
LV6: dec ah
jnz LV2
jmp LV9
LV7: mov al, bl
adc al, al
jc LV8
jmp LV2a
LV8: daa
mov bl, al
stc
jmp LV3
LV9: mov di, 5000h ; [cx][bx]=03457415;mov di, 5000h
mov BYTE PTR [di+24h], ch ; upper part of BBCD COST
mov BYTE PTR [di+25h], cl ;
mov BYTE PTR [di+26h], bh
mov BYTE PTR [di+27h], bl ; lower part of BCDCOST
ret
BIN2BCD ENDP
; ORG 2000h
INT22 PROC FAR
mov al, 40h
mov dx, 0002h
out dx, al
mov dx, 0000h
in al, dx ; reading Scan Code
cmp al, 11h
jz INTL1
iret
INTL1: mov di, 5000h
mov WORD PTR [di+05h], 8808h
mov WORD PTR [di+07h], 0808h
call far ptr XT8279
AGNKB: mov dx, 0002h
in al, dx
rcr al, 01h
jc INTL2
jmp AGNKB
INTL2: mov dx, 0002h
mov al, 40h
10/Expt-10A
out dx, al
mov dx, 0000h
in al, dx
mov BYTE PTR [di+4Bh], al ; saving the Scan Code
cmp al, 0Eh
jz L1RS
cmp al, 0Dh
jz L1RS
cmp al, 0Ch
jz L1RS
cmp al, 0Bh
jz L1RS
;cmp al, 0Ah
;jz L1RS
cmp al, 15h
jz L1RS
cmp al, 14h
jz L1RS
cmp al, 13h
jz L1RS
cmp al, 1Dh
jz L1RS
cmp al, 1Ch
jz L1RS
cmp al, 1Bh
jz L1RS
jmp AGNKB
sti
11/Expt-10A
;iret
mov bp, sp
mov WORD PTR [bp+00h], 1050h ; OFFSET of L3 of MLP
mov WORD PTR [bp+02h], 0000h ; SEG of L3 of MLP
iret
INT22 ENDP
12/Expt-10A
Experiment – 10B
Conversion and Operation of the MDA-8086 Microprocessor Trainer
as a Digital Weighing Machine (DWM)
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-10B.1: [Aim of the Experiment] To get familiar with the procedures of converting the
MDA-8086 microprocessor trainer into a Digital Weighing Machine (DWM).
Task-10B.2: [Converting the MDA-8086 Trainer into DWM] Let us carry out the following steps
to convert the MDA-8086 trainer into a DWM.
1. Look into the following block diagram of Fig-71.1, which could be used to represent the
MDA-8086 based DWM.
647
Load Cell Breadboard MDA-8086
+5
-5
0V A LCD
U29
m P3 COST: 1998.80
8255
p
DS1 W: 19.990 R: 99.99
DS2
DS3
DS4 E
A 8 9
Q3
D Q2
C Q1 4 5 6 7
Q0
0 1 2 3
2. Assume that the ‘Load Cell’ is connected (Practically they not connected). You will be
performing the load cell exercises in Experiment-7.2.
3. Also assume that the ‘Breadboard, the Instrument Amplifier and the ADC’ is also present
(Practically they not connected).
4. Assume that the Load Cell has produced a signal of 12.37mV corresponding to 12.370kg of
loads. This signal has been amplified and digitized to upBCD format by the ADC. Also
assume that the WTupBCD signals have been acquired via the interface controller U29 (8255)
and are saved in the following memory locations of the ‘DWM Data Structure’ of Fig-7.4 (see
text).
05053 UpBCD Wt: 1/100 Goods
05052 UpBCD Wt: 1/10 upBCD
05051 UpBCD Wt: 1 T7
Wt
05050 UpBCD Wt: 10
Also assume that the upBCD weight data are converted to pBCD and ASCII and saved in the
following memory locations of the data structure.
1/Expt-10B
05021 pBCD: 1/10, 1/100 Wt
05020 pBCD: 10, 1
BCD
Field
Figure-71.3: Table Containing BCD Weight
0503F ASC II for 0 DP17
ASC II for 1/100
ASC II for 1/10 ASCII
ASC II for . Wt
ASC II for 1 Field
ASC II for 10
ASC II for : T4b
05038 ASC II for W DP10
Figure-71.4: Table Containing ASCII Weight
5 We will be using the keyboard of the MDA-8086 trainer to enter the product rate. The rate will
be entered one digit at a time. Let us assume that the following memory locations of the
following data structure contain the RTASCII (product Rate in ASCII format) and RTBCD
(product rate in BCD format).
05047 ASCII for 1/100 DP1F
ASCII for 1/10
ASCII for .
ASCII
ASCII for 1 Rate
ASCII for 10 Field
ASCII for :
05041 ASCII for R DP19
T4c 632a
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA D PB DPC DPD DPE DPF
C O S T : 0 0 0 0 . 0 0
5 93
W : 1 2 . 3 7 0 R : 0_ 0_ . 0_ 0_
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
C O S T : 0 0 0 0 . 0 0 5 93
W : 1 2 . 3 7 0 R : _ _ . _ _
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
Figure-71.10: LCD Panel after Pressing the Rate Entry Key ‘E’
8 Enter the product rate of Tk 27.65 by pressing down the digits: 2 7 6 and 5. When the entry of
all the 4-digits are done, the display appears as below:
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA D PB DPC DPD DPE DPF
C O S T : 0 30 40 20 . 0 30
5 93
W : 1 2 . 3 7 0 R : 2_ 7_ . 6_ 5_
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
3/Expt-10B
Task-10B.4 [Exercises]
1 Change the simulated weight to 15.750Kg by editing the program p713.asm at the relevant
points. Reassemble the program and down load it to the trainer. Enter the rate as: Tk 34.50.
The LCD panel must show correct input/output values.
2 Press the E-key to enter a new rate (say: Tk 57.69). The rate field of the LCD is opened.
3 Type 5 and then ‘GO’. The rate field shows: R: 5 _ . _ _. This indicates that the program has not
accepted the ‘GO’ key as a valid digit key. Type all other non-digit key and check that the
program has correctly filtered out them. If any of the non-digit keys is found not been filtered
out, then bring necessary change in the program p713.asm to get it filtered.
4 Do you know what type of data the keyboard generates when you press the keys (3 4 6 and 9)
one after another as product rate?
Ans: When the key-3 is pressed down, the electronics of the keyboard (see Fig-44.4] generates
an 8-bit code called ‘Scan Code’. Thus there are 4-packets of ‘8-bit’ scan codes for the above
four digits. What are the values of these scan codes? To get the values of these scan codes
execute the program, p446.asm.
5 Assume that the scan codes for the above four (of Step-4) digits are: 03h, 04h, 06h and 09h
respectively. Now, write 8086 ASM program to convert these codes into their corresponding
ASCII codes 33h, 34h, 36h and 39h) and store them at the memory location of Fig-71.5.
Program to Read Scan Codes and Saving: [Execute and Check the Result]
ST: nop
L1: mov 5000h ; pointing a table that will hold the scan codes
Mov ah, 04h
out KRS(01H), 00h ; keyboard is reset
L2: in al, KRD(01h) ; read the raw scan code
test al, 10000000B ; checking if B7-bit is 0
jnz L2 ; no key is pressed down
L3: and al, 00011111B ; closed key found and save in KBUF [upper 3-bits 0]
mov BYTE PTR [bx+4Ch], al ; scode is saved at memory location : 0000:504C..504F
L4: out KRS(01h), 00h ; reset the keyboard
dec ah
jz L5
inc bx
jmp L2 ; read the scan code of the next key
L5: jmp F000:FFFFh (EA FF FF 00 F0) ; the goes to the prompt (the ready mode).
Program to Convert Scan Code to ASCII (SC2AS): [Execute and Check the Result]
- mov ah, 04h
mov si, 5000h ; pointing the table that contain the Scan Code
L: mov al, BYTE PTR [si+4Ch] ; getting the 1st Scan Code, 2nd scan code ……
- mov bx, OFFSET ASCII ; bx-register knows how far the ASCII table is.
xlat ; now al-register contains the ASCII code
- mov BYTE PTR [si+41h] ; ASCII code for the 1st digit is saved
dec ah
jz M
inc si
jmp L
ASCII DB 30h, 31h, 32h, 33h, 34h, 35h, 36h, 37h, 38h, 39h
M: conversion is done!
4/Expt-10B
Task-10B.5 – Complete ASM Code Listing for DWM :
MYCODE SEGMENT
ASSUME cs:MYCODE
LCDIR EQU 00h
LCDSR EQU 02h
LCDDR EQU 04h
LCDCG EQU 06h
KRR EQU 01h
KDR EQU 01h
ORG 1000h
START: nop
mov ax, 0000h
mov ss, ax
mov ds, ax
mov sp, 8000h
L2: mov WORD PTR [bx+28h], 2020h ; blank blank ; init Message (L35-L51)
mov WORD PTR [bx+2Ah], 4F43h ; O C
mov WORD PTR [bx+2Ch], 5453h ; T S
mov WORD PTR [bx+2Eh], 303Ah ; 0 :
mov WORD PTR [bx+30h], 3030h ; 0 0
mov WORD PTR [bx+32h], 2E30h ; . 0
5/Expt-10B
L4: nop ; flag init (L67 -L69)
mov bx, 5000h
mov WORD PTR [bx+4Ch], 0000h ; flags
L31: mov al, 00h ; ckecking if key close (L70-L74)
L31a: out KRR, al
in al, KDR
test al, 80h
jnz L31a
and al, 0Fh ; closed key found (L75-L81)
mov BYTE PTR [si+4Bh], al
nop
nop
out KRR, al ; keyboard is reset
cmp al, 0Eh
jnz L31a
mov bx, 5000h ; closed key is 'E' and init message (L82-L84)
mov WORD PTR [bx+43h], 5F5Fh ; _ _ at DP1B and DP1C
mov WORD PTR [bx+46h], 5F5Fh ; _ _ at DP1E and DP1F
mov si, 5000h ; xfer message to LCD (L86-L99)
mov bx, 0028h
mov cl, 10h
call far ptr BUSY
mov al, 80h
out LCDIR, al
call far ptr T42LCD ; xfer ASCII of T4 of Fig-44.8 to LCD
inc bx
mov cl, 10h
call far ptr BUSY
mov al, 0C0h ; 2nd line of LCD
out LCDIR, al
call far ptr T42LCD
mov si, 5000h ; now digit printing at Rate Filed (L114-L162)
L41: mov dl, 04h ; for 4 digits to print
mov bp, 0043h ; pointer
mov al, 00h
L41a: out KRR, al ; keyborad reset
nop
in al, KDR
test al, 80h
jnz L41a ; key has not been pressed
L41b: mov ah, al
and al, 0Fh ; key has been pressed down
mov BYTE PTR [si+4Bh], al ; scan code is saved
nop
nop
out KRR, al ; keyboard is reset
call far ptr DIGIT ; filtering out no-digit
cmp BYTE PTR [si+4Dh], 01h;
jnz L41a
mov BYTE PTR [si+4Dh], 00h ; flag is reset, valid digit (0-9)
mov si, 5000h
mov bh, 50h
mov bl, BYTE PTR [si+4Bh]
mov ah, BYTE PTR [bx] ; ASCII code for digit in ah-register
call far ptr BUSY
mov al, ah
;out LCDDR, al
mov BYTE PTR [si+bp], al
HERE: mov si, 5000h ; converting RATE ASCII into BCD (L165-L196)
mov ax, WORD PTR [si+43h] ; al=34 ; ah=37 ASCII2BCD
mov cl, 04h
rol al, cl ;
and al, 0F0h ; al=40
and ah, 0Fh ; ah=07
or al, ah ;al=47
mov BYTE PTR [si+4Dh], al ;(0504D)= 47 ; upper Byte of BCDRATE
mov ax, WORD PTR [si+46h] ; al=35 ; ah=36 ; ASCII2BCD
mov cl, 04h
rol al, cl
and al, 0F0h ; al=50
and ah, 0Fh ;ah=06
or al, ah ;al=56
mov BYTE PTR [si+4Ch], al ;(0504C) = 56 ; lower byte of BCDRATE
LX3:
mov si, 5000h ; xfer meggage to LCD (L53 -L66)
mov bx, 0028h
8/Expt-10B
mov cl, 10h
call far ptr BUSY
mov al, 80h
out LCDIR, al
call far ptr T42LCD ; xferring ASCII code from T4 to LCD
inc bx
mov cl, 10h
call far ptr BUSY
mov al, 0C0h
out LCDIR, al
call far ptr T42LCD
ASCII DB 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h
BUSY PROC FAR
in al, LCDSR
and al, 80h
jnz BUSY
ret
BUSY ENDP
BCD2ASC ENDP
MYCODE ENDS
END START
10/Expt-10B
Experiment – 11A
Study of the Asynchronous Serial Communication Link
Between IBMPC and MicroTalk-8086 Trainer
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-11A.1
Lab Works on COM1 Port of IBMPC and MicroTalk-8086 Trainer using DOS and ASM Codes
The diagram shown below depicts the interconnection between the 8086 (microprocessor), 8259
(Interrupt Priority controller), 8251A (Serial IO Controller), 8279 (Keyboard/Display Controller),
488/489 (TTL ↔ RS232 Converter) of MicroTalk-8086 trainer and the IBMPC. Study this diagram
carefully and then carry out the steps that follow:
MPU IPC: 8259 : U14 KBDIC 7SCCD
A A BUS
DRAM
IR 7
D7-D0 D DP0 DP7 DP8
R D/ R/
WR/ W/ C ol
J6-11 KIR Q 4 IR Q
M -IO/ IO/ IR 2(22h)
IR 1(21h)
Key Buffer
C S/ J6-3
IR 0(20h)
INTR INT R ow
INTA/ INTA/
DR 1000h
CR 1002h
0000h DR
0002h CR Keypad
8086: U2
BUS
R xR DY 8279 : U24
6.144M Hz C LK TxR DY TTL <---> RS232
307.2KHz TxC 488
TxT J6-18 2 3 TxR S J10-2
R xC
2000h DR R xD R xT J6-17 3 489 1 R xR S J10-3
2002h CR
Figure-11A.1: Hardware Connection Diagram among 8086, 8251, 8259, ‘Keyboard-Display’ and IBMPC
When this test is carried out, we shall see that:
a. The message ‘dO’ keeps flashing at the DP7DP8 positions of the trainer.
b. You press a key on the keyboard of the IBM-PC; the PC transmits the corresponding
ASCII code. The trainer receives the ASCII code, displays it on the DP7DP8 positions of
the trainer. The trainer also transmits back the same ASCII code to the PC. The PC receives
the ASCII code and displays the corresponding character on the monitor. And then, the
message ‘dO’ comes back.
c. Press a key on the keypad of the trainer. The character ‘A’ appears on the monitor of PC.
Procedures:
i. Power down the IBM-PC and the MicroTalk-8086 trainer..
ii. Use a 9-pin serial cable to connect the trainer and the COM1 port of IBMPC.
iii. Power up the trainer. Use a hookup wire and short: J6-3(KIRQ) and J6-11 (IR2).
iv Execute at: F1940h. The message ‘dO’ starts blinking at DP7DP8 positions of the trainer.
1/Expt-11A
v. Power up the IBM-PC.
vi. In the IBM-PC, execute the program, c:\MTK8086\DVH463.EXE
Listing of DVH463.ASM Program
MYSTACK SEGMENT para stack 'stack'
DW 100 dup (0)
STKTOP LABEL word
MYSTACK ENDS
RDCHAR: mov ah,02h ;fuction value for ROM BIOS `int 14h' call
int 14h ;ROM BIOS function call, data in al register
mov dl,al
mov ah,02h
int 21h ;DOS BIOS function call, display data at CRT
jmp CHKAGN
MYCODE ENDS
END START
viii. Press a key on the keypad of the trainer. The character ‘A’ appears on the monitor of
the PC. Press Capital-Q to exit the program.
ix. Press a key on the keyboard of the PC. We observe that the corresponding ASCII code
has appeared at the DP7DP8 positions of the trainer. The character also appears on the
monitor.
2/Expt-11A
3/Expt-11A
Experiment – 11B
Study of the Asynchronous Serial Communication Link
Between IBMPC and MDA-8086 Trainer
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-11B.1
Lab Works on COM1 Port of IBMPC and MDA-8086 Trainer using DOS and ASM Codes
The schematic diagram for the serial interface of the MDA-8086 (Korean made 8086 trainer)
trainer is given below. Write complete program both for the IBMPC and the 8251A controller of
the mmda-8086 trainer to establish communication between these two equipments at the setting
of: 4800 Bd, 1 start bit, 8 character bits, even parity and 2 stop bits. And then carry out the
following functional checks.
8086: U1 : MPU IPC: 8259 : U14 LCD
BUS
BUS
00h IR
IR7 02h SR
04h DR
IR0(43h)
IR2(42h)
IR1(41h)
IR0(40h) Keyboard
INTR INT
INTA/ INTA/ 01h DR
01h CR
DR 10h
CR 12h
2.4576MHz
+5 BUS RxR DY
GT0
CLK TxRDY
TTL <---> RS232
CK0
OT0 TxC
TxT 10 7 TxR S
09h C0 RxC
0Fh CR 08h DR R xD R xT 12 13 RxR S
0Ah CR
a. Download the codes of your program starting at 0000:1000 and then execute at 01000h
b. Type a character in the keyboard of the IBMPC, its ASCII, Scan and Label would
appear on LCD
c. Type a character in the keyboard of MDA-8086, its Label would appear on the monitor
of IBMPC.
Solution Hints:
a. Open a DOS screen in the IBMPC under WIN98. Save the screen as p4513a.asm. This
program would read a character from the Rx-register by polling the RxRDY-bit and
then write it back on the Tx-register by polling the TxRDY-bit.
1/Expt-11B
Determine TxC for 4800 Bd (assume BRF = x16) and then configure the PIT chip 8253
accordingly.
TxC = BRF x Bd = 16 x 4800 = 76800 Hz
Configure Counter-0 of PTI chip 8253 (U41) to work as a frequency divider of:
CK0/TxC = 2.4576MHz/0.076800 MHz = 32(20h) in order to output a frequency of
76800Hz
2/Expt-11B
Experiment – 12
Programming of the 8279-Based Display Unit
of the MicroTalk-8086 Learning System
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your knowledge & understanding)
Task-12.1:
Display the message ‘Good’ at the data field of the display unit of the MicroTalk-8085 trainer.
The Procedures:
1. Fill up the following Common Cathode Codes Table for all Possible Characters Displayable on 7-
Segment Display Devices
Character Displayable Form Segment Bits Data Value
- - p g f e d c b a -
0 0 0 0 1 1 1 1 1 1 3FH
1 1 0 0 0 0 0 1 1 0 06H
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
o (small O)
D
R
L
U
S
T
1/Expt-12
2. Update the following Memory Resident Data Table for the Message ‘Good’
3. Study the following Circuit Diagram of the 8279 and Display Unit of MicroTalk-8086
D9 D8 D7 D6 D5 D4 D3 D2 D1
8279 : U10 DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8
p p
g g
DDR f f
e e
Display RAM Data 8 d d
4-Bit 0 DP0 c c
Frequency
Counter 1 DP1 b b
Divider
2 DP2 a a
Q3 D
C DP3 cc cc cc cc cc cc cc cc cc
1024KHz Q2
In 100KH B DP4
Fin Q1
Out A DP5
Q0
4
to
16
D
E
0000, C DECODER
0002 CS/ O
D S0/
E S1/
R F
A1 A0 (C-D/) DPF S2/
SL3 D S3/
SL2 C S4/
DR
SL1 B S5/
SL0 A S6/
CR S7/
S8/
SR
4. Programming Table – 1
Register Name Abbreviation Address Mapping Read/Write Mode
Control Register CR 0000h Standard & Variable Write Only
Status Register SR 0002h Standard & Variable Read Only
Display Data DDR 0000h Standard & Variable Read/Write
Register
Keyboard Data KDR 0000h Standard & Variable Read/Write
Register
2/Expt-12
5. Programming Table – 2
6. Code, Store and Execute the following Pseudo Codes that describes the solution of Task-
F.1.
L1: do nothing;
L5 : if ( cx == 0)
goto L6
else
{
(SI) + 01H → SI
goto L3
}
L6: halt
3/Expt-12
L1:
Entry
L2:
Initialization
DDR for 16-Digits
Display,Left Entry
L3:
Read Data
Read from
Data
Memory Table
from Port-B
byte-by-byte
L4:
Write Label-c
Data to DDR
L5:
Write
Done
?
L6:
Exit
111-00:GM:1199
4/Expt-12
5/Expt-12
Experiment – 13
Programming of the 8279-Based Keyboard Unit
of the MicroTalk-8086 Learning System
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your knowledge & understanding)
Keyboard Section
+5V
C S3/
0000, B S2/
8x5K A S1/
0002 CS/
KDR S0/
` RL0 C1 C2 C3
K11
A1 RL1 ROW-1 K13
A0(C-D/)
E RL2 ROW-2
D7-D0 L
E RL3 ROW-3
C
T
4 IRQ R
RL4 ROW-4
O
N RL5 ROW-5
I
C
S
RL6 ROW-6 K63
SR
RL7 ROW-7
112a: GM: 0701 : CR
06/2005 RESET
1/Expt-13
3. Follow Fig-44.3 and Fill up the following table for the Keypad of the MicroTalk-8086
Key Designation Key Label Scan Codes (Binary) Scan Codes (Hex)
K11 D/DOP 00 001 001 09H
K21 ---------------------- --------------------- ----------------------
……
K51 ---------------------- ------------------------ ----------------------
K61 ---------------------- ------------------------ ----------------------
4. Programming Table-2
Control Byte Written to Purpose
40H Control Register To make read access to KDR
5. Pseudo Codes for the solution of the problem (p441.asm) Flow Chart for the Pseudo Codes:
L1: nothing
L2: SR0 → al
L3: if (al0 = 1) L1: 113-00: GM: 0701
2/Expt-13
Figure-44.2:: Flow Chart to Acquire/Display Scan Code
3/Expt-13
Experiment – 13B
Programming the Keyboard Unit of the MDA-8086 System
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your knowledge & understanding)
Task-13B.1: [Aim of the Experiment] Acquiring the ‘Scan Codes’ for the keys of the keypad of
the MDA-8086 trainer and displaying those on the LCD panel of the trainer.
Example-13B.2: [Objectives of the Experiment] This experiment is presented with the intention
that the readers, while conducting the experiment, will be familiar with:
1. Various terminologies relating with keyboard design.
2. Design of ‘Bus Compatible’ keyboard using discrete ICs.
3. Design of bus compatible keyboard using programmable IC like 8279.
4. The procedure of converting scan codes into ASCII codes.
Example-13B.3: [Terminologies]
Scan Code: A key has two pins and it becomes an operational key when its two terminals are
placed between a row and a column as is shown in Fig-44.1. When a key is pressed down, the
associated electronics around that key generates an 8-bit code, which is termed as ‘Scan Code =
scode)’. The value of the scode depends on the row and column across which the key is placed.
Thus, the scan codes of the keys of a keypad are always different from each other.
Example-44.4: [Hardware Block Diagram of the MDA-8086 Keyboard]
Decoder: U16
CS/: 01h
WR/ KRS/
RD/
BHE/
M-IO/ KRD/
U25
S/ Status Signal
Q
DB-sig: 33m S
R/
IRQ
U24
Key Pad
OE/
B7 DB-Sig
B6
B5 0V G0 STP C D E F
D15-D8 Q7-Q0 B4 Q4 12 11 0C 0D 0E 0F
B3 Q3 + REG 8 9 A B
B2 Q2 15 13 08 09 0A 0B
B1 Q1 - DA 4 5 6 7
B0 Q0 14 16 04 05 06 07
: AD 0 1 2 3
10 17 00 01 02 03
541
Figure—13B.1: Hardware Block Diagram for the Keyboard of the MDA-8086 Trainer
6/Expt-13B
Example-13B.5: [Working Principles of the Keyboard of Fig-13B.1]
The decoder (U16), which has conditioned the signals CS/, RD/, WR/, BHE/ and M-IO/ signals
are not the part of the keyboard circuit. This is shown here as a reference. The U’s numbers
correspond to the actual U’s of the circuit diagram of the keyboard as depicted in the MDA-8086
user’s manual.
The keypad contains 24 keys with the labels as indicated. The 2-digit hex number shown below
the key label is the 8-bit scan code for that key. There are electronics circuitry to the left and the
top of the key array of the keypad. The B7-B0 bits at the input of U24 represent the 8-bit scan code
of a pressed down key. The Fig-58.1 indicates that the values of the B4-B0 and B7 bits are
dependent on the positions of the keys in the key matrix. The detailed study of the keyboard
circuit of Fig-58.1 is available in Exercise-1.
The keyboard is designed in such a way so that whenever none of the keys in the keypad is
pressed down, the B7-bit of the scan code is at LH. Thus, the B7-bit works as a status, which
carries the closed condition of a key in the keypad. Before the keyboard is put into operation, the
B7-bit is made LH by executing the instruction: out KRS(01H), 00h. This instruction activates the
KRS/ signal of the decoder, which in turn sets the flip-flop U25. The result is that the B7-bit at the
input of U24 assumes LH.
When a key is pressed in the keypad, the internal electronics to the left of the key array activates
and generates a bit pattern for the bits: B4-B0. At the same time, the top electronics of the key
array generates a low going pulse, ‘DB-sig’. The DB-sig resets the flip-flop U25 making B7-bit LL.
The DB-sig may be inverted using a gate as shown in Fig-44.1 and can be used to interrupt the
CPU. Alternately, the CPU may poll the B7-bit for LL and then can read the scan code from the
input of the buffer U24 by executing the instruction: in al, KRD (01h). The complete cods for the
polling and reading of the keyboard is given below:
L1: out KRS(01H), 00h ; keyboard is reset
L2: in al, KRD(01h) ; read the raw scan code
test al, 10000000B ; checking if B7-bit is 0
jnz L2 ; ne key is pressed down
L3: and al, 00011111B ; closed key found and save in KBUF
mov BYTE PTR KBUF, al ; KBUF is a memory location of DSM (say, 03010h)
L4: out KRS(01h), 00h ; reset the keyboard
jmp -------- ; take action as needed against the closed key.
Scan Code Table for the Keyboard of MDA-8086:
Key Designation Key Label Scan code Key Designation Key Label Scan Code
K11 GO 12h K31 - 14hh
K12 STP 11h K32 DA 16h
K13 C 0Ch K33 4 04h
K14 D 0Dh K34 5 05hh
K15 E 0Eh K35 6 06h
K16 F 0Fh K37 7 07h
K21 + 15h K41 : 10h
K22 REG 13h K42 AD 17hh
K23 8 08h K43 0 00h
K24 9 09h K45 1 01h
K25 A 0Ah K46 2 02h
K26 B 0Bh K47 3 03h
6/Expt-13B
Task-13B.6: [Reading and Saving Scan Code] Write a small program to read the scode of a
pressed down key of the keypad. Save the scode at memory location: 03100h (0000:3100). After
the execution of the program, manually check the content of the memory location 03100h and
look for the correct scode for the key that have pressed down.
Solution:
L1: out KRR(01H), 00h ; keyboard is reset
L2: in al, KDR(01h) ; read the raw scan code
test al, 10000000B ; checking if B7-bit is 0
jnz L2 ; no key is pressed down
L3: and al, 00011111B ; closed key found and save in KBUF [upper 3-bits 0]
mov BYTE PTR ds: [3100h], al ; scode is saved at memory location : 0000:3100
L4: out KRS(01h), 00h ; reset the keyboard
jmp F000:FFFFh (EA FF FF 00 F0) ; the goes to the prompt (the ready mode).
Example-13B.7: The scode of the Task-44.6 has been stored at memory location 0000:1100 by executing the
instruction: mov BYTE PTR ds:[3100h], al. Verify that the following instruction can also be used to store
the scode at the memory location: 0000:3100.
mov bx, 3100h
mov BYTE PTR ds:[bx]
Exercise-13B.8: Modify the program of Task-44.6 so that the CPU will respond (it will go to Ready Prompt)
when and only when you press the ‘REG’ key. All other keys will be ignored. Scode is saved at: 03100h.
Solution Hints: The solution of Exercise-44.8 is given below in the form of Pseudo Code and Flow Chart.
Convert it into machine codes. Enter the program codes into the CSM starting at 0000:1000 and execute it.
Pseudo Codes: Flow Chart:
L0: entry
L1: xxh → KRS (01h) ; reset keyboard L0:
L2: al ← KRD (01h) ; read raw scan code
Entry
L3: if (a7 = 1) ; checking the status bit
L1:
goto L2 ; key not closed
L4: if (al != 13h) ; is it REG key? Reset the Keyboard
goto L2 ; it is not REG key L2:
L5: al → 03100h ; saving Scan code for REG.
Read Scan Code
L6: goto F000:FFFFh (EA FF FF 00 F0)
L3:
Assembly Codes: Y B7 = 1
L0: nop
N L4:
L1: out 01h, al
N Scode=13h ?
L2: in al, 01h
L3: mov ah, al Y L5:
…………… Condition Scode
jnc L2 and save at 01100h
L4: cmp al, 13h L6:
jnz L2
Exit to Prom pt
L5: mov 03100h, al
542
L6: jmp far PTR F000: FFFF
Figure-44.2: Flow Chart for Exercise-44.8
Exercise-13B.9: Modify the program of Exercise-44.8 so that the CPU will now exit to the Ready Prompt
when either the ‘GO’ or ‘STP’ key is pressed down.
6/Expt-13B
Exercise-13B.10: Rewrite and execute the program of Task-44.6 by assigning variable port addresses for the
devices KRS and KRD.
Taks-13B.11: Write, code and execute an 8086 assembly program, which will show the message
‘Closed key Found’ on the top line of the LCD when the key ‘GO’ is pressed down:
Solution:
1. Configure the LCD for 8-data lines, 16x2 line, 5x7 dots, display ON and cursor OFF.
2. Manually initialize the message ‘Closed Key Found’ in the following data structure of DSM:
0000:3200 ASCII Cde of 'C'
0000:3201 ASCII Cde of 'l'
0000:3202 ASCII Cde of 'o'
ASCII Cde of 's'
ASCII Cde of 'e'
ASCII Cde of 'd'
Space
ASCII Cde of 'K'
ASCII Cde of 'e'
ASCII Cde of 'y'
Space
ASCII Cde of 'F'
ASCII Cde of 'o'
ASCII Cde of 'u'
ASCII Cde of 'n'
0000:320F ASCII Cde of 'd'
0000:3210 Mark of End (24h)
543
Figure-44.3 Data Structure for Task-44.10
6/Expt-13B
544
R8 R10 R12 +5V
3.3k 3.3k 3.3k
IRQ
CS/ (01h)
BHE/ Read Enable
M-IO/
D15-D0
Figure-13B.4: Complete Schematic Diagram for the Keyboard of the MDA-8086 System
Exercise-13B.14: The CPU can read the scan code of a closed key by reading the status of Bit-7 of the input
value of U24. The CPU will keep reading the data out of U24 until it finds that Bit-7 is at LL. This way of
reading a data is called ‘Polling Method’. Polling method gives the guarantee that a valid data will always
be found but at the expense of time. The alternate way of reading scan code without wastage of time is the
‘Interrupt Method’. In this method, the keyboard will inform the CPU by way of interruption when there
has been a key closed in the keypad. Refer to the diagram of Fig-44.4, we notice that having the occurrence
of a key closure, and at the expiry of 33mS denouncing time, the IRQ output goes LH. This signal may be
connected with the INTR pin of the 8086 for interruption.
Exercise-13B.15: Explain the reason of connecting the output data of U24 with the D15-D8 lines of the 8086
instead of D7-D0 lines.
Answer: In the diagram of Fig-44.4, we notice that the address assigned to the keyboard is 01h, which is an
odd numbered fixed ort address. The architecture of 8086 dictates that the CPU can perform data read/write
operations with the odd numbered port and memory locations should their data lines are tied with the
upper byte (D15-D8) of the data bus. More over, the execution of the instruction, mov al, KRD (01h)
automatically asserts LL at the BHE/ pin of the CPU due to the presence of an odd numbered port address
in the instruction. The activation of BHE/ signal connects only the upper byte of the data bus with the
accumulator register of the CPU.
As a reference study, we may include here that the data bits of the even numbered-address ports and
memory locations are always connected with the lower byte of the data bus.
6/Expt-13B
Experiment – 14A
Converting MicroTalk-8086 Trainer into a 24-Hr Clock
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions
are given as topics for additional studies to enhance your knowledge & understanding)
Task-14A.1: 24-Hr Clock [1-sec Time Tick is obtained from 50Hz Line Frequency]
Procedures:
1. Download program …\mtk8086\P14Aclk.abs starting at RAM location 0000:1000 (01000h).
2. Use keyboard of the trainer and update the following memory locations with current time.
(00474) = Second : 00 - 59
(00475) = Minutes : 00 – 59
(00476) = Hours : 00 – 23
3. Use the DOP command and execute the down loaded program at: 01000h
4. Take a jumper wire and gently short PZC (J3-26) and NMI (J2-19) points.
4. The display of the trainer should show the Time as per format of Fig-14A.1 as shown below.
DRAM0 DP0
CS/ DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8
DRAM1 DP1
Jumper DRAM2 DP2
DRAM3 DP3 Data
HRS
DRAM4 DP4
20mS B B DRAM5 DP5
J3-26 MIN
DRAM6 DP6
NMI Hr Min Sec
DRAM7 DP7
PZC J2-19 SEC
DRAM8 DP8
739abx
T13
T11 T12
00447 D3
HRS 7-Seg Display
00446 D4
00450 HRS D3D4
00445 D5
00476 HRS 0044F MIN D5D6 MIN
00475 MIN 0044E SEC D7D8
BCD2CC 00444 D6 CCX8279
00443 D7
00474 SEC Running BCD Time SEC
F000:F47C 00442 D8 HRS MIN SEC
Initial BCD Time F000:FFB8
Running CC Time
739abx
1/Expt-14A
MYCODE ENDS
END START
1/Expt-14A
Experiment - 9
Multiplication of Two Unsigned 16-Bit Numbers
Task - 9.1[16-bitx16-bit Multiplication by Counting: p91a.asm] In this task, we shall
multiply two unsigned 16-bit numbers by ‘full repetitive addition’ method using the
MicroTalk-8086/MDA-8086 microprocessor learning system. There will be absolutely no
use of either of the following two instructions:
-
1/Expt-9
Jmp L2B
L2D: al → r3’’r2’’ ; we have : [r5’’r4’’ r3’’r2’’] for L2: [x3x2]x [y1y0]
L3: - compute {[x1x0]x[y3y2]} by repetitive addition
mov al, 00h ; al is the working register and also holds IPR
mov ah, y3y2 ; ah holds the multiplier
L3A: add al, x1x0
jc L3C
L3B: dec ah
jnz L3A
jmp L3D
L3C: r5’’’r4’’’ + C → r5’’’r4’’’
jmp L3B
L3D: al → r3’’’r2’’’ ; we have : [r5’’’r4’’’ r3’’’r2’’’] for L3: [x1x0] x [y3y2]
L4: - compute {[x3x2]x[y3y2]} by repetitive addition
mov al, 00h ; al is the working register
mov ah, y3y2 ; ah holds the multiplier
L4A: add al, x3x2
jc L4C
L4B: dec ah
jnz L4A
jmp L4D
L4C: r7r6 + C → r7r6
jmp L4B
L4D: al → r5’’’’r4’’’’ ; we have : [r7r6 r5’’’’r4’’’’] for L4: [x3x2] x [y3y2]
L5: - now add the three components of r3r2 of L1, L2 and L3
mov ah, 00h ; ah-register will accumulate the carries
[r3’r2’ + r3’’r2’’] → al
jc L5A
jmp L5B
L5A: ah + 01h → ah
L5B: al + r3’’’r2’’’ → al
jc L5C
jmp L5D
L5C: ah + 01 → ah
L5D: al → r3r2 ; the value of ah-register will be added with r5r4 components
L6: - now add the three r5r4 components of L2, L3 and L4.
mov cl, 00h; ; cl-register will accumulate the carries
[r5’’r4’’ + ah ] → al
jc L6A
jmp L6B
L5A: cl + 01h → cl
L5B: al + r5’’’r4’’’’ → al
jc L6C
jmp L6D
L5C: cl + 01 → cl
2/Expt-9
L6D: al + r5’’’’r4’’’’ → al
Jc L6E
Jmp L6F
L6E: cl + 01h → cl
L6F: al → r5r4 ; the value of cl-register will be added with r7r6
L7: - now add r7r6 with cl-register
r7r6 + cl → r7r6
L8: - the multiplications is done-
Implementation:
1. Assume the input numbers as: Multiplicand = 1234h
Multiplier = ABCDh
2. Expected Result : Product = 0C374FA4h
3. Use keyboard and store the multiplicand and the multiplier in the specified RAM
locations of the input/output data structure of Fig-63.2.
3. Use keyboard and store 00h to all four-memory locations of the data structure holding
the results.
4. Write the complete 8086-assembly program for the above mixed codes and save as:
drive:\mda86\p631a.asm. In the meantime execute the following test program
(p91a.c).
#include <stdio.h>
#include <conio.h>
#include <string.h>
void bmult();
unsigned char r1r0=0, r3r2=0, r5r4=0, r7r6=0;
unsigned char r3r2_1=0, r3r2_2=0, r3r2_3=0;
unsigned char r5r4_2=0, r5r4_3=0, r5r4_4=0;
void main()
{
union buff {
unsigned long size;
unsigned char ch [4];
} y;
clrscr();
bmult();
y.ch[0] = r1r0;
y.ch[1] = r3r2;
y.ch[2] = r5r4;
y.ch[3] = r7r6;
printf("\n%lx ", (y.size));
getch();
3/Expt-9
void bmult()
{
// x3x2 = 12; x1x0 = 34h, y3y2 =AB; y1y0=CDh
BM: asm mov bl, 0x00
asm mov al, 0x00
asm mov ah, 0x34 // y1y0 ; y3y2y1y0=1234h
L1A: asm add al, 0xCD // x1x0; X3x2x1x0=ABCDh
asm jc L1C
L1B: asm dec ah
asm jnz L1A
asm jmp L1D
L1C: asm inc bl
asm jmp L1B
L1D: asm mov r1r0, al // r3r2_1, r1r0
asm mov r3r2_1, bl // 29A4h
asm mov bl, 0x00
asm mov al, 0x00
asm mov ah, 0x34 // y1y0; y3y2y1y0=1234
L2A: asm add al, 0xAB //x3x2 ; x3x2x1x0=ABCD
asm jc L2C
L2B: asm dec ah
asm jnz L2A
asm jmp L2D
L2C: asm inc bl
asm jmp L2B
L2D: asm mov r3r2_2, al // r5r4_2, r3r2_2
asm mov r5r4_2, bl // 22BCh
4/Expt-9
asm jnz L4A
asm jmp L4D
L4C: asm inc bl //r7r6
asm jmp L4B
L4D: asm mov r5r4_4, al // r7r6, r5r4_4
asm mov r7r6, bl //0C06h
L5: asm mov ah, 0x00
asm mov bl, r3r2_1
asm mov al, r3r2_2
asm add al, bl
asm jc L5A
asm jmp L5B
L5A: asm inc ah
L5B: asm mov bl, r3r2_3
asm add al, bl
asm jc L5C
asm jmp L5D
L5C: asm inc ah
L5D: asm mov r3r2, al // r3r2=5Ah;
L6: asm mov al, ah
asm mov ah, 0x00
asm mov bl, r5r4_2
asm add al, bl
asm jc L6A
asm jmp L6B
L6A: asm inc ah
L6B: asm mov bl, r5r4_3
asm add al, bl
asm jc L6C
asm jmp L6D
L6C: asm inc ah
L6D: asm mov bl, r5r4_4
asm add al, bl
asm jc L6E
asm jmp L6F
L6E: asm inc ah
L6F: asm mov r5r4, al
L7: asm add r7r6, ah
}
5. Assemble the program: p631a.asm and enter the machine codes in the CSM starting at
slocation: 01000h.
6. Execute the program at : 01000h.
7. Open the following memory locations for the result and we must find the correct
result:
010404 = A4
010405 = 4F
5/Expt-9
010406 = 37
010407 = 0C
7. Test your program for another set of values. Also test that the program works for the
input data: 0000h and 0000h.
6/Expt-9
Product Advertisement
Microprocessor/Microcontroller
Learning/Development Systems
(Accompanied with Rich Documentation)
Designed to Meet the Learning and Research Needs of the
Students, Teachers, Scientists, Technocrats and Engineers
MicroTalk-8085 MicroTalk-8086
MicroTalk-80286 MicroTalk-8x51
MicroTalk-80386
I02, D03, B?, M?
Users List: BUET, KUET, RUET, DUET, ITU, DU, JU, AUST, IUBAT, QU, AIUB, AUB,
Mohila Polytechnic, Ctg. Polytechnic, Zamuna Fertilizer, Cybernetic Systems …
Designed, Developed and Built in Bangladesh By
Golam Mostafa B.Sc.Engg (EE-BUET), M.Sc.Engg (CSE-BUET): Ex-Schlumberger, GEC and BCIC
Associate Professor, Ahsanullah University of Science and Technology, Dhaka
Karighar Research and Development Center
16/1-2 (Apt: 2/801), Segun Bagicha: Dhaka-1000: Bangladesh
Phone: 02-7161846, 01726-341559 Email: mostafagb@yahoo.com