8086 lab manual
TRANSCRIPT
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
i
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
ii
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
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.
blbh
Cl, bh, bl = IPBCD
015
si = BIN
538 cl
023 (Six BCD Digits)
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
2/Expt-1B
: 1AD 0 2 34 5 6 78 9 A BC D E F
- DA+ REG
G0 STPNMI RES
546
CS/
D15-D8D7-D0
DR:01h
KBIC : 74244 :U24 CPU : 8086 : U1
CS/D7-D0D7-D0
LCDIC
9600 Bd
RS : 01h
IRSR
DR
16 Characters x 2 Lines
LCD
CR:1Eh
PA:18h
0V
PB:1AhPC:1Ch
D7-D0 D7-D0
PIO: 8255:U30
8x8Common CathodeType Bi-colorLED Array
CS/
+5V
Vin
MIC
TH1
DIP2
DAC:U33
CR:18hDR:18h
VR
2
ADC: 0804 : U31
CS/
D7-D0D7-D0
P6
Speaker
DCS/
Out
SPKIC: U25
DR: 11h
D7-D0 D7-D0
CS/SIO: 8251:U14 TTL <----> RS232 : U15
TTL TxRSTxTTL
RxRSTTLRxTTL
CON: DB9
SR: 0AhCR: 0Ah
DR: 08h
9600 Bd
CS/
PUT: U41
:8253
D15-D7-D0
TC-1:0Bh
TC-0:09h
TC-2:0DhCR:0Fh
D8
CON10Users Interface Controller CS/20h, 22h,24h, 26h
D7-D0
D15-D8
EVN: ROM:U7F0000, ..... FFFFE
ODD: ROM:U8F0001,...... ,FFFFF
Mem/Port Decoder : U16
CS/
CS/D7-D0
D7-D0
Sx/A,M-IO/,BHE/
D15-
D7- D7-D0
CS/
CS/
D7-D0CS/ ODD: RAM : U10
00001, ........ 0FFFF
EVN : RAM : U900000,......... 0FFFE
D8
D0
D7- D7-D0D0
CR:10h
DR:12hIR7
CK0
IR6IR5IR4IR3IR2
(41h)IR1(40h)IR0
CK1
CK2
Sy/
PCLK: 2.4576MHz+5VGT0
OT0
TxC,RxCCLK for 9600 Bd
GT1GATE1
0VOT1
0VGATE2
GT2OT2
+5VIR2
IPCU428259
27256
27256
62256
62256
INTININTA
/IN
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.
TRTA
/
NMI +5VNMI
GM: 547: 11/03:3 Hrs
0V
D8
CR:1Fh
PCR:1Dh
PBR:1Bh
PAR:19h
CA7SD
PB0-PB3LED11-LED14
Step. Motor Int.PB4-PB7 DAC
U33
LM:U38ADC:U31P8
CS/D D15-D8
PIO:8255U29
RxRDY 0V 0V
TxRDY
Figure-1B.1: Hardware Block Diagram of MDA-8086 Trainer
Task-1B.3 Getting Familiar with Keyboard Layout of MDA-8086 Trainer
3/Expt-1B
Figure-1B.2: keyboard Layout of MDA-8086 Learning System
: 1AD 0 2 3
4 5 6 7
8 9 A B
C D E F
- DA
+ REG
G0 STP
MON RES
546
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.
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.
0301003011
B0FF
MLoc Contentalah
+5VCAa
b
c
d
e
f
g
p
CA7SD8255 : U29
Port-A19h PA7-PA0
CR: 1Fh
xxxxx TDELAY
D7-D0D15-D8
PC = CS:IP
(1)
(1)
(2)
(3)
(3)
(4)RAM: U9, U10
8086 : U1
CS/
548
CA Code for BlankCA Code for 3
Comment
01000
DSM
CSMProgram Codes
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
Midas 935-0964/5 The trainer is ready to accept valid command
2 AD Seg. Oset Data xxxx yyyy zz
The 20-bit address of an arbitrary memory location is opened in the format of: ‘Segment: Offset’. The present content of the memory location has also appeared in the data field.
3 0 0 0 0 Seg. Oset Data 0000 yyyy zz
The segment part of the 20-bit address is set to 0000h. This is actually 00000h (the right most digit is understood to be 0). Now, set the offset part of the 20-bit address.
4/Expt-1B
5/Expt-1B
4 : Seg. Oset Data 0000 yyyy _ zz
The cursor has moved to the offset field and is blinking. Use the data keys (0 to F) to set the value of the offset.
5 3 0 1 0 Seg. Oset Data 0000 3010 _ zz
The 20-bit address, 03010 (0000:3010) is entered. Now, deposit the cacode data (B0h) for character ‘3’.
6 DA Seg. Oset Data 0000 3010 zz _
The cursor has moved at the data field. Now, use data keys (0 to 9) to deposit the cacode, B0h at the indicated memory Location.
7 B 0 Seg. Oset Data 0000 3010 B0 _
The data value B0h is deposited at location, 0000:3010. Now, deposit cacode (FFh) for the ‘blank’ character at the memory location, 0000:3010.
8 + Seg. Oset Data 0000 3011 zz _
The next memory location is opened. Enter data, FFh at the indicated memory location using the data keys (0 to 9). To move to the previous memory location, use the ‘ – ‘ command.
9 F F Seg. Oset Data 0000 3011 FF _
The CA-code for blank is entered at memory location: 03011
10 RESET MDE8086 Kit V9.5 Midas 935-0964/5
The trainer is ready to accept valid command
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: L1: L2: L2A: HERE1: L3: HERE2: L4:
0000:1000 – 0000:1001 - 0000:100E – 0000:1015 - 0000:101D- 0000:101F - 0000:1027 - 0000:1029-
nop mov ax, 0000h mov ds, ax mov ax, 0000h mov ss, ax mov sp, 8FFEh mov al, 80h out CRU29(1Fh), al mov bx, 3000h mov al, BYTE PTR ds;[bx+10h] out PARU29(19h), al mov cx, 0FFFFh loop HERE1 mov al, BYTE PTR ds:[bx+11h] out PARU((19h), al mov cx, 0FFFFh loop HERE2 jmp L2A
90 B8 00 00 8E D8 B8 00 00 8E D0 BC FE 8F B0 80 E6 1F BB 00 30 8A 47 10 E6 19 B9 FF FF E2 FE 8A 47 11 E6 19 B9 FF FF E2 FE EA 15 10 00 00
; 00000h = Base Add.of Data Seg. ; 00000h = Base Add of Stack Seg. ; Stack Pointer Reg. set to: 08FFEh ; Control Byte to set PAR as output ; bx-register to work as pointer ; reading cacode for ‘3’ ; sending cacode of ‘3’ to PAR ; Insert Time Delay ; reading cacode for ‘blank’ ; sending cacode of ‘blank’ to PAR ; Insert Time Delay ; 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
Midas 935-0964/5 The trainer is ready
2 AD Seg. Ost Data xxxx yyyy zz
The cursor blinks at the segment field. Use data keys to set the segment at: 0000h.
3 : Seg. Ost Data 0000 yyyy _ zz
The cursor blinks at the offset field. Use data key to set the address at : 1000h
4 GO Statring Address 0000:1000
Program has been executed. Character ‘3’ should blink.
Task-1B.5 Familiarization with Internal Structure of CA 7-Segment Display Device
6/Expt-1B
1 32 4 5
678910
538
e d ca c p
bacafg
caa
b
cd
g
7
p
6
5
42
538
e
f10
ca
a(7)
538
b(6)c(4)d(2)e(1)f(9)g(10)
p(5)
(a) Physical View (b) Internal LED Structure (c) Electrical Equivalent
Figure-1B.4: Structure of Common Anode Type 7-Segment Display Device Task-1B.6 Enter appropriate data at the appropriate memory locations of DSM to blink
character A on the CA7SD. Make CA-code for A looking at the diagram of Fig-1B.3. 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.
7/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.
8/Expt-1B
+5VGND
Jumper Positionat: Local Monitor
P1
538
Jumper Positionat: Serial Monitor
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
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............
9/Expt-1B
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.
10/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.
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
00000
003FFInterrupt
Vvector Table
00400
FFFFF
0FFFF
0900008000
RA
M
10000
0D000
07000
0300002FFF
00F0000EFF
RO
M
545
Data Structure
00FFFScratch Pad
01000
04FFF05000
06000
Space forCode Segment
Space forData Segment
Space forExtra Segment
Space forStack Segment
Use
r-1
FFFF:0000 Start Up Location
F0000
0CFFF
EFFFFUseable after Decoding
Reserved4x 4KByres U
ser-
2
Reserved4x 2KByres
Use
r-3
(00)01 (00)00545
LCDIR(00)02 LCDSR(00)04 LCDDR
KBD DR/FR
(00)05
(00)08 8251 : DR(00)09 8253: TC-0(00)0A 8251: CR/SR8252: TC-1(00)0B
(00)0D
(00)03
8253: TC-2(00)0F 8253: CR
(00)10 8259: CR(00)11 SPEAKER: DR(00)12 8259: DR
(00)18ADC : DR/CR
OR8255 (U30):PAR
ADC : DR/CROR
8255 (U30):PBR
ADC : DR/CROR
8255 (U30):PCR
ADC : DR/CROR
8255 (U30):CR
(00)1A
(00)1C
(00)1E
(00)19 8255 (U29) PAR
8255 (U29): PBR(00)1B
8255 (U29): PCR(00)1D
8255 (U29): CR(00)1F
(00)20(00)22(00)24(00)26
IO CON10IO CON10
IO CON10IO CON10
FFFEFFFF Figure-1B.6: Memory Space of MDA-8086 Figure-1B.7: Port Space Map of MDA-8086
11/Expt-1B
12/Expt-1B
Task-1B.16 Component Layout of MDA-8086
13/Expt-1B
Figure-1B.8: Component Layout Diagram of the MDA-8086 System Task-1.17 Schematics of the MDA-8086 Learning System
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
432
: 1AD 0 2 34 5 6 78 9 A BC D E F
- DA+ REG
G0 STPNMI RES
546
CS/
D15-D8D7-D0
DR:01h
KBIC : 74244 :U24 CPU : 8086 : U1
CS/D7-D0D7-D0
LCDIC
9600 Bd
RS : 01h
IRSR
DR
16 Characters x 2 Lines
LCD
CR:1Eh
PA:18h
0V
PB:1AhPC:1Ch
D7-D0 D7-D0
PIO: 8255:U30
8x8Common CathodeType Bi-colorLED Array
CS/
+5V
Vin
MIC
TH1
DIP2
DAC:U33
CR:18hDR:18h
VR
2
ADC: 0804 : U31
CS/
D7-D0D7-D0
P6
Speaker
DCS/
Out
SPKIC: U25
DR: 11h
D7-D0 D7-D0
CS/SIO: 8251:U14 TTL <----> RS232 : U15
TTL TxRSTxTTL
RxRSTTLRxTTL
CON: DB9
SR: 0AhCR: 0Ah
DR: 08h
9600 Bd
CS/
PUT: U41
:8253
D15-D7-D0
TC-1:0Bh
TC-0:09h
TC-2:0DhCR:0Fh
D8
CON10Users Interface Controller CS/20h, 22h,24h, 26h
D7-D0
D15-D8
EVN: ROM:U7F0000, ..... FFFFE
ODD: ROM:U8F0001,...... ,FFFFF
Mem/Port Decoder : U16
CS/
CS/D7-D0
D7-D0
Sx/A,M-IO/,BHE/
D15-
D7- D7-D0
CS/
CS/
D7-D0CS/ ODD: RAM : U10
00001, ........ 0FFFF
EVN : RAM : U900000,......... 0FFFE
D8
D0
D7- D7-D0D0
CR:10h
DR:12hIR7
CK0
IR6IR5IR4IR3IR2
(41h)IR1(40h)IR0
CK1
CK2
Sy/
PCLK: 2.4576MHz+5VGT0
OT0
TxC,RxCCLK for 9600 Bd
GT1GATE1
0VOT1
0VGATE2
GT2OT2
+5VIR2
IPCU428259
27256
27256
62256
62256
INTININTA
/IN
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.
TRTA
/
NMI +5VNMI
GM: 547: 11/03:3 Hrs
0V
D8
CR:1Fh
PCR:1Dh
PBR:1Bh
PAR:19h
CA7SD
PB0-PB3LED11-LED14
Step. Motor Int.PB4-PB7 DAC
U33
LM:U38ADC:U31P8
CS/D D15-D8
PIO:8255U29
RxRDY 0V 0V
TxRDY
Figure-1B.1: Hardware Block Diagram of MDA-8086 Trainer
Task-1B.3 Getting Familiar with Keyboard Layout of MDA-8086 Trainer
433
Figure-1B.2: keyboard Layout of MDA-8086 Learning System
: 1AD 0 2 3
4 5 6 7
8 9 A B
C D E F
- DA
+ REG
G0 STP
MON RES
546
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.
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.
0301003011
B0FF
MLoc Contentalah
+5VCAa
b
c
d
e
f
g
p
CA7SD8255 : U29
Port-A19h PA7-PA0
CR: 1Fh
xxxxx TDELAY
D7-D0D15-D8
PC = CS:IP
(1)
(1)
(2)
(3)
(3)
(4)RAM: U9, U10
8086 : U1
CS/
548
CA Code for BlankCA Code for 3
Comment
01000
DSM
CSMProgram Codes
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
Midas 935-0964/5 The trainer is ready to accept valid command
2 AD Seg. Oset Data xxxx yyyy zz
The 20-bit address of an arbitrary memory location is opened in the format of: ‘Segment: Offset’. The present content of the memory location has also appeared in the data field.
3 0 0 0 0 Seg. Oset Data 0000 yyyy zz
The segment part of the 20-bit address is set to 0000h. This is actually 00000h (the right most digit is understood to be 0). Now, set the offset part of the 20-bit address.
434
435
4 : Seg. Oset Data 0000 yyyy _ zz
The cursor has moved to the offset field and is blinking. Use the data keys (0 to F) to set the value of the offset.
5 3 0 1 0 Seg. Oset Data 0000 3010 _ zz
The 20-bit address, 03010 (0000:3010) is entered. Now, deposit the cacode data (B0h) for character ‘3’.
6 DA Seg. Oset Data 0000 3010 zz _
The cursor has moved at the data field. Now, use data keys (0 to 9) to deposit the cacode, B0h at the indicated memory Location.
7 B 0 Seg. Oset Data 0000 3010 B0 _
The data value B0h is deposited at location, 0000:3010. Now, deposit cacode (FFh) for the ‘blank’ character at the memory location, 0000:3010.
8 + Seg. Oset Data 0000 3011 zz _
The next memory location is opened. Enter data, FFh at the indicated memory location using the data keys (0 to 9). To move to the previous memory location, use the ‘ – ‘ command.
9 F F Seg. Oset Data 0000 3011 FF _
The CA-code for blank is entered at memory location: 03011
10 RESET MDE8086 Kit V9.5 Midas 935-0964/5
The trainer is ready to accept valid command
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: L1: L2: L2A: HERE1: L3: HERE2: L4:
0000:1000 – 0000:1001 - 0000:100E – 0000:1015 - 0000:101D- 0000:101F - 0000:1027 - 0000:1029-
nop mov ax, 0000h mov ds, ax mov ax, 0000h mov ss, ax mov sp, 8FFEh mov al, 80h out CRU29(1Fh), al mov bx, 3000h mov al, BYTE PTR ds;[bx+10h] out PARU29(19h), al mov cx, 0FFFFh loop HERE1 mov al, BYTE PTR ds:[bx+11h] out PARU((19h), al mov cx, 0FFFFh loop HERE2 jmp L2A
90 B8 00 00 8E D8 B8 00 00 8E D0 BC FE 8F B0 80 E6 1F BB 00 30 8A 47 10 E6 19 B9 FF FF E2 FE 8A 47 11 E6 19 B9 FF FF E2 FE EA 15 10 00 00
; 00000h = Base Add.of Data Seg. ; 00000h = Base Add of Stack Seg. ; Stack Pointer Reg. set to: 08FFEh ; Control Byte to set PAR as output ; bx-register to work as pointer ; reading cacode for ‘3’ ; sending cacode of ‘3’ to PAR ; Insert Time Delay ; reading cacode for ‘blank’ ; sending cacode of ‘blank’ to PAR ; Insert Time Delay ; 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
Midas 935-0964/5 The trainer is ready
2 AD Seg. Ost Data xxxx yyyy zz
The cursor blinks at the segment field. Use data keys to set the segment at: 0000h.
3 : Seg. Ost Data 0000 yyyy _ zz
The cursor blinks at the offset field. Use data key to set the address at : 1000h
4 GO Statring Address 0000:1000
Program has been executed. Character ‘3’ should blink.
Task-1B.5 Familiarization with Internal Structure of CA 7-Segment Display Device
436
1 32 4 5
678910
538
e d ca c p
bacafg
caa
b
cd
g
7
p
6
5
42
538
e
f10
ca
a(7)
538
b(6)c(4)d(2)e(1)f(9)g(10)
p(5)
(a) Physical View (b) Internal LED Structure (c) Electrical Equivalent
Figure-1B.4: Structure of Common Anode Type 7-Segment Display Device Task-1B.6 Enter appropriate data at the appropriate memory locations of DSM to blink
character A on the CA7SD. Make CA-code for A looking at the diagram of Fig-1B.3. 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.
437
(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.
438
+5VGND
Jumper Positionat: Local Monitor
P1
538
Jumper Positionat: Serial Monitor
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
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............
439
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.
440
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.
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
00000
003FFInterrupt
Vvector Table
00400
FFFFF
0FFFF
0900008000
RA
M
10000
0D000
07000
0300002FFF
00F0000EFF
RO
M
545
Data Structure
00FFFScratch Pad
01000
04FFF05000
06000
Space forCode Segment
Space forData Segment
Space forExtra Segment
Space forStack Segment
Use
r-1
FFFF:0000 Start Up Location
F0000
0CFFF
EFFFFUseable after Decoding
Reserved4x 4KByres U
ser-
2
Reserved4x 2KByres
Use
r-3
(00)01 (00)00545
LCDIR(00)02 LCDSR(00)04 LCDDR
KBD DR/FR
(00)05
(00)08 8251 : DR(00)09 8253: TC-0(00)0A 8251: CR/SR8252: TC-1(00)0B
(00)0D
(00)03
8253: TC-2(00)0F 8253: CR
(00)10 8259: CR(00)11 SPEAKER: DR(00)12 8259: DR
(00)18ADC : DR/CR
OR8255 (U30):PAR
ADC : DR/CROR
8255 (U30):PBR
ADC : DR/CROR
8255 (U30):PCR
ADC : DR/CROR
8255 (U30):CR
(00)1A
(00)1C
(00)1E
(00)19 8255 (U29) PAR
8255 (U29): PBR(00)1B
8255 (U29): PCR(00)1D
8255 (U29): CR(00)1F
(00)20(00)22(00)24(00)26
IO CON10IO CON10
IO CON10IO CON10
FFFEFFFF Figure-1B.6: Memory Space of MDA-8086 Figure-1B.7: Port Space Map of MDA-8086
441
442
Task-1B.16 Component Layout of MDA-8086
443
Figure-1B.8: Component Layout Diagram of the MDA-8086 System Task-1.17 Schematics of the MDA-8086 Learning System
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.
1/Expt-2
Figure-2.1 : Memory Based Data Structure for Adding Two Unsigned Hexadecimal Numbers
03000 =0000:3000
04FFF = 0000:4FFF
03010 = 0000:301003011 = 0000:3011 Inputs
Output
608
Memory Location Content Table
(20-Bit)
Expanded Data Segment Memory (DSM)
03001 = 0000:3001
Data1= 21
03012 = 0000:3012
Rlbyte = 18
seg:off
Data2=F7
00000 = 0000:0000
FFFFF = F000:FFFF
04000 = 0000:400003FFF = 0000:3FFF
Rubyte = 0104001 = 0000:4001
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
START: Entry
al + ah --> c, al
(03010) --> al(03011) --> ah
L3:
L1:
L2:
L4:
L5:
L6:
10:GM:10-08
Carry = 1?
al ---> 04000h00 – 04001h
N
Y L 7:
al ----> 04000h01 – 04001h
Initialize:Based Addr of DSMPointer Register
Halt
Figure-2.2: Flow Chart for Adding Two 8-bit Numbers
2/Expt-2
3/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
Task-2.8 Adding Three 8-bit Unsigned Numbers
START: Entry
al + ah --> c, al
(03010) --> al(03011) --> ah(03012h) --> dl
L3:
L1:
L2:
L3A:
L4 :
L5:
L6:
L7:
Halt
578bc
Carry = 1?
00h ---> 04001h
N
Y
01h ----> 04001h
al + dl ---> c , al
Carry = 1?
NL5A:
00h+(04001h) --> 04001h
01h+(04001h)--->04001h
al ---> 04000h
Y L 9:
L8:
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.
1/Expt-2
04FFF = 0000:4FFF
03010 = 0000:301003011 = 0000:3011 Inputs
Output
12
Memory Location Content Table
(20-Bit)
Expanded Data Segment Memory (DSM)
MLPR
03012 = 0000:3012
Rlbyte
seg:off
MLPC
00000 = 0000:0000
FFFFF = F000:FFFF
04000 = 0000:400003FFF = 0000:3FFF
Rubyte04001 = 0000:4001
Task-3.2 Data Structure Let us assume that we have the following two numbers to multiply.
i. The MLPR (range: 00h – FFh ii. The MPLC (range: 00h – FFh) iii. The Product (range: 0000h – FE01h). The upper part of the result, is in fact, the accumulation of the carry bits that had been generated during addition process.
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
8086: U2
PA0
PCR: 3604h
PBR: 3602h
PAR: 3600h
3606hCR
8255: U23
A
D7-D0
RD/WR/
CS/
W/R/
D
A
M-IO/ IO/PA7
PB0
PB7
LED0
LED7
LED8
LED15
PC7 – PC0 (J7)
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.
D7D6D5D4D3D2D1D0
AD15 39AD14AD13AD12AD11AD10AD09AD08
2728293031323334
RD/WR/
0536
CS/
A1A0
RST
VccGND
06
0809
35
2607
+5V0V
A.M-IO/
8086 : U1 8255 : U29
02030405060708
3229
RD/WR/
A2A1
RST
PAR (19h)
P3/P4
PA0PA1PA2PA3PA4PA5PA6PA7
0403020140393837
0203040506070809
PBR(1Bh)
PCR (1Dh)
CR (1Fh)
CA7SDD
8x330R07 a06040201091005
bcdefgp
08CA
+5V
p
a
b
c
d
e
fg
538
R26-R33
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
G07R07
G00
8086: U1
R00
G70R70
PA0PB0
PA7PB7
PC0PC71Ch
PA: 18h
PB: 1Ah
1EhCR
8255: U30 DOTLED
A
D7-D0
RD/WR/
CS/
W/R/
D
A
M-IO/ IO/
Col0
Col7
Row0
Row7G77R77
418
3725
1410 12 22
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 (12)
Chapter - 1: Fundamental Concepts (a) Basic Tasks of a MPU and Building Blocks of a MPU-based System; (b) RAM Structure, Data Read from a RAM Location, Development of Pseudo Code and 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 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.
1 Experiment – 1A, 1B Experiment – 2 Experiment - 3 Selected Exercises from Ch-1
5 13 - 15 (3)
Chapter - 2: Architecture (a) Physical Pin Diagram, Pin Classification, Bus-structured Diagram. (b) Internal Register Set, Function of Flag Register. (c) Memory Organization showing ODD/EVN Banks, Truth table of RD/, WR/, M-IO/, BHHE/, A0.
1 Experiments: Same as Above Selected Exercises from Ch-2
6 16 - 18 (3)
Chapter – 3: Instruction Set (a) Definitions and Classifications of Instructions, Addressing Modes. (b) Various Format of JMP and CALL Instructions.
1 Experiments: Same as Above Selected Exercises from Ch-3
7 - 8 19 - 24 (6)
Chapter – 4: IO Controller Programming (a) Parallel IO Programming using 8255, LCD Display System and Programming. (b) Keyboard and CC7SDD Programming using 8279, Serial IO Programming using 8251
1 Experiment – 4 Experiment – 5A Selected Exercises from Ch-4
9 25 - 27 (3)
Chapter – 4: Interrupt Structure (a) Meaning of Interrupting the CPU, Events that occur during Interrupt, Interrupt Pins of 8086, IPD (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.
1 Experiment – 6A, 6B Selected Exercises from Ch-5
10 - 11 28 - 33 (6)
Chapter – 6: Data Conversion Algorithm (a) 2s-Complemet Code, BCD2BIN Conversion by (i) Counting Rule (ii) by Horner Rule. (b) BIN2BCD Conversion by (i) Counting Rule (ii) by Horner Rule. (c) Rules to Adjust Incorrect BCD, daa Instruction
1 Experiment – 7 Experiment – 8, 9 Selected Exercises from Ch-8
12 34 - 36 (3)
Chapter – 7: System Design (8086 Based Digital Weighing Machine: DWM) (a) Block Diagram of an 8086-based DWM, Weight Acquisition, Multiplexed ADC, Rate Acquisition (b) Cost Computation Flow Chart, 16-bit x 16-bit Multiplication
1 Experiment - 10A, 10B Selected Exercises from Ch-7
13– 14 37 - 42 (6)
Chapter – 8: Microcontroller (a) Definition of MCU, Physical Pin of 89S51, Block Diagram showing Internal Resources (b) Block Diagram of Port-mode, Mixed-mode and Bus-mode Operation (c) Instruction Set, Block Diagram of 8051-based (i) DWM (ii) RTC, (iii) CARMET , (iv) PENERMET
1 Experiment – 10A Experiment – 10B Selected Exercises from Ch-8
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.
1/Expt-5A
2x16 Charracter LCDDP
0 DPF
DP10 DP1F
D0
D1
D2
D3
D4
D5
D6
D7
E R-W/ D-I/ VA Vdd Vss
MicroTalk -8086
AD7
AD2AD1AD0
AD3AD4AD5AD6
7891011121314 6 5 4 3 2 1+5
L+ L-
To
See
at D
ark
0V+5V
Viewing Angle0V R1:1k5
A2A1
WR/RD/0V
1
0V+5V
23456
Y0/Y1/Y2/
12
151413 3
U1: 74LS138 U2: 7486722ab
SEP2/: 3E00h -
15 16
0V
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
Operational Truth Table-1:
Signal Activities Function 8086 Instruction 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
3/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
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.
D07D1D2D3D4D5D6D7
89
1011121314
Vss
Vdd
VL
2
3
1
+5V
0V
VA110k
ViewingAngle
D-I/5 R-W/4
A1A2
A DecoderE6
AD07 09AD06AD05AD04AD03AD02AD01AD00
8086 : U1
10111213141516
3229
RD/WR/
16x2 LCD540
M-IO/
DP0DP10
DPFDP1F
Figure-5B.1: Bus Structured Connection Diagram between 8086-LCD of MDA-8086 Trainer
[Operational Truth Table-1]
Signal Activities Function 8085 Instruction 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
L4: Collect the ASCII code of 1st 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
L8: Collect the ASCII code of 1st 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.
PBR:3602h
PAR:3600h
8
8
LED15…...LED8U23: 8255U2 : 8086
MPU PIO
CS/
NMI17+5V
0V
K1B B
1406x : GM: 1/2008
CR:3606h
+5VINTR
18K2
R1
LED7…...LED0
INTA/31
R2
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.
D7D6D5D4D3D2D1D0
AD15 39AD14AD13AD12AD11AD10AD09AD08
2728293031323334
RD/WR/
0536
CS/
A1A0
RST
VccGND
06
0809
35
2607
+5V0V
A.M-IO/
8086 : U1 8255 : U29
02030405060708
3229
RD/WR/
A2A1
RST
PAR (19h)PA0PA1PA2PA3PA4PA5PA6PA7
0403020140393837
0203040506070809
PBR(1Bh)
CR (1Fh)
CA7SD
8x330R07 a06040201091005
bcdefgp
08CA
+5V
p
a
b
c
d
e
fg
538
R26-R33
PB0
LED11NMI
+5V
MONKey 0V
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.
dldh
dx = IPBIN
blbh
bx = BCD
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
4/Expt-7
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
Operational Truth Table-1:
Signal Activities Function 8086 Instruction 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 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
5/Expt-
; send Cbyte3 (0Ch) into LCDIR
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.
DLD DDOP
AAUT
EEXA
FFRW
WAIT
F3
BBKW
CCHG
7EXW
8EXB
9FLR
F4 4CS
5PC
6FB
F5
RST
1IP
2AX
3Al
0PRT
BKSS/S RST
608
Row
SL
UD
4 to 16 Decoder
3 to 8 Decoder
DP0DP1
DP2DP3
DP4 DP8DP6DP5 DP7
DPFDP9
DPADPB DPCDP
D
DPE
Addr Field Data Field
AD
D15-D0
A D C A D C A D C A D C A D C
A D CA D C
A
A D CA D CA D CA D C
DC
CS/ CS/ CS/CS/ CS/
CS/
CS/
CS/CS/CS/CS/CS/
U10ROMEVN
(32K)
U9ROMODD
(32K)
U12RAMEVN
(32K)
U11RAMODD
(32K)
U15ADC
U16DAC
AnOut AnIn
CS/-U16CS/-U15
3400h 3200h 00001h -0FFFFh
00000h -0FFFEh
F0001h -FFFFFh
F0000h -FFFFEh
CS/-U11CS/-U12CS/-U09CS/-U10
U24KBDC
U30DMPIO
U23LEDPIO
U13PIT
U17USART
U14IPC
1000-1FFE 2000-2FFE 3000-31FE 3800-39FE3600-37FE
CS/-U24
0000 - 0FFECS/-U23CS/-U30
CS/-U13
RxRDY
IR2-IR7
(20h)IR0(21h)IR1
22h-27hTxE
RxRS TxRS
CS/-U17CS/-U14
AM-IO/
BHE/
U1, U3MEMPORTDECODER
CKRST
RDY
6.144 MHz
U29CKG
RS <-->TTLU18, U19
RxT TxT
GT CK OT
U1MPU
PA PB
16 LEDs
SMI
4xPh
PA PB PC
8x8 LED MAT
PC
J7
J8J5J10
J6
J6609:GM:03-04
Keyboard
Display
J5 J5
DT-R/ DIRDEN/ EN/
U4, U5DBUFF
ALE CKA
C
ADC
U6,U7,U8ALATCH
D
C
J1CS/-User (3)
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.
3/Expt-1
DNLD DDOP
AAUT
EEXA
FFRW
F2
F3
BBKW
CCHG
7EXW
8EXB
9FLR
F4 4CS
5PC
6FB
F5
RST
1IP
2AX
3AL
0PRT
BKSS/S RST
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.
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
5/Expt-1
03000 =0000:3000
04FFF = 0000:4FFF
03010 = 0000:301003011 = 0000:3011
Inputs
Output
45
Memory Location Content Table
(20-Bit)
Expanded Data Segment Memory (DSM)
03001 = 0000:3001
Data1= 2C
03012 = 0000:3012
Result = 73
seg:off
Data2=47
00000 = 0000:0000
FFFFF = F000:FFFF
04000 = 0000:400003FFF = 0000:3FFF
04001 = 0000:4001
Base Addres
Beginning Address
c. The offset (how far) of the beginning address of DSM from the Base Address is: 3000hs.
ALl Four Memory Segments of User-1
CSM
DSM
ESM
SSM
01000 = 0000 : 1000)
02 F = 0000:2FFF)(03000 = 0000:3000)
(0 FF = 0000:4FFF)(05000 = 0000:5000)
(06000 = 0000:6000)(07000 = 0000:7000)
(0 FF = 0000:8FFF)
FF
4F
8F
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)
6/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 1 0 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 2 C 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
Location Assembly Instructions Machine
Codes Meaning
START: L1: L2: L3: L4: L5: L6:
01000 (0000:1001) 0100A 0100C 01010 01018 0101E
- nop - mov bx, 3000h mov al, BYTE PTR [bx+10h] mov ah, BYTE PTR [bx+11h] - add al, ah - mov BYTE PTR [bx+1000h], al - mov ah, al mov al, 80h mov dx, 3606h out dx, al - mov al, ah mov dx, 3600h out dx, al - hlt
- 90 - BB 00 30 8A 47 10 8A 67 11 02 C4 88 87 00 10 - 8A E0 B0 80 BA 06 36 EE - 8A C4 BA 00 36 EE - F4
; must be here for the ; bx Register is a pointer ; 2Ch comes into CPU ; 44h comes into CPU ; data are added ; result is stored in DSM ; result is sent to LEDs ; 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….
01000 = 0000:1000
02FFF = 0000:2FFF
Memory Location Content Table
(20-Bit) seg:off
Expanded Code Segment Memory (CSM)
90BB
0001001 = 0000:100101002 = 0000:100201003 = 0000:1003
Opcode
Operand
00000 = 0000:0000
FFFFF = F000:FFFF
46
30
Opcode
Base Addres
Beginning Address of CSM
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.
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 r u n 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’].
LED0LED7
LED8LED15
LED Assemly
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.
8/Expt-1
03000
03010 2C
043FFDSM CPU
D
ALU
al
LEDPIO(U23)
LD0
LD7
610
03011 47
al ah
Result
7303012
Result
D
PAR
(360
0h)
CR
(360
6h)
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>--
9/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.
10/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.
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
12/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.
13/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.
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
607aDR of 8279: U24
2000
CR /SR: 8279: U24
1FFE
31FE
37FE
3605
00000002
0FFE Shadow1000 DR of 8259 : U141002 CR of 8259 : U14
ShadowDR of 8251: U17CR of 8251: U172002
2FFE Shadow3000300230043006
Shadow
C0 of 8253: U13C1 of 8253: U13C2 of 8251: U13CR /SR: 8251: U13
3200 DR/CR :ADC:U15
33FE Shadow3400 DR of DAC : U16
35FE Shadow360036023604
Shadow
PA of 8255:U23PB of 8255:U23PC of 8255:U23CR of 8255:U23
380038023804
39FE
3806Shadow
PA of 8255:U30
PC of 8255:U30PB of 8255:U30
CR of 8255:U30
3BFE
3A00
3C00
3DFE3E00
3FFE4000
0001
FFFE
Decoded atSEP0 (J1-7)
Decoded atSEP1 (J1-6)
Decoded atSEP2 (J1-5)
Can be Usedafter
Decoding
Port Space Map
FFFF
Can be Usedafter
Decoding
EVEN PortODD Port
00000
003FFInterrupt
Vvector Table
00400
FFFFF
0FFFF
0900008000
RAM
10000
0D000
07000
0300002FFF
00F0000EFF
ROM
545
Data Structure
00FFFScratch Pad
01000
04FFF05000
06000
Space forCode Segment
Space forData Segment
Space forExtra Segment
Space forStack Segment
User
-1
FFFF:0000 Start Up Location
F0000
0CFFF
EFFFFUseable after Decoding
Reserved4x 4KByres Us
er-2
Reserved4x 2KByres
User
-3
Figure-1.6: Memory and Port Space Map of MicroTalk-8086
14/Expt-1
15/Expt-1
Task-1.13 Component Layout of MicroTalk-8086
16/Expt-1
Figure-1.7: Component Layout Diagram of the MDA-8086 System Task-1.14 Schematics of the MDA-8086 Learning System
17/Expt-1
Figure-1.8: CPU Subsystem
18/Expt-1
Figure-1.9: Composite Memory and Port Subsystem
Figure-110: Memory Subsystem Print: P19_Expt1A.doc
19/Expt-1
cc7
RES/
S4
PCLK
KC4
cc6
K40
F4
S2
S5
cc14
DB2 .
DP0
S7SEGCC
109754216
3
abcdefgp
cc
S1
S4
DB5
K13
F/FRW
DB7S6
cc9
DB1
DB4
K52
2/AX
DB3
S5
.
DP8
S7SEGCC
109754216
3
abcdefgp
cc
S3
cc4
cc4
DB5S6
S3
S0
S6S7
S5
cc[0:7 ]
KC6
S4
S6S6
K20
F2
.
DP3
S7SEGCC
109754216
3
abcdefgp
cc
S1
S3
DB6
S2
S2
S6
cc2
cc12
.
DP4
S7SEGCC
109754216
3
abcdefgp
ccS0
DB[0:7]
.
DP5
S7SEGCC
109754216
3
abcdefgp
cc
S1 S1
S2S3
S2
K31
7/EXW
CS8279
S0
S0
S3
S5
S0
cc2
K33
9/FLR
.
DP12
S7SEGCC
109754216
3
abcdefgp
cc
SL0
KR7
A1
S3
VCC
S7S7
K53
3/AL
VCC
cc7
IORC/
S7
S5S4
K63
RST2
K62
BKS-S/S
S0S1
S1
cc0
S7
D7
S7
S2
S[0:7 ]
cc12
S0
.
DP7
S7SEGCC
109754216
3
abcdefgp
cc
S6
.
DP9
S7SEGCC
109754216
3
abcdefgp
cc
K22
B/BKW
S5
cc8
S1.
DP1
S7SEGCC
109754216
3
abcdefgp
cc
S7
cc0
S5S4
S7
S3
SL2
cc3
DB0
S6KIRQ
S0
cc14cc13
S1
S7D0
S4
KC5
.
DP13
S7SEGCC
109754216
3
abcdefgp
cc
S3S2
S2S1
S4
.
DP2
S7SEGCC
109754216
3
abcdefgp
cc
S6S7
S2
cc5
SL1
D6
S3
.
DP10
S7SEGCC
109754216
3
abcdefgp
cc
K60
RST1
cc8 S4
.
DP11
S7SEGCC
109754216
3
abcdefgp
cc
S1
S6
S6
DB3
S7
K41
4/CS
cc11S2 S2
S4
S2
K21
A/AUT
K43
6/FB
cc[8:15]
cc3
S7
K61
0/PRT
S1S1
S3
S5
S0
cc10S1
S3
S5
DB2
K23
C/CHG
S6
S4S5
DB7
RESET
K42
5/PC
S1
D2
S2
S4
K12
E/EXA
S7
SL3
U25
74LS244
2468
1
18161412
11131517
9753
19
A1A2A3A4
1OE
Y1Y2Y3Y4
A5A6A7A8
Y5Y6Y7Y8
2OE
cc5
S2
S4S5
S5
S0
.
DP6
S7SEGCC
109754216
3
abcdefgp
ccDB0
S4
cc13
K11
D/DOP
S7
DB6S7
D4S4
S4
S7
S0 S0
S6
KR0
S1
DB1
U24
8279
1213141516171819
21
24252627
28293031
36
37
32333435
234
10
1122
9
39
7
5
6
2
1
38
8
DB0DB1DB2DB3DB4DB5DB6DB7
A0
QA3QA2QA1QA0
QB3QB2QB1QB0
SHFT
CN/ST
SL0SL1SL2SL3
BDIRQ
RD
WRCS
RESET
CLK
RL1
RL6
RL4
RL5
RL3
RL2
RL0
RL7
S5
cc1
3
K51
1/IP
U26
74LS138123
15141312111097
645
ABC
Y0Y1Y2Y3Y4Y5Y6Y7
G1G2AG2B
S4
D5
AIOW C/
S5
.
DP15
S7SEGCC
109754216
3
abcdefgp
cc
S7
S0
K32
8/EXB
K30
F3
S4S5
S5
DB4
3.072MHz
D3
S2
S1
U28
74LS138
123
15141312111097
645
ABC
Y0Y1Y2Y3Y4Y5Y6Y7
G1G2AG2B
S0S1
S3
cc1
S0
S3
S3
cc9S2
S3
S6
cc11KC7
S0 S0
S6
S3
.
DP14
S7SEGCC
109754216
3
abcdefgp
cc
S6
K50
F5
S3
cc15
D1
S6
cc15
S5
cc6
cc10
S2
U27
74LS138
123
15141312111097
645
ABC
Y0Y1Y2Y3Y4Y5Y6Y7
G1G2AG2B
K10
DNLD
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.
1/Expt-10A
RST0
1
BKS
65
2 3
7
4
8
U238255
Breadboard
Amp
ADC
Load Cell
Q0Q1Q2Q3
DS4DS3DS2DS1
+5-5
0V
713-04
U28086
9
E
DP0DP1
DP2DP3
DP4 DP5DP6
DP7DP8
DP9DP10
DP11DP12
DP13DP14
DP15
Weight Field Rate Field
Cost Field
CC7S Type Display ofMicroTalk-8086 Trainer
J7
U248279
Figure-71.1: Block Diagram of DWM Based on the MicroTalk-8086 Trainer
Output 20mV / 20Kg. Wt.
+ Excitation (Green)
- Excitation (Black)
+ Sense (Blue)
- Sense (Yello)
Load Cell
Weight
+ Output (Red)
+ Output (White)
+ -
GM: loadcellcircuit323: 15/12/01: 714-04
-5V
+5V
Figure-71.2: Pictorial View of Load Cell Figure-71.3: Electrical Circuit of the Load Cell
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
2/Expt-10A
05050050510505205053
upBCDWt
UpBCD Wt: 10UpBCD Wt: 1UpBCD Wt: 1/10UpBCD Wt: 1/100 Goods
T7
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
05020 pBCD: 10, 1
pBCD: 1/10, 1/100 WtField
05021 BCD
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
05000
05004 WtField
T1aCC-Code: 10 (TEN)CC-Code: 1 (UNI)CC-Code: 1/10CC-Code: 1/100always 3Fh for 0
DP0
DP4
DP1DP2DP3
4b. Assemble, convert, download and execute p712a.asm. The DP0-DP4 shows: 12.370 kg.
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).
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
3/Expt-10A
05047 ASCII for 1/100 DP1F
Cursor PositionNo of Digits to PrintCursor TypeKey Scan Code0504B
05048050490504A
0504C0504D
T5
Rate
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 The DP0-DP4 shows: 12.370 kg. 05022
05023pBCD: 10, 1pBCD: 1/10, 1/100 Rate
Field BCD 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 pBCD: 1/10, 1/100pBCD: 10, 1pBCD: 1000, 10005025
CostField05026 BCD
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
050090500A0500B
0500F
DP10
DP15
CostField
T1cCC-Code: 1000 (K)CC-Code:100 (HUN)CC-Code: 10 (TEN)CC-Code: 1 (UNI)CC-Code: 1/10CC-Code: 1/100
DP11DP12DP13DP14
no Use
6b. Assemble, download and execute: p712c.asm The DP0-DP4 shows : 12.370 kg (weight) The DP5-DP8 shows: 27.95 Tk (rate) The DP10-DP15 shows: 0345.74 Tk (Cost).
Figure-71.10: Table Containing CC-code Cost
4/Expt-10A
Figure-71.11: Data Structure for the Digital Weighing Machine
05000
05004 WtField
T1aCC-Code: 10 (TEN)CC-Code: 1 (UNI)CC-Code: 1/10CC-Code: 1/100always 3Fh for 0
05005
RtaeFieldT1bCC-Code: 10 (TEN)
CC-Code: 1 (UNI)CC-Code: 1/10CC-Code: 1/10005008
DP0
DP4
DP1DP2DP3
DP5DP6DP7DP8
050090500A0500B
0500F
DP10
DP15
CostField
T1cCC-Code: 1000 (K)CC-Code:100 (HUN)CC-Code: 10 (TEN)CC-Code: 1 (UNI)CC-Code: 1/10CC-Code: 1/100
DP11DP12DP13DP14
05010
0501F05020
05027
upBCD: X0 :1/ 100
upBCD: X0 : 10upBCD: X0 : 1upBCD: X0 :1/10upBCD: X0 :1/100 Wt
FieldT2a
no Use05013
0501505014
05018
upBCD: X0 : 10upBCD: X0 : 1upBCD: X0 : 1/10upBCD: X0 : 1/100 Rtae
FieldT2b
no Use
no Use0501A05019
upBCD: X0 : 1000upBCD: X0 : 100upBCD: X0 : 10upBCD: X0 : 1upBCD: X0 : 1/10
pBCD: 10, 1
CostField
T2c
pBCD: 1/10, 1/100 WtField
pBCD: 1/10, 1/100pBCD: 10, 1pBCD: 1000, 10005025
CostField
05021050220502305024
05026
CC-C
ode
Tabl
e: T
1up
BCD
Tab
le: T
2pB
CDTa
ble:
T3
pBCD: 10, 1pBCD: 1/10, 1/100
DP0
DP3
DP5
DP8
DP10
DP15
RateField
05028
0503705038
05047
ASC
II T
able
: T4
7-Se
men
t Dis
play
Dev
ices
LCD
Dis
play
050290502A
DP0
DPF
ASCII for BlankASCII for BlankASCII for CASCII for OASCII for SASCII for TASCII for :ASCII for 1000ASCII for 100ASCII for 10ASCII for 1ASCII for .ASCII for 1/10ASCII for 1/100ASCII for BlankASCII for BlankASCII for WASCII for :ASCII for 10ASCII for 1
ASCII for 1/10ASCII for 1/100ASCII for 0
DP10
CostField
T4a
WtFieldT4b
ASCII for BlankASCII for RASCII for :ASCII for 10ASCII for 1ASCII for .ASCII for 1/10
DP17
ASCII for .
DP18
ASCII for 1/100 DP1F
0503F05040
RateField
T4c
Cursor PositionNo of Digits to PrintCursor TypeKey Scan Code0504B
05048050490504A
7-Se
gmen
tan
d LC
D
05050050510505205053
upBCDWt
Scratch Pad Memory
UpBCD Wt: 10UpBCD Wt: 1UpBCD Wt: 1/10UpBCD Wt: 1/100
0504C0504D0504E0504F
Goods
T5
T6
T7
DP0DP1
DP2DP3
DP4 DP5DP6
DP7DP8
DP9DP10
DP11DP12
DP13DP14
DP15
Weight Field Rate Field
Cost Field
DP0 DP1 DP2 DP 3 DP4 DP 5
DP16
DP6 DP7 DP 8 DP9 DPA D PB DPC
DP1E
DPD DPE DPF
DP10 DP 11 DP12 DP13 DP13 DP!4 DP 15 DP 17 DP18 DP1A DP1B DP 1C DP1D DP1F
C O
W
S T : 0
R
0 00 0 .0
: 1 2 . 3 7 0 : _ 593
_ . _ _
GM:04/04: 632
Rate
ASCII Type LCD Display ofMDA-8086 amd MTS-86C
CC7S Type Display ofMicroTalk-8086 Trainer
1 2.
4
3 907 7.2
0
5
5.43 7
Example Data1. Weight: 12.370 kg2. Rate: 27.95 Tk3. Cost : 345.74 Tk
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.
5/Expt-10A
DP0DP1
DP2DP3
DP4 DP5DP6
DP7DP8
DP9DP10
DP11DP12
DP13DP14
DP15
Weight Field Rate Field
Cost Field
CC7S Type Display ofMicroTalk-8086 Trainer
715-04
1 2. 3 7 0 0 0. 0 0
0 0 0 0. 0 0
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.
DP0DP1
DP2DP3
DP4 DP5DP6
DP7DP8
DP9DP10
DP11DP12
DP13DP14
DP15
Weight Field Rate Field
Cost Field
CC7S Type Display ofMicroTalk-8086 Trainer
715-04
1 2. 3 7 0 _ _. _ _
0 0 0 0. 0 0
Figure-71.13: 7-Segment Display Panel after Pressing the Rate Entry Key ‘E’
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.
6/Expt-10A
DP0DP1
DP2DP3
DP4 DP5DP6
DP7DP8
DP9DP10
DP11DP12
DP13DP14
DP15
Weight Field Rate Field
Cost Field
CC7S Type Display ofMicroTalk-8086 Trainer
715-04
1 2. 3 7 0 2 7. 9 5
0 3 4 5. 7 4
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.
7/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
8/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
9/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
10/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
11/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
12/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
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.
LCD
COST: 1998.80
W: 19.990 R: 99.99
30 1 2
4 5 6 7
8 9
E
U298255P3
MDA-8086Breadboard
Amp
ADC
Load Cell
Q0Q1Q2Q3
DS4DS3DS2DS1
+5-5
0V
647
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).
05050050510505205053
upBCDWt
UpBCD Wt: 10UpBCD Wt: 1UpBCD Wt: 1/10UpBCD Wt: 1/100 Goods
T7
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
05020 pBCD: 10, 1pBCD: 1/10, 1/100 Wt
Field05021 BCD
Figure-71.3: Table Containing BCD Weight
05038 ASCII for WASCII for :ASCII for 10ASCII for 1
ASCII for 1/10ASCII for 1/100ASCII for 0
DP10
ASCIIWt
FieldT4b
DP17
ASCII for .
0503F
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).
2/Expt-10B
05047
ASCII for RASCII for :ASCII for 10ASCII for 1ASCII for .ASCII for 1/10
DP19
ASCII for 1/100 DP1F
05041
ASCIIRateField
T4c 632a
Figure-71.5: Table Containing ASCII Rate
0502205023
pBCD: 10, 1pBCD: 1/10, 1/100 Rate
Field BCD
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/100pBCD: 10, 1pBCD: 1000, 10005025
CostField05026 BCD
Figure-71.7: Table Containing BCD Cost
05028
05037
050290502A
DP0
DPF
ASCII for BlankASCII for BlankASCII for CASCII for OASCII for SASCII for TASCII for :ASCII for 1000ASCII for 100ASCII for 10ASCII for 1ASCII for .ASCII for 1/10ASCII for 1/100ASCII for BlankASCII for Blank
ASCIICost
FieldT4a
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.
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.
DP 0 DP1 DP2 DP3 DP4 DP 5
DP16
DP6 DP7 DP 8 DP9 DP A D PB DPC
DP1E
DPD DPE DPF
DP10 DP 11 DP12 DP13 DP13 DP !4 DP 15 DP17 DP 18 DP1A D P1B DP1C DP1D DP1F
C O
W
S T : 0
R
0 00 0 .0
: 1 2 . 3 7 0 : _ 593
_ . _ _0 0 0 0
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:
3/Expt-10B
DP 0 DP1 DP2 DP3 DP4 DP 5
DP16
DP6 DP7 DP 8 DP9 DP A D PB DPC
DP1E
DPD DPE DPF
DP10 DP 11 DP12 DP13 DP13 DP !4 DP 15 DP17 DP 18 DP1A D P1B DP1C DP1D DP1F
C O
W
S T : 0
R
0 00 0 .0
: 1 2 . 3 7 0 : _ 593
_ . _ _
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:
DP 0 DP1 DP2 DP3 DP4 DP 5
DP16
DP6 DP7 DP 8 DP9 DP A D PB DPC
DP1E
DPD DPE DPF
DP10 DP 11 DP12 DP13 DP13 DP !4 DP 15 DP17 DP 18 DP1A D P1B DP1C DP1D DP1F
C O
W
S T : 0
R
0 00 0 .0
: 1 2 . 3 7 0 : _ 593
_ . _ _
3
2 7 6 5
3243
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.
4/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!
5/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
6/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
7/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
8/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
9/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
10/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
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:
8086: U2
A
D7-D0
RD/WR/
CS/
W/
D
A
M-IO/ IO/
8259 : U14IPC:MPU
DRCR 1002h
1000h
R/
INTRINTA/
INTINTA/
IR2(22h)IR1(21h)
BUSKBDIC
8279 : U24
Keypad
DP7 DP8
7SCCD
DRAM
Key B
uffe
rIRQ4KIRQ
J6-3J6-11
IR0(20h)
IR7DP0
BUS
USART: 8251: U17 IBM-PC
TxRDY
RxD
489,488: U18,U19
J6-18
J6-17
TTL <---> RS232RxRDY
TxRS
677
RxRS
J10-2
J10-3CRDR
2002h2000h
TxT
RxT
2 3
13
488
489
CRDR
0002h0000h
6.144MHz307.2KHz
CLKTxCRxC
Col
Row
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
2/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.
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 : MPUBUS
8259 : U14IPC:
DRCR 12h
10h
INTRINTA/
INTINTA/
IR2(42h)IR1(41h)
BUSLCD
IR0(40h)
IR7
BUS
USART: 8251: U17 IBM-PC
TxRDY
RxD
MAX232: U15
TTL <---> RS232RxRDY
TxRS
RxRSCRDR
0Ah08h
TxT
RxT
10 7
1312
2.4576MHz
CLKTxCRxC
8253 : U41: PIT
CK0GT0 +5
OT0C0CR
09h0Fh
Keyboard
IR0(43h)
IRSR
00h02h
DR04h
DRCR01h
01h
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
2/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.
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
DP0
4to16
DECODER
01
2
F DPF
DP1DP2
Q0Q1Q2
Q3
FrequencyDivider
4-BitCounter
FinInOut
DCBA
100KH
8
SL0SL1SL2SL3
DECODER
1024KHz
CS/0000,0002
A0 (C-D/)A1
DP3DP4DP5
DDR
CR
SR
82798086 : GM : 1199
Data
DR
abcdef
pg
cc cc cc cc cc cc cc cc cc
ABCD
S0/S1/S2/S3/S4/S5/S6/S7/S8/
8279 : U10 D9DP0
D8DP1
D7DP2
D6DP3
D5DP4
D3DP6
D4DP5
D1DP8
D2DP7
abcdefgp
Display RAM
U11, U13, U14
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 Register
DDR 0000h Standard & Variable Read/Write
Keyboard Data Register
KDR 0000h Standard & Variable Read/Write
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
Entry
Initialization
DDR for 16-DigitsDisplay,Left Entry
Write Label-cData to DDR
L1:
L2:
L3:
L4:
L5:
Read Datafrom Port-B
Read Data fromMemory Table
byte-by-byte
Exit
WriteDone
?L6:
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
`
112a: GM: 0701 :06/2005
Display Section
Keyboard Section
Q0
Q3Freq.Divide
r
100K1024KHz
4-Bit Counter
4-to-8 Decoder
8279
74138
C
BA
S0/S1/
RL0
RL1
RL2
RL3
RL4
RL5
RL6
RL7
+5V
8x5KKDR
ROW-1
ROW-2
ROW-3
ROW-4
ROW-5
ROW-7
ROW-6
C1 C2 C3
CR
SR
4 IRQ
D7-D0
A0(C-D/)A1
CS/0000,0002
ELECTRONICS
K11K13
K63
8
DP7 DP8
Scan Code Display
S2/S3/
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 K21 …… K51 K61
D/DOP ---------------------- ---------------------- ----------------------
00 001 001 --------------------- ------------------------ ------------------------
09H ---------------------- ---------------------- ----------------------
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
Convert 1-Byte ScanCode to 2-Bytes 7-seg
Display the S can Codeat D2D1 of Trainer
Entry
L1:
L2:
L3:
L4:
L5: L6:
L7:
L8:
Read Status Register
S R0Bit =1
?
Y
N
ReadS can Code
113-00: GM: 0701L3: if (al0 = 1) Closed Key is there; Go to L4 Else no closed key; goto L2 L4: Scan_Code → al [Cbyte(40H) → CR(0002h);
KDR(0000h) → al] L5: go to L6 L6: convert 1-Byte Scan Code to 2-Bytes
7-Segment codes for the purpose of display (al → 0044Eh; call F000:F47C)
L7: display the converted data of label-6 on the D2D1 position; blank D7D6D5D4D3 positions (00h → 00444h – 0044Ah s call F000:FFB6)
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]
CS/: 01hWR/RD/BHE/M-IO/
Decoder: U16
S/
KRS/
KRD/
OE/
D15-D8 Q7-Q0
Q
R/
DB-sig: 33mS
B0B1B2B3B4B5B6B7
0V
Q0Q1Q2Q3Q4
DB-Sig
U25
U24
Status Signal
:10
101
AD17
000
202
303
404
505
606
707
808
909
A0A
B0B
C0C
D0D
E0E
F0F
-14
DA16
+15
REG13
G012
STP11
541
Key Pad
IRQ
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 K11 GO 12h K12 STP 11h K13 C 0Ch K14 D 0Dh K15 E 0Eh K16 F 0Fh K21 + 15h K22 REG 13h K23 8 08h K24 9 09h K25 A 0Ah K26 B 0Bh
Key Designation Key Label Scan Code K31 - 14hh K32 DA 16h K33 4 04h K34 5 05hh K35 6 06h K37 7 07h K41 : 10h K42 AD 17hh K43 0 00h K45 1 01h K46 2 02h 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 L2: al ← KRD (01h) ; read raw scan code L3: if (a7 = 1) ; checking the status bit goto L2 ; key not closed L4: if (al != 13h) ; is it REG key? goto L2 ; it is not REG key L5: al → 03100h ; saving Scan code for REG.
Entry
Reset the Keyboard
Read Scan Code
B7 = 1Y
Condition Scodeand save at 01100h
N
Scode=13h ?
542Exit to Prompt
N
Y
L0:
L1:
L2:
L3:
L4:
L5:
L6:
L6: goto F000:FFFFh (EA FF FF 00 F0) Assembly Codes: L0: nop L1: out 01h, al L2: in al, 01h L3: mov ah, al
…………… jnc L2
L4: cmp al, 13h jnz L2 L5: mov 03100h, al 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:
Figure-44.3 Data Structure for Task-44.10
0000:3200 ASCII Cde of 'C'0000:32010000:3202
ASCII Cde of 'l'ASCII Cde of 'o'ASCII Cde of 's'
Space
ASCII Cde of 'e'ASCII Cde of 'd'
543
ASCII Cde of 'e'ASCII Cde of 'K'
ASCII Cde of 'y'Space
ASCII Cde of 'F'ASCII Cde of 'o'ASCII Cde of 'u'ASCII Cde of 'n'ASCII Cde of 'd'Mark of End (24h)
0000:320F0000:3210
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
0V
R93.3k
R113.3k
R133.3k
+5VR83.3k
R103.3k
R123.3k
TR1 TR2 TR3
D0D1D2D3D4D5D6D7
EI+5V
EO 5 B
0V 34
+5V
11 10
C8: 1uFR7 : 33k
Q/
Q
1
6
+ U26 74121
GS 2 D
CK3
Q/
Q
6
5U25: 7474
CS/ (01h)BHE/M-IO/
WR/
RD/
R/1
0V
14
15
9
10111213
0201
0304
5
U27 4532
Q0Q1Q2
76
B0B1B2
B3B4
B7
246
811131517
OE/1,19
U2474244
Q0Q1
B5B6
Q4Q5Q6Q7
181414129753
D15-D0
U217432
Read Enable
Reset Enable
544
01234567
89
ABCDEF
:STP
GO-+REG
DAAD
D15D14D13D12D11D10D09D08
33m S
IRQ
0V8x3.3kRA1:
Q2Q3
Needs to be Installed by the User
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.
DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8
Hr Sec
739abx
DP0
Min
CC-type 7-Segment Display Unit
DataDRAM2DRAM1
DP0DRAM0
DRAM3DRAM4DRAM5DRAM6
DRAM8DRAM7
DP1
HRSDP4DP3DP2
DP6DP5
DP8DP7
MIN
SEC
U24 : 8279U2 : 8086
PZC
J3-26NMI
J2-19
Jumper
20mS
CS/
B B
Figure-14A.1: Hardware Structure for the 24-Hr Clock Task-14A.2: Working Principles of the 24-Hr Clock System
00474 SEC
0047600475 MIN
HRS
Initial BCD Time
0044E0044F00450
SECMINHRS
Running BCD Time
D3D4D5D6D7D8 BCD2CC
Running CC Time
SEC
MIN
HRS
00442004430044400445
0044700446
D8D7D6D5D4D3
T11 T12 T13
F000:F47C
CCX8279
F000:FFB8 HRS
7-Seg Display
MIN SEC
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: Figure-9.1: Computation Mechanism Figure-9.2: Input/Output Data Structure
03000 Multiplier03001y1y0y3y2
0300203003
x1x0x3x2 Multiplicand
Inputs
03004
03006
0300503006
r1r0r3r2
r7r6r5r4 Product
(Result) Output
559b00000
DSM
CSM02FFF
04FFF
01000
x3x2 x1x0y3y2 y1y0
r3'r2' r1r0r5''r4'' r3''r2''
r5'''r4''' r3'''r2'''
= (x1x0) x (y1y0) : L1= (x3x2) x (y1y0) : L2= (x1x0) x (y3y2) : L3
r7r6 r5''''r4'''' = (x3x2) x (y3y2) :L4r1r0- -- -- -
CarryCarry
519
: Multiplier: Multiplicand
- -
Carry
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
Microprocessor/Microcontroller Product Advertisement
Learning/Development Systems (Accompanied with Rich Documentation)
Designed to Meet the Learning and Research Needs of the Students, Teachers, Scientists, Technocrats and Engineers
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: [email protected]
MicroTalk-8085 MicroTalk-8086
MicroTalk-80286 MicroTalk-8x51
MicroTalk-80386
16-Bit Protected Virtual Address ModeMicroprocessor Learning /Dev System
using Intel 80286 High Perfomance Arch.
16-Bit Microprocessor Learning /DevSystem using Intel 8086 Architecture
8-Bit Microprocessor Learning /DevSystem using Intel 8085 Architecture
8-Bit Microcontroller Learning /DevSystem using Intel /Atmel 8x51 Architecture
32-Bit Protected Virtual Address Mode Microprocessor Learning /Dev Systemusing Intel 80386DX High Perfomance Architecture
I02,
D03
, B?
, M?
I96
, D
99
, B
99,
M?
I92,
D93
, B97
, M04
I88,
D90
, B92
, M05
I93
, D
95
, B
99
, M
05