You are on page 1of 154

8086

Microprocessor
Laboratory Experiments Manual
Using MicroTalk-8086 and MDA-8086 Trainers

MicroTalk-8086 ( Bangladesh ) MDA-8086 ( Korea )

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 – 2 Familiarization with the Assembly Instructions of 8086 Microprocessors by


Adding Two 8-bit Unsigned Hexadecimal Numbers. 1/Expt-2

Experiment – 3 Familiarization with the Assembly Instructions of 8086 Microprocessors by


Multiplying Two 8-bit Hex Numbers by Repetitive Additions. 1/Expt-3

Experiment – 4 Familiarization with the Procedures of Programming the 8255 Parallel IO


Controller. 1/Expt-4

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-

Experiment – 6A Familiarization with the Functionality Check of the NMI-interrupt of 8086


using MicroTalk-8086 Trainer. 1/Expt-6A
Experiment – 6B Familiarization with the Functionality Check of the NMI-interrupt of 8086
using MDA-8086 Trainer. 1/Expt-6B

Experiment – 7 Task-7.1 [BCD-to-BINary]


Conversion of 2-digit BCD Number (range: 00 – 99) into Equivalent BINary
Number by Counting Method. 1/Expt-7
Task-7.2 [BCD-to-BINary]
Conversion of 4-digit BCD Number into Equivalent BINary Number by
Horner Method (Fast Method). 2/Expt-7

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 – 9 [BINary Multiplication] Multiplication of two 16-bit unsigned BINary


Numbers 1/Expt-9

Experiment – 10A Familiarization with the Procedures of Converting MicroTalk-8086 Trainer


into a Digital Weighing Machine 1/Expt-10A
Experiment – 10B Familiarization with the Procedures of Converting MDA-8086 Trainer into a
Digital Weighing Machine 1/Expt-10B

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

Experiment – 12 Programming of the 8279-Based Display Unit of the MicroTalk-8086 Learning


System. 1/Expt-12

Experiment – 13A Programming of the 8279-Based Keyboard Unit of the MicroTalk-8086


Learning System. 1/Expt-13A
Experiment – 13B Programming the Discrete Components-Based Keyboard Unit of the MDA-
8086 Learning System. 1/Expt-13B

Experiment – 14A Converting MicroTalk-8086 Trainer into a 24-Hr Clock System

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.

5. Enter the input BINary number as: 25h

6. Execute the program:

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

si = BIN Cl, bh, bl = IPBCD


bl
cl bh
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: 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.

Task-1B.1 Familiarization with the Components Layout


In this task you will be locating and getting familiar with the following functional units of the
MDA-8086 trainer. These units are considered as the Building Blocks of a microprocessor based
system. The MDA-8086 is an 8086 microprocessor learning system made in Korea.
i. 8086 Microprocessor
ii. RAM (Random Access Read and Write Memory)
iii. EPROM (Ultraviolet Erasable and Electrically Programmable Random Access Read
Only Memory)
iv. Input Device (The Keyboard)
v. Keyboard Interface Controller (not visible)
vi. Output Devices:
a. Liquid Crystal Display Unit (LCD)
b. Common Anode Type 7-Segment Display Device (CA7SDD)
c. Light Emitting Diodes (LED11-LED14)
d. 8x8 Bicolor Dot Matrix LED [DOTLED]. Each dot contains Red and Green LEDs.
vii. Output Device Interface Controllers (not visible)
viii. Primary Memory Decoder (not visible)
ix. Primary Port Decoder (not visible)

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

ADC: 0804 : U31 IN TA INTA (40h)IR0 IR2


Speaker IN TR/ INT / (41h)IR1
+5V
IR2
CS/ CS/ IR3
Out
D D8 D7-D0 D7-D0 IR4
DR: 11h DR:12h IR5
IPC IR6
U42 CR:10h IR7
SPKIC: U25
8259
ODD: ROM:U8 27256 CS/ CS/ 62256 ODD: RAM : U10
F0001,...... ,FFFFF D15-D8D15-D8 00001, ........ 0FFFF
D7-D0 D7-D0 NMI
NMI +5V

EVN: ROM:U7 27256 CS/ CS/ 62256 EVN : RAM : U9


F0000, ..... FFFFE D7-D0 D7-D0 00000,......... 0FFFE
D7-D0 D7-D0

A,M-IO/,BHE/
Sx/ Sy/ 0V
Mem/Port Decoder : U16
GM: 547: 11/03:3 Hrs

Figure-1B.1: Hardware Block Diagram of MDA-8086 Trainer

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)

(1) CA Code for Blank DSM


03011 FF
03010 B0 CA Code for 3

PC = CS:IP
Program Codes CSM
(2) xxxxx TDELAY
(4) 01000
RAM: U9, U10
548

Figure-1B.3: Connection Diagram between CA7SD and the CPU

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

L2: 0000:100E – mov al, 80h B0 80 ; bx-register to work as pointer


out CRU29(1Fh), al E6 1F ; reading cacode for ‘3’
mov bx, 3000h BB 00 30 ; sending cacode of ‘3’ to PAR
L2A: 0000:1015 - mov al, BYTE PTR ds;[bx+10h] 8A 47 10 ; Insert Time Delay
out PARU29(19h), al E6 19
mov cx, 0FFFFh B9 FF FF
HERE1: 0000:101D- loop HERE1 E2 FE

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

L4: 0000:1029- jmp L2A EA 15 10 00 00 ; repeat the process

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

538 538 538

(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.

Task-1B.7 Learning How to Get Machine Codes of Character Blinking of Task-1B.4


In this task, we will get familiar with the procedures of getting the machine codes for the
character-blinking program of Table-B of Task-1B.4. We shall use MASM (Macro Assembler)
program and the IBM-PC to obtain the machine codes for the assembly instructions of Table-B of
Task-1B.4. The procedures are:
(a) Create a directory named as MDA8086 in the hard drive C. And now accommodate the
following program files under this directory. These programs may easily be collected
from the CD that has been supplied with the MDA-8086 trainer. If the directory already
exists and contains these files then go to step-b
Sno. File Name Purpose
1 COMM.EXE Serial Monitor of the MDA-8086 Trainer
2 LINK.EXE To create relocatable *.EXE file from *.OBJ file
3 LOD186.EXE To create ‘Absolute (*.ABS)’ file from *.obj file
4 MASM.EXE To create *.LST and *.OBJ files form *.ASM file
5 EDIT.EXE To create Assembly Program (Source Code) for 80x86 MPUs
6 EXER <DIR> A Working Directory
(b) Boot the IBMPC in Windows 98/XP and then go to DOS path using the Start Menu. The
monitor would show as:
c:\windows>_
Bring the IBM-PC in the following DOS path:
c:\mda8086>--
The procedures:
1. Type cd.. and then press enter key
2. Type mda8086 and then press enter key.
(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-1B.4.

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

Figure-1B.5: Jumper P1 is at Local Monitor Environment


(p) Power OFF and then ON of the MDA-8086 trainer and then press the RESET key.
(q) The LCD display of the trainer shows the following prompt message:
MDE8086 Kit V9.5
Midas 335-0964/5
(r) Use keyboard of the trainer and enter the machine codes of Step-n 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. For multi-byte data, the lower bytes should be
entered first.
(s) Enter the data B0h (for character 3) at RAM location 0000:3010 and FFh (for Blank) at
RAM location 0000:3011 of the data segment memory.
(t) Execute the program at location: 0000:1000 using the GO command.
(u) Observe that the device 3 is blinking on the CA7SD device.
(v) The Task-1B.7 is well done.
Task-1B.8 In this Task, we will learn how to transfer the machine codes of the Step-n of Task-
1B.7 from the IBMPC to the CSM of the MDA-8086 trainer. This method is known as Down
Loading. To do it, we will be using the COM1 port of the IBMPC. 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 MDA-8086 trainer. Bring P1 jumper (Switch) at the ‘Serial Monitor’/KIT
position. Connect the serial cable of the trainer with the COM1 port of the IBMPC.
2. Bring the IBM-PC in the following DOS prompt:
c:\mda8086> _
3. From the start icon of the IBMPC execute the WinComm and then goto Step-4 below.
OR
Type COMM at the cursor position and then press Enter key. A communication screen will
appear. Press F5 function key and modify the screen as follows:
Serial Port (1/2) : [X] ==>1 press Enter key
Serial baud rate Set
1200 = 1 2400 = 2 4800 = 3
9600 = 4 19.2K = 5 38.4 = 6
Baud Rate Select (1 – 6) : [X] = = > 4 (always) press Enter key
Parity bit NP =0, Po = 1, Pe = 2 : [X] ==>0 press Enter key
Word Size 7-bit=2, 8-bit=3 : [X] ==>3 press Enter key
Stop bit 1-bit=0, 2-bit=1 : [X] ==>0 press Enter key
Change OK (Y/N) ? y press Enter key

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:

c:\mda8086> _ The converted file is located at: c:\mda8086\P1B.abs.


8. Type EDIT at the cursor position of the DOS prompt. Open the file P1B.abs
9. The screen shows multiple lines, which are very similar to the following line. This
particular format is known as Intel-hex Format. For details, see Page-12/Expt1A).
: 0A 1000 00 90 B8 80 E6 1F B0 B0 E6 19 F4 46

Starting address of storage


10. Exit the screen and come to the DOS prompt of: c:\mda8086> _
11. Type COMM at the DOS prompt and press the Enter key OR click on the WinComm.
12. Reset the MDA-8086 trainer to activate Serial Link with IBMPC.
13. Type L at the cursor position. Press Enter key. And then press F3 key.
14. Type c:\mda8086\P1B.abs and then press Enter key. The program codes have already
been transferred into the trainer with the message ‘OK Completed’.
15. Bring the jumper P1 (Switch) of the trainer into Local Monitor/KIT position.
16 Enter B0h (CA code for 3) at memory location 03010h (0000:3010) and FFh (CA code for
Blank) at memory location 03011h (0000:3011) of the DSM.
17 Execute at 0000:1000 using the GO command of the trainer.
18 The device CA7SD must blink the character ‘3’
Task-1B.9 Find the location of the file ‘fnd.abs’ in your computer and bring it under the
directory of c:\mda8086. Down load the codes of the fnd.abs file in the trainer. Execute the
program in the trainer at: 0000:1000. Observe that the device CA7SD shows:
0,1,2,3,4,5,6,7,8,9,0,1,2............
Task-1B.10 (P110.asm) Write an 8086-based assembly language program to display the
characters: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,0,1,2,3...... cyclically on the device CA7SD. Get your
program codes down loaded from the PC to the trainer. The offset of the 1st code byte must be at:
2000h.

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.

Task-1B.13 Hardware Features of MDA-8086


A. Central Processing Unit Subsystem [see Fig-1.1]
1. 8086 Microprocessor running in Minimum Mode
2. Data Buffers for the data lines of the CPU
3. Address Latches for the Multiplexed Address-Data Bus
4. PAL-Based Composite Memory and Port Decoder
B. Memory Subsystem [see Fig-11.4]
1. 64 Kbytes of EPROM 2. 64 Kbytes of RAM
C: Interrupt Structure Subsystem [see Fig-1.1]
8259-Based 8-Channel Interrupt Priority Controller. It receives interrupt requests from the following
devices and funnels them to the 8086.
1. IR0: From the Timer/Counter-1 of the 8253 (U41)
2. IR1: From the Timer/Counter-2 of the 8253
3. IR2: Hardware activation using onboard key: IR2
4. IR3: From Serial Communication Chip, U14
5. IR4-IR7: Available to user via ‘EXT CONNECTOR, SLOT’.
D: Input/Output Subsystem [see Fig-1.1]
1. Keyboard: Discrete IC-Based Keypad containing 24 Keys
2. Display: LCD-Based Display containing 16x2 Characters
3. Parallel IO: a: Onboard 8255 (U29), which is interfaced with the following onboard IO devices:
i. FND (Common Anode Type 7-segment Display Device)
ii. LED Assembly (LED11 – LED14)
iii. Stepper Motor Driving Circuitry
iv. Digital-to-Analog Converter (U33), which feds analog signal to either of:
* Onboard Level Meter (U38, U39)
* Onboard Analog-to-Digital Converter (U31)
b: Onboard 8255 (U30), which is interfaced with the following onboard IO devices:
8x8 Bi-color Dot Matrix LED Assembly (DOT1)
4. Serial IO: 8251-Based (U14) Serial Communication Scheme, which communicates with the IBM-
PC using RS-232 (U15) Link at a fixed Bd (Baud Rate) of: 9600 bps.
5. ADC: ADC0804-Based Analog-to-Digital Converter. It takes analog signal either from:
a. Onboard Potentio Meter (VR2)
b. Onboard Thermostat (TH1)
c. Onboard DAC (U33, U36)
d. Onboard Microphone
6. DAC: DAC0800 being driven by Port-C of the 8255 (U29). It feds analog signal either to:
* Onboard Level Meter (U38, U39)
* Onboard Analog-to-Digital Converter (U31)
7. Speaker: Externally installable Output device via socket ‘SPK’. The speaker is interfaced to the
8086 via (U25, TR4) at an port address: 11h and data line: D8.

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

FFFF:0000 Start Up Location

F0000
EFFFF
Useable after Decoding
10000 (00)26 IO CON10
0FFFF (00)24 IO CON10
Reserved (00)22 IO CON10
User-3

4x 2KByres (00)20 IO CON10


ADC : DR/CR
0D000 (00)1F 8255 (U29): CR (00)1E OR
0CFFF 8255 (U30):CR
ADC : DR/CR
User-2

Reserved (00)1D 8255 (U29): PCR (00)1C OR


4x 4KByres 8255 (U30):PCR
ADC : DR/CR
09000 (00)1B 8255 (U29): PBR (00)1A OR
08000 Space for 8255 (U30):PBR
Stack Segment ADC : DR/CR
07000 (00)19 8255 (U29) PAR (00)18 OR
06000 Space for 8255 (U30):PAR
User-1

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

Figure-1B.6: Memory Space of MDA-8086 Figure-1B.7: Port Space Map of MDA-8086

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.

Task-1B.1 Familiarization with the Components Layout


In this task you will be locating and getting familiar with the following functional units of the
MDA-8086 trainer. These units are considered as the Building Blocks of a microprocessor based
system. The MDA-8086 is an 8086 microprocessor learning system made in Korea.
i. 8086 Microprocessor
ii. RAM (Random Access Read and Write Memory)
iii. EPROM (Ultraviolet Erasable and Electrically Programmable Random Access Read
Only Memory)
iv. Input Device (The Keyboard)
v. Keyboard Interface Controller (not visible)
vi. Output Devices:
a. Liquid Crystal Display Unit (LCD)
b. Common Anode Type 7-Segment Display Device (CA7SDD)
c. Light Emitting Diodes (LED11-LED14)
d. 8x8 Bicolor Dot Matrix LED [DOTLED]. Each dot contains Red and Green LEDs.
vii. Output Device Interface Controllers (not visible)
viii. Primary Memory Decoder (not visible)
ix. Primary Port Decoder (not visible)

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

ADC: 0804 : U31 IN TA INTA (40h)IR0 IR2


Speaker IN TR/ INT / (41h)IR1
+5V
IR2
CS/ CS/ IR3
Out
D D8 D7-D0 D7-D0 IR4
DR: 11h DR:12h IR5
IPC IR6
U42 CR:10h IR7
SPKIC: U25
8259
ODD: ROM:U8 27256 CS/ CS/ 62256 ODD: RAM : U10
F0001,...... ,FFFFF D15-D8D15-D8 00001, ........ 0FFFF
D7-D0 D7-D0 NMI
NMI +5V

EVN: ROM:U7 27256 CS/ CS/ 62256 EVN : RAM : U9


F0000, ..... FFFFE D7-D0 D7-D0 00000,......... 0FFFE
D7-D0 D7-D0

A,M-IO/,BHE/
Sx/ Sy/ 0V
Mem/Port Decoder : U16
GM: 547: 11/03:3 Hrs

Figure-1B.1: Hardware Block Diagram of MDA-8086 Trainer


432
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.
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)

(1) CA Code for Blank DSM


03011 FF
03010 B0 CA Code for 3

PC = CS:IP
Program Codes CSM
(2) xxxxx TDELAY
(4) 01000
RAM: U9, U10
548

Figure-1B.3: Connection Diagram between CA7SD and the CPU

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

L2: 0000:100E – mov al, 80h B0 80 ; bx-register to work as pointer


out CRU29(1Fh), al E6 1F ; reading cacode for ‘3’
mov bx, 3000h BB 00 30 ; sending cacode of ‘3’ to PAR
L2A: 0000:1015 - mov al, BYTE PTR ds;[bx+10h] 8A 47 10 ; Insert Time Delay
out PARU29(19h), al E6 19
mov cx, 0FFFFh B9 FF FF
HERE1: 0000:101D- loop HERE1 E2 FE

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

L4: 0000:1029- jmp L2A EA 15 10 00 00 ; repeat the process

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

538 538 538

(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.

Task-1B.7 Learning How to Get Machine Codes of Character Blinking of Task-1B.4


In this task, we will get familiar with the procedures of getting the machine codes for the
character-blinking program of Table-B of Task-1B.4. We shall use MASM (Macro Assembler)
program and the IBM-PC to obtain the machine codes for the assembly instructions of Table-B of
Task-1B.4. The procedures are:
(a) Create a directory named as MDA8086 in the hard drive C. And now accommodate the
following program files under this directory. These programs may easily be collected
from the CD that has been supplied with the MDA-8086 trainer. If the directory already
exists and contains these files then go to step-b
Sno. File Name Purpose
1 COMM.EXE Serial Monitor of the MDA-8086 Trainer
2 LINK.EXE To create relocatable *.EXE file from *.OBJ file
3 LOD186.EXE To create ‘Absolute (*.ABS)’ file from *.obj file
4 MASM.EXE To create *.LST and *.OBJ files form *.ASM file
5 EDIT.EXE To create Assembly Program (Source Code) for 80x86 MPUs
6 EXER <DIR> A Working Directory
(b) Boot the IBMPC in Windows 98/XP and then go to DOS path using the Start Menu. The
monitor would show as:
c:\windows>_
Bring the IBM-PC in the following DOS path:
c:\mda8086>--
The procedures:
1. Type cd.. and then press enter key
2. Type mda8086 and then press enter key.
(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-1B.4.

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

Figure-1B.5: Jumper P1 is at Local Monitor Environment


(p) Power OFF and then ON of the MDA-8086 trainer and then press the RESET key.
(q) The LCD display of the trainer shows the following prompt message:
MDE8086 Kit V9.5
Midas 335-0964/5
(r) Use keyboard of the trainer and enter the machine codes of Step-n 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. For multi-byte data, the lower bytes should be
entered first.
(s) Enter the data B0h (for character 3) at RAM location 0000:3010 and FFh (for Blank) at
RAM location 0000:3011 of the data segment memory.
(t) Execute the program at location: 0000:1000 using the GO command.
(u) Observe that the device 3 is blinking on the CA7SD device.
(v) The Task-1B.7 is well done.
Task-1B.8 In this Task, we will learn how to transfer the machine codes of the Step-n of Task-
1B.7 from the IBMPC to the CSM of the MDA-8086 trainer. This method is known as Down
Loading. To do it, we will be using the COM1 port of the IBMPC. 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 MDA-8086 trainer. Bring P1 jumper (Switch) at the ‘Serial Monitor’/KIT
position. Connect the serial cable of the trainer with the COM1 port of the IBMPC.
2. Bring the IBM-PC in the following DOS prompt:
c:\mda8086> _
3. From the start icon of the IBMPC execute the WinComm and then goto Step-4 below.
OR
Type COMM at the cursor position and then press Enter key. A communication screen will
appear. Press F5 function key and modify the screen as follows:
Serial Port (1/2) : [X] ==>1 press Enter key
Serial baud rate Set
1200 = 1 2400 = 2 4800 = 3
9600 = 4 19.2K = 5 38.4 = 6
Baud Rate Select (1 – 6) : [X] = = > 4 (always) press Enter key
Parity bit NP =0, Po = 1, Pe = 2 : [X] ==>0 press Enter key
Word Size 7-bit=2, 8-bit=3 : [X] ==>3 press Enter key
Stop bit 1-bit=0, 2-bit=1 : [X] ==>0 press Enter key
Change OK (Y/N) ? y press Enter key

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:

c:\mda8086> _ The converted file is located at: c:\mda8086\P1B.abs.


8. Type EDIT at the cursor position of the DOS prompt. Open the file P1B.abs
9. The screen shows multiple lines, which are very similar to the following line. This
particular format is known as Intel-hex Format. For details, see Page-12/Expt1A).
: 0A 1000 00 90 B8 80 E6 1F B0 B0 E6 19 F4 46

Starting address of storage


10. Exit the screen and come to the DOS prompt of: c:\mda8086> _
11. Type COMM at the DOS prompt and press the Enter key OR click on the WinComm.
12. Reset the MDA-8086 trainer to activate Serial Link with IBMPC.
13. Type L at the cursor position. Press Enter key. And then press F3 key.
14. Type c:\mda8086\P1B.abs and then press Enter key. The program codes have already
been transferred into the trainer with the message ‘OK Completed’.
15. Bring the jumper P1 (Switch) of the trainer into Local Monitor/KIT position.
16 Enter B0h (CA code for 3) at memory location 03010h (0000:3010) and FFh (CA code for
Blank) at memory location 03011h (0000:3011) of the DSM.
17 Execute at 0000:1000 using the GO command of the trainer.
18 The device CA7SD must blink the character ‘3’
Task-1B.9 Find the location of the file ‘fnd.abs’ in your computer and bring it under the
directory of c:\mda8086. Down load the codes of the fnd.abs file in the trainer. Execute the
program in the trainer at: 0000:1000. Observe that the device CA7SD shows:
0,1,2,3,4,5,6,7,8,9,0,1,2............
Task-1B.10 (P110.asm) Write an 8086-based assembly language program to display the
characters: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,0,1,2,3...... cyclically on the device CA7SD. Get your
program codes down loaded from the PC to the trainer. The offset of the 1st code byte must be at:
2000h.
439
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.

Task-1B.13 Hardware Features of MDA-8086


A. Central Processing Unit Subsystem [see Fig-1.1]
1. 8086 Microprocessor running in Minimum Mode
2. Data Buffers for the data lines of the CPU
3. Address Latches for the Multiplexed Address-Data Bus
4. PAL-Based Composite Memory and Port Decoder
B. Memory Subsystem [see Fig-11.4]
1. 64 Kbytes of EPROM 2. 64 Kbytes of RAM
C: Interrupt Structure Subsystem [see Fig-1.1]
8259-Based 8-Channel Interrupt Priority Controller. It receives interrupt requests from the following
devices and funnels them to the 8086.
1. IR0: From the Timer/Counter-1 of the 8253 (U41)
2. IR1: From the Timer/Counter-2 of the 8253
3. IR2: Hardware activation using onboard key: IR2
4. IR3: From Serial Communication Chip, U14
5. IR4-IR7: Available to user via ‘EXT CONNECTOR, SLOT’.
D: Input/Output Subsystem [see Fig-1.1]
1. Keyboard: Discrete IC-Based Keypad containing 24 Keys
2. Display: LCD-Based Display containing 16x2 Characters
3. Parallel IO: a: Onboard 8255 (U29), which is interfaced with the following onboard IO devices:
i. FND (Common Anode Type 7-segment Display Device)
ii. LED Assembly (LED11 – LED14)
iii. Stepper Motor Driving Circuitry
iv. Digital-to-Analog Converter (U33), which feds analog signal to either of:
* Onboard Level Meter (U38, U39)
* Onboard Analog-to-Digital Converter (U31)
b: Onboard 8255 (U30), which is interfaced with the following onboard IO devices:
8x8 Bi-color Dot Matrix LED Assembly (DOT1)
4. Serial IO: 8251-Based (U14) Serial Communication Scheme, which communicates with the IBM-
PC using RS-232 (U15) Link at a fixed Bd (Baud Rate) of: 9600 bps.
5. ADC: ADC0804-Based Analog-to-Digital Converter. It takes analog signal either from:
a. Onboard Potentio Meter (VR2)
b. Onboard Thermostat (TH1)
c. Onboard DAC (U33, U36)
d. Onboard Microphone
6. DAC: DAC0800 being driven by Port-C of the 8255 (U29). It feds analog signal either to:
* Onboard Level Meter (U38, U39)
* Onboard Analog-to-Digital Converter (U31)
7. Speaker: Externally installable Output device via socket ‘SPK’. The speaker is interfaced to the
8086 via (U25, TR4) at an port address: 11h and data line: D8.

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

FFFF:0000 Start Up Location

F0000
EFFFF
Useable after Decoding
10000 (00)26 IO CON10
0FFFF (00)24 IO CON10
Reserved (00)22 IO CON10
User-3

4x 2KByres (00)20 IO CON10


ADC : DR/CR
0D000 (00)1F 8255 (U29): CR (00)1E OR
0CFFF 8255 (U30):CR
ADC : DR/CR
User-2

Reserved (00)1D 8255 (U29): PCR (00)1C OR


4x 4KByres 8255 (U30):PCR
ADC : DR/CR
09000 (00)1B 8255 (U29): PBR (00)1A OR
08000 Space for 8255 (U30):PBR
Stack Segment ADC : DR/CR
07000 (00)19 8255 (U29) PAR (00)18 OR
06000 Space for 8255 (U30):PAR
User-1

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

Figure-1B.6: Memory Space of MDA-8086 Figure-1B.7: Port Space Map of MDA-8086

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

Memory Location Content Table


(20-Bit) seg:off
04FFF = 0000:4FFF

Output

04001 = 0000:4001 Rubyte = 01


04000 = 0000:4000 Rlbyte = 18
03FFF = 0000:3FFF

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

Task-2.4 Flow Chart for Adding Two Unsigned Numbers


10:GM:10-08
START: Entry

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

Figure-2.2: Flow Chart for Adding Two 8-bit Numbers

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

00h ---> 04001h

L4 :

al + dl ---> c , al

L5:
Y L 9:
Carry = 1
L5A: ?
N 01h+(04001h)--->04001h

00h+(04001h) --> 04001h

L6:

al --- > 04000h

L7:

Halt

Figure-2.3: Flow Chart for Adding Three 8-bit Numbers

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

i. The MLPR (range: 00h – FFh (20-Bit) seg:off


04FFF = 0000: 4FFF
ii. The MPLC (range: 00h – FFh)
iii. The Product (range: 0000h – FE01h). The upper Output
part of the result, is in fact, the accumulation
of the carry bits that had been generated during 04001 = 0000:4001 Rubyte
addition process. 04000 = 0000:4000
03FFF = 0000: 3FFF
Rlbyte

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.

L1: mov bx, 3000h


mov ax, WORD PTR [bx+10h] ; reading MLPR and MLPC
L2: mul ah
L3: mov WORD PTR [bx+0400h] ; result
L4: hlt

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.1 Get Familiar with the 40-pins of the 8255


See Fig-4.3 (a) of this book.

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.

Task-3.3 Programming the 8255 (U23) of MicroTalk-8086 for Data IO Operations


The following 8086-8255-LED based interface circuit of Fig-4.1 has been taken from the User
Technical Reference Manual of MicroTalk-8086 trainer. With the help of this circuit, we will get
familiar with the architectures and programming of the 8255 controller for data IO operations.
GM:672: 08/04

PCR: 3604h

PC7 – PC0 (J7)

A A PBR: 3602h
PB7
D7- D0 D LED15

RD/ R/ PB0 LED8


WR/ W/
M -IO/ IO/ PAR: 3600h
PA7 LED7
CS/

LED0
PA0
CR
3606h

8086: U2 8255: U23

Figure-4.1: 8255-based Interfacing Circuit for Experiments using MicroTalk-8086 Trainer


Task-3.4 Adding Two Numbers and Show Result in Bit Form on LED15 – LED0
1. Open the addition program of Experiment-2 and save it as P4.asm
2. Put the following Pseudo/ASM codes at Label L6 in order to send the result on the LEDs of 8255.
L6: Set the direction of the IO lines of variable ports PAR and PBR as
output. Consult Section-4.2 (a) of his book for the required Cbyte.
mov dx, 3606h
mov al, 92h ; PAR, PBR as output; PCR as input
out dx, al

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.5 Blinking only LED0 for 10 Times


Convert the following Text Codes into 8086 ASM codes and save as: P4B.asm. Execute the program and
check that the LED0 blinks for 10 times.
1. Set Direction of PAR as output by sending appropriate Cbyte into CR
2. Set a Counter for 10 counts corresponding to 10 times blinking.
3. Ignite LED0 by sending LH to PA0
Insert Time by calling the following subroutine.:
TDEL: mov cx, 0FFFFh
ADEC: loop ADEC ; again decrement
ret
4. Extinguish LED0 by sending LL to PA0
Insert time delay by calling the subroutine TDEL: ; Time Delay
5. Decrement Counter
if (Counter !=0)
goto Step-3
6. End

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

3. Declare all the codes of P4C.asm as a subroutine named BLED0.

4. Configure PCR as input.

5. Read PCR

6. If (PC0 != LH)
Goto Step-5

7. Blink LED0 for 10 times by calling subroutine BLED0.

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.

8086 : U1 8255 : U29 P3/P4 CA7SDD

PAR (19h) 8x330R a


AD15 39 27 D7 PA0 04 02 07 a
AD14 02 28 D6 03 03 06 b f b
PA1
AD13 03 29 D5 02 04 04 c g
PA2
AD12 04 30 D4 PA3 01 05 02 d
AD11 05 31 D3 40 06 01 e e c
PA4 p
AD10 06 32 D2 PA5 39 07 09 f
AD09 07 33 D1 PA6 38 08 10 g d
AD08 08 34 D0 37 09 05 p
PA7
RD/ 32 05 RD/ R26-R33 CA
WR/ 29 36 WR/ PBR(1Bh) 08

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

Figure-4.2: 8255-based Interfacing Circuit for Experiments using MDA-8086 Trainer

Task-3.8 Blink Character 5 for Seven Times on the CA7SDD Device


MYCODE SEGMENT
ASSUME cs:MYCODE
ORG 1000h

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

L3: mov al, CAB ; CAB is equal to CA-code of Blank = FFh


out PAR, al
call TDEL

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

8086: U1 8255: U30 DOTLED

Figure-4.3: Interconnecting Diagram of 8086, 8255 and the DOTLED

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.

MicroTalk -8086 2x16 Charracter LCD


DP0 DPF

DP10 DP1F
D7
D6
D5
D4
D3
D2
D1

E R-W / D-I/ VA Vdd Vss L+ L-


D0
14
13
12
11
10

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

U1: 74LS138 U2: 7486


722ab

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.

Task-5A.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 P5A4.asm. Assemble the program,
download it and execute it. Check that the LCD shows the desired character.
i. Clear Display by sending:
call TDEL
Cbyte1 (01h) into LCDIR
ii. Entry Mode Set by sending:
call TDEL
Cbyte2 (04h) into LCDIR:
iii. Display ON/OFF Control by sending
call TDEL
Cbyte3 (0Ch) into LCDIR.
vi. Cursor Shift Mode by sending:
call TDEL
Cbyte4 (18h) into LCDIR.
v. Function Set by sending:
call TDEL
Cbyte5 (38h) into LCDIR

vi. Sending Character A to LCD


call TDEL
Dbyte (41h for A) into LCDDR.

TDEL: mov cx, 00FFh


KJ: loop KJ
ret

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

L1: call LCDINIT

L2: call BUSY


mov al, 82h ; cursor position at DP2 of Line-0
mov dx, LCDIR
out dx, al

L3: mov si, OFFSET MSG ; knowing how far the message Chittagong is!
mov bx, 0000h ; pointing the 1st character (C) of the message

L3A: mov ah, BYTE PTR [si+bx]


cmp ah, 00h ; to check if printing of the message is done
jz L4 ; message printing done
call BUSY
mov al, ah
mov dx, LCDDR
out dx, al
inc bx ; pointing at the next character
jmp L3A ; collect and print the next character

L4: mov bx, 0474h


mov WORD PTR [bx], 0000h
mov WORD PTR [bx+02h], 0F000h
jmp DWORD PTR [bx] ; the trainer goes to the prompt: 8086 CPU

MSG DB '***Chittagong***', 00h

BUSY: mov cx, 00FFh


KJ: loop KJ
ret
LCDINIT:
; Send Cbyte1 (01h) into LCDIR
; send Cbyte2 (04h) into LCDIR
; send Cbyte3 (0Ch) into LCDIR
; send Cbyte4 (18h) into LCDIR
; send Cbyte5 (38h) into LCDIR

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.

Task-5B.2 Familiarization with the Instruction Set of 2-Line LCD Panel


See Section-4.4 (c) of this book.

Task-5B.3 Familiarization with the Connection of 8086-LCD of MDA-8086 Trainer


The following 8086-LCD interface circuit of Fig-5B.1 has been taken and redrawn from the MDA-
8086 manual.
540
8086 : U1 16x2 LCD
DP10DP0
AD07 09 14 D7
AD06 10 13 D6
AD05 11 12 D5
AD04 12 11 D4
AD03 13 10 D3
AD02 14 9 D2
AD01 15 8 D1
AD00 16 7 D0
R D/ 32
WR/ 29 6 E
A Decoder
M -IO/

A2 4 D-I/
A1 5 R -W /

+5V 2 Vdd

Viewing
VA1 Angle 3 VL
10k
0V 1 Vss DP1F DPF

Figure-5B.1: Bus Structured Connection Diagram between 8086-LCD of MDA-8086 Trainer


[Operational Truth Table-1]
Function 8085 Instruction Signal Activities
WR/ RD/ E A2 A1
Write into Instruction Register: LCDIR (00h) out LCDIR, al 0 1 1 0 0
Read from Status Register: LCDSR (02h) in al, LCDSR 1 0 1 0 1
Write into Data Register: LCDDR (04h) out LCDDR, al 0 1 1 1 0
Read from DDR/CGR Register: LCDCR (06h) in al, LCDCR 1 0 1 1 1

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

Figure-6A.1: Circuit for Functionality Check of NMI-interrupt

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

PAR (19h) 8x330R a


AD15 39 27 D7 PA0 04 02 07 a
AD14 02 28 D6 03 03 06 b f b
PA1
AD13 03 29 D5 02 04 04 c g
PA2
AD12 04 30 D4 PA3 01 05 02 d
AD11 05 31 D3 40 06 01 e e c
PA4 p
AD10 06 32 D2 PA5 39 07 09 f
+5V AD09 07 33 D1 PA6 38 08 10 g d
AD08 08 34 D0 37 09 05 p
PA7
RD/ 32 05 RD/ R26-R33 CA
WR/ 29 36 WR/ PBR(1Bh) 08
LED11
NMI
A.M-IO/ 06 CS/

A2 08 A1 PB0
MON
Key
A1 09 A0 0V

RST 35 RST

+5V 26 Vcc
0V 07 GND
CR (1Fh)
+5V
538

Figure-6B.1: Circuit for Functionality Check of NMI-interrupt


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 MDA-8086 and test it.
MLP = To blink character 3 on the CA7SD device of Fig-6B.1 continuously.
START1: nop
ML1: Cbyte → CR ; to set direction of PBR, PAR as output
ML2: CA_3 → CA7SD
Insert Time Delay by calling the SUT TDEL1
ML3: Send CA_Blank → CA7SD
Insert Time Delay by calling TDEL1
ML4: Goto ML2 ; repeat the cycle
TDEL1: load cx-register with FFFFh
Keep decrementing until cx = 0
Return from SUR

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

BIN = (((d3)0Ah + d2) 0Ah + d1 ) 0Ah + d0


= (((IPBIN x 0Ah + d3)0Ah + d2) 0Ah + d1 ) 0Ah + d0
where: IPBIN = Initial Partial Binary = 0000h
2. Computation Philosophy
a. Extract d3 and compute: (IPBIN x 0Ah + d3) → IPBIN
b. Carry out Step-a, for all the digits of the input BCD 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.
bh bl dh dl

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

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.

Task-5A.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 P5A4.asm. Assemble the program,
download it and execute it. Check that the LCD shows the desired character.
i. Clear Display by sending:
call TDEL
Cbyte1 (01h) into LCDIR
ii. Entry Mode Set by sending:
call TDEL
Cbyte2 (04h) into LCDIR:
iii. Display ON/OFF Control by sending
call TDEL
Cbyte3 (0Ch) into LCDIR.
vi. Cursor Shift Mode by sending:
call TDEL
Cbyte4 (18h) into LCDIR.
v. Function Set by sending:
call TDEL
Cbyte5 (38h) into LCDIR

vi. Sending Character A to LCD


call TDEL
Dbyte (41h for A) into LCDDR.

TDEL: mov cx, 00FFh

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

L1: call LCDINIT

L2: call BUSY


mov al, 82h ; cursor position at DP2 of Line-0
mov dx, LCDIR
out dx, al

L3: mov si, OFFSET MSG ; knowing how far the message Chittagong is!
mov bx, 0000h ; pointing the 1st character (C) of the message

L3A: mov ah, BYTE PTR [si+bx]


cmp ah, 00h ; to check if printing of the message is done
jz L4 ; message printing done
call BUSY
mov al, ah
mov dx, LCDDR
out dx, al
inc bx ; pointing at the next character
jmp L3A ; collect and print the next character

L4: mov bx, 0474h


mov WORD PTR [bx], 0000h
mov WORD PTR [bx+02h], 0F000h
jmp DWORD PTR [bx] ; the trainer goes to the prompt: 8086 CPU

MSG DB '***Chittagong***', 00h

BUSY: mov cx, 00FFh


KJ: loop KJ
ret
LCDINIT:
; Send Cbyte1 (01h) into LCDIR
; send Cbyte2 (04h) into LCDIR
; send Cbyte3 (0Ch) into LCDIR

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.

Task-1.1 Familiarization with Components Layout


In this task you will be locating and getting familiar with the following functional units of the
MicroTalk-8086 trainer. These units are considered as the building blocks of a microprocessor
based system. The MicroTalk-8086s is an 8086 microprocessor learning system, which has been
designed, developed and built in Bangladesh by the author.
i. 8086 Microprocessor
ii. RAM (Random Access Read and Write Memory)
iii. EPROM (Ultraviolet Erasable and Electrically Programmable Random Access Read
Only Memory)
iv. Input Device (The Keyboard)
v. Keyboard Interface Controller
vi. Output Device (CC7SD = Common Cathode 7-Segment Display Device)
vii. Output Device Interface Controllers
viii. Primary Memory Decoder
ix. Primary Port Decoder

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

IR2-IR7 RxRS TxRS GT CK OT 16 LEDs 4xPh 8x8 LED MAT

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

U14 U17 U23 U30


U13 UD
IPC USART LED DM
U4, U5 PIT
PIO PIO
DBUFF A
DEN/ EN/ D
DT-R/ DIR
C
D DP9 DPB DPC DPE
DP DPF
DPA
D
D15-D0
A
ALE
CK
D 4 to 16 Decoder
C
AD A
SL
U6,U7,U8
C ALATCH C
3 to 8 Decoder
U1
MPU
M-IO/
A BHE/ D E F
DLD
DOP EXA FRW
A B C
WAIT
CS/-User (3)
J1 AUT BKW CHG
CS/-U14
CS/-U17 7 8 9
F3
CS/-U13
0000 - 0FFE
EXW EXB FLR
CS/-U23
CS/-U30 4 5 6
CS/-U24 F4
CS/-U10 CS/ Row CS PC FB
CS/-U09
1 2 3
CS/-U12 F5
CS/-U11 IP AX Al
CS/-U15
CS/-U16 0 BKS
RST RST
PRT S/S
608
CS/ ADC CS/ ADC CS/ ADC CS/ ADC CS/ ADC CS/ ADC U24
U1, U3 3400h Keyboard
3200h 00001h - 00000h - F0001h - F0000h - KBDC
MEMPORT
0FFFFh 0FFFEh FFFFFh FFFFEh
DECODER
U11 U12 U9 U10
U16 U15 ROMEVN
RAMODD RAMEVN ROMODD
DAC ADC (32K)
(32K) (32K) (32K)
AnOut AnIn

J5 J5

Figure-1.1: Hardware Block Diagram of McroTalk-8086 Trainer

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

Figure-1.2: Keyboard Layout of MicroTalk-8086 System

The 24 keys of the keypad may be classified into the following categories:

A: CPU Control Key


1. RST (System ReSeT) : When this key is pressed down and then released, the 8086 are reset
and starts from the cold state. The PC looks for the ‘Opcode’ of a valid instruction at
memory location: FFFF (CS):0000 (IP) = FFFF0h. Activation of the RST key displays the
following message on the 7-segment CC-type display device (CC7SD).:
8086 CPU
B: Command Keys
1. EXA (Memory EXAmination): Command to open the 20-bit address of a memory location.

2. AUT (AUTo Increment): Command to enter data into memory locations on auto
incrementing the address field.

3. DOP (DO a Program): Commanding the CPU to execute a program.

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.

7. EXW (Examine Word): Command to examine/edit the contents of two consecutive


memory locations.

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

SSM Memory Location Content Table


(20-Bit) seg:off
04FFF = 0000:4FFF
(07000 = 0000:7000)
(06000 = 0000:6000)
Output

ESM 04001 = 0000: 4001


04000 = 0000: 4000 Result = 73
03FFF = 0000:3FFF
(05000 = 0000:5000)
(0 4F FF = 0000:4FFF)
Inputs

DSM 03012 = 0000: 3012


03011 = 0000: 3011 Data2=47
03010 = 0000: 3010 Data1= 2C
(03000 = 0000:3000)
02 FF F = 0000:2FFF)

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

Memory Location Content Table


(20-Bit) seg:off
02FFF = 0000:2FFF

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

Figure-1.4: Code Segment Memory for the Program Codes of Table-B


7. Reset the trainer. Use the EXA and RRW commands to open the addresses starting at 01000h
and check that the codes have been correctly entered into the specified memory locations.
8. Now is the turn to execute the program of Table-B, which we have already loaded into the
CSM of Fig-1.4. Remember that the program execution will always begin from the starting
location of the program. To execute the program follow the steps of Table-C.
Table-C
Steps to be followed to Execute the Program of Table-B
Sn. Press Key 7Seg Display Remarks
1 RST 8086 CPU Trainer is ready
2 DOP - - - - - do Address Field is opened to accept the 20-bit starting address of
the CSM (This is the beginning address of your program).
3 01000 run The program is executed.

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!)

Task-1.6 Working Principles of Number Addition Program of Table-B


The diagram of Fig-1.5 depicts the ‘Signal Flow’ structure for the problem of adding two numbers 2Ch and
47h of Task-1.4.
610
DSM CPU LEDPIO(U23)
043FF Result

CR (3606h)

PA R (3600h)
LD7
al ah
03012 73 ALU
03011 47
03010 2C

al
D LD0
D
03000

Result

Figure-1.5: Signal Flow Diagram of the Addition Problem of Task-1.4


Working Principles: The CPU brings the data1 (2Ch) into its al-register. It then brings data2 (47h) into its
ah-register. The contents of the al and ah registers are added in the ALU of the 8086 CPU. The result (73h) is
be shown in the output LEDs: LD7-LD0. In Fig-1A.1, we see that the LEDs are connected with the CPU via
the interface controller LEDPIO (U23: 8255). Thus, we may say that the CPU sends the result from its al-
register into the LEDPIO and from PIO the result automatically goes into the LEDs. The result is also saved
at memory location: 03012h of the DSM.

Task-1.7 Getting Machine Codes


In this task, we will get familiar with the procedures of getting the machine codes for the number
addition program of Table-B of Task-1.4. We shall use MASM (Macro Assembler) program and
the IBM-PC to obtain the machine codes for the assembly instructions of Table-B of Task-1.4. The
procedures are:
(a) Check that the D drive of your computer contains the directory (Folder)) named as
MTK8086 and then goto Step-b. If the directory doesn’t exit, then copy the folder
MTK8086 from the MicroTalkCD into the D drive. The following files (Folders) are the
essential components for learning 8086 Assembly Programming.
Sno. File Name Purpose
1 MTK86COM1 Serial Communication Interface for MicroTalk-8086 Trainer
2 LINK.EXE To create relocatable *.EXE file from *.OBJ file
3 LOD186.EXE To create ‘Absolute (*.ABS)’ file from *.obj file
4 MASM.EXE To create *.LST and *.OBJ files form *.ASM file
5 EDIT.EXE To create Assembly Program (Source Code) for 80x86 MPUs
6 EXER <DIR> A Working Directory
(b) Boot the IBM-PC in WIN98/WINXP and then click on the Command Prompt menu by
following the path: Start → All Programs → Accessories → Command Prompt.
(c) Bring the IBM-PC in the following DOS path:
d:\mtk8086>--

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

1000 90 START: nop

1001 BB 3000 L1: mov bx, 3000h


1004 8A 47 10 mov al, BYTE PTR [bx+10h]
1007 8A 67 11 mov ah, BYTE PTR [bx+11h]
100A 02 C4 L2: add al, ah
100C 88 87 1000 L3: mov BYTE PTR [bx+1000h], al

1010 8A E0 L4: mov ah, al


1012 B0 80 mov al, 80h
1014 BA 3606 mov dx, 3606h
1017 EE out dx, al

1018 8A C4 L5: mov al, ah


101A BA 3600 mov dx, 3600h
101D EE out dx, al

101E F4 L6: hlt

101F MYCODE ENDS


END START

(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.

Figure-1A.6: GUI Interface to Download Program Codes from IBMPC to MicroTalk-8086

6. Go to the DOS path: d:\mtk8086


7. Now, convert the T14.obj (object) file into T14.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 T14.obj
(b) Type d:\mtk8086\T14.abs
(c) press Enter key
The conversion is completed with the message LOAD COMPLETED and the PC comes to the
following DOS path:
d:\mtk8086> _ The converted file is located at: d:\mtk8086\T14.abs.
8. Type EDIT at the cursor position of the DOS prompt. Open the file T14.abs
9. The screen shows the following lines known as Intel-Hex formatted frames. Each frame is
composed of many fields and the fields have meanings, which are explained in Task-1.9.
:1410000090BB00308A47108A671102C4888700108AE0B080FF
:0B101400BA0636EE8AC4BA0036EEF4CD
:0400000300001000E9
:00000001FF

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:

(a) indicates that a new data frame to begin


(b) indicates number of information bytes to transfer that is contained in (e).
(c) indicates the starting location of RAM to store information bytes
(d) indicates ‘Not the End of File’, when the value is 00
(e) indicates the actual information byte (In this example it is 16)
(f) indicates checksum and is computes ad follows:
all data bytes from and including (b) to (e) are added. The carry is
discarded. Two's complement of the remaining 8-bit are taken as CHKSUM and is
transmitted as the last filed of the frame. For more details, the readers are
referred to MicroTalk-8086 User Technical Reference Manual CD for the
following resources:
85serlink.asm. This is a ROM-based program of the MicroTalk-8085 trainer
program and receives the Intel-Hex frames from the IBMPC. MTK86COM1 is the
GUI program of the IBMPC and transmits the Intel-Hex frames.

Working Principles of the Receiver Program of MicroTalk-8086 Trainer:


1. The program receives data from the IBMPC character by character in ASCII format. This
means that the data byte of caption (b) is received as 31H and 30H.

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.

Taks-1.12 Memory Space and Port Space Organization of MicroTalk- 8086


Port Space Map
FFFFF ODD Port EVEN Port
FFFF FFFE

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

Extra Segment 3602 PB of 8255:U23


RAM

05000 3600 PA of 8255:U23


04FFF Space for
35FE Shadow
3400 DR of DAC : U 16
03000 Data Segment 33FE
Shadow
02FFF Space for 3200 DR/CR :ADC:U15
31FE
Shadow
01000 Code Segment 3006 CR /SR: 8251: U13
00FFF 3004 C2 of 8251: U13
Scratch Pad 3002
3000
C1 of 8253: U13
C0 of 8253: U13
00F00 2FFE
Shadow
00EFF 2002 CR of 8251: U17
Data Structure 2000 DR of 8251: U17
1FFE
00400 Shadow
003FF 1002 CR of 8259 : U 14
Interrupt 1000 DR of 8259 : U 14
0FFE Shadow
Vvector Table
00000 0001
0002
0000
CR /SR: 8279: U24
DR of 8279: U24
545 607a

Figure-1.6: Memory and Port Space Map of MicroTalk-8086

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

K50 K51 K52 K53

F5 1/IP 2/AX 3/AL

8279 K60 K61 K62 K63

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

MicroTalk-8086 ( Bangladesh ) MDA-8086 ( Korea )

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

DP1 DP3 DP6 DP8


DP0 DP2 DP4 DP5 DP7

DP9 D P11 D P13 D P15


D P10 D P12 D P14
+5
-5 Cost Field
0V A U24
U23 U2
m 8279
J7 8255 8086
p
DS1
DS2 E
DS3
DS4
7 8 9
A 4 5 6
Q3
D Q2
C Q1 1 2 3
Q0
0 BKSRST

Figure-71.1: Block Diagram of DWM Based on the MicroTalk-8086 Trainer

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

Figure-71.4: Table Containing upBCD Weight Data


Also assume that the upBCD weight data are converted to pBCD and CC-codes and are saved
into following memory locations of Table-3 (Fig-71.5) and Table-T1 (Fig-71.6) respectively.
For the weight of 12.370kg, we have:
(05020) = 12 for 12 kg
(05021) = 37 for 370 gm
05021 pBCD: 1/10, 1/100 Wt
05020 pBCD: 10, 1
BCD
Field
Figure-71.5: Table Containing BCD Weight
For the weight of 12.370kg, we have:
(05000) = 06 for the digit- 1
(05001) = 5B for the digit-2
(05002) = 4F for the digit-3
(05003) = 07 for the digit-7
(05004) = 3F for the digit-0
05004 always 3Fh for 0 DP4
CC-C ode: 1/100 DP3 Wt
4b. Assemble, convert, download and execute CC-C ode: 1/10 DP2 Field
CC-C ode: 1 (UNI) DP1 T1a
p712a.asm. The DP0-DP4 shows: 12.370 kg. 05000 CC-C ode: 10 (TEN) DP0

Figure-71.6: Table Containing CC-code Weight


5 We will be using the keyboard of the MicroTalk-8086 trainer to enter the product rate. The
rate will be entered one digit at a time and will be instantly processed by the CPU. The
keyboard of the trainer will be supplying an 8-bit Scan Code for a digit that has been pressed.
Let us assume that the rate of the product is: Tk 27.95/kg. Now, when the user presses the key
with label-2, the CPU will receive the code 0Dh. Let us assume that the specified memory
locations of Table-T5 (Fig-71.7) will contain the RTSCAN (product Rate in SCAN Code
format). The specified memory locations of Table-T3 (Fig-71.8) will contain the BCD (product
rate in BCD format).
2/Expt-10A
For the product rate of Tk 27.95/kg, we have:
(0504B) = 15 for digit-2
next (0504B) = 0B for digit-7
next (0504B) = 1B for digit-9
next (0504B) = 14 for digit-5
0504D
0504C Rate
0504B Key Scan Code
0504A C ursor Type T5
05049 No of Digits to Print
05048 C ursor Position
05047 ASCII for 1/100 DP1F
Figure-71.7: Table Containing Scan Code Rate

For the product rate of Tk 27.95/kg, we have:


(05022) = 27 for Tk 27
(05023) = 95 for Paisa 95
5b. Assemble, Download and Execute: P712b.asm
05023 pBC D: 1/10, 1/100
The DP0-DP4 shows: 12.370 kg. 05022 pBC D: 10, 1
Rate
BCD
Field
The DP5-DP8 shows: 27.95 Tk
Figure-71.8: Table Containing BCD Rate

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

0500F CC -Code: 1/100 DP15


6b. Assemble, download and execute: p712c.asm CC -Code: 1/10 DP14
Cost
CC -Code: 1 (UNI) DP13
The DP0-DP4 shows : 12.370 kg (weight) CC -Code: 10 (TEN) DP12 Field
The DP5-DP8 shows: 27.95 Tk (rate) 0500B CC -Code:100 (HUN) DP11 T1c
0500A CC -Code: 1000 (K) DP10
The DP10-DP15 shows: 0345.74 Tk (Cost). 05009 no Use
Figure-71.10: Table Containing CC-code Cost

3/Expt-10A
GM:04/04: 632

05053 UpBCD Wt: 1/100 Goods


05052 UpBCD Wt: 1/10 upBCD
05051 UpBCD Wt: 1
T7
Wt
05050 UpBCD Wt: 10
0504F
0504E Scratch
0504D T6
Pad Memory Rate
0504C
0504B Key Scan Code
0504A Cursor Type T5
05049 No of Digits to Print
05048 Cursor Position
05047 ASCII for 1/100 DP1F
ASCII for 1/10
ASCII for .
ASCII for 1
Rate ASCII Type LCD Display of
ASCII for 10 Field
ASCII for : T4c MDA-8086 amd MTS-86C
ASCII for R
05040 ASCII for Blank DP18 DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA DPB DPC DPD DPE DPF
0503F ASCII for 0 DP17
ASCII for 1/100

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

05025 pBCD: 1000, 100


pBCD

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

upBCD: X0 : 100 T2c


0501A upBCD: X0 : 1000 DP10
05019 no Use
05018 upBCD: X0 : 1/100
upBCD: X0 : 1/10
DP8 Rtae CC7S Type Display of
Field
upBCD: X0 : 1
T2b MicroTalk-8086 Trainer Example Data
05015 upBCD: X0 : 10 DP5
05014 no Use Weight Field Rate Field 1. Weight: 12.370 kg
05013 upBCD: X0 :1/100 DP3 Wt
upBCD: X0 :1/10 2. Rate: 27.95 Tk
upBCD: X0 : 1 Field DP1 DP3 DP6 DP8 3. Cost : 345.74 Tk
05010 upBCD: X0 : 10 DP0 T2a DP0 DP2 DP4 DP5 DP7
0500F CC-Code: 1/100 DP15
CC-Code: 1/10 DP14
CC-Code: 1 (UNI) DP13 Cost
1 2. 3 7 0 2 7. 9 5
7-Sement Display Devices

CC-Code: 10 (TEN) DP12 Field


CC-Code Table: T1

0500B CC-Code:100 (HUN) DP11 T1c


0500A CC-Code: 1000 (K) DP10
05009 no Use
05008 CC-Code: 1/100 DP8 Rtae
CC-Code: 1/10 DP7
CC-Code: 1 (UNI) DP6 Field 0 3 4 5. 7 4
05005 CC-Code: 10 (TEN) DP5 T1b
05004 always 3Fh for 0 DP4 DP9 DP11 DP13 DP15
CC-Code: 1/100 DP3 Wt DP10 DP12 DP14
CC-Code: 1/10 DP2 Field
CC-Code: 1 (UNI) DP1 T1a
05000 CC-Code: 10 (TEN) DP0 Cost Field

Figure-71.11: Data Structure for the Digital Weighing Machine


4/Expt-10A
7 We also assume that the MicroTalk-8086 trainer has routines to convert data from one format
to another like BCD2CC. It is also assumed that the trainer contains a routine that transfers the
CC-code data to the 7-sement display devices.
8 We are now ready to operate the MicroTalk- 8086 trainer as a Digital Weighing Machine.

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

Figure-71.12: 7-Segment Display Panel after the Execution of p713.asm


6 We have assumed a weight of 12.370 kg. The rate is seen to be Tk 00.00. So, the Cost is Taka:
0000.00
7 The execution of the p713.asm program has configured the ‘E’-key (E stands for Rate Entry) of
the trainer as a command key and it can be used to tell the trainer to accept rate from the
keyboard. Let us press the E-key, the display appears as Fig-71.13 with the rate field opened.
715-04 CC7S Type Display of
MicroTalk-8086 Trainer
Weight Field Rate 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

DP1 DP3 DP6 DP8


DP0 DP2 DP4 DP5 DP7

1 2. 3 7 0 2 7. 9 5

0 3 4 5. 7 4
DP9 DP11 DP13 DP15
DP10 DP12 DP14

Cost Field

Figure-71.14: 7-Segment Display Panel after Entering of the Product Rate


9 This is the end of the conversion and operation of the MDA-8086 as a Digital Weighing
Machine. Check that the DWM is working all right by entering different product rates.

Task-10A.4 [Exercises] [p714.asm] Open p713.asm and save as p714.asm


1 Change the simulated weight to 15.750Kg by editing the program p714.asm at the relevant
memory locations. Reassemble the program and down load it to the trainer. Enter the rate as:
Tk 34.50. The display must show correct input/output values (Cost: 0543.37 Tk).
2 Press the E-key to enter a new rate (say: Tk 57.69). The rate field of the display is opened.
3 Type 5 and then ‘F2’. The rate field shows: 5 _ . _ _. This indicates that the program has not
accepted the ‘F2’ 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 having not been
filtered out, then bring necessary change in the program p714.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-73.1] 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 ROM-based program of the trainer at: F05B0h and press keys.
5 Let us take that the scan codes for the above four (of Step-4) digits are: 1Dh, 0Ch, 1Ch and 1Bh
respectively.
6 Now, write 8086 ASM program to convert the above scan codes into their corresponding CC-
codes codes 4Fh, 66h, 7Dh and 6Fh) and store them at the appropriate memory locations of
the data structure of Fig-71.11.

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

L2: ; storage of WTupBCD at T7 of Fpg-71.11


mov bx, 5000h
mov WORD PTR [bx+50h], 0201h
mov WORD PTR [bx+52h], 0703h ; 12.37 kg
mov WORD PTR [bx+22h], 0000h ; 27.95 Tk/kg

L3: call far ptr WTACQ ; Acquisition of Weight as 0X: 0000:1050


mov ch, 02h ; number of packed bytes to obtain
mov si, 5050h ; pointing at upBCD table, T7
mov di, 5020h ; pointing at pBCD table, T3
call far ptr up2BCD ; to convert unpacked BCD to Packed BCD

mov si, 5020h ; point at BCDWT ; 1237d = 04D5h


call far ptr BCD2BIN ; converting BCD wt into Binary Wt
mov WORD PTR [si+2Ch],ax ; saving BINWT at: 504D,504C

mov si, 5022h ; point at BCDRATE ; 2795d = 0AEBh


call far ptr BCD2BIN ; converting BCD wt into Binary Wt
mov WORD PTR [si+2Ch],ax ; saving BINRT at: 504F, 504E

mul WORD PTR [si+2Ah] ; BINCOST in [dx][ax] 32-bit

mov di, 5000h


mov WORD PTR [di+4Ch], ax ; saving lowerr 16-bit of BINCOST
mov WORD PTR [di+4Eh], dx ; saving upper 16-bit of BINCOST

call far ptr BIN2BCD ; convert BIN Cost to BCD Cost by Horner Rule

mov ch, 04h ; number of CCCodes to obtain


mov si, 5020h ; point at BCD table, T3a
mov di, 5000h ; point at CCcode table, T1a
call far ptr BCD2CC
mov ch, 04h ; number of CCCodes to obtain
mov si, 5022h ; point at BCD table, T3a
mov di, 5005h ; point at CCcode table, T1a

7/Expt-10A
call far ptr BCD2CC

mov ch, 06h ; number of CCCodes to obtain


mov si, 5024h ; point at BCD table, T3c
mov di, 500Ah ; point at CCcode table, T1a
call far ptr BCD2CC

mov ch, 10h ; number pf cccode bytes to transfer


mov ah, 90h ; Display Position of 8279
mov si, 5000h ; point at ccode table, T1a
mov BYTE PTR [si+04h], 3Fh ; place 0 at DP4
mov BYTE PTR [si+09h], 00h ; blank
or BYTE PTR [si+01h], 80h ; placing decimal point 12.37kg
or BYTE PTR [si+06h], 80h ; plce . 27.95
or BYTE PTR [si+0Dh], 80h
call far ptr CCX79
jmp L3
WTACQ PROC FAR
; read from ADC and save the upBCD (0X) in table, T7 of Fig-71.11
ret
WTACQ ENDP

BCD2BIN PROC FAR


mov ax, 0000h ;initial partial result
mov bl, BYTE PTR [si+01h] ; begin of BCD2BIN conversion =37(12)
and bl, 0Fh ; bl=00
cmp bl, 00h
jz L41e
L41d: add ax, 0001h
dec bl
jz L41e
jmp L41d

L41e: mov bl, BYTE PTR [si+01h]


mov cl, 04h
ror bl, cl
and bl, 0Fh ; bl = 05
cmp bl, 00h
jz L41h
L41g: add ax, 000Ah
dec bl
jz L41h
jmp L41g

L41h: mov bl, BYTE PTR [si] ; 12 (37)


and bl, 0Fh ; bl = 07
cmp bl, 00h
jz L41j
L41i: add ax, 0064h
dec bl
jz L41j
jmp L41i

L41j: mov bl, BYTE PTR [si]


mov cl, 04h
ror bl, cl
and bl, 0Fh ; bl=04
cmp bl, 00h
jz L41l
L41k: add ax, 03E8h
dec bl
jz L41l
jmp L41k
L41l: ret ; 16-bit BINary result in: ax-register
BCD2BIN ENDP

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

up2BCD PROC FAR


L1SR1: mov cl, 04h
mov al, BYTE PTR [si]
rol al, cl
and al, 0F0h
or al, BYTE PTR [si+01h]
mov BYTE PTR [di], al ; saving the pBCD at table T3a
dec ch
jz L2SR1
inc si
inc si
inc di
jmp L1SR1
L2SR1: ret
up2BCD ENDP
BCD2CC PROC FAR
mov ax, 0F000h
mov es, ax ; point at the base of LUT3
L1SR2: mov al, BYTE PTR [si] ; 03 , 45, 74, 15
mov dl, al
9/Expt-10A
and al, 0F0h ; making X0 = 00
mov ah, 0FEh
mov bx, ax
mov al, BYTE PTR es:[bx] ; getting the CCcode
mov BYTE PTR [di], al ; save cccode at T1a
mov cl, 04h
mov al, dl
rol al, cl
and al, 0F0h ; making X0
mov bx, ax
mov al, BYTE PTR es:[bx] ; getting CCcode
inc di
mov BYTE PTR [di], al ; saving cccode in T1a
dec ch
jz L2SR2
inc si
inc di
jmp L1SR2
L2SR2: ret
BCD2CC ENDP

CCX79 PROC FAR


mov dx, 0002h ; point at CR
mov al, ah
out dx, al
mov dx, 0000h ; point at DR of 8279
L1SR3: mov al, BYTE PTR [si]
out dx, al
dec ch
jz L2SR3
inc si
jmp L1SR3
L2SR3: ret
CCX79 ENDP

XT8279 PROC far


mov ch, 10h ; number pf cccode bytes to transfer
mov ah, 90h ; Display Position of 8279
mov si, 5000h ; point at ccode table, T1a
mov BYTE PTR [si+04h], 3Fh ; place 0 at DP4
mov BYTE PTR [si+09h], 00h ; blank
or BYTE PTR [si+01h], 80h ; placing decimal point 12.37kg
or BYTE PTR [si+06h], 80h ; plce . 27.95
or BYTE PTR [si+0Dh], 80h
call far ptr CCX79
ret
XT8279 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

L1RS: ; al = scan CC-code


mov di, 5000h
mov dx, 0F000h
mov es, dx
mov bp, 0FFD0h
mov ah, 00h
mov si, ax
mov al, BYTE PTR es:[bp+si] ; getting CCcode
mov cl, BYTE PTR [di+48h]
mov ch, 00h
mov bp, cx
mov BYTE PTR [di+bp], al ; saving the Cccode at T1b
call far ptr XT8279 ; T1b ---> 8279 with decimal point
dec BYTE PTR [di+49h] ; number of digits to print
jz L2RS
inc BYTE PTR [di+48h]
jmp AGNKB

L2RS: ; cc---> upBCD jmp L2RS ; 4-digits of Weight are acquired


mov ch, 04h ; bytes to convert
mov si, 5005h ;
and BYTE PTR [si+01h], 07Fh ; 0111 1111 ; remove point
mov di, 5015h
call far ptr CC2uBCD
; upBCD ---> pBCD
mov ch, 02h ; number of bytes to obtain
mov si, 5015h
mov di, 5022h
call far ptr uB2BCD
mov di, 5000h
mov BYTE PTR [di+48h], 05h
mov BYTE PTR [di+49h], 04h
;test OK
;mov al, 80h
;mov dx, 3606h
;out dx, al
;mov al, 01h
;mov dx, 3600h
;out dx, al
;hlt

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

uB2BCD PROC FAR


LY1: mov al, BYTE PTR [si]
mov cl, 04h
mov ah, BYTE PTR [si+01h]
ror ah, cl
and ah, 0Fh
or al, ah
mov BYTE PTR [di], al
dec ch
jz LY2
inc si
inc si
inc di
jmp LY1
LY2: ret
uB2BCD ENDP

CC2uBCD PROC FAR


mov dx, 0F000h
mov es, dx
LX1: mov bp, 0FF00h ; FF00 ; 1234 : 06, 5b, 4F, 6D
mov ah, 00h
mov al, BYTE PTR [si] ; getting CCcode 0D
add bp, ax ; FF00 + 0006 = FF06
mov al, BYTE PTR es:[bp] ; getting 10 from FFF0D
mov BYTE PTR [di], al ; saving upBCD
dec ch
jz LX2
inc si
inc di
jmp LX1
LX2: ret
CC2uBCD ENDP
MYCODE ENDS
END START

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

Figure-71.1: Block Diagram of DWM Based on the MDA-8086 Trainer

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

Figure-71.2: Table Containing upBCD Weight Data

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

Figure-71.5: Table Containing ASCII Rate

05023 pBC D: 1/10, 1/100 Rate


05022 pBC D: 10, 1 BCD
Field

Figure-71.6: Table Containing BCD Rate


6 We assume that the MDA-8086 trainer contains the product cost computation routine and it
has already computed the cost by multiplying the weight and rate. Let us assume that the
COSTBCD and COSTAS are stored in the following memory locations of the data structure.
05027 pBCD: 1/10, 1/100 Cost
05026 pBCD: 10, 1 BCD
05025 pBCD: 1000, 100 Field

Figure-71.7: Table Containing BCD Cost


05037 ASCII for Blank DPF
ASCII for Blank
ASCII for 1/100
ASCII for 1/10
ASCII for .
ASCII for 1
ASCII for 10 ASCII
ASCII for 100 Cost
ASCII for 1000 Field
ASCII for :
ASCII for T T4a
ASCII for S
ASCII for O
0502A ASCII for C
05029 ASCII for Blank
05028 ASCII for Blank DP0

Figure-71.8: Table Containing ASCII Cost


7 We also assume that the MDA-8086 trainer has routines to convert data from one format to
another like BCD2ASCII. It is also assumed that the trainer contains a routine that transfers
the ASCII data to the LCD display panel.
8 We are now ready to operate the MDA-8086 trainer as a Digital Weighing Machine.
2/Expt-10B
Task-10B.3: [Operating the MDA-8086 as DWM: p713.asm] We may follow the steps as outlined
below:
1 Connect the IBM-PC and the MDA-8086 trainer using the serial cable of COM1 port. Apply
power to the IBM-PC and the MDA-8086 trainer.
2 Now open the file p713.asm program from the path: c:\mda8086\p713.asm. This is the
program, which converts the MDA-8086 trainer into a DWM.
3 Assembly the program p713.asm. Convert it to p713.abs and down load into MDA-8086.
4 Execute the downloaded program starting at location: 01000 (0000:1000).
5 Observe that the following message appears at the LCD panel of the trainer.

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

Figure-71.9: LCD Panel after the Execution of p713.asm


6 In step-4 of Task-71.2, we have assumed a load of 12.370 kg. The rate is seen to be Tk 00.00. So,
the Cost is: 0000.00 Tk.
7 The execution of the p713.asm program has configured the ‘E’-key (E stands for Rate Entry) of
the trainer as a command key and now we may use this key to tell the trainer to accept rate
from the keyboard. Let us press the E-key, the display shows:
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 : _ _ . _ _
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

Figure-71.11: LCD Panel after Entering of the Product Rate


9 This is the end of the conversion and operation of the MDA-8086 as a Digital Weighing
Machine. Check that the DWM is working all right by entering different product rates.

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

L1: call far ptr BUSY ; LCD initialization (L12 -L26)


mov al, 38h
out LCDIR, al
call far ptr BUSY
mov al, 0Ch
out LCDIR, al

call far ptr BUSY


mov al, 10h
out LCDIR, al

call far ptr BUSY


mov al, 01h
out LCDIR, al
mov bx, 5000h ; ASCII table initialization (L28-33)
mov WORD PTR [bx], 3130h ; 0 1
mov WORD PTR [bx+02h], 3332h ; 2 3
mov WORD PTR [bx+04h], 3534h ; 4 5
mov WORD PTR [bx+06h], 3736h ; 6 7
mov WORD PTR [bx+08h], 3938h ; 8 9

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

mov WORD PTR [bx+34h], 3030h ; 0 0


mov WORD PTR [bx+36h], 2020h ; blank blank
mov WORD PTR [bx+38h], 3A57h ; : W
mov WORD PTR [bx+3Ah], 3231h ; 2 1
mov WORD PTR [bx+3Ch], 332Eh ; 3 .
mov WORD PTR [bx+3Eh], 3037h ; 0 7
mov WORD PTR [bx+40h], 5220h ; R blank
mov WORD PTR [bx+42h], 303Ah ; 0 :
mov WORD PTR [bx+44h], 2E30h ; . 0
mov WORD PTR [bx+46h], 3030h ; 0 0

L3: mov si, 5000h ; xfer meggage to LCD (L53 -L66)


mov bx, 0028h
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

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

mov si, 5000h


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
6/Expt-10B
call far ptr BUSY
mov al, 0C0h ; 2nd line of LCD
out LCDIR, al
call far ptr T42LCD
dec dl
jz HERE ; 4-digit Rtae Entry is complete
cmp dl, 02h ; to find position for (.) to avoid printing
jnz L41c
inc bp
L41c: inc bp
jmp L41a

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

mov ax, WORD PTR [si+3Ah] ; al=31 ; ah=32 ASCII2BCD


mov cl, 04h
rol al, cl
and al, 0F0h
and ah, 0Fh
or al, ah
mov BYTE PTR [si+4Fh], al ; upper byte of BCDWT

mov ax, WORD PTR [si+3Dh] ; al=37 ; ah=37 ASCII2BCd


mov cl, 04h
rol al, cl
and al, 0F0h
and ah, 0Fh
or al, ah
mov BYTE PTR [si+4Eh], al ; lower byte of BCDWT

call far ptr BCD2BIN ; converting BCD-RATE into BIN


mov dx, ax ; BINRATE in dx-register
mov ax, WORD PTR [si+4Eh] ; converting BCDWT into BIN
mov WORD PTR [si+4Ch],ax ; (0504D)(0504C) = BCDWT
call far ptr BCD2BIN ;
mov WORD PTR [si+4Eh], ax ; (0504F)(0504E) = BINWT
mov WORD PTR [si+4Ch], dx ; (0504D)(0504C) = BINRATE

mov ax, WORD PTR [si+4Ch] ; multgiplication ; multiplier


mul WORD PTR [si+4Eh] ; (dx)(ax) = 32-bint BINCOST

mov WORD PTR [si+4Ch], ax ; lower 16-bit BINCOST


mov WORD PTR [si+4Eh], dx ; upper 16-bit BINCOST

LV1: mov bx, 5000h ; converting 32-bit BIN2BCD by Horner Rule


mov di, WORD PTR [bx+4Eh]
mov si, WORD PTR [bx+4Ch];(di, si) = 32-BIT BINCOST
mov WORD PTR [bx+4Eh], 0000h
mov WORD PTR [bx+4Ch], 0000h;(0540F,0540E,0540D,0540C)=00000000
; initial 8-digit BCDCOST)
mov bx, 0000h ; converting 32-bit BIN2BCD using Horner Rule
7/Expt-10B
mov cx, 0000h; (cx,bx) = 00000000 = initial partial BCDCOST
mov ah, 20h ; number of rotation
mov al, 00h
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 si, 5000h


mov WORD PTR [si+4Eh], cx
mov WORD PTR [si+4Ch], bx

mov ah, 03h ; 3-bytes to convert


mov dx, 002Fh ; pointer
mov bp, 004Fh ; converting BCDCOST into ASCIICOST
LV9a: mov bx, OFFSET ASCII
mov al, BYTE PTR [si+bp] ; al= 05
mov cl, 04h
ror al, cl
and al, 0Fh ; al = 00
xlat ; al=30h
mov bx, dx ; bx=002Fh
mov BYTE PTR [si+bx], al
mov dx, bx
mov al, BYTE PTR [si+bp]
and al, 0Fh
mov bx, OFFSET ASCII
xlat
inc dx
mov bx, dx
mov BYTE PTR [si+bx], al
mov dx, bx
dec ah
jz LX3; HERE1
dec bp
cmp dx, 0032h
jnz LX2
inc dx
LX2: inc dx
jmp LV9a

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

HERE1: jmp L31;HERE1

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

T42LCD PROC FAR


L3a: mov ah, BYTE PTR [si+bx]
call far ptr BUSY
mov al, ah
out LCDDR, al
dec cl
jz L3b
inc bx
jmp L3a
L3b: ret
T42LCD ENDP

DIGIT PROC FAR


cmp al, 12h ;GO
jz EXIT
cmp al, 11h ; STP
jz EXIT
cmp al, 0Ch ; C
jz EXIT
cmp al, 0Dh ; D
jz EXIT
cmp al, 0Eh ; E
jz EXIT
cmp al, 0Fh ; F
jz EXIT
cmp al, 15h ; +
jz EXIT
cmp al, 13h ; REG
jz EXIT
cmp al, 0Ah ; A
jz EXIT
cmp al, 0Bh ; B
jz EXIT
cmp al, 14h ; -
jz EXIT
cmp al, 16h ; DA
jz EXIT
cmp al, 10h ; :
jz EXIT
cmp al, 17h ; 'AD'
jz EXIT
mov BYTE PTR [si+4Bh], al
mov BYTE PTR [si+4Dh], 01h ; valid digit is found
EXIT: ret
DIGIT ENDP
9/Expt-10B
BCD2BIN PROC FAR
mov si, 5000h
mov ax, 0000h
mov bl, BYTE PTR [si+4Ch] ; begin of BCD2BIN conversion
and bl, 0Fh ; bl=00
cmp bl, 00h
jz L41e
L41d: add ax, 0001h
dec bl
jz L41e
jmp L41d
L41e: mov bl, BYTE PTR [si+4Ch]
mov cl, 04h
ror bl, cl
and bl, 0Fh ; bl = 05
cmp bl, 00h
jz L41h
L41g: add ax, 000Ah
dec bl
jz L41h
jmp L41g

L41h: mov bl, BYTE PTR [si+4Dh]


and bl, 0Fh ; bl = 07
cmp bl, 00h
jz L41j
L41i: add ax, 0064h
dec bl
jz L41j
jmp L41i

L41j: mov bl, BYTE PTR [si+4Dh]


mov cl, 04h
ror bl, cl
and bl, 0Fh ; bl=04
cmp bl, 00h
jz L41l
L41k: add ax, 03E8h
dec bl
jz L41l
jmp L41k
L41l: ret ; 16-bit BINary result in: ax-register
BCD2BIN ENDP
BCD2ASC PROC FAR
nop

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

677 USART: 8251: U17 489,488: U18,U19 IBM-PC

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

MYDATA SEGMENT para public 'data'


DB 00h
MYDATA ENDS

MYCODE SEGMENT para public 'code'


ASSUME cs:MYCODE,ss:MYSTACK, ds:MYDATA

START: mov ax,MYSTACK


mov ss,ax
mov sp,offset STKTOP
mov ax, MYDATA
mov ds, ax
mov ah,00h ;initialising COM1
mov dx,0000h ;pointing at COM1
mov al,11000111B ;4800-Bd,2-SB,NP,8-DB ; 11100111 ; 9600Bd
int 14h ;ROM BIOS function call

sti ;enable interrupts

CHKAGN: mov dx,0000h ;points at COM1


mov ah,03h ;ROM BIOS function value for int 14h
int 14h ;ROM BIOS function call ,get COM1's status
test ah,01h ;ah-B0 = 1 means data ready at UART
jnz RDCHAR ;data has just arrived at COM1
jmp KYBD ;see if any command from Keyboard

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

KYBD: mov ah,01h ;function value


int 16h ;ROM BIOS functioncall,ZF=1 means no char
jnz RDKY ;ZF=0,scan and ascii codes in type-ahead buff
jmp CHKAGN ;

RDKY: mov ah,00h


int 16h ;ROM BIOS function call, sc=ah,ac=al
cmp al,51h ;see if Quit command (capital Q)
jne NEXT
mov ax,4C00h ;function value to return to DOS prompt
int 21h ;DOS fuction call
NEXT: mov ah,01h ;function value
mov dx,0000h ;point at COM1
int 14h ;ROM BIOS function call

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

8253 : U41: PIT USART: 8251: U17 MAX232: U15 IBM-PC

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

Configure 8251A (U17):


i. To operate for the settings of: 4800 Bd, 1 start bit, 8 character bits, even parity and 2
stop bits by sending appropriate MICB (Mode Instruction Control Byte) into CR
ii. For activating the modem control lines and Rx/Tx enabling; send appropriate CICB
(Command Instruction Control Byte) into CR.
Now keep polling the RxRDY-bit of the status register of the 8251A to find the presence of a valid
character that has come form the IBMPC. Read it and write it back into the Tx-register by polling
the TxRDY-bit.
Assemble the program; make an Intel-Hex (p4513a.abs) formatted file. Download the Intel-Hex
file into the MDA - 8086 trainer starting at RAM location: 000:1000h
b. Open a second DOS screen in the IBMPC under WIN98. Save the screen as p4513b.asm. This is a
‘Terminal Emulator Program’, which reads a character from the keyboard of the IBMPC by
polling and writes on the Tx-register of the COM1 port of the IBMPC. The program also reads a
character form the Rx-register of COM1 and displays it on the monitor.
i. Set the COM1 port setting as: “4800 Bd, 1 start bit, 8 character bits, even parity and 2 stop
bits” by calling ROMBIOS ‘ ah=00h, dx=0000h, al=BRCB, int 14h’.
ii. Configure the modem control lines by writing appropriate bits into MCR-register of 8250
iii. Read the ASCII code of a pressed down in the keyboard of the IBMPC by polling. Use
ROMBIOS ‘ah=00h, int 16h’ for this purpose. Detection of ‘Q’ would terminate the program.
iv. Write the ASCII code of the pressed down key on the Tx-register by polling the TxRDY-
bit.
v. Poll the RXRDY-bit and read character from the Rx-register of COM1 port.
vi. Use DOSBIOS ‘ ah=02h, dl=ASCII, int 21h’ to send the receiver character on the monitor.
vii. Assemble the program and link it to make the file p4513b.exe.
c. Reset the MDA-8086 trainer and then execute at: 0000:1000
d. In the IBMPC, execute the program p4513b.
e. Type the character A from the keyboard. The monitor must show it.
f. This verifies that the IBMPC and the MDA-8086 trainer are communicating using the customized
serial link.
g. Now, add addition code with program p4513a.asm so that the MDA-8086 trainer could display
on the LCD display, the ASCII code, Scancode and Label of the key that has been pressed down
on the keyboard of the IBMPC.
h. Now, add addition code with program p4513a.asm so that the MDA-8086 trainer could receive
the 8-bit code of a pressed down of it keypad and then send its Label to IBMPC.
i. Now, add additional codes with p4513a.sam so that the MDA-trainer could read character from
the Rx-register on interrupt.
j. Now, add necessary codes with the program p4513b.asm, so that the IBMPC could read character
from the Rx-register on interrupt.

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

Figure-12.11 : CC-code Table for Experiment: Task-43.1

1/Expt-12
2. Update the following Memory Resident Data Table for the Message ‘Good’

Memory Location in RAM Content CC-Code for Character


0A000 - G
0A001 - O
0A002 - O
0A003 - D
Figure-12.2 : CC-code Table for Experiment: Task-43.1

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

U11, U13, U14


82798086 : GM : 1199

Figure-12.3: Circuit Diagram of the Display Subsystem of MicroTalk-8086

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

Control Byte Purpose


000 00 000B = 08H 16 Digit Display; Character Entry from Left
000 10 000B = 18B 16 Digit Display; Character Entry from Right
010 00 000B = 40H To read data from the KDR
011 0 0000B = 60H Read data from DDR (display RAM0 pointed by the lower 4-bits of
Cbyte)
011 1 0000B = 70H Read data from DDR (display RAM0 pointed by the lower 4-bits of
Cbyte)
Next read will be automatically from RAM1 of DDR and so on……
100 0 0000B = 80H Write data into DDR (Display RAM0 pointed by the lower 4-bits of
CByte)
100 1 0010B = 90H Write data into DDR (Display RAM2 pointed by the lower 4-bits of
CByte)
Next write will be automatically at RAM3 of DDR and so on………..

6. Code, Store and Execute the following Pseudo Codes that describes the solution of Task-
F.1.

L1: do nothing;

L2: Cbyte (08H) → CR (0002h);


Cbyte (90H) → CR (0002h)
Register, cx as a Counter for 04 characters
SI-register to Point the beginning of the data source table;

L3: (ds: [di]) → al

L4: al → DDR (0000h)

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

Figure-12.4:: Flow Chart for Expt-4.31

Assembly Codes: Machine Codes:


L1: 05100 - nop L1: 05100 - 90
L2: - mov al, 08h L2: - B0 08
mov dx, 0002h BA 02 00
out dx, al EE
mov al, 90h B0 90
out dx, al EE
mov cx, 0004h B9 04 00
mov si, 0A000h BE 00 0A
L3: - mov al, BYTE PTR ds:[si] (default ds=0000h) L3: - 8A 04
L4: - mov dx, 0000h L4: - BA 00 00
out dx, al EE
L5: - dec cx L5: - 49
jz L6 74 03
inc si 46
jmp L3 EB F4
L6: - hlt L6: - F4

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)

Task-13.1 Onboard 8279 Based Keyboard Programming


Scanning Keyboard of Microtalk-8086 trainer and Recording the Corresponding Scan Codes.
Objectives of the Experiment:
01. Verify that the Scan Codes are generated as per Scan Code Format of the 8279 (Fig-44.3 )
02. Display of the Scan Codes at DP7DP8 position of the display unit of the trainer.
The procedures:
1. Study the following Keyboard Circuit Diagram of the MicroTalk-8086 Trainer
DP7 DP8
8279

4-Bit Coun ter


8

1024KHz F req . 100K Q3


D iv ide
r Q0 Scan C o de D isplay

Display Section 4-to-8 Decoder 74138

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

Figure-13.1: Keyboard Diagram for the MicroTalk-8086 Trainer


2. Programming Table – 1
Keyboard Scan Code Format:

CONTROL SHIFT COLUMN LINES ROW LINES


B7 B6 B5 B4 B3 B2 B1 B0
0 0 X X X X X X
Figure-13.2: Keyboard Scan Code Format for 8279 Chips

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 ---------------------- ------------------------ ----------------------

K12 – K62 ----------------------- ------------------------ ---------------------

K13 _______________ ______________ _______________


K23 ---------------------- --------------------- ----------------------
K33 ---------------------- ---------------------- ----------------------
K43 ---------------------- ----------------------- ----------------------
K53 ---------------------- ------------------------ ----------------------
K63 ---------------------- ------------------------ ----------------------

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

Closed Key is there;


Go to L4 Entry
Else L2:
no closed key;
Read Status
goto L2 Register
L4: Scan_Code → al [Cbyte(40H) → CR(0002h);
KDR(0000h) → al] L3:
L5: go to L6 S R0 L8:
L6: convert 1-Byte Scan Code to 2-Bytes Bit =1
Display the S can Code
7-Segment codes for the purpose of display N ?
at D2D1 of Trainer
(al → 0044Eh; call F000:F47C) L4: Y
L7:
L7: display the converted data of label-6 on the
Read Convert 1-Byte S can
D2D1 position; blank D7D6D5D4D3 positions S can Code Code to 2-Bytes 7-seg
(00h → 00444h – 0044Ah s
call F000:FFB6) L5: L6:
L8: go to L2
6. Code, store and execute the pseudo codes.
7. Press the keys of the keypad of the trainer. Observe the corresponding 2-digit code in the
display.
8. The readers may readily find the scan codes of the keys by executing an EPROM based
program at address F05B0h.
9. The readers may also assemble and download the program p441.asm, which similar to F05B0h

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

3. The Program Codes:


RPT: if (closed key is GO)
{
transfer the content of the above data structure into LCD
stay HERE
}
else
goto RPT
Exercise-13B.12: Write, code and execute an 8086-based assembly program in the MDA-8086 system to
accomplish the following:
a. The LCD panel is cleared up. There is no character on the LCD.
b. When you press the ‘REG (Rate Entry for Goods)’ key, a cursor like ‘_’ will be blinking at the DP0
position of the LCD.
c. You press any key from 0-9 on the keypad, the corresponding image of the pressed key will appear
at the current cursor position. The blinking cursor will shift to the right.
c. Your program will accept any four digits from the keyboard.
d. At the end of four digits entry, the CPU will again recognize the ‘REG’ command. Your program will
transfer control back to Step-b.
Solution Hints: Given below a solution hints in the form of Pseudo Code. Draw the flow chart, the assembly
codes and then execute the program. Check strictly, the correctness of every step of the pseudo code
program.
Pseudo Codes:
L0: initialize the LCD for the required ‘Mode of Operation’
L1: initialize a Counter (register, cl) for total number of digits to be printed.
initialize a flag (initial value 00h) to indicate that the LCD shows blinking cursor ‘_’.
L2: reset the keyboard
L3: read raw scan code of the keyboard
6/Expt-13B
if (B7-bit of the raw scan code is LH)
goto L3
if (flag = 00h)
if (scode = 13h)
{
show: blinking cursor ‘_’ at the DP0 position of the LCD
1 → flag [ at the end of 4-digit entry flag will be made LL)
}
else
goto L2
else
{
reset keyboard
if (scode != 13h)
goto L2
else
{
print the digit on the LCD at the present cursor position
decrement counter
if (counter = 0)
goto L1
else
goto L2
}
Exercise-13B.13: Draw the complete circuit diagram for the keyboard of the MDA-8086 system. And also
write down the working principles of this keyboard circuit.
Schematic Diagram: The complete schematic diagram is shown in Fig-58.4 below, which is a redrawn
version of the original schematic given in the user’s manual of the MDA-8086. The only new thing in this
diagram is that the diagram of Fig-58.4 has much better readability than the one of the user’s manual.
Working Principles: The heart of the keyboard circuit is the component U27, which is a ‘Priority Encoder’
chip. This is the chip, which actually generates the scan codes for the keys of the keypad. However, the
transistors, TR1-TR3 also play a great role for generating the scan codes by providing the column lines for
the keyboard matrix. The keyboard works in very interesting way.
When none of the keys of the keyboard is pressed down, the row lines are isolated from the column lines
and the inputs to the U27 are: 00000000B. According to the truth table of the U27 (4532), when the inputs are
at 0s, the output E0=LH and GS=0. It is assumed that prior to the operation of the keyboard, the keyboard
has been reset by asserting LH at B7 with the execution of the instruction: out KRS(01H), 00h. The LH value
of the B7-bit is an indication that none of the keys in the keyboard has been pressed down. When any of the
keys of the keypad is pressed down, the b7-bit immediately goes to LL. Thus, the CPU can easily know
whether a key has been pressed or not just by monitoring the value of the b7-bit.
Say, the key-8 is pressed down. The column line provided by TR2 is shorted with the D7 line of the U27. The
voltage at D7 of U27 becomes: 5V – VEBTR2 (0.7V) = 4.3V, which is Logic-H. Because, the TR2 is ON, its
collector voltage is very close to +5V (LH), which constitutes Bit-3 of the scan code. With the bit pattern as
10000000 at the inputs of U27, the output of U27 would be 111 (Q2Q3Q1). The EO-pin assumes LL and the
GS-pin assumes LH. The activity of the EO signal triggers the 33mS-oneshot U26. The 33mS pulse width is
intentionally chosen to allow the complete extinction of the denouncing pulses of the mechanical key, key-8.
The inverted output of U26 clocks the GS-bit into the latch, U25 after 33mS time delay. This results in
putting LL at B7-bit of the scan code. Thus, the scan code for the key-8 stands as: 00001000 (08h). At this
moment, if the CPU reads the scan code out of U24, it will find a valid scan code by seeing LL at B7-bit.

6/Expt-13B
544
R8 R10 R12 +5V
3.3k 3.3k 3.3k

TR1 TR2 TR3 17 B7


0V 15 B6 U24
13 B5 74244
11 B4
8 B3
R9 U27 +5V R7 : 33k C8: 1uF
R11
3.3k R13 4532
3.3k 3.3k 11 + 10 U26
0V +5V 5 EI 0V 3 74121 Q7 3 D15
4 Q 6 Q6 5 D14
Q5 7 D13
33m S
EO 15 5 B Q/ 1 Q4 9 D12
0 8 : 04 D7 Q3 12 D11
1 9 STP 03 D6 Q2 14 D10
2 A GO 02 D5 Q1 14 D09
3 B - 01 D4 U25: 7474 Q0 18 D08
4 C + 13 D3 3 CK Q 5
5 D REG 12 D2
6 E DA 11 D1 GS 14 2 D Q/ 6
7 F AD 10 D0 R/
Q2 6 1 6 B2
Q1 7 4 B1
RA1: 8x3.3k Q0 9 2 B0
WR/ 0V OE/
U21 Reset Enable
1,19
7432

IRQ
CS/ (01h)
BHE/ Read Enable
M-IO/

RD/ Needs to be Installed by the User

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.

U2 : 8086 U24 : 8279 CC-type 7-Segment Display Unit

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

Figure-14A.1: Hardware Structure for the 24-Hr Clock

Task-14A.2: Working Principles of the 24-Hr Clock System

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

Figure-14A.2: Software Data Structure for the 24-Hr Clock


1. Initial BCD Time is entered into the indicated memory locations of T11 using the keyboard
of the MicroTalk-8086 trainer.
2. The CPU is interrupted at every 20-mS. The COU goes to ISRNMI and checks if 500
interrupts have occurred, which is equivalent to 1-Sec elapsed time (50x20 = 1000mS).
3. At every 1-sec, the CPU updated the ‘Running BCD Time’ and is converted to ‘Running CC
Time’ using ROM-based subroutine BCD2CC.
4. The ‘CC Time’ is transferred into the display RAM of the 8279 using ROM-based subroutine
CCX8279. The ‘CC Time’ automatically enters into the 7-Segment display unit.
1/Expt-14A
Task-14A.3 : Listing of the ASM Codes for the 24-Hr Clock System […..\P14Aclk.asm]
; Converting MicroTalk-8086 into a 24-Hr Clock System: Dated: 8/1/2009 by Golam Mostafa
START: nop
mov cl, 00h ; counter

L1: mov bx, 0000h ; Link ISRNMI with NMIITC


mov WORD PTR [bx+08h], OFFSET ISRNMI
mov WORD PTR [bx+0Ah], SEG ISRNMI
L2: mov bx, 0400h ;Transfer Initial BCD Time from T11 into T12
mov ax, WORD PTR [bx+74h]
mov WORD PTR [bx+4Eh], ax
mov al, BYTE PTR [bx+76h]
mov BYTE PTR [bx+50h], al
call BCD2CC ; converting BCDTIME into CCTIME
mov WORD PTR [bx+48h], 0000h
mov WORD PTR [bx+4Ah], 0000h
or BYTE PTR [bx+44h], 80h ; place point
or BYTE PTR [bx+46h], 80h
call CCX8279 ; xfering CCTIME into 8279
L3: jmp L3 ; wait for interrupt
ISRNMI: ; beginning of ISR due to NMI
ISR1: inc cl
cmp cl, 100 ; 3Ch = 48+2 = 100x20 = 1000mS = 1Sec
je ISR2 ; looks like NMI senses both Redge and LH of PZC
iret
ISR2: mov cl, 00h ; counter Reset
mov al, BYTE PTR [bx+4Eh]
add al, 01h
daa
cmp al, 60h
je ISR3
mov BYTE PTR [bx+4Eh], al
jmp ISR6
ISR3: mov BYTE PTR [bx+4Eh], 00h
mov al, BYTE PTR [bx+4Fh]
add al, 01h
daa
cmp al, 60h
je ISR4
mov BYTE PTR [bx+4Fh], al
jmp ISR6
ISR4: mov BYTE PTR [bx+4Fh], 00h
mov al, BYTE PTR [bx+50h]
add al, 01h
daa
cmp al, 24h
je ISR5
mov BYTE PTR [bx+50h], al
jmp ISR6
ISR5: mov WORD PTR [bx+4Eh], 0000h
mov BYTE PTR [bx+50h], 00h
ISR6: call BCD2CC

mov WORD PTR [bx+48h], 0000h


mov WORD PTR [bx+4Ah], 0000h
or BYTE PTR [bx+44h], 80h ; placing decimal point
or BYTE PTR [bx+46h], 80h
call CCX8279
iret
BCD2CC: mov di, 0F00h
mov WORD PTR [di], 0F47Ch
mov WORD PTR [di+02h], 0F000h
call DWORD PTR [di]
ret
CCX8279:mov di, 0F00h
mov WORD PTR [di], 0FFB6h
mov WORD PTR [di+02h], 0F000h
call DWORD PTR [di]
ret

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:
-

i. mul al, byte_data ii. mul ax, word_data

Let us assume that we have the following two 16-bit numbers:


04FFF
519
x3x2 x1x0 : Multiplicand 03006 r7r6
y3y2 y1y0 : Multiplier 03006 r5r4 Product
Output
r3'r2' r1r0 = (x1x0) x (y1y0) : L1 03005 r3r2 (R esult)
03004 r1r0 DSM
r5''r4'' r3''r2'' = (x3x2) x (y1y0) : L2 03003 x3x2
Multiplicand
03002 x1x0 Inputs
r5'''r4''' r3'''r2''' = (x1x0) x (y3y2) : L3 03001 y3y2
03000 y1y0 Multiplier
r7r6 r5''''r4'''' = (x3x2) x (y3y2) :L4
02FFF
-- -- -- -- r1r0 CSM
01000
Carry Carry Carry
00000
559b
Figure-9.1: Computation Mechanism Figure-9.2: Input/Output Data Structure

Program: p631a.asm: Mixed Codes


START: nop
00h → r7r6, r5r4, r3r2, r1r0 ; initial results
00h → r3’r2’, r3’’r2’’, r3’’’r2’’’, r5’’r4’’, r5’’’r4’’’, r5’’’’r4’’’’
L1: - compute [x1x0]x[y1y0] by repetitive addition
mov al, 00h ; al is the working register and also holds IPR
mov ah, y1y0 ; ah holds the multiplier
L1A: add al, x1x0
jc L1C
L1B: dec ah
jnz L1A
jmp L1D
L1C: r3’r2’ + C → r3’r2’
Jmp L1B
L1D: al → r1r0 ; we have : [r3’r2’ r1r0] for L1: [x1x0)]x [y1y0]
L2: - compute [x3x2]x[y1y0] by repetitive addition
mov al, 00h ; al is the working register s
mov ah, y1y0 ; ah holds the multiplier
L2A: add al, x3x2
jc L2C
L2B: dec ah
jnz L2A
jmp L2D
L2C: r5’’r4’’ + C → r5’’r4’’

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

asm mov bl, 0x00


asm mov al, 0x00
asm mov ah, 0x12 // y3y2; y3y2y1y0 = 1234h
L3A: asm add al, 0xCD // x1x0l x3x2x1x0=ABCDh
asm jc L3C
L3B: asm dec ah
asm jnz L3A
asm jmp L3D
L3C: asm inc bl //r5r4_3
asm jmp L3B
L3D: asm mov r3r2_3, al // r5r4_3, r3r2_3
asm mov r5r4_3, bl // 0E6Ah

asm mov bl, 0x00


asm mov al, 0x00
asm mov ah, 0x12 // y3y2 ; y3y2y1y0=1234h
L4A: asm add al, 0xAB // x3x2; x3x2x1x0=ABCDh
asm jc L4C
L4B: asm dec ah

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.

Task - 9.2[16-bitx16-bit Multiplication by ‘8-bit mul Instruction’: p91b.asm] In


this task, we shall multiply two unsigned 16-bit numbers by ‘partial repetitive addition’
method using the MTS-86C microprocessor learning system. . There will be a use of the
mul instruction.s
[
Let us assume that we have the following two 16-bit numbers:
Mixed Codes:
START: nop
L1: al ← y1y0
al x BYTE PTR [1402h] ; (x1x0) x (y1y0)
al → r1r0
ah → r3r2
L2: al ← y1y0
al x BYTE PTR [1403h] ; (x3x2) x (y1y0)
al + r3r2 → r3r2
jnc L2A
inc ah
L2A: ah → r5r4
L3: al ←y3y2
al x BYTE PTR [1402h] ; (x1x0) x (y3y2)
al + r3r2 → r3r2
jnc L3A
inc ah
L3A: ah + r5r4 → r5r4
jnc L4
r7r6 + 01h → r7r6
L4: al ← y3y2
al x BYTE PTR [1403h] ; (x3x2) x (y3y2)
al + r5r4 → r5r4
jnc L4A
inc ah
L4A: ah + r7r6 →r7r6

Task - 9.3[16-bitx16-bit Multiplication by ‘Double Precision mul Instruction’:


p631c.asm]
START: nop
L1: mov ax, multiplicand
mul WORD PTR [bx+03000h]
L2: mov WORD PTR [bx+03004h], ax ; lower 16-bit of result
mov WORD PTR [bx+03006h], dx ; upper 16-bit of results

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

I88, D90, B92, M05

I92, D93, B97, M04


8-Bit Microprocessor Learning /Dev 16-Bit Microprocessor Learning /Dev
System using Intel 8085 Architecture System using Intel 8086 Architecture

MicroTalk-80286 MicroTalk-8x51

I93, D95, B99, M05


I96, D99, B99, M?

16-Bit Protected Virtual Address Mode


Microprocessor Learning /Dev System 8-Bit Microcontroller Learning /Dev
using Intel 80286 High Perfomance Arch. System using Intel /Atmel 8x51 Architecture

MicroTalk-80386
I02, D03, B?, M?

32-Bit Protected Virtual Address Mode Microprocessor Learning /Dev System


using Intel 80386DX High Perfomance Architecture

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

You might also like