8086 Lab Manual
8086 Lab Manual
Golam Mostafa
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!
Contents
Experiment 1A Experiment 1B Experiment 2 Experiment 3 Experiment 4 Experiment 5A Experiment 5B Experiment 6A Experiment 6B Familiarization with the Components Organization and the Operating Procedures of the MicroTalk-8086 Trainer 1/Expt-1A Familiarization with the Organization and the Operating Procedures of the MDA-8086 Trainer 1/Expt-1B. Familiarization with the Assembly Instructions of 8086 Microprocessors by Adding Two 8-bit Unsigned Hexadecimal Numbers. 1/Expt-2 Familiarization with the Assembly Instructions of 8086 Microprocessors by Multiplying Two 8-bit Hex Numbers by Repetitive Additions. 1/Expt-3 Familiarization with the Procedures of Programming the 8255 Parallel IO Controller. 1/Expt-4 Familiarization with the Procedures of Interfacing a Text Mode LCD Panel with MicroTalk-8086 Trainer. 1/Expt-5A Familiarization with the Procedures of Programming the Text Mode LCD Panel of the MDA-8086 Trainer. 1/ExptFamiliarization with the Functionality Check of the NMI-interrupt of 8086 using MicroTalk-8086 Trainer. 1/Expt-6A Familiarization with the Functionality Check of the NMI-interrupt of 8086 using MDA-8086 Trainer. 1/Expt-6B 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
Experiment 7
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 [BINary Multiplication] Multiplication of two 16-bit unsigned BINary Numbers 1/Expt-9
Experiment 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 MDA8086 Learning System. 1/Expt-13B Experiment 14A Converting MicroTalk-8086 Trainer into a 24-Hr Clock System
ii
Experiment 8
Converting BINary Number into Equivalent BCD
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put Tick Mark ( ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-8.1 Converting Two-digit BINary number (range: 00h 63h) into equivalent BCD number (range: 00 99) using Counting Method (Slow Process). 1. Draw Input/Out Data Structure. Keep Input BIN at location 03010h and the Output BCD at location 04010h. 2. Convert the following conversion Pseudo Codes into 8086 ASM codes and save as: bin2bcdc..asm.
MYCODE SEGMENT ASSUME cs:MYCODE ORG 1000h nop Bring BINary ah-register from location 03010h mov al, 00h ; IPBCD add al, 01h If ((al3 al0) > 9) Goto L6 dec ah jnz L2 mov BYTE PTR [bx+1010h], al ; BCD result at location: 04010h hlt add al, 06h jmp L3 ENDS END START
4. 5. 6. 7. 8.
Assemble the above program and down load it. Enter the input BINary number as: 25h Execute the program: Open memory location 04010h and we must see 37 (the desired BCD number). 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 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. Draw DSM-based Data Structure for the Input/Output numbers. Draw the following Register-based Data Structure for the Input/Output Numbers.
15 si = BIN 538 cl bh bl 0 23 (Six BCD Digits) 0 Cl, bh, bl = IPBCD
2.
3. 3.
4.
Convert the following Pseudo Codes into ASM codes. Save as: [Link]. 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] mov ah, 10h ; Extrcat b15 rcl si, 01h call BCDC dec ah Jnz L2 mov BYTE PTR [di+1012h], cl Mov WORD PTR [di+1010h], bx hlt al, bl al, al bl, al al, bh al, al bh, al al, cl al, al cl, al ; getting the input BINary from DSM ; number of bits in the input Binary number ; b15 is in C-bit ; BCD Computation ; extract next bit (b14, .b0) ; BCD at locations: 04012, 04011, 04010
L2:
BCDC: mov adc daa mov mov adc daa mov mov adc daa mov ret
2/Expt-8
3/Expt-8
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)
Experiment 1B
Procedures:
Collect the MDA-8086 trainer from the lab attendant. Open the top cover of the trainer. Look at the PCB (Printed Circuit Board) of the trainer and the component layout of Fig-1B.8. Now, on the PCB, locate the circuit designation U1. This is the 8086 microprocessor chip. Look very carefully on the top of the U1-chip and you will find the inscription 8086. 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 CCtype 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. 2. 3. 4. 5. 6.
1/Expt-1B
Task-1.2
There are many more interface controllers on the PCB of the MDA-8086, which we could not describe in Task-1B.1. The following Hardware Block Diagram of Fig-1B.1 contains the total IO scenario of the trainer. For complete circuit diagram, consult user manual for MDA-8086 trainer.
KBIC : 74244 :U24
NMI RES
CPU : 8086 : U1
D15-D8
LCDIC
CS/
LCD
CS/
9 5 1
A B 6 7 2 3
D7-D0
RS : 01h
DR:01h
20h, 22h, CS/ 24h, 26h
PAR:19h
D7-D0
D7-D0
IR
16 Characters x 2 Lines
CON10
SR DR
PB0-PB3 LED11-LED14
CS/
SIO: 8251:U14
D15-D8
CS/
D7-D0
CON: DB9
PBR:1Bh
DAC U33
PCR:1Dh CR:1 Fh
PIO:8255 U29
D7-D0
TTL
RxRS
LM:U38
P8
ADC:U31
DR: 08h
SR: 0Ah
RxRDY
0V
0V
TxRDY
PIO: 8255:U30
DIP2
Vin
D15-D8
P6
D7-D0
TC-0:09h
D7-D0
CS/
GATE1 0V
DAC:U33 TH1
D7-D0
DR:18h
TC-1:0Bh
GATE2 0V
TC-2:0Dh CR:0Fh
0V
MIC
CR:18h
Speaker
Out
CS/ D
IN TA IN TR/
D8
D7-D0
DR: 11h
SPKIC: U25
ODD: ROM:U8
F0001,...... ,FFFFF
8259
D15-D8D15-D8
(40h)IR0 (41h)IR1 IR2 IR3 IR4 D7-D0 IR5 DR:12h IR6 IPC IR7 U42 CR:10h
CS/ 62256 D7-D0
IR2
+5V
NMI +5V
NMI
EVN: ROM:U7
F0000, ..... FFFFE
D7-D0 D7-D0
EVN : RAM : U9
00000,......... 0FFFE
A,M-IO/,BHE/
Sx/
Sy/
0V
GM: 547: 11/03:3 Hrs
2/Expt-1B
Task-1B.3
G0 + :
546
STP REG
C 8 4 0
D 9 5 1
E A 6 2
F B 7 3
DA AD
The 26 keys of the keypad may be classified into the following categories: A: CPU Control Key 1. RES (system RESet) : When this key is pressed down and then released, the 8086 is reset and starts from the cold state. The PC looks for a valid instruction at memory location: FFFF (CS):0000 (IP) = FFFF0h. Activation of the RES key displays the following message on the LCD monitor. Note that the jumper at P1 must be set to Local Monitor (the left side) position.
MDE 8086 kit ! ! Midas 335-0964/5
2. MON (Monitor) /NMI (Non Maskable Interrupt): When pressed, the CPU is immediately interrupted B: Command Keys 1. AD (set memory ADdress) : This command key allows the user to set the 20-bit address of a memory location in the format of [Segment:Offset]. Press this key and we will see the following message on the LCD with the cursor blinking at the Segment Field.
Seg. Oset data
xxxx yyyy zz a. Seg. stands for Memory Segment, Oset stands for Memory Offset and data refers to the 8-bit content of the memory location, xxxx:yyyy. b. Now, we can set the Segment part of our desired memory location. Let us assume that we wish to examine the content of the memory location F000h (F000:0000) of the ROM area of Fig-11.1. We may use the data keys (0 to F) to change the segment into: F000h. c. Now is the turn to change the Offset. Press [:] key.
2. : (set the Offset) : This key allows editing the Offset part of a memory location. When this is pressed, the cursor moves to the Offset Field. And now, the user can use the data keys to set the offset to the desired value. 3. DA (update address and allow Data entry) : This key brings cursor to the Data Field. Now, the user may use the data key (0 to F) to enter new data (assume that the present memory location is a RAM location). 4. + (increment by One) : This key allows moving to the next memory location. 5. - (decrement by One): This key allows moving in the previous memory location. 6. GO (GO to the beginning point of the program to be executed): This key allows executing a program. 7. REG (examing and changing REGister contents): This key allows checking and editing the content of the internal registers of the 8086. 8. STP (Single STep): This key allows executing one instruction at a time. C: Data Keys Keys with labels: 0, 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are the hexadecimal data keys.
3/Expt-1B
Task-1B.4 Familiarization with the Operation of MDA-8086 Trainer by Blinking Character 3 on the CA7SDD.
Brief Theory: The CA7SDD is connected with the 8086 CPU as per diagram depicted in Fig-1B.3.
8086 : U1
8255 : U29
Port-A 19h D7-D0
CA7SD
a
CS/
PA7-PA0
CA b
+5V
D15-D8
f e g d
(1)
ah
CR: 1Fh
c p
(3)
al
(3)
(1)
MLoc
03011 03010
Content
FF B0
DSM
PC = CS:IP
Program Codes
(4)
xxxxx 01000 TDELAY
CSM
(2)
548
To show character 3 on CA7SD (output device), we need to send code B0h (1011 0000) into Port-A register of U29. B0h is the 8-bit CA-code for character 3 (see Fig-1.4 for the internal structure of CA7SD). To blank (nothing) the output device, we need to send code FFh into Port-A. After sending B0h, we need to wait for sometimes (Time Delay) so that the character 3 remains visible for a while. Likewise, after sending code for blank, we also need to insert some time delay so that the display remains OFF for sometimes. To blink 3 on the CA7SD, we may follow the steps: A. B. 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. 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. Now, let us carry out the following: Power up the MDA-8086 trainer. Carry out the steps of Table-A to enter data into memory locations of DSM. 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: 1 2 Press Key RES AD LCD Display MDE8086 Kit V9.5 Midas 935-0964/5 Seg. Oset Data xxxx yyyy zz Seg. Oset 0000 yyyy Data zz Remarks The trainer is ready to accept valid command 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. 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.
C. 1. 2. 3.
0000
4/Expt-1B
4 5 6 7
: 3010 DA B0
Oset Data yyyy _ zz Oset Data 3010 _ zz Oset Data 3010 zz _ Oset Data 3010 B0 _ Data zz _
9 10
FF RESET
Seg. Oset Data 0000 3011 FF _ MDE8086 Kit V9.5 Midas 935-0964/5
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. The 20-bit address, 03010 (0000:3010) is entered. Now, deposit the cacode data (B0h) for character 3. 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. The data value B0h is deposited at location, 0000:3010. Now, deposit cacode (FFh) for the blank character at the memory location, 0000:3010. 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. The CA-code for blank is entered at memory location: 03011 The trainer is ready to accept valid command
Enter the Machine Codes of the following Program starting at location: 01000h (0000:1000)
Label: START: L1: Mem. Loc 0000:1000 0000:1001 Assembly Codes nop mov ax, 0000h mov ds, ax mov ax, 0000h mov ss, ax mov sp, 8FFEh mov out mov mov out mov loop mov out mov loop jmp al, 80h CRU29(1Fh), al bx, 3000h al, BYTE PTR ds;[bx+10h] PARU29(19h), al cx, 0FFFFh HERE1 al, BYTE PTR ds:[bx+11h] PARU((19h), al cx, 0FFFFh HERE2 L2A Machine Codes 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 Meaning ; 00000h = Base [Link] Data Seg. ; 00000h = Base Add of Stack Seg. ; Stack Pointer Reg. set to: 08FFEh ; Control Byte to set PAR as output
Table-B
L2:
0000:100E
L2A:
0000:1015 -
; bx-register to work as pointer ; reading cacode for 3 ; sending cacode of 3 to PAR ; Insert Time Delay
HERE1: L3:
0000:101D0000:101F -
; reading cacode for blank ; sending cacode of blank to PAR ; Insert Time Delay
HERE2: L4:
0000:1027 0000:1029-
4.
Carry out the steps of Table-C to execute the above program of Table-B.
Program Execution: Carry Out the following steps:
Table-C
Sn: 1 2 3 4
LCD Display MDE8086 Kit V9.5 Midas 935-0964/5 Seg. Ost Data xxxx yyyy zz Seg. Ost Data 0000 yyyy _ zz Statring Address 0000:1000
Remarks The trainer is ready The cursor blinks at the segment field. Use data keys to set the segment at: 0000h. The cursor blinks at the offset field. Use data key to set the address at : 1000h Program has been executed. Character 3 should blink.
5/Expt-1B
Task-1B.5
10 g 9 f
ca
8 ca
7 a
6 b
b
6
4 5 538
p
p(5) g(10) f(9) e(1) d(2) c(4) b(6) a(7)
e 1
d 2
ca 3
c 4
p 5 538
538
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.
(b)
(c) (d)
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. 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. Type only the labels and the assembly instructions of Table-B of Task-1B.4.
6/Expt-1B
(e)
Save the screen (what you have typed in the screen) with the file name of: [Link]. Save the file as: c:\mda8086\[Link]
The Procedures: 1. Press Alt key and then release. And then press Enter key.
(f)
2. Choose Save As... from the menu using the arrow keys. 3. Now type the file name: [Link] and then press Enter key. Type the following lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT ASSUME ORG ENDS END para public cs:MYCODE 1000h code ; declaring logical segment
(g) (h)
Type the following assembler statements at the end of your assembly program.
MYCODE START
(i)
2. Choose Save from the menu using the arrow keys. 3. Now press Enter key. 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.
(j) (k)
2. Choose Exit from the menu using the arrow keys. 3. Now press Enter key. Type cls and press Enter key for clearing up the screen. Now, convert the source codes of your program c:\mda8086\[Link] 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 [Link] (assembly) and press Enter key 3. Type [Link] (object) and then Press Enter key 4. Type [Link] (list) and press Enter key. 5. Press Enter key
(l)
(m)
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\[Link]. 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. Open the [Link] file in the following ways to see its contents:
The Procedures: 1. Type EDIT at the DOS prompt. And then press Enter key.
(n) (o)
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, [Link] from the menu. Press Enter. 5. Now the machine codes of your program are in the screen. 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. Look for the jumper P1 (Fig-1B.5) or switch KIT/PC of the MDA-8086 trainer. Bring the jumper at the Local Monitor or KIT position.
7/Expt-1B
P1
GND +5V
538
Power OFF and then ON of the MDA-8086 trainer and then press the RESET key. The LCD display of the trainer shows the following prompt message:
MDE8086 Kit V9.5 Midas 335-0964/5
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. 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. Execute the program at location: 0000:1000 using the GO command. Observe that the device 3 is blinking on the CA7SD device. 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 Task1B.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. 3. Bring the IBM-PC in the following DOS prompt: c:\mda8086> _ 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) Serial baud rate Set 1200 = 1 2400 = 2 4800 = 3 9600 = 4 19.2K = 5 38.4 = 6 Baud Rate Select (1 6) Parity bit NP =0, Po = 1, Pe = 2 Word Size 7-bit=2, 8-bit=3 Stop bit 1-bit=0, 2-bit=1 Change OK (Y/N) ? y : [X] ==>1 press Enter key
press Enter key press Enter key press Enter key press Enter key press Enter key
8/Expt-1B
4.
Power down and Power up the MDA-8086 trainer. Press the RESET key of the trainer to get the prompt message on the screen of the IBMPC.
* * 8086 Monitor 9.5 * * * * Midas 335-0964/5 * * 8086> _
5. 6. 7.
To bring the IBMPC into DOS mode, press Alt and hold and then press X key. And then press the Enter key. The IBM-PC in the path: c:\mda8086> _ Now, convert the [Link] (object) file into [Link] (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 [Link]
(b) (c) Type c:\mda8086\[Link] 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\[Link].
8. 9.
Type EDIT at the cursor position of the DOS prompt. Open the file [Link] 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
Exit the screen and come to the DOS prompt of: c:\mda8086> _ Type COMM at the DOS prompt and press the Enter key OR click on the WinComm. Reset the MDA-8086 trainer to activate Serial Link with IBMPC. Type L at the cursor position. Press Enter key. And then press F3 key. Type c:\mda8086\[Link] and then press Enter key. The program codes have already been transferred into the trainer with the message OK Completed. Bring the jumper P1 (Switch) of the trainer into Local Monitor/KIT position. 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. Execute at 0000:1000 using the GO command of the trainer. The device CA7SD must blink the character 3
Task-1B.9 Find the location of the file [Link] in your computer and bring it under the directory of c:\mda8086. Down load the codes of the [Link] file in the trainer. Execute the program in the trainer at: 0000:1000. Observe that the device CA7SD shows: 0,1,2,3,4,5,6,7,8,9,0,1,2............ Task-1B.10 ([Link]) Write an 8086-based assembly language program to display the characters: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,0,1,2,3...... cyclically on the device CA7SD. Get your program codes down loaded from the PC to the trainer. The offset of the 1st code byte must be at: 2000h.
9/Expt-1B
6. DAC:
7. Speaker:
10/Expt-1B
C: Example Programs A disk accompanying the trainer contains a good number of example programs.
FFFF:0000
Start Up Location
F0000 EFFFF
10000 0FFFF
ROM
FFFF
FFFE
User-3
Reserved 4x 2KByres
Reserved 4x 4KByres
09000 08000 07000 06000
User-2
0D000 0CFFF
8255 (U29): CR
8255 (U29): PCR 8255 (U29): PBR
8255 (U29) PAR
05000 04FFF
03000 02FFF
Space for Extra Segment Space for Data Segment Space for Code Segment
Scratch Pad
Data Structure
Interrupt Vvector Table
IO CON10 IO CON10 IO CON10 IO CON10 ADC : DR/CR OR 8255 (U30):CR ADC : DR/CR OR 8255 (U30):PCR ADC : DR/CR OR 8255 (U30):PBR ADC : DR/CR OR 8255 (U30):PAR
01000 00FFF
00F00 00EFF
00400 003FF
00000
(00)12 (00)10
(00)0A (00)08
(00)04 (00)02 (00)00
8259: DR 8259: CR
8251: CR/SR 8251 : DR
LCDDR LCDSR LCDIR
545
KBD DR/FR
545
11/Expt-1B
12/Expt-1B
13/Expt-1B
14/Expt-1B
15/Expt-1B
16/Expt-1B
17/Expt-1B
18/Expt-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)
Experiment 1B
Procedures:
Collect the MDA-8086 trainer from the lab attendant. Open the top cover of the trainer. Look at the PCB (Printed Circuit Board) of the trainer and the component layout of Fig-1B.8. Now, on the PCB, locate the circuit designation U1. This is the 8086 microprocessor chip. Look very carefully on the top of the U1-chip and you will find the inscription 8086. 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 CCtype 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. 2. 3. 4. 5. 6.
431
Task-1.2
There are many more interface controllers on the PCB of the MDA-8086, which we could not describe in Task-1B.1. The following Hardware Block Diagram of Fig-1B.1 contains the total IO scenario of the trainer. For complete circuit diagram, consult user manual for MDA-8086 trainer.
KBIC : 74244 :U24
NMI RES
CPU : 8086 : U1
D15-D8
LCDIC
CS/
LCD
CS/
9 5 1
A B 6 7 2 3
D7-D0
RS : 01h
DR:01h
20h, 22h, CS/ 24h, 26h
PAR:19h
D7-D0
D7-D0
IR
16 Characters x 2 Lines
CON10
SR DR
PB0-PB3 LED11-LED14
CS/
SIO: 8251:U14
D15-D8
CS/
D7-D0
CON: DB9
PBR:1Bh
DAC U33
PCR:1Dh CR:1 Fh
PIO:8255 U29
D7-D0
TTL
RxRS
LM:U38
P8
ADC:U31
DR: 08h
SR: 0Ah
RxRDY
0V
0V
TxRDY
PIO: 8255:U30
DIP2
Vin
D15-D8
P6
D7-D0
TC-0:09h
D7-D0
CS/
GATE1 0V
DAC:U33 TH1
D7-D0
DR:18h
TC-1:0Bh
GATE2 0V
TC-2:0Dh CR:0Fh
0V
MIC
CR:18h
Speaker
Out
CS/ D
IN TA IN TR/
D8
D7-D0
DR: 11h
SPKIC: U25
ODD: ROM:U8
F0001,...... ,FFFFF
8259
D15-D8D15-D8
(40h)IR0 (41h)IR1 IR2 IR3 IR4 D7-D0 IR5 DR:12h IR6 IPC IR7 U42 CR:10h
CS/ 62256 D7-D0
IR2
+5V
NMI +5V
NMI
EVN: ROM:U7
F0000, ..... FFFFE
D7-D0 D7-D0
EVN : RAM : U9
00000,......... 0FFFE
A,M-IO/,BHE/
Sx/
Sy/
0V
GM: 547: 11/03:3 Hrs
432
Task-1B.3
G0 + :
546
STP REG
C 8 4 0
D 9 5 1
E A 6 2
F B 7 3
DA AD
The 26 keys of the keypad may be classified into the following categories: A: CPU Control Key 1. RES (system RESet) : When this key is pressed down and then released, the 8086 is reset and starts from the cold state. The PC looks for a valid instruction at memory location: FFFF (CS):0000 (IP) = FFFF0h. Activation of the RES key displays the following message on the LCD monitor. Note that the jumper at P1 must be set to Local Monitor (the left side) position.
MDE 8086 kit ! ! Midas 335-0964/5
2. MON (Monitor) /NMI (Non Maskable Interrupt): When pressed, the CPU is immediately interrupted B: Command Keys 1. AD (set memory ADdress) : This command key allows the user to set the 20-bit address of a memory location in the format of [Segment:Offset]. Press this key and we will see the following message on the LCD with the cursor blinking at the Segment Field.
Seg. Oset data
xxxx yyyy zz a. Seg. stands for Memory Segment, Oset stands for Memory Offset and data refers to the 8-bit content of the memory location, xxxx:yyyy. b. Now, we can set the Segment part of our desired memory location. Let us assume that we wish to examine the content of the memory location F000h (F000:0000) of the ROM area of Fig-11.1. We may use the data keys (0 to F) to change the segment into: F000h. c. Now is the turn to change the Offset. Press [:] key.
2. : (set the Offset) : This key allows editing the Offset part of a memory location. When this is pressed, the cursor moves to the Offset Field. And now, the user can use the data keys to set the offset to the desired value. 3. DA (update address and allow Data entry) : This key brings cursor to the Data Field. Now, the user may use the data key (0 to F) to enter new data (assume that the present memory location is a RAM location). 4. + (increment by One) : This key allows moving to the next memory location. 5. - (decrement by One): This key allows moving in the previous memory location. 6. GO (GO to the beginning point of the program to be executed): This key allows executing a program. 7. REG (examing and changing REGister contents): This key allows checking and editing the content of the internal registers of the 8086. 8. STP (Single STep): This key allows executing one instruction at a time. C: Data Keys Keys with labels: 0, 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are the hexadecimal data keys.
433
Task-1B.4 Familiarization with the Operation of MDA-8086 Trainer by Blinking Character 3 on the CA7SDD.
Brief Theory: The CA7SDD is connected with the 8086 CPU as per diagram depicted in Fig-1B.3.
8086 : U1
8255 : U29
Port-A 19h D7-D0
CA7SD
a
CS/
PA7-PA0
CA b
+5V
D15-D8
f e g d
(1)
ah
CR: 1Fh
c p
(3)
al
(3)
(1)
MLoc
03011 03010
Content
FF B0
DSM
PC = CS:IP
Program Codes
(4)
xxxxx 01000 TDELAY
CSM
(2)
548
To show character 3 on CA7SD (output device), we need to send code B0h (1011 0000) into Port-A register of U29. B0h is the 8-bit CA-code for character 3 (see Fig-1.4 for the internal structure of CA7SD). To blank (nothing) the output device, we need to send code FFh into Port-A. After sending B0h, we need to wait for sometimes (Time Delay) so that the character 3 remains visible for a while. Likewise, after sending code for blank, we also need to insert some time delay so that the display remains OFF for sometimes. To blink 3 on the CA7SD, we may follow the steps: A. B. 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. 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. Now, let us carry out the following: Power up the MDA-8086 trainer. Carry out the steps of Table-A to enter data into memory locations of DSM. 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: 1 2 Press Key RES AD LCD Display MDE8086 Kit V9.5 Midas 935-0964/5 Seg. Oset Data xxxx yyyy zz Seg. Oset 0000 yyyy Data zz Remarks The trainer is ready to accept valid command 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. 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.
C. 1. 2. 3.
0000
434
4 5 6 7
: 3010 DA B0
Oset Data yyyy _ zz Oset Data 3010 _ zz Oset Data 3010 zz _ Oset Data 3010 B0 _ Data zz _
9 10
FF RESET
Seg. Oset Data 0000 3011 FF _ MDE8086 Kit V9.5 Midas 935-0964/5
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. The 20-bit address, 03010 (0000:3010) is entered. Now, deposit the cacode data (B0h) for character 3. 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. The data value B0h is deposited at location, 0000:3010. Now, deposit cacode (FFh) for the blank character at the memory location, 0000:3010. 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. The CA-code for blank is entered at memory location: 03011 The trainer is ready to accept valid command
Enter the Machine Codes of the following Program starting at location: 01000h (0000:1000)
Label: START: L1: Mem. Loc 0000:1000 0000:1001 Assembly Codes nop mov ax, 0000h mov ds, ax mov ax, 0000h mov ss, ax mov sp, 8FFEh mov out mov mov out mov loop mov out mov loop jmp al, 80h CRU29(1Fh), al bx, 3000h al, BYTE PTR ds;[bx+10h] PARU29(19h), al cx, 0FFFFh HERE1 al, BYTE PTR ds:[bx+11h] PARU((19h), al cx, 0FFFFh HERE2 L2A Machine Codes 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 Meaning ; 00000h = Base [Link] Data Seg. ; 00000h = Base Add of Stack Seg. ; Stack Pointer Reg. set to: 08FFEh ; Control Byte to set PAR as output
Table-B
L2:
0000:100E
L2A:
0000:1015 -
; bx-register to work as pointer ; reading cacode for 3 ; sending cacode of 3 to PAR ; Insert Time Delay
HERE1: L3:
0000:101D0000:101F -
; reading cacode for blank ; sending cacode of blank to PAR ; Insert Time Delay
HERE2: L4:
0000:1027 0000:1029-
4.
Carry out the steps of Table-C to execute the above program of Table-B.
Program Execution: Carry Out the following steps:
Table-C
Sn: 1 2 3 4
LCD Display MDE8086 Kit V9.5 Midas 935-0964/5 Seg. Ost Data xxxx yyyy zz Seg. Ost Data 0000 yyyy _ zz Statring Address 0000:1000
Remarks The trainer is ready The cursor blinks at the segment field. Use data keys to set the segment at: 0000h. The cursor blinks at the offset field. Use data key to set the address at : 1000h Program has been executed. Character 3 should blink.
435
Task-1B.5
10 g 9 f
ca
8 ca
7 a
6 b
b
6
4 5 538
p
p(5) g(10) f(9) e(1) d(2) c(4) b(6) a(7)
e 1
d 2
ca 3
c 4
p 5 538
538
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.
(b)
(c) (d)
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. 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. Type only the labels and the assembly instructions of Table-B of Task-1B.4.
436
(e)
Save the screen (what you have typed in the screen) with the file name of: [Link]. Save the file as: c:\mda8086\[Link]
The Procedures: 1. Press Alt key and then release. And then press Enter key.
(f)
2. Choose Save As... from the menu using the arrow keys. 3. Now type the file name: [Link] and then press Enter key. Type the following lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT ASSUME ORG ENDS END para public cs:MYCODE 1000h code ; declaring logical segment
(g) (h)
Type the following assembler statements at the end of your assembly program.
MYCODE START
(i)
2. Choose Save from the menu using the arrow keys. 3. Now press Enter key. 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.
(j) (k)
2. Choose Exit from the menu using the arrow keys. 3. Now press Enter key. Type cls and press Enter key for clearing up the screen. Now, convert the source codes of your program c:\mda8086\[Link] 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 [Link] (assembly) and press Enter key 3. Type [Link] (object) and then Press Enter key 4. Type [Link] (list) and press Enter key. 5. Press Enter key
(l)
(m)
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\[Link]. 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. Open the [Link] file in the following ways to see its contents:
The Procedures: 1. Type EDIT at the DOS prompt. And then press Enter key.
(n) (o)
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, [Link] from the menu. Press Enter. 5. Now the machine codes of your program are in the screen. 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. Look for the jumper P1 (Fig-1B.5) or switch KIT/PC of the MDA-8086 trainer. Bring the jumper at the Local Monitor or KIT position.
437
P1
GND +5V
538
Power OFF and then ON of the MDA-8086 trainer and then press the RESET key. The LCD display of the trainer shows the following prompt message:
MDE8086 Kit V9.5 Midas 335-0964/5
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. 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. Execute the program at location: 0000:1000 using the GO command. Observe that the device 3 is blinking on the CA7SD device. 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 Task1B.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. 3. Bring the IBM-PC in the following DOS prompt: c:\mda8086> _ 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) Serial baud rate Set 1200 = 1 2400 = 2 4800 = 3 9600 = 4 19.2K = 5 38.4 = 6 Baud Rate Select (1 6) Parity bit NP =0, Po = 1, Pe = 2 Word Size 7-bit=2, 8-bit=3 Stop bit 1-bit=0, 2-bit=1 Change OK (Y/N) ? y : [X] ==>1 press Enter key
press Enter key press Enter key press Enter key press Enter key press Enter key
438
4.
Power down and Power up the MDA-8086 trainer. Press the RESET key of the trainer to get the prompt message on the screen of the IBMPC.
* * 8086 Monitor 9.5 * * * * Midas 335-0964/5 * * 8086> _
5. 6. 7.
To bring the IBMPC into DOS mode, press Alt and hold and then press X key. And then press the Enter key. The IBM-PC in the path: c:\mda8086> _ Now, convert the [Link] (object) file into [Link] (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 [Link]
(b) (c) Type c:\mda8086\[Link] 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\[Link].
8. 9.
Type EDIT at the cursor position of the DOS prompt. Open the file [Link] 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
Exit the screen and come to the DOS prompt of: c:\mda8086> _ Type COMM at the DOS prompt and press the Enter key OR click on the WinComm. Reset the MDA-8086 trainer to activate Serial Link with IBMPC. Type L at the cursor position. Press Enter key. And then press F3 key. Type c:\mda8086\[Link] and then press Enter key. The program codes have already been transferred into the trainer with the message OK Completed. Bring the jumper P1 (Switch) of the trainer into Local Monitor/KIT position. 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. Execute at 0000:1000 using the GO command of the trainer. The device CA7SD must blink the character 3
Task-1B.9 Find the location of the file [Link] in your computer and bring it under the directory of c:\mda8086. Down load the codes of the [Link] file in the trainer. Execute the program in the trainer at: 0000:1000. Observe that the device CA7SD shows: 0,1,2,3,4,5,6,7,8,9,0,1,2............ Task-1B.10 ([Link]) Write an 8086-based assembly language program to display the characters: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,0,1,2,3...... cyclically on the device CA7SD. Get your program codes down loaded from the PC to the trainer. The offset of the 1st code byte must be at: 2000h.
439
6. DAC:
7. Speaker:
440
C: Example Programs A disk accompanying the trainer contains a good number of example programs.
FFFF:0000
Start Up Location
F0000 EFFFF
10000 0FFFF
ROM
FFFF
FFFE
User-3
Reserved 4x 2KByres
Reserved 4x 4KByres
09000 08000 07000 06000
User-2
0D000 0CFFF
8255 (U29): CR
8255 (U29): PCR 8255 (U29): PBR
8255 (U29) PAR
05000 04FFF
03000 02FFF
Space for Extra Segment Space for Data Segment Space for Code Segment
Scratch Pad
Data Structure
Interrupt Vvector Table
IO CON10 IO CON10 IO CON10 IO CON10 ADC : DR/CR OR 8255 (U30):CR ADC : DR/CR OR 8255 (U30):PCR ADC : DR/CR OR 8255 (U30):PBR ADC : DR/CR OR 8255 (U30):PAR
01000 00FFF
00F00 00EFF
00400 003FF
00000
(00)12 (00)10
(00)0A (00)08
(00)04 (00)02 (00)00
8259: DR 8259: CR
8251: CR/SR 8251 : DR
LCDDR LCDSR LCDIR
545
KBD DR/FR
545
441
442
443
444
445
446
447
448
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. ii. iii. The input numbers can have the range: 00h - FFh The 1st number (data1) is available via memory location 03010h and the 2nd number is available via memory location 03011h. The Lower part of the result in memory location 04000h and the Upper part (accumulated carries) of the result is in location 04001h.
Expanded Data Segment Memory(DSM)
FFFFF = F000:FFFF Memory Location seg:off (20-Bit) 04FFF = 0000:4FFF Content Table
Experiment 2
Output
04001 = 0000:4001 04000 = 0000:4000 03FFF = 0000:3FFF Rubyte = 01 Rlbyte = 18
Data2=F7 Data1= 21
Inputs
Figure-2.1 : Memory Based Data Structure for Adding Two Unsigned Hexadecimal Numbers
608
1/Expt-2
Task-2.3
START: L1:
L2:
L6: L7:
Task-2.4
L5:
2/Expt-2
Task-2.5
MYCODE
START: L1:
; data1 is read ; data2 is read ; result in : c, al ; jump to L7 if carri bit = LH ; lower 8-bit of result ; no carry; so 00h is saved
MYCODE
Task-2.6
1. 2. 3. 4.
Open DOS screen in the path MTK8086 (or MDA8086) and type the assembly codes of Task-2.5. Save the source codes as: [Link] Exit the DOS screen. Assemble the program [Link] to create the following files: i. [Link] ii. [Link] After error free assembly, open the text file [Link] file and get familiar with what it contains. The list (lst) file allows us to find the sources of errors when the file [Link] is not correctly assembled. Close the [Link] file. Create [Link] file by processing the [Link] file with the help of LOD186. Open the text file [Link] to get familiar with its format. You will get familiar with the structure of this file in Chapter-7. The [Link] file contains the binary codes of the file [Link] along with some other information. The [Link] 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. Download the [Link] 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. 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. Execute the downloaded program. Open the output memory locations of the DSM to see the result.
5. 6. 7. 8.
9. 10. 11. 12
3/Expt-2
START: L1:
(03010) --> al (03011) --> ah (03012h) --> dl L2: al + ah --> c, al L3: Carry = 1 ? L3A: N 00h ---> 04001h L4 : al + dl ---> c , al L5: Carry = 1 ? N 00h+(04001h) --> 04001h L6: al --- > 04000h L7: Halt Y L 9: Y L8:
L5A:
01h+(04001h)--->04001h
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. 3. 4. 5. 6. 7. 8. 9. Convert the Flow Chart of Fig2.3 into Pseudo Codes. Convert the Flow Chart of Fig2.3 into 8086 assembly codes. And save as [Link] Assemble the [Link] to get [Link], [Link] files. Process [Link] file to get [Link] file. Download [Link] file into the trainer. Enter three 8-biitnumbers into the specified input memory locations of the DSM Execute the program at the address specified by the ORG directive in the [Link] program. 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 2s 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.
Task-3.2 Data Structure Let us assume that we have the following two numbers to multiply.
i. ii. iii. The MLPR (range: 00h FFh The MPLC (range: 00h FFh) 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.
Expanded Data Segment Memory(DSM)
FFFFF = F000:FFFF
Content
Table
Output
04001 = 0000:4001 04000 = 0000:4000 03FFF = 0000: 3FFF Rubyte Rlbyte
MLPC MLPR
Inputs
00000 = 0000:0000
12
1/Expt-2
Task-3.3
START: L1:
L2:
Draw Flow Chart for the above Pseudo Codes and show it to the teacher. Write 8086 assembly codes in your Lab Khata for the above pseudo codes and show to the teacher. Carry out the following steps:
a. b. c. d. e. Save the assembly codes as [Link] with ORG at 2500h. Assemble [Link] to get [Link] and [Link] files. Process [Link] file to get [Link] file. Download [Link] file into the RAM of the trainer. 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 [Link] by giving different numbers for the MLPR and MLPC.
Task-3.7
Check that the execution of the following codes ([Link]) provide the same result as has been provided by the program [Link].
L1: L2: L3: L4: mov mov mul mov hlt bx, 3000h ax, WORD PTR [bx+10h] ah WORD PTR [bx+0400h] ; reading MLPR and MLPC ; result
2/Expt-2
3/Expt-2
Experiment 4
Familiarization with the Procedures of Programming the 8255 PIO Controller
Read Every Step of a Task and then Work accordingly. Whenever, a Step is Done, put Tick Mark ( ) on that Step using a Wood Pencil. Ask Teacher for Help when necessary.
Task-3.1 Get Familiar with the 40-pins of the 8255
See Fig-4.3 (a) of this book.
Task-3.2 Get Familiar with the Bus-structured Diagram of 8255 PIO Controller
See Fig-4.3 (b) of this book.
If you are using MicroTalk-8086 trainer, then performs the Tasks-3.3 to 3.6. If you are using MDA-8086 trainer, then start from Task-3.7.
Task-3.3 Programming the 8255 (U23) of MicroTalk-8086 for Data IO Operations The following 8086-8255-LED based interface circuit of Fig-4.1 has been taken from the User Technical Reference Manual of MicroTalk-8086 trainer. With the help of this circuit, we will get familiar with the architectures and programming of the 8255 controller for data IO operations.
GM:672: 08/04 PCR: 3604h PC7 PC0 (J7)
A D
CR 3606h
PA0
8086: U2
8255: U23
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 [Link] 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: L8:
L9:
Read result from the DSM of experiment-2. mov cx, BYTE PTR [bx+0100h] 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 hlt
3. Assemble the program [Link] and then download the [Link] file. 4. Enter 45h and FCh as input numbers via the memory locations of the DSM of Experiment-2. 5. Execute the program and check that the LEDs show correct result. 6. Check the functionality of the program giving various sets of input numbers.
Task-3.6 Detect a Particular Bit (PC0 for LH) via PCR and then Blink PA0 for 10 Times
1. Use a telephone hook up wire and connect PC0 at LL. 2. Open file [Link] and save as [Link] 3. Declare all the codes of [Link] as a subroutine named BLED0. 4. Configure PCR as input. 5. Read PCR 6. If (PC0 != LH) Goto Step-5 7. Blink LED0 for 10 times by calling subroutine BLED0.
2/Expt-2
Task-3.7 8255 Programming using MDA-8086 Trainer The following 8086-8255-CA7SDD interface circuit of Fig-4.2 has been taken and redrawn from the MDA-8086 manual.
8086 : U1
AD15 AD14 AD13 AD12 AD11 AD10 AD09 AD08 RD/ WR/ 39 02 03 04 05 06 07 08 32 29 A .M-IO/ A2 A1 RST +5V 0V 27 28 29 30 31 32 33 34 05 36 06 08 09 35 26 07 D7 D6 D5 D4 D3 D2 D1 D0 RD/ WR/ CS/ A1 A0 RST Vcc GND
P3/P4
8x330R 07 06 04 02 01 09 10 05 a b c d e f g p
CA7SDD
a f b g e d CA 08 c p
PBR(1Bh)
R26-R33
PCR (1Dh)
CR (1Fh)
+5V 538
START: L1:
L2:
L3:
L4:
3/Expt-2
L5:
TDEL: ADEC:
bx, 0400h ; blinking done; now going to prompt WORD PTR [bx], 0000h WORD PTR [bx+02h], 0F000h DWORD PTR [bx] ; control transfers at F000:0000= F0000h cx, 0FFFFh ADEC
MYCODE
START
Task-3.9 Draw Flow Chart for the ASM Codes of Section-3.8 and show it to the teacher. Task-3.10 Ignite the LED, G00 of the following interface circuit of Fig-4.3.
[About Dot Matrix LED] Let us have a look on the component side of the MDA-8086 trainer and we find that there is an 8-by-8 Dot Matrix LED (DOTLED). Each dot of the device contains two separate common cathode type Light Emitting Diodes of RED and GREEN colors. This two-diode structure has been depicted in Fig-42.1. Thus there are in total 64 LEDs. These diodes are connected across rows and columns in such a way so that a user program can access a single LED.
GM:624: 04/04
Col7 Col0
10 PC7 14 PC 0 12 22
1C h
A D7-D0 RD/ WR/ M-IO/
A D
25 37
R ow7
R70 G70
R77 G77
CS/
CR 1Eh
PB0 PA0
18 4
R ow0
R00 G00
R07 G07
8086: U1
8255: U30
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
13 - 15 (3)
Experiments: Same as Above Selected Exercises from Ch-3 Experiment 4 Experiment 5A Selected Exercises from Ch-4 Experiment 6A, 6B Selected Exercises from Ch-5
7- 8
10 - 11
28 - 33 (6)
Experiment 7 Experiment 8, 9 Selected Exercises from Ch-8 Experiment - 10A, 10B Selected Exercises from Ch-7 Experiment 10A Experiment 10B Selected Exercises from Ch-8
12
34 - 36 (3) 37 - 42 (6)
13 14
: 8086/Microprocessor/Interfacing and System Design/using MicroTalk-8086 MPU Learning/Dev. System/ By: Golam Mostafa : Microprocessors/Interfacing/ By: Douglas V. Hall: McGraw-Hill Book Company : 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 MicroTalk8086 trainer. The connection diagram is shown below in Fig-5A.1. The base address for the registers of the LCD is taken from the decoded SEP2/-pin of the MicroTalk-8086 trainer. The SEP2/-pin assumes LL-state for any 16-bit even port address that is chosen from the band 3E00h 3FFEh and is asserted on the 8086 bus.
MicroTalk -8086
DP0
DP10
D7 D6 D5 D4 D3 D2 D1
E
D0 6
R-W /
5
D-I/
4
VA
3
Vdd
2
Vss L+ L15 16 1
A2 A1 0V +5V 0V
R1:1k5
Viewing Angle 0V
SEP2/: 3E00h -
6 5 4 3 2 1
13 14 15
2 1
U1: 74LS138
U2: 7486
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
1/Expt-5A
T o See at Dark
14 13 12 11 10 9 8 7
+5
722ab
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 [Link]. 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: KJ: mov loop ret cx, 00FFh KJ
2/Expt-5A
Task-5A.5
Show the following Message on the Center of the LCD Panel ***Chittagong***
Assemble the following program ([Link]), 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 EQU EQU EQU nop call call mov mov out mov mov mov cmp jz call mov mov out inc jmp mov mov mov jmp DB mov loop ret ; ; ; ; ; MYCODE Send send send send send LCDINIT BUSY al, 82h ; cursor position at DP2 of Line-0 dx, LCDIR dx, al si, OFFSET MSG ; knowing how far the message Chittagong is! bx, 0000h ; pointing the 1st character (C) of the message ah, BYTE PTR [si+bx] ah, 00h ; to check if printing of the message is done L4 ; message printing done BUSY al, ah dx, LCDDR dx, al bx ; pointing at the next character L3A ; collect and print the next character bx, 0474h WORD PTR [bx], 0000h WORD PTR [bx+02h], 0F000h DWORD PTR [bx] ; the trainer goes to the prompt: 8086 CPU '***Chittagong***', 00h cx, 00FFh KJ 3E00h 3E04h 3E02h
L3:
L3A:
L4:
LCDINIT: Cbyte1 Cbyte2 Cbyte3 Cbyte4 Cbyte5 (01h) (04h) (0Ch) (18h) (38h) into into into into into LCDIR LCDIR LCDIR LCDIR LCDIR
ENDS END
START
3/Expt-5A
Task-5A.6
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 MDA8086 manual.
8086 : U1
AD07 AD06 AD05 AD04 AD03 AD02 AD01 AD00 R D/ WR/ 09 10 11 12 13 14 15 16 32 29 A M -IO/
540
16x2 LCD
DP10DP0
14 13 12 11 10 9 8 7
D7 D6 D5 D4 D3 D2 D1 D0
Decoder
A2 A1
+5V VA1 10k 0V Viewing Angle
4 5
2 3 1
D-I/ R -W /
Vdd VL Vss
DPF
DP1F
1/Expt-2
Task-5B.4
1. 2. 3. 5.
Convert the following Text Codes into ASM code. Save the program as [Link]. Assemble the program, download it and execute it. Check that the LCD shows the desired character. Initialize the LCD Panel by the codes of Section-4.4 (d) of this book. Set the cursor position at DP0 of Top Line by sending Cbyte-7 [see Instruction Set at Section-4.4 (c)]. Collect ASCII code of A from Section-4.4 (e) of this book and send it into LCDDR. 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 [Link]. 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 nop Initialize the LCD Set the Cursor Position at DP0 of Top Line Get the OFFSET of the MSG1 (***Ahsanullah***) into bx-register Get the displacement of the characters if MSG1 into si-register. mov bx, OFFSET MSG1 mov si, 0000h ; displacement of the 1st character of MSG1 st Collect the ASCII code of 1 character from MSG1 and send it to LCD mov dl, BYTE PTR cs:[bx+si] ; MSG1 is in the current Code Segment 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 Set the Cursor Position at DP0 of Bottom Line mov bx, OFFSET MSG2 mov si, 0000h ; displacement of the 1st character of MSG1 st Collect the ASCII code of 1 character from MSG2 and send it to LCD mov dl, BYTE PTR cs:[bx+si] ; MSG1 is in the current Code Segment cmp al, 00h jz L10 ; end-of-MSG2 character call BUSY ; to see that LCD is ready mov al, dl mov LCDDR, al inc jmp hlt DB DB mov lopp ret ENDS END si L7 ***Ahsanullah***, ***University***, cx, 00FFh ; ADEC ; ; ready to read next character of MSG1
L4: L5:
00h ; 00h marks the end of MSG1 00h fixed time delay given to LCD to digest the last character written inti it.
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 NMIinterrupt of the 8086 microprocessor.
U2 : 8086 31 INTA/ +5V +5V K2 K1 18 INTR B CS/ B PAR:3600h
R1 R2
LED15 ...LED8
17 NMI
8 CR:3606h
0V MPU
1406x : GM: 1/2008
PIO
LED7...LED0
Task-6A.2 1. Write ASM code for the following Main Line Program (MLP). Save it as: [Link] 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: ML1: ML2: ML3: ML4: TDEL1: nop Cbyte CR ; to set direction of PBR, PAR as output Ignite LED15-LED0 Insert Time Delay by calling the SUT TDEL1 Extinguish LED15-LED8 Insert Time Delay by calling TDEL1 Goto ML1 ; repeat the cycle 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: [Link]
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: ISR1: ISR2: ISR3: ISR4: ; ISR5: TDEL2: AGND2: nop set direction of PAR and PBR by sending Cbyte into CR Mov ah, 07h ; counter of 7 LH LED0 Call TDEL2 LL LED0 Call TDEL2 dec ah Jnz ISR2 iret ; return from interrupt subroutine hlt mov cx, 0FFFFh 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.
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 NMIinterrupt of the 8086 microprocessor.
8086 : U1
AD15 AD14 AD13 AD12 AD11 AD10 AD09 AD08 RD/ WR/ NMI
MON Key
8255 : U29
39 02 03 04 05 06 07 08 32 29 A.M-IO/ A2 A1 RST +5V 0V 27 28 29 30 31 32 33 34 05 36 06 08 09 35 26 07 D7 D6 D5 D4 D3 D2 D1 D0 RD/ WR/ CS/ A1 A0 RST Vcc GND
PB0
CA7SD
04 03 02 01 40 39 38 37 02 03 04 05 06 07 08 09 8x330R 07 06 04 02 01 09 10 05 a b c d e f g p a f e d CA 08 g b c
PAR (19h)
PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7
+5V
PBR(1Bh)
R26-R33 LED11
0V
CR (1Fh)
+5V
538
Task-6A.2 1. Write ASM code for the following Main Line Program (MLP). Save it as: [Link] 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: ML1: ML2: ML3: ML4: TDEL1: nop Cbyte CR ; to set direction of PBR, PAR as output CA_3 CA7SD Insert Time Delay by calling the SUT TDEL1 Send CA_Blank CA7SD Insert Time Delay by calling TDEL1 Goto ML2 ; repeat the cycle 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: [Link] 3. Download it starting into the code area of MDA-8086 starting at 02000h. ISRNMI = To blink LED11 only for 7 times.
START2: ISR1: ISR2: ISR3: ISR4: ; ISR5: TDEL2: AGND2: nop set direction of PAR and PBR by sending Cbyte into CR Mov ah, 07h ; counter of 7 LH LED11 Call TDEL2 LL LED11 Call TDEL2 dec ah Jnz ISR2 iret ; return from interrupt subroutine hlt mov cx, 0FFFFh 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.
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: [Link].
MYCODE SEGMENT ASSUME cs:MYCODE ORG 1000h nop Bring BCD into ah-register Extract UPF Mov al, 00h ; IPR1 = 00h While (UPF !=0) IPR1 + UPW IPR1 Bring BCD into ah-register Extrcat TPF Mov cl, 00h ; IPR2 = 00h While (TPF !=0) IPR2 + TPW IPR2 Binary = (IPR1 + IPR2) 04010h halt ENDS
START: L1:
L2:
3. 4. 5. 6. 7. 8.
9.
Assemble and down load the absolute program. Enter the input BCD number as: 23 at location 03010h Execute the program. Open memory location 04010h and we must see 17. Enter different values for the BCD and check that the program produces correct Binary. 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 [Link]): Input BCD at: DP0DP1 Output Binary at: DP6DP7 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 [Link]): 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 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. Draw DSM-based Data Structure for the Input/Output numbers. Draw the following Register-based Data Structure for the Input/Output Numbers.
bh bx = BCD 538 bl dh dl dx = IPBIN
2.
3. 3.
4.
Convert the following Pseudo Codes into ASM codes. Save as: [Link]. Download and execute it. The DSM locations: 04011h and 04010h would contain the Binary number.
L1: L2: 0000h dx (IPBIN) mov bh, BYTE PTR [di+11h] ; getting the input BCD from DSM ; Extrcat d3 mov cl, 04h shr bh, cl call BINC ; Binary Computation mov bh, BYTE PTR [di+11h] and bh, 0Fh ; getting d2 call BINC
L3:
L4: mov mov shr call L5: mov And call L6: mov BINC: mov mul mov add ret
bh, BYTE PTR [di+10h] cl, 04h bh, cl ; getting d1 BINC bh, BYTE PTR [di+10h] bh, 0Fh ; getting d0 BINC WORD PTR [di+1010h], dx ; BINary number at: 04011, 04010 ax, 000Ah dx dl, bh dx, ax
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 MicroTalk8086 trainer. The connection diagram is shown below in Fig-5A.1. The base address for the registers of the LCD is taken from the decoded SEP2/-pin of the MicroTalk-8086 trainer. The SEP2/-pin assumes LL-state for any 16-bit even port address that is chosen from the band 3E00h 3FFEh and is asserted on the 8086 bus.
3/Expt-7
Figure-5A.1: Connection Diagram between 2-Line LCD panel and 8086 Buses
From the above operational truth table, we can easily verify that the addresses assigned to the registers are indeed correct! When the address bits A2A1 = 00, the Instruction Register (because D-I/=LL) is selected for write (because R-W/=LL) operation. The decoder has been designed in such way so that the E-pin of the LCD assumes LH-state while the 8086 asserts LL signal on its WR/-pin during the execution of the out LCDIR, al instruction. Similarly, when the address bits A2A1=10, the Status Register is selected for read (because R-W/ = LH) operation. For address bits A2A1=01, the LCDDR register is selected for write operation. 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 [Link]. 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. mov cx, 00FFh
TDEL:
4/Expt-7
KJ:
loop ret
KJ
Task-5A.5
Show the following Message on the Center of the LCD Panel ***Chittagong***
Assemble the following program ([Link]), 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 EQU EQU EQU nop call call mov mov out mov mov mov cmp jz call mov mov out inc jmp mov mov mov jmp DB mov loop ret LCDINIT: ; Send Cbyte1 (01h) into LCDIR ; send Cbyte2 (04h) into LCDIR ; send Cbyte3 (0Ch) into LCDIR LCDINIT BUSY al, 82h dx, LCDIR dx, al 3E00h 3E04h 3E02h
L3:
; knowing how far the message Chittagong is! ; pointing the 1st character (C) of the message
L3A:
ah, BYTE PTR [si+bx] ah, 00h ; to check if printing of the message is done L4 ; message printing done BUSY al, ah dx, LCDDR dx, al bx ; pointing at the next character L3A ; collect and print the next character bx, 0474h WORD PTR [bx], 0000h WORD PTR [bx+02h], 0F000h DWORD PTR [bx] ; the trainer goes to the prompt: 8086 CPU '***Chittagong***', 00h cx, 00FFh KJ
L4:
5/Expt-7
; send Cbyte4 (18h) into LCDIR ; send Cbyte5 (38h) into LCDIR MYCODE ENDS END
START
Task-5A.6
6/Expt-7
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
Experiment 1A
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
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.
J6
IR2-IR7
J10
RxRS TxRS
J5
GT CK OT
J8
16 LEDs 4xPh
609:GM:03-04
RxT
TxT
SMI
U29 CKG
CK RST RDY
22h-27h
1000-1FFE
CS/
J6
(20h)IR0 (21h)IR1
RxRDY TxE 2000-2FFE
CS/
J7
Display
PA PB PC
3000-31FE
CS/
PA PB PC
3800-39FE
CS/
3600-37FE
CS/
Addr Field
DP0 DP2 DP4 DP1 DP3
Data Field
DP6 DP8 DP5 DP7
ADC
ADC
ADC
ADC
ADC
U4, U5 DBUFF
DEN/ DT-R/ EN/ DIR
U14 IPC
U17 USART
U13 PIT
A D C
U30 DM PIO
UD
D
D15-D0
ALE CK
AD
A D C
SL
4 to 16 Decoder
U6,U7,U8 ALATCH C
U1 MPU
3 to 8 Decoder
M-IO/ A BHE/
DLD
WAIT
CS/-User CS/-U14 CS/-U17 CS/-U13 CS/-U23 CS/-U30 CS/-U24 CS/-U10 CS/-U09 CS/-U12 CS/-U11 CS/-U15 CS/-U16
(3)
J1
F3
0000 - 0FFE
CS/
Row
F4 F5 RST
CS/
ADC
3400h
CS/
ADC
3200h
CS/
ADC
CS/
ADC
CS/
ADC
CS/
ADC
00001h 0FFFFh
00000h 0FFFEh
F0001h FFFFFh
F0000h FFFFEh
U24 KBDC
Keyboard
U16 DAC
AnOut
U15 ADC
AnIn
U9 ROMODD (32K)
J5
2/Expt-1
Task-1.3
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.
DNLD F2
F3 F4 F5 RST
The 24 keys of the keypad may be classified into the following categories: A: 1. CPU Control Key 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: 1. 2. 3. 4. Command Keys EXA (Memory EXAmination): Command to open the 20-bit address of a memory location. AUT (AUTo Increment): Command to enter data into memory locations on auto incrementing the address field. DOP (DO a Program): Commanding the CPU to execute a program. DNLD (DowN LoaD): Command the CPU to automatically initialize the ROM-Based serial link routine prior to down loading the program code/data from the IBM-PC.
3/Expt-1
5.
PC (Program Counter): Command to enter the starting address of the 1st instruction of user program, which is to be single stepped. Also, this key works as a home key to bring the display showing the address of the instruction to be single stepped. EXB (Examine Byte data): Command to examine/edit the content of one memory location. EXW (Examine Word): Command to examine/edit the contents of two consecutive memory locations. FRW (FoRWard): Command to examine the contents of the next memory locations or next Register or the next Port. BKW (BacKWard): Command to examine the contents of the previous memory locations or next Register or the next Port. CHG (ChanGe): Command to alter the contents of memory locations or Registers or Ports. PRT (PORT): Command to examine the content of a Port location (yet to be implemented) FLR (FLag Register): Command to examine the contents of the flag register in hex format. FB (Flag register in Bit form): Command to examine the contents of flag register in bit format. 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. 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. 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. 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. 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. F2, F3, F4, F5 (Function Keys): Actions to be defined by the user. 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.
19. C:
4/Expt-1
Task-1.4
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. Getting familiar with the procedures of entering program code/data into memory (RAM) locations. Getting familiar with the procedures of executing a program, the code/data of which has already been stored into memory (RAM) locations. An example program will be taken to demonstrate the practice of the above steps. The program is: Adding two 8-bit numbers and show the result on the LED7 LED0 of the trainer.
2. 3. 4. 5.
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. b. c. The Base Address is: 00000h The Beginning Address of DSM is: 03000h The offset (how far) of the beginning address of DSM from the Base Address is: 3000hs.
Expanded Data Segment Memory(DSM)
FFFFF = F 000:FFFF
SSM
(07000 = 0000:7000) (06000 = 0000:6000)
Content
Table
Output
ESM
(05000 = 0000:5000) (0 4F FF = 0000:4FFF)
Result = 73
Inputs
DSM
(03000 = 0000:3000) 02 FF F = 0000:2FFF)
Data2=47 Data1= 2C
CSM
01000 = 0000 : 1000)
Beginning Address
Base Addres
45
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. b. Data1 (2Ch) will be kept at memory location: 03010h (0000:0310). Data2 (47h) will be kept at memory location: 03011h (0000:0311)
5/Expt-1
Sn. 1 2 3 4 5 6 7 8 9 10 11 12 13
Table-A Procedures to Enter 21h and F7h into Memory Locations 03010h and 03011h Press Key 7Seg Display Remarks RST 8086 CPU Trainer is ready EXA - - - - - Ad Address Field is opened to accept 20-bit memory address 030 030 - - Ad Three digits are entered for the Address Field 5 0305 Ad Next digit but Wrong for the memory address. (Typing Error) BKS 030 - - Ad Typing error is corrected. 10 03010 Ad 20-bit address is entered. Now, the CPU is waiting to know if Byte or Word examine is requested EXB 03010 XX Display shows the 8-bit data of memory location: 03010h CHG 03010 - Data field is ready to accept new data 2C 03010 2C The data 2Ch has been stored in location: 03010h FRW 03011 XX Address field shows the content of the next memory location CHG 03011 - Data field is ready to accept new data 47 03011 47 Data 47h has been deposited at location: 03011h 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.
Label: START: L1: Memory Location 01000 (0000:1001) Table-B Assembly Instructions - 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 Machine Codes - 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 Meaning ; 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
L5:
01018
L6:
0101E
; 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. b. 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. 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. The next byte of our program is 8A it must be stored at memory location: 0000:1004. And so on.
c.
6/Expt-1
d.
Follow the steps of Table-A to enter the Machine Codes of the program of Table-B into CSM part of memory. This time use the AUT command to open the address field. In AUT mode, the data field will automatically be opened and the address field would also be advance automatically.
Expanded Code Segment Memory(CSM)
FFFFF = F000:FFFF Memory Location (20-Bit) seg:off 02FFF = 0000:2FFF Content Table
01003 = 0000:1003 01002 = 0000:1002 01001 = 0000:1001 01000 = 0000:1000 00000 = 0000:0000
BB 90
30 00
46
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 7Seg Display Remarks 8086 CPU Trainer is ready - - - - - do Address Field is opened to accept the 20-bit starting address of the CSM (This is the beginning address of your program). run The program is executed.
Sn. 1 2 3
9. It is hoped that the program of Table-B has been executed correctly. Let us look for the result:
a. Look at the LED assembly of the trainer. The LED assembly should have the following ON/OFF conditions: [Black Fill means LH and No Fill means LL].
LED Assemly
LED15 LED7 LED8 LED0
608
b. Reset the trainer. Open the memory location: 04000h of the DSM of Fig-1.3 (b). We will find a data value of 73h. To open a memory location, follow the steps of Table-A.
7/Expt-1
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 ABh 67h FF Data2 10h 89h FF Expected Result BBh F0h 01FE LED Status (LED7-LED0) 1011 1011 1111 0000 1111 1110 Memory Content (03012h) BBh F0h FE (01 is missing!)
Task-1.5
Task-1.6
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.
DSM
043FF
Result
CPU
al ah
ALU
LEDPIO (U23)
PA R (3600h) CR (3606h)
LD7
73 47 2C D
al D
Result
LD0
03000
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 alregister 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
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 doesnt 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. 1 2 3 4 5 6 File Name MTK86COM1 [Link] [Link] [Link] [Link] EXER <DIR> Purpose Serial Communication Interface for MicroTalk-8086 Trainer To create relocatable *.EXE file from *.OBJ file To create Absolute (*.ABS) file from *.obj file To create *.LST and *.OBJ files form *.ASM file To create Assembly Program (Source Code) for 80x86 MPUs A Working Directory
(b) (c)
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. Bring the IBM-PC in the following DOS path: d:\mtk8086>--
8/Expt-1
The procedures: 1. Type cd \ and then press enter key. The screen shows: c:>_ 2. Type d: and then press enter key. The screen shows: d:>_ 3. Type cd mtk8086 and then press enter key. The screen shows: d:\mtk8086>_ 4. Press Alt-key and then hit Enter-key to enlarge the screen. 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. Type only the labels and the assembly instructions of Table-B of Task-1.4. Save the screen (what you have typed in the screen) with the file name of: [Link]. Save the file as: d:\mtk8086\[Link]
The Procedures: 1. Press Alt key and then release. And then press Enter key.
(f)
2. Choose Save As... from the menu using the arrow keys. 3. Now type the file name: [Link] and then press Enter key. Type the following 3 lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT ASSUME ORG ENDS END cs: MYCODE 1000h
(g) (h)
Type the following assembler statements at the end of your assembly program.
MYCODE START
(i)
2. Choose Save from the menu using the arrow keys. 3. Now press Enter key. 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.
(j) (k)
2. Choose Exit from the menu using the arrow keys and then press Enter key. Type cls and press Enter key for clearing up the screen. Now, convert the source codes of your program d:\mtk8086\[Link] 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 [Link] (assembly) and press Enter key 3. Type [Link] (object) and then Press Enter key 4. Type [Link] (list) and press Enter key. 5. Press Enter key
(l)
(m)
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\[Link]. 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. Open the [Link] file in the following ways to see its contents:
The Procedures: 1. Type EDIT at the DOS prompt. And then press Enter key.
2. Press Alt key and then press Enter key. 3. Choose Open... from the menu using the arrow keys. Press Enter key.
9/Expt-1
4. Use tab key and arrow key to choose the file, [Link] from the menu. Press Enter. 5. Now the machine codes of your program are in the screen and they look like:
MYCODE ASSUME 1000 1000 1001 1004 1007 100A 100C 1010 1012 1014 1017 1018 101A 101D 101E 101F 90 BB 8A 8A 02 3000 47 10 67 11 C4 START: L1: L2: L3: L4: SEGMENT cs:MYCODE ORG 1000h nop mov mov mov add mov mov mov mov out mov mov out hlt ENDS START bx, al, ah, al, 3000h BYTE PTR [bx+10h] BYTE PTR [bx+11h] ah
L5:
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. Power OFF and then ON of the MicroTalk-8086 trainer and then press the RST key. The 7-segmnet display of the trainer shows the following prompt message:
8086 CPU
Use keyboard of the trainer and enter the machine codes of Step-n ([Link]) 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. Enter the data 2Ch at RAM location 0000:3010 and 47h at RAM location 0000:3011 of the data segment memory. Execute the program at location: 0000:1000 Observe that the LED7 LED0 show the correct result of 73h (0111 0011). The Task-1.7 is well done.
Task-1.8
In this Task, we will transfer the machine codes of the Step-n of Task-1.7 from the IBM-PC to the CSM of the MicroTalk-8086 trainer. This method is known as Down Loading. To do it, we will be using the COM1 port of the IBM-PC. This method saves a lot of time while developing a large program. We do not need to enter the data and codes manually in the memory locations. The procedures are: 1. Power down the MicroTalk-8086 trainer. Connect the serial cable of the trainer with the COM1 port of the IBM-PC. 2. Bring the IBM-PC in WIN98/WINXP mode. 3. Check that the MTK86COM1 interface is present in the Start menu and then goto Step-4. Otherwise, install it from the MTK8086 folder. MTK86COM1 allows transferring Intel-Hex formatted file from IBMPC into the RAM space of MicroTalk-8086 trainer.
10/Expt-1
4. 5.
Power up the MicroTalk-8086 trainer. From the Start menu locate the MTK86COM1 interface and execute it. The following GUI interface will appear on the screen.
6. 7.
Go to the DOS path: d:\mtk8086 Now, convert the [Link] (object) file into [Link] (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 [Link]
(b) Type d:\mtk8086\[Link] (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\[Link].
8. 9.
Type EDIT at the cursor position of the DOS prompt. Open the file [Link] 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
Exit the screen and come to the DOS prompt of: d:\mtk8086> _ Go to the MTK86COM1 interface and follow the menu to transfer the [Link] file. Reset the MicroTalk--8086 trainer. Enter 2Ch and 47h at memory location 03010h and 03011h of the DSM. Execute at 0000:1000 using the DOP command of the trainer. The LED7-LED0 will show the result.
11/Expt-1
Task-1.9 Down load the file [Link] 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
: 10 C100 (a) (b) (c)
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: [Link]. 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.
2.
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.
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. 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) 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.
3.
4.
12/Expt-1
Hardware Features:
B. Memory Subsystem
1. 64 Kbytes of EPROM 2. 64 Kbytes of RAM
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 Display: 7-Segment CC-type Display Unit containing 16 Digits 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 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 ADC: ADC0804-Based Analog-to-Digital Converter. DAC: AD558-Based Digital-to-Analog Converter. Timer: 8253-Based 3-Channel Programmable Timer/Counter. All 9 Signals are at the Edges. 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
2. 3.
4.
5. 6. 7. 8.
Software Features:
A: Resident Monitor Program
1. 2. 3. 4. 5. 6. 7. Powerful and Comprehensive Resident Monitor Program Auto/Manual Data Entry for both Byte/Word Operations Program Execution Capability Forward/Backward/Change/Backspace Facilities Byte/Word Examine/Edit Capability Single Instruction Execution Capability for Program Debugging. Registers Contents can be Examined and Changed.
13/Expt-1
Flag Register Contents can be Examined in Bit-form and Hex-form. ROM-Based Test Routine for all the Onboard Peripheral Controllers A good number of Ready Made Stand alone routines A good number of Subroutines to Facilitate System Design 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.
FFFFF
FFFF:0000
F0000 EFFFF
ODD Port
EVEN Port
Start Up Location
ROM
FFFF
User-3
10000 0FFFF
4000 3FFE
Can be Used after Decoding
3E00 3DFE
Decoded at SEP1 ( J1-6)
Reserved 4x 4KByres
User-2
0D000 0CFFF
3C00 3BFE
Decoded at SEP0 ( J1-7)
3A00 39FE
03000 02FFF
01000 00FFF
Space for Stack Segment Space for Extra Segment Space for Data Segment Space for Code Segment
Shadow CR of 8255 U23 : PC of 8255 U23 : PB of 8255:U23 PA of 8255:U23 Shadow DR of DAC : U 16 Shadow DR/CR :ADC:U15 Shadow CR /SR: 8251: U13 C2 of 8251 U13 : C1 of 8253 U13 : C0 of 8253 U13 :
User-1
RAM
00F00 00EFF
Scratch Pad
Shadow
00400 003FF
Data Structure
00000
Shadow
0002 0000
14/Expt-1
15/Expt-1
16/Expt-1
17/Expt-1
18/Expt-1
DB[0:7]
U24
D0 D1 D2 D3 D4 D5 D6 D7
A1
S[0:7]
DP0
DP1
S7 S6 S5 S4 S3 S2 S1 S0
DP2
S7 S6 S5 S4 S3 S2 S1 S0
DP3
DP4
DP5
DP6
DP7
12 13 14 15 16 17 18 19 21
24 QA3 25 QA2 26 QA1 27 QA0 28 QB3 29 QB2 30 QB1 31 QB0 32 SL0 33 SL1 34 SL2 35 SL3 23 BD 4 IRQ
KIRQ SL0 SL1 SL2 SL3
DB7 DB6 DB5 DB4 DB3 DB3 DB2 DB2 DB1 DB1 DB0 DB0
17 15 13 11 8 6 4 2
A8 A7 A6 A5 A4 A3 A2 A1
Y8 Y7 Y6 Y5 Y4 Y3 Y2 Y1
3 5 7 9 12 14 16 18
S7 S6 S5 S4 S3 S2 S1 S0
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
74LS244 1 2 A 3 B VCC C
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
c c S7SEGCC 3
p g f e d c b a
.
cc0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc1
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc2
p g f e d c b a
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc3
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc4
p g f e d c b a
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc5
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc6
p g f e d c b a
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc7
p g f e d c b a
cc[0:7]
DP8
DP9
S7 S6 S5 S4 S3 S2 S1 S0
DP10
DP11
DP12
DP13
S7 S6 S5 S4 S3 S2 S1 S0
DP14
S7 S6 S5 S4 S3 S2 S1 S0
DP15
S7 S6 S5 S4 S3 S2 S1 S0
3.072MHz PCLK 3
IORC/ RESET
AIOWC/ CS8279
37 10 9 36 11 22
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc8
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc9
p g f e d c b a
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc10
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc11
S7 S6 S5 S4 S3 S2 S1 S0
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc12
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc13
6 1 2 4 5 7 9 10
c c S7SEGCC 3
cc14
p g f e d c b a
6 1 2 4 5 7 9 10
c c S7SEGCC 3
p g f e d c b a
.
cc15
cc[8:15]
38 39 1
KR0
K10
K11
K12
K13
DNLD
K20
2 5 6
F2 K30
B/BKW K32
C/CHG K33
9/FLR
8/EXB
K42 5/PC
K52 2/AX
7 8 KR7
F3 K40
F4
K41 4/CS
K43 6/FB
K53 3/AL
K50 F5
8279
K60 RST1
K51 1/IP
K61 0/PRT
K62 BKS-S/S
K63 RST2
RES/
19/Expt-1
20/Expt-1
21/Expt-1
22/Expt-1
23/Expt-1
24/Expt-1
25/Expt-1
Golam Mostafa
Conversion and Operation of MicroTalk-8086 Trainer into a Digital Weighing Machine (DWM)
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-10A.1: [Aim of the Experiment] To get familiar with the procedures of converting the MicroTalk-8086 microprocessor trainer into a Digital Weighing Machine (DWM). Task-10A.2: [Converting the MicroTalk- 8086 Trainer into DWM] Let us carry out the following steps to convert the MicroTalk-8086 trainer into a DWM (Digital Weighing Machine). 1. Look into the following block diagram of Fig-71.1, which could be used to represent the MicroTalk-8086 based DWM. Load cell is shown in fig-71.2. Amplifier is shown in elsewhere.
713-04
Experiment 10A
Load Cell
Breadboard
Rate Field
DP5 DP6 DP7 DP8
+5 -5 0V
A m p
DS1 DS2 DS3 DS4 Q3 Q2 Q1 Q0
J7
U23 8255
U2 8086
U24 8279
Cost Field
7 4 1
8 5 2
A D C
6 3
0 BKSRST
+5V + Output 20mV / 20Kg. Wt. + Output (White) - Excitation (Black) -5V
+ Output (Red)
- Sense (Yello)
Load Cell
1/Expt-10A
2. Assume that the Load Cell is connected (Practically it is not connected). We will be performing the load cell exercises in Experiment-7.2. 3. Also assume that the Breadboard, the Instrument Amplifier (See Fig-72.1) and the ADC (See Fig-72.2) are also present (Practically they not connected). 4a. Assume that the Load Cell has produced a signal of 12.37mV corresponding to 12.370kg of loads. This signal has been amplified and digitized to upBCD format by the ADC. Also assume that the WTupBCD (Weight as Unpacked BCD as: 01, 02, 03, 07 for 12.37 Kg) signals have been acquired via the interface controller U23 (8255) and are saved into the following four memory locations (Fig-71.4) of Table-T7 of the DWM Data Structure (Fig-71.11). For the weight of 12.370Kg, we have:
(05050) (05051) (05052) (05053) = = = = 01 02 03 07
05053 05052 05051 05050
upBCD Wt
Goods
T7
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) (05021) = 12 = 37
05021 05020
Wt Field
BCD
4b. Assemble, convert, download and execute [Link]. The DP0-DP4 shows: 12.370 kg.
05000
Wt Field T1a
5 We will be using the keyboard of the MicroTalk-8086 trainer to enter the product rate. The rate will be entered one digit at a time and will be instantly processed by the CPU. The keyboard of the trainer will be supplying an 8-bit Scan Code for a digit that has been pressed. Let us assume that the rate of the product is: Tk 27.95/kg. Now, when the user presses the key with label-2, the CPU will receive the code 0Dh. Let us assume that the specified memory locations of Table-T5 (Fig-71.7) will contain the RTSCAN (product Rate in SCAN Code format). The specified memory locations of Table-T3 (Fig-71.8) will contain the BCD (product rate in BCD format).
2/Expt-10A
15 0B 1B 14
Key Scan Code C ursor Type No of Digits to Print C ursor Position ASCII for 1/100 DP1F
T5
5b. Assemble, Download and Execute: [Link] The DP0-DP4 shows: 12.370 kg. The DP5-DP8 shows: 27.95 Tk
Rate Field
BCD
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) (05026) (05027) = 03 = 45 = 74 for Tk 0300 for Tk 45 for Paisa 74
05027 05026 05025 pBC D: 1/10, 1/100 pBC D: 10, 1 pBC D: 1000, 100
Cost Field
BCD
For the product cost of : Tk 345.74 (rate of Tk 27.95/kg x weight of 12.370kg), we have:
(0500A) (0500B) (0500C) (0500D) (0500E) (0500F) = = = = = = 3F 4F 66 6D 07 66 for digit-0 for digit-3 for digit-4 for digit-5 for digit7 for digit-4
0500F
6b. Assemble, download and execute: [Link] The DP0-DP4 shows : 12.370 kg (weight) The DP5-DP8 shows: 27.95 Tk (rate) The DP10-DP15 shows: 0345.74 Tk (Cost).
CC -Code: 1/100 CC -Code: 1/10 CC -Code: 1 (UNI) CC -Code: 10 (TEN) CC -Code:100 (HUN) CC -Code: 1000 (K) no Use
3/Expt-10A
GM:04/04: 632
05053 05052 05051 05050 0504F 0504E 0504D 0504C 0504B 0504A 05049 05048 05047
Goods
T7 T6 T5
Rate
05040 0503F
05038 05037
0502A 05029 05028 05027 05026 05025 05024 05023 05022 05021 05020 0501F
05000
pBCD: 1/10, 1/100 pBCD: 10, 1 pBCD: 1/10, 1/100 pBCD: 10, 1 upBCD: X0 :1/ 100 upBCD: X0 : 1/10 upBCD: X0 : 1 upBCD: X0 : 10 upBCD: X0 : 100 upBCD: X0 : 1000 no Use upBCD: X0 : 1/100 upBCD: X0 : 1/10 upBCD: X0 : 1 upBCD: X0 : 10 no Use upBCD: X0 :1/100 upBCD: X0 :1/10 upBCD: X0 : 1 upBCD: X0 : 10 CC-Code: 1/100 CC-Code: 1/10 CC-Code: 1 (UNI) CC-Code: 10 (TEN) CC-Code:100 (HUN) CC-Code: 1000 (K) no Use CC-Code: 1/100 CC-Code: 1/10 CC-Code: 1 (UNI) CC-Code: 10 (TEN) always 3Fh for 0 CC-Code: 1/100 CC-Code: 1/10 CC-Code: 1 (UNI) CC-Code: 10 (TEN)
DP15
DP10 DP8 DP5 DP3 DP0 DP15 DP14 DP13 DP12 DP11 DP10
DP8 DP7 DP6 DP5 DP4 DP3 DP2 DP1 DP0
upBCD Table: T2
pBCD Table: T3
Key Scan Code Cursor Type No of Digits to Print Cursor Position ASCII for 1/100 ASCII for 1/10 ASCII for . ASCII for 1 ASCII for 10 ASCII for : ASCII for R ASCII for Blank ASCII for 0 ASCII for 1/100 ASCII for 1/10 ASCII for . ASCII for 1 ASCII for 10 ASCII for : ASCII for W ASCII for Blank ASCII for Blank ASCII for 1/100 ASCII for 1/10 ASCII for . ASCII for 1 ASCII for 10 ASCII for 100 ASCII for 1000 ASCII for : ASCII for T ASCII for S ASCII for O ASCII for C ASCII for Blank ASCII for Blank pBCD: 1/10, 1/100 pBCD: 10, 1 pBCD: 1000, 100
DP1F
ASCII Table: T4
LCD Display
Wt Field T4b
DP10 DPF
COS T : 0 0 0 0 . 0 0 W : 1 2 . 3 7 0 R : _ _ . _ _
5 93
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A DP1B DP1C DP1D DP1E DP1F
DP0
Rate Field
DP5 DP6 DP7 DP8
CC-Code Table: T1
1 2. 3 7 0
2 7. 9 5
0 3
DP9 DP11 DP10
4 5. 7 4
DP13 DP15 DP12 DP14
Cost Field
4/Expt-10A
7 We also assume that the MicroTalk-8086 trainer has routines to convert data from one format to another like BCD2CC. It is also assumed that the trainer contains a routine that transfers the CC-code data to the 7-sement display devices. 8 We are now ready to operate the MicroTalk- 8086 trainer as a Digital Weighing Machine. Task-10A.3: [Operating the MicroTalk-8086 as DWM: [Link]] 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 [Link] program from the path: c:\mtk8086\[Link]. This is the program, which converts the MicroTalk-8086 trainer into a DWM. 3 Assembly the program [Link]. Convert it to [Link] and down load into MicroTalk-8086. 4 Execute the downloaded program starting at location: 01000 (0000:1000). 5 Observe that the following message (Fig-71.12) appears at the 7-segment panel of the trainer.
715-04
Rate Field
DP5 D P6 DP7 D P8
1 2. 3 7 0
0 0. 0 0
0 0
D P9 D P11 DP10
0 0. 0 0
DP13 D P15 DP12 DP14
Cost Field
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 [Link] program has configured the E-key (E stands for Rate Entry) of the trainer as a command key and it can be used to tell the trainer to accept rate from the keyboard. Let us press the E-key, the display appears as Fig-71.13 with the rate field opened.
715-04
Rate Field
D P5 D P6 D P7 D P8
1 2. 3 7 0
_ _. _ _
0 0
D P9 D P11 D P10
0 0. 0 0
D P13 D P15 D P12 D P14
Cost Field
Figure-71.13: 7-Segment Display Panel after Pressing the Rate Entry Key E
5/Expt-10A
8 Enter the product rate of Tk 27.95 by pressing down the digits: 2 7 9 and 5. When the entry of all the 4-digits are done, the display appears as Fig-7.14 which shows the Cost of the product.
715-04
Rate Field
DP5 DP6 DP7 DP8
1 2. 3 7 0
2 7. 9 5
0 3
DP9 DP11 DP10
4 5. 7 4
DP13 DP15 DP12 DP14
Cost Field
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] [[Link]] Open [Link] and save as [Link] 1 Change the simulated weight to 15.750Kg by editing the program [Link] 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 [Link] 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 CCcodes codes 4Fh, 66h, 7Dh and 6Fh) and store them at the appropriate memory locations of the data structure of Fig-71.11.
6/Expt-10A
START: L1:
nop ; 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 mov dx, 0002h out dx, al mov al, 34h out dx, al ; 16-digit ; poit at CR of 8279 ; clock scaling of Fpg-71.11 0201h 0703h 0000h ; 12.37 kg ; 27.95 Tk/kg
L2:
; storage of WTupBCD at T7 mov bx, 5000h mov WORD PTR [bx+50h], mov WORD PTR [bx+52h], mov WORD PTR [bx+22h], call mov mov mov call mov call mov mov call mov mul mov mov mov call mov mov mov call mov mov mov far ch, si, di, far ptr WTACQ 02h 5050h 5020h ptr up2BCD
L3:
; Acquisition of Weight as 0X: 0000:1050 ; number of packed bytes to obtain ; pointing at upBCD table, T7 ; pointing at pBCD table, T3 ; to convert unpacked BCD to Packed BCD
si, 5020h ; point at BCDWT ; 1237d = 04D5h far ptr BCD2BIN ; converting BCD wt into Binary Wt WORD PTR [si+2Ch],ax ; saving BINWT at: 504D,504C si, 5022h ; point at BCDRATE ; 2795d = 0AEBh far ptr BCD2BIN ; converting BCD wt into Binary Wt WORD PTR [si+2Ch],ax ; saving BINRT at: 504F, 504E WORD PTR [si+2Ah] di, 5000h WORD PTR [di+4Ch], ax WORD PTR [di+4Eh], dx ; BINCOST in [dx][ax] 32-bit ; saving lowerr 16-bit of BINCOST ; saving upper 16-bit of BINCOST
far ptr BIN2BCD ; convert BIN Cost to BCD Cost by Horner Rule ch, si, di, far 04h 5020h 5000h ptr BCD2CC ; number of CCCodes to obtain ; point at BCD table, T3a ; point at CCcode table, T1a ; number of CCCodes to obtain ; point at BCD table, T3a ; point at CCcode table, T1a
7/Expt-10A
call mov mov mov call mov mov mov mov mov or or or call jmp WTACQ WTACQ
far ptr BCD2CC ch, si, di, far 06h 5024h 500Ah ptr BCD2CC ; number of CCCodes to obtain ; point at BCD table, T3c ; point at CCcode table, T1a
ch, 10h ; number pf cccode bytes to transfer ah, 90h ; Display Position of 8279 si, 5000h ; point at ccode table, T1a BYTE PTR [si+04h], 3Fh ; place 0 at DP4 BYTE PTR [si+09h], 00h ; blank BYTE PTR [si+01h], 80h ; placing decimal point 12.37kg BYTE PTR [si+06h], 80h ; plce . 27.95 BYTE PTR [si+0Dh], 80h far ptr CCX79 L3
PROC FAR ; read from ADC and save the upBCD (0X) in table, T7 of Fig-71.11 ret ENDP FAR ax, 0000h ;initial partial result bl, BYTE PTR [si+01h] ; begin of BCD2BIN conversion =37(12) bl, 0Fh ; bl=00 bl, 00h L41e ax, 0001h bl L41e L41d bl, BYTE PTR [si+01h] cl, 04h bl, cl bl, 0Fh ; bl = 05 bl, 00h L41h ax, 000Ah bl L41h L41g bl, BYTE PTR [si] bl, 0Fh ; bl = 07 bl, 00h L41j ax, 0064h bl L41j L41i ; 12 (37)
BCD2BIN PROC mov mov and cmp jz L41d: add dec jz jmp L41e: mov mov ror and cmp jz add dec jz jmp mov and cmp jz add dec jz jmp
L41g:
L41h:
L41i:
L41j:
mov mov ror and cmp jz L41k: add dec jz jmp L41l: ret BCD2BIN ENDP
bl, BYTE PTR [si] cl, 04h bl, cl bl, 0Fh ; bl=04 bl, 00h L41l ax, 03E8h bl L41l L41k ; 16-bit BINary result in: ax-register
8/Expt-10A
BIN2BCD PROC LV1: mov mov mov mov mov mov mov mov mov rcl rcl jc mov add daa mov mov adc daa mov mov adc daa mov mov adc daa mov dec jnz jmp mov adc jc jmp daa mov stc jmp
LV2:
FAR bx, 5000h ; converting 32-bit BIN2BCD by Horner Rule di, WORD PTR [bx+4Eh] ; di=upper 16-bit of BINCOST si, WORD PTR [bx+4Ch];si=lower 16-bit (di, si) = 32-BIT BINCOST WORD PTR [bx+4Eh], 0000h WORD PTR [bx+4Ch], 0000h;(0504F,0504E,0504D,0504C)=00000000 ; initial 8-digit BCDCOST) bx, 0000h ; converting 32-bit BIN2BCD using Horner Rule cx, 0000h; (cx,bx) = 00000000 = initial partial BCDCOST ah, 20h ; number of rotation al, 00h ; result: (ch,cl,bh,bl) si, 01h di, 01h LV7 al, bl al, al bl, al al, bh al, al bh, al al, cl al, al cl, al al, ch al, al ch, al ah LV2 LV9 al, bl al, al LV8 LV2a bl, al LV3 di, 5000h ; [cx][bx]=03457415;mov di, 5000h BYTE PTR [di+24h], ch ; upper part of BBCD COST BYTE PTR [di+25h], cl ; BYTE PTR [di+26h], bh BYTE PTR [di+27h], bl ; lower part of BCDCOST
LV2a: LV3:
LV4:
LV5:
LV6:
LV7:
LV8:
LV9:
mov mov mov mov mov ret BIN2BCD ENDP up2BCD L1SR1: PROC mov mov rol and or mov dec jz inc inc inc jmp ret ENDP PROC mov mov mov mov
FAR cl, 04h al, BYTE PTR [si] al, cl al, 0F0h al, BYTE PTR [si+01h] BYTE PTR [di], al ch L2SR1 si si di L1SR1
0F000h ax ; point at the base of LUT3 BYTE PTR [si] ; 03 , 45, 74, 15 al
9/Expt-10A
and mov mov mov mov mov mov rol and mov mov inc mov dec jz inc inc jmp ret ENDP PROC mov mov out mov mov out dec jz inc jmp ret ENDP PROC mov mov mov mov mov or or or call ret ENDP ORG PROC mov mov out mov in cmp jz iret mov mov mov call mov in rcr jc jmp mov mov
al, 0F0h ah, 0FEh bx, ax al, BYTE BYTE PTR cl, 04h al, dl al, cl al, 0F0h bx, ax al, BYTE di BYTE PTR ch L2SR2 si di L1SR2
; making X0 = 00 PTR es:[bx] [di], al ; getting the CCcode ; save cccode at T1a
L1SR3:
FAR dx, 0002h ; point at CR al, ah dx, al dx, 0000h ; point at DR of 8279 al, BYTE PTR [si] dx, al ch L2SR3 si L1SR3
far ch, 10h ; number pf cccode bytes to transfer ah, 90h ; Display Position of 8279 si, 5000h ; point at ccode table, T1a BYTE PTR [si+04h], 3Fh ; place 0 at DP4 BYTE PTR [si+09h], 00h ; blank BYTE PTR [si+01h], 80h ; placing decimal point 12.37kg BYTE PTR [si+06h], 80h ; plce . 27.95 BYTE PTR [si+0Dh], 80h far ptr CCX79
XT8279 ; INT22
2000h FAR al, 40h dx, 0002h dx, al dx, 0000h al, dx al, 11h INTL1
INTL1:
AGNKB:
INTL2:
di, 5000h WORD PTR [di+05h], 8808h WORD PTR [di+07h], 0808h far ptr XT8279 dx, 0002h al, dx al, 01h INTL2 AGNKB dx, 0002h al, 40h
10/Expt-10A
out mov in mov cmp jz cmp jz cmp jz cmp jz ;cmp ;jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz jmp L1RS: ; mov mov mov mov mov mov mov mov mov mov mov call dec jz inc jmp
dx, al dx, 0000h al, dx BYTE PTR [di+4Bh], al al, 0Eh L1RS al, 0Dh L1RS al, 0Ch L1RS al, 0Bh L1RS al, 0Ah L1RS al, 15h L1RS al, 14h L1RS al, 13h L1RS al, 1Dh L1RS al, 1Ch L1RS al, 1Bh L1RS AGNKB
al = scan CC-code di, 5000h dx, 0F000h es, dx bp, 0FFD0h ah, 00h si, ax al, BYTE PTR es:[bp+si] ; getting CCcode cl, BYTE PTR [di+48h] ch, 00h bp, cx BYTE PTR [di+bp], al ; saving the Cccode at T1b far ptr XT8279 ; T1b ---> 8279 with decimal point BYTE PTR [di+49h] ; number of digits to print L2RS BYTE PTR [di+48h] AGNKB L2RS ; 4-digits of Weight are acquired
L2RS:
mov ch, 04h ; bytes to convert mov si, 5005h ; and BYTE PTR [si+01h], 07Fh ; 0111 1111 ; remove point mov di, 5015h call far ptr CC2uBCD ; upBCD ---> pBCD mov ch, 02h ; number of bytes to obtain mov si, 5015h mov di, 5022h call far ptr uB2BCD mov di, 5000h mov BYTE PTR [di+48h], 05h mov BYTE PTR [di+49h], 04h ;test OK ;mov al, 80h ;mov dx, 3606h ;out dx, al ;mov al, 01h ;mov dx, 3600h ;out dx, al ;hlt sti
11/Expt-10A
;iret mov mov mov iret INT22 uB2BCD LY1: ENDP PROC mov mov mov ror and or mov dec jz inc inc inc jmp ret ENDP
bp, sp WORD PTR [bp+00h], 1050h ; OFFSET of L3 of MLP WORD PTR [bp+02h], 0000h ; SEG of L3 of MLP
FAR al, BYTE PTR [si] cl, 04h ah, BYTE PTR [si+01h] ah, cl ah, 0Fh al, ah BYTE PTR [di], al ch LY2 si si di LY1
LY2: uB2BCD
CC2uBCD PROC mov mov LX1: mov mov mov add mov mov dec jz inc inc jmp LX2: ret CC2uBCD ENDP MYCODE ENDS END
FAR dx, 0F000h es, dx bp, 0FF00h ; FF00 ; 1234 : 06, 5b, 4F, 6D ah, 00h al, BYTE PTR [si] ; getting CCcode 0D bp, ax ; FF00 + 0006 = FF06 al, BYTE PTR es:[bp] ; getting 10 from FFF0D BYTE PTR [di], al ; saving upBCD ch LX2 si di LX1
START
12/Expt-10A
Conversion and Operation of the MDA-8086 Microprocessor Trainer as a Digital Weighing Machine (DWM)
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions are given as topics for additional studies to enhance your Knowledge & Understanding)
Task-10B.1: [Aim of the Experiment] To get familiar with the procedures of converting the MDA-8086 microprocessor trainer into a Digital Weighing Machine (DWM). Task-10B.2: [Converting the MDA-8086 Trainer into DWM] Let us carry out the following steps to convert the MDA-8086 trainer into a DWM. 1. Look into the following block diagram of Fig-71.1, which could be used to represent the MDA-8086 based DWM.
647
Experiment 10B
Load Cell
+5 -5 0V
Breadboard
MDA-8086
LCD COST: 1998.80 W: 19.990 R: 99.99
A m p
DS1 DS2 DS3 DS4 Q3 Q2 Q1 Q0
P3
U29 8255
E 8 4 0 9 5 1 6 2 7 3
A D C
2. Assume that the Load Cell is connected (Practically they not connected). You will be performing the load cell exercises in Experiment-7.2. 3. Also assume that the Breadboard, the Instrument Amplifier and the ADC is also present (Practically they not connected). 4. Assume that the Load Cell has produced a signal of 12.37mV corresponding to 12.370kg of loads. This signal has been amplified and digitized to upBCD format by the ADC. Also assume that the WTupBCD signals have been acquired via the interface controller U29 (8255) and are saved in the following memory locations of the DWM Data Structure of Fig-7.4 (see text).
05053 05052 05051 05050
UpBCD UpBCD UpBCD UpBCD Wt: 1/100 Wt: 1/10 Wt: 1 Wt: 10
upBCD Wt
Goods
T7
Also assume that the upBCD weight data are converted to pBCD and ASCII and saved in the following memory locations of the data structure.
1/Expt-10B
05021 05020
Wt Field
BCD
05038
0 1/100 1/10 . 1 10 : W
DP17
5 We will be using the keyboard of the MDA-8086 trainer to enter the product rate. The rate will be entered one digit at a time. Let us assume that the following memory locations of the following data structure contain the RTASCII (product Rate in ASCII format) and RTBCD (product rate in BCD format).
05047
ASCII ASCII ASCII ASCII ASCII ASCII ASCII for for for for for for for 1/100 1/10 . 1 10 : R DP1F
05041
DP19
632a
Rate Field
BCD
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 05026 05025 pBCD: 1/10, 1/100 pBCD: 10, 1 pBCD: 1000, 100
Cost Field
BCD
DP0
7 We also assume that the MDA-8086 trainer has routines to convert data from one format to another like BCD2ASCII. It is also assumed that the trainer contains a routine that transfers the ASCII data to the LCD display panel. 8 We are now ready to operate the MDA-8086 trainer as a Digital Weighing Machine.
2/Expt-10B
Task-10B.3: [Operating the MDA-8086 as DWM: [Link]] 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 [Link] program from the path: c:\mda8086\[Link]. This is the program, which converts the MDA-8086 trainer into a DWM. 3 Assembly the program [Link]. Convert it to [Link] and down load into MDA-8086. 4 Execute the downloaded program starting at location: 01000 (0000:1000). 5 Observe that the following message appears at the LCD panel of the trainer.
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA D PB DPC DPD DPE DPF
C O S T : 0 0 0 0 . 0 0 W : 1 2 . 3 7 0 R : 0 0 . 0 0 _ _ _ _
5 93
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
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 [Link] program has configured the E-key (E stands for Rate Entry) of the trainer as a command key and now we may use this key to tell the trainer to accept rate from the keyboard. Let us press the E-key, the display shows:
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA D PB DPC DPD DPE DPF
C O S T : 0 0 0 0 . 0 0 W : 1 2 . 3 7 0 R : _ _ . _ _
5 93
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
8 Enter the product rate of Tk 27.65 by pressing down the digits: 2 7 6 and 5. When the entry of all the 4-digits are done, the display appears as below:
DP0 DP1 DP2 DP3 DP4 DP5 DP6 DP7 DP8 DP9 DPA D PB DPC DPD DPE DPF
C O S T : 0 3 4 2 . 0 3 0 0 0 0 W : 1 2 . 3 7 0
_ _ R : 2 7 . 6 5 _ _
DP10 DP11 DP12 DP13 DP13 DP!4 DP15 DP16 DP17 DP18 DP1A D P1B DP1C DP1D DP1E DP1F
9 This is the end of the conversion and operation of the MDA-8086 as a Digital Weighing Machine. Check that the DWM is working all right by entering different product rates.
3/Expt-10B
5 93
Task-10B.4 [Exercises] 1 Change the simulated weight to 15.750Kg by editing the program [Link] 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 [Link] 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, [Link]. 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: L1: nop mov Mov out in test jnz and mov out dec jz inc jmp jmp 5000h ah, 04h KRS(01H), 00h al, KRD(01h) al, 10000000B L2 al, 00011111B BYTE PTR [bx+4Ch], al KRS(01h), 00h ah L5 bx L2 F000:FFFFh (EA FF FF 00 F0) ; pointing a table that will hold the scan codes ; keyboard is reset ; read the raw scan code ; checking if B7-bit is 0 ; no key is pressed down ; closed key found and save in KBUF [upper 3-bits 0] ; scode is saved at memory location : 0000:504C..504F ; reset the keyboard
L2:
L3: L4:
L5: mov mov L: mov - mov xlat - mov dec jz inc jmp -
; read the scan code of the next key ; the goes to the prompt (the ready mode).
Program to Convert Scan Code to ASCII (SC2AS): [Execute and Check the Result]
ah, 04h si, 5000h al, BYTE PTR [si+4Ch] bx, OFFSET ASCII BYTE PTR [si+41h] ah M si L ; pointing the table that contain the Scan Code ; getting the 1st Scan Code, 2nd scan code ; bx-register knows how far the ASCII table is. ; now al-register contains the ASCII code ; ASCII code for the 1st digit is saved
ASCII DB 30h, 31h, 32h, 33h, 34h, 35h, 36h, 37h, 38h, 39h
M: conversion is done!
4/Expt-10B
L1:
far ptr BUSY al, 38h LCDIR, al far ptr BUSY al, 0Ch LCDIR, al far ptr BUSY al, 10h LCDIR, al far ptr BUSY al, 01h LCDIR, al
bx, 5000h ; ASCII table initialization (L28-33) WORD PTR [bx], 3130h ; 0 1 WORD PTR [bx+02h], 3332h ; 2 3 WORD PTR [bx+04h], 3534h ; 4 5 WORD PTR [bx+06h], 3736h ; 6 7 WORD PTR [bx+08h], 3938h ; 8 9 WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD WORD PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR PTR [bx+28h], [bx+2Ah], [bx+2Ch], [bx+2Eh], [bx+30h], [bx+32h], [bx+34h], [bx+36h], [bx+38h], [bx+3Ah], [bx+3Ch], [bx+3Eh], [bx+40h], [bx+42h], [bx+44h], [bx+46h], 2020h ; blank blank ; init Message (L35-L51) 4F43h ; O C 5453h ; T S 303Ah ; 0 : 3030h ; 0 0 2E30h ; . 0 3030h 2020h 3A57h 3231h 332Eh 3037h 5220h 303Ah 2E30h 3030h ; ; ; ; ; ; ; ; ; ; 0 0 blank blank : W 2 1 3 . 0 7 R blank 0 : . 0 0 0
si, 5000h ; xfer meggage to LCD (L53 -L66) bx, 0028h cl, 10h far ptr BUSY al, 80h LCDIR, al far ptr T42LCD ; xferring ASCII code from T4 to LCD bx cl, 10h far ptr BUSY al, 0C0h LCDIR, al far ptr T42LCD
5/Expt-10B
nop mov mov mov out in test jnz and mov nop nop out cmp jnz mov mov mov mov mov mov call mov out call inc mov call mov out call
; flag init (L67 -L69) bx, 5000h WORD PTR [bx+4Ch], 0000h ; flags al, 00h ; ckecking if key close (L70-L74) KRR, al al, KDR al, 80h L31a al, 0Fh ; closed key found (L75-L81) BYTE PTR [si+4Bh], al KRR, al ; keyboard is al, 0Eh L31a bx, 5000h ; closed key is WORD PTR [bx+43h], 5F5Fh WORD PTR [bx+46h], 5F5Fh reset 'E' and init message (L82-L84) ; _ _ at DP1B and DP1C ; _ _ at DP1E and DP1F
si, 5000h ; xfer message to LCD (L86-L99) bx, 0028h cl, 10h far ptr BUSY al, 80h LCDIR, al far ptr T42LCD ; xfer ASCII of T4 of Fig-44.8 to LCD bx cl, 10h far ptr BUSY al, 0C0h LCDIR, al far ptr T42LCD
L41: L41a:
L41b:
mov mov mov mov out nop in test jnz mov and mov nop nop out call cmp jnz mov mov mov mov mov call mov ;out mov mov mov mov call mov out call inc mov
si, 5000h ; now digit printing at Rate Filed (L114-L162) dl, 04h ; for 4 digits to print bp, 0043h ; pointer al, 00h KRR, al ; keyborad reset al, KDR al, 80h L41a ; key has not been pressed ah, al al, 0Fh ; key has been pressed down BYTE PTR [si+4Bh], al ; scan code is saved KRR, al ; keyboard is reset far ptr DIGIT ; filtering out no-digit BYTE PTR [si+4Dh], 01h; L41a BYTE PTR [si+4Dh], 00h ; flag is reset, valid digit (0-9) si, 5000h bh, 50h bl, BYTE PTR [si+4Bh] ah, BYTE PTR [bx] ; ASCII code for digit in ah-register far ptr BUSY al, ah LCDDR, al BYTE PTR [si+bp], al si, 5000h bx, 0028h cl, 10h far ptr BUSY al, 80h LCDIR, al far ptr T42LCD bx cl, 10h
; xfer ASCII of T4 of
Fig-44.8 to LCD
6/Expt-10B
L41c:
call mov out call dec jz cmp jnz inc inc jmp mov mov mov rol and and or mov mov mov rol and and or mov mov mov rol and and or mov mov mov rol and and or mov call mov mov mov call mov mov mov mul mov mov
far ptr BUSY al, 0C0h ; 2nd line of LCD LCDIR, al far ptr T42LCD dl HERE ; 4-digit Rtae Entry is complete dl, 02h ; to find position for (.) to avoid printing L41c bp bp L41a si, 5000h ; converting RATE ASCII into BCD (L165-L196) ax, WORD PTR [si+43h] ; al=34 ; ah=37 ASCII2BCD cl, 04h al, cl ; al, 0F0h ; al=40 ah, 0Fh ; ah=07 al, ah ;al=47 BYTE PTR [si+4Dh], al ;(0504D)= 47 ; upper Byte of BCDRATE ax, WORD cl, 04h al, cl al, 0F0h ah, 0Fh al, ah BYTE PTR PTR [si+46h] ; al=35 ; ah=36 ; ASCII2BCD ; al=50 ;ah=06 ;al=56 [si+4Ch], al ;(0504C) = 56 ; lower byte of BCDRATE
HERE:
ax, WORD PTR [si+3Ah] ; al=31 ; ah=32 ASCII2BCD cl, 04h al, cl al, 0F0h ah, 0Fh al, ah BYTE PTR [si+4Fh], al ; upper byte of BCDWT ax, WORD PTR [si+3Dh] ; al=37 ; ah=37 ASCII2BCd cl, 04h al, cl al, 0F0h ah, 0Fh al, ah BYTE PTR [si+4Eh], al ; lower byte of BCDWT far ptr BCD2BIN ; converting BCD-RATE into BIN
dx, ax ; BINRATE in dx-register ax, WORD PTR [si+4Eh] ; converting BCDWT into BIN WORD PTR [si+4Ch],ax ; (0504D)(0504C) = BCDWT far ptr BCD2BIN ; WORD PTR [si+4Eh], ax ; (0504F)(0504E) = BINWT WORD PTR [si+4Ch], dx ; (0504D)(0504C) = BINRATE ax, WORD PTR [si+4Ch] WORD PTR [si+4Eh] WORD PTR [si+4Ch], ax WORD PTR [si+4Eh], dx ; multgiplication ; multiplier ; (dx)(ax) = 32-bint BINCOST ; lower 16-bit BINCOST ; upper 16-bit BINCOST
LV1:
bx, 5000h ; converting 32-bit BIN2BCD by Horner Rule di, WORD PTR [bx+4Eh] si, WORD PTR [bx+4Ch];(di, si) = 32-BIT BINCOST WORD PTR [bx+4Eh], 0000h WORD PTR [bx+4Ch], 0000h;(0540F,0540E,0540D,0540C)=00000000 ; initial 8-digit BCDCOST) bx, 0000h ; converting 32-bit BIN2BCD using Horner Rule
7/Expt-10B
LV2:
LV2a: LV3:
LV4:
LV5:
LV6:
mov mov mov rcl rcl jc mov add daa mov mov adc daa mov mov adc daa mov mov adc daa mov dec jnz jmp mov adc jc jmp daa mov stc jmp mov mov mov mov mov mov
0000h; (cx,bx) = 00000000 = initial partial BCDCOST 20h ; number of rotation 00h 01h 01h bl al
bl, al al, bh al, al bh, al al, cl al, al cl, al al, ch al, al ch, al ah LV2 LV9 al, bl al, al LV8 LV2a bl, al LV3 si, 5000h WORD PTR [si+4Eh], cx WORD PTR [si+4Ch], bx ah, 03h ; 3-bytes to convert dx, 002Fh ; pointer bp, 004Fh ; converting BCDCOST into ASCIICOST bx, al, cl, al, al, OFFSET ASCII BYTE PTR [si+bp] ; al= 05 04h cl 0Fh ; al = 00 ; al=30h bx, dx ; bx=002Fh BYTE PTR [si+bx], al dx, bx al, BYTE PTR [si+bp] al, 0Fh bx, OFFSET ASCII dx bx, dx BYTE PTR [si+bx], al dx, bx ah LX3; HERE1 bp dx, 0032h LX2 dx dx LV9a si, 5000h ; xfer meggage to LCD (L53 -L66) bx, 0028h
LV7:
LV8:
LV9:
LV9a:
LX2: LX3:
mov mov mov ror and xlat mov mov mov mov and mov xlat inc mov mov mov dec jz dec cmp jnz inc inc jmp mov mov
8/Expt-10B
mov call mov out call inc mov call mov out call
cl, 10h far ptr BUSY al, 80h LCDIR, al far ptr T42LCD bx cl, 10h far ptr BUSY al, 0C0h LCDIR, al far ptr T42LCD
jmp DB PROC in and jnz ret ENDP PROC mov call mov out dec jz inc jmp ret ENDP PROC cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz cmp jz mov mov ret ENDP
FAR ah, BYTE PTR [si+bx] far ptr BUSY al, ah LCDDR, al cl L3b bx L3a
FAR al, 12h ;GO EXIT al, 11h ; STP EXIT al, 0Ch ; C EXIT al, 0Dh ; D EXIT al, 0Eh ; E EXIT al, 0Fh ; F EXIT al, 15h ; + EXIT al, 13h ; REG EXIT al, 0Ah ; A EXIT al, 0Bh ; B EXIT al, 14h ; EXIT al, 16h ; DA EXIT al, 10h ; : EXIT al, 17h ; 'AD' EXIT BYTE PTR [si+4Bh], al BYTE PTR [si+4Dh], 01h ; valid digit is found
EXIT: DIGIT
9/Expt-10B
BCD2BIN PROC mov mov mov and cmp jz L41d: add dec jz jmp L41e: mov mov ror and cmp jz add dec jz jmp mov and cmp jz add dec jz jmp
FAR si, 5000h ax, 0000h bl, BYTE PTR [si+4Ch] bl, 0Fh ; bl=00 bl, 00h L41e ax, 0001h bl L41e L41d bl, BYTE PTR [si+4Ch] cl, 04h bl, cl bl, 0Fh ; bl = 05 bl, 00h L41h ax, 000Ah bl L41h L41g bl, BYTE PTR [si+4Dh] bl, 0Fh ; bl = 07 bl, 00h L41j ax, 0064h bl L41j L41i
L41g:
L41h:
L41i:
L41j:
mov mov ror and cmp jz L41k: add dec jz jmp L41l: ret BCD2BIN ENDP BCD2ASC PROC nop BCD2ASC ENDP MYCODE ENDS END
bl, BYTE PTR [si+4Dh] cl, 04h bl, cl bl, 0Fh ; bl=04 bl, 00h L41l ax, 03E8h bl L41l L41k ; 16-bit BINary result in: ax-register FAR
START
10/Expt-10B
Study of the Asynchronous Serial Communication Link Between IBMPC and MicroTalk-8086 Trainer
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions are given as topics for additional studies to enhance your Knowledge & Understanding) Task-11A.1
Lab Works on COM1 Port of IBMPC and MicroTalk-8086 Trainer using DOS and ASM Codes The diagram shown below depicts the interconnection between the 8086 (microprocessor), 8259 (Interrupt Priority controller), 8251A (Serial IO Controller), 8279 (Keyboard/Display Controller), 488/489 (TTL RS232 Converter) of MicroTalk-8086 trainer and the IBMPC. Study this diagram carefully and then carry out the steps that follow:
MPU
A D7-D0 R D/ WR/ M -IO/
Experiment 11A
IPC:
A D
8259 : U14
IR 7
BUS
KBDIC
7SCCD
DP0 DP7 DP8
C S/
J6-3
Key Buffer
R/ W/ IO/
DRAM
INTR INTA/
INT INTA/
DR CR
J6-11
KIR Q
IR Q
C ol
R ow
1000h 1002h
8086: U2
BUS
0000h 0002h
R xR DY TxR DY
DR CR
Keypad
6.144M Hz 307.2KHz
8279 : U24
J10-2 J10-3
2 3
488 489
3 1
TxR S R xR S
DR R xD CR
R xT
677
USART:
8251: U17
489,488: U18,U19
IBM-PC
Figure-11A.1: Hardware Connection Diagram among 8086, 8251, 8259, Keyboard-Display and IBMPC
When this test is carried out, we shall see that: a. The message dO keeps flashing at the DP7DP8 positions of the trainer. b. You press a key on the keyboard of the IBM-PC; the PC transmits the corresponding ASCII code. The trainer receives the ASCII code, displays it on the DP7DP8 positions of the trainer. The trainer also transmits back the same ASCII code to the PC. The PC receives the ASCII code and displays the corresponding character on the monitor. And then, the message dO comes back. c. Press a key on the keypad of the trainer. The character A appears on the monitor of PC. Procedures: i. Power down the IBM-PC and the MicroTalk-8086 trainer.. ii. Use a 9-pin serial cable to connect the trainer and the COM1 port of IBMPC. iii. Power up the trainer. Use a hookup wire and short: J6-3(KIRQ) and J6-11 (IR2). iv Execute at: F1940h. The message dO starts blinking at DP7DP8 positions of the trainer.
1/Expt-11A
v. vi.
MYSTACK SEGMENT para stack 'stack' DW 100 dup (0) STKTOP LABEL word MYSTACK ENDS MYDATA MYDATA MYCODE START: SEGMENT para public 'data' DB 00h ENDS
Power up the IBM-PC. In the IBM-PC, execute the program, c:\MTK8086\[Link] Listing of [Link] Program
SEGMENT para public 'code' ASSUME cs:MYCODE,ss:MYSTACK, ds:MYDATA mov mov mov mov mov mov mov mov int sti ax,MYSTACK ss,ax sp,offset STKTOP ax, MYDATA ds, ax ah,00h dx,0000h al,11000111B 14h ;initialising COM1 ;pointing at COM1 ;4800-Bd,2-SB,NP,8-DB ; 11100111 ; 9600Bd ;ROM BIOS function call ;enable interrupts dx,0000h ah,03h 14h ah,01h RDCHAR KYBD ah,02h 14h dl,al ah,02h 21h ah,01h 16h RDKY CHKAGN ah,00h 16h al,51h NEXT ax,4C00h 21h ah,01h dx,0000h 14h ;points at COM1 ;ROM BIOS function value for int 14h ;ROM BIOS function call ,get COM1's status ;ah-B0 = 1 means data ready at UART ;data has just arrived at COM1 ;see if any command from Keyboard ;fuction value for ROM BIOS `int 14h' call ;ROM BIOS function call, data in al register
CHKAGN: mov mov int test jnz jmp RDCHAR: mov int mov mov int KYBD: mov int jnz jmp mov int cmp jne mov int mov mov int
;DOS BIOS function call, display data at CRT ;function value ;ROM BIOS functioncall,ZF=1 means no char ;ZF=0,scan and ascii codes in type-ahead buff ; ;ROM BIOS function call, sc=ah,ac=al ;see if Quit command (capital Q) ;function value to return to DOS prompt ;DOS fuction call ;function value ;point at COM1 ;ROM BIOS function call
RDKY:
NEXT:
MYCODE
viii. ix.
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. Press a key on the keyboard of the PC. We observe that the corresponding ASCII code has appeared at the DP7DP8 positions of the trainer. The character also appears on the monitor.
2/Expt-11A
3/Expt-11A
Study of the Asynchronous Serial Communication Link Between IBMPC and MDA-8086 Trainer
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions are given as topics for additional studies to enhance your Knowledge & Understanding) Task-11B.1
Lab Works on COM1 Port of IBMPC and MDA-8086 Trainer using DOS and ASM Codes The schematic diagram for the serial interface of the MDA-8086 (Korean made 8086 trainer) trainer is given below. Write complete program both for the IBMPC and the 8251A controller of the mmda-8086 trainer to establish communication between these two equipments at the setting of: 4800 Bd, 1 start bit, 8 character bits, even parity and 2 stop bits. And then carry out the following functional checks.
8086: U1 : MPU
BUS
Experiment 11B
IPC:
8259 : U14
IR7
BUS
LCD
00h 02h 04h IR SR DR
INTR INTA/
INT INTA/
DR CR 10h 12h
Keyboard
01h 01h DR CR
2.4576MHz
+5
BUS
09h 0Fh
C0 CR
RxR DY TxRDY
10 12
7 13
TxR S RxR S
DR R xD CR
R xT
MAX232: U15
IBM-PC
a. b. c.
Download the codes of your program starting at 0000:1000 and then execute at 01000h Type a character in the keyboard of the IBMPC, its ASCII, Scan and Label would appear on LCD 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 [Link]. This program would read a character from the Rx-register by polling the RxRDY-bit and then write it back on the Tx-register by polling the TxRDY-bit.
1/Expt-11B
Determine TxC for 4800 Bd (assume BRF = x16) and then configure the PIT chip 8253 accordingly. TxC = BRF x Bd = 16 x 4800 = 76800 Hz Configure Counter-0 of PTI chip 8253 (U41) to work as a frequency divider of: CK0/TxC = 2.4576MHz/0.076800 MHz = 32(20h) in order to output a frequency of 76800Hz Configure 8251A (U17):
i. ii. 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 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 ([Link]) 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 [Link]. 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 TxRDYbit. 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 [Link]. Reset the MDA-8086 trainer and then execute at: 0000:1000 In the IBMPC, execute the program p4513b. Type the character A from the keyboard. The monitor must show it. This verifies that the IBMPC and the MDA-8086 trainer are communicating using the customized serial link. Now, add addition code with program [Link] 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. Now, add addition code with program [Link] 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. Now, add additional codes with [Link] so that the MDA-trainer could read character from the Rx-register on interrupt. Now, add necessary codes with the program [Link], so that the IBMPC could read character from the Rx-register on interrupt.
c. d. e. f. g.
h. i. j.
2/Expt-11B
Experiment 12
Programming of the 8279-Based Display Unit of the MicroTalk-8086 Learning System
(You must Finish all the Tasks of this Experiment. Exercises, Examples and Questions are given as topics for additional studies to enhance your knowledge & understanding)
Task-12.1:
Display the message Good at the data field of the display unit of the MicroTalk-8085 trainer. The Procedures: 1. Fill up the following Common Cathode Codes Table for all Possible Characters Displayable on 7Segment Display Devices Character 0 1 2 3 4 5 6 7 8 9 A B C D E F G o (small O) D R L U S T Displayable Form 0 1 Segment Bits p g f e d c b a 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 Data Value 3FH 06H
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
8279 : U10
DDR
4-Bit Counter
p g f e
Frequency Divider
0 1
D C B A
Data
Q3
DP1 DP2
DP3 DP4 DP5
1024KHz
In Out
100KH
Fin
Q2 Q1 Q0
d c b a cc
cc
cc
cc
cc
cc
cc
cc
4 to 16 D E C O D E R F
0000, 0002
A1
DECODER
CS/
A0 (C-D/)
DPF
DR
CR
SR
D C B A
4. Programming Table 1 Register Name Control Register Status Register Display Data Register Keyboard Data Register Abbreviation CR SR DDR KDR Address 0000h 0002h 0000h 0000h Mapping Standard & Variable Standard & Variable Standard & Variable Standard & Variable Read/Write Mode Write Only Read Only Read/Write Read/Write
2/Expt-12
5. Programming Table 2 Control Byte 000 00 000B = 08H 000 10 000B = 18B 010 00 000B = 40H 011 0 0000B = 60H 011 1 0000B = 70H Purpose 16 Digit Display; Character Entry from Left 16 Digit Display; Character Entry from Right To read data from the KDR Read data from DDR (display RAM0 pointed by the lower 4-bits of Cbyte) 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 Write data into DDR (Display RAM0 pointed by the lower 4-bits of CByte) 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 TaskF.1.
L1: L2: do nothing; 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; (ds: [di]) al al DDR (0000h) if ( cx == 0) goto L6 else { (SI) + 01H SI goto L3 } halt
L3: L4: L5 :
L6:
3/Expt-12
L1:
Entry
L2:
Exit
111-00:GM:1199
Assembly Codes: L1: 05100 - nop L2: - mov al, 08h mov dx, 0002h out dx, al mov al, 90h out dx, al mov cx, 0004h mov si, 0A000h L3: - mov al, BYTE PTR ds:[si] (default ds=0000h) L4: - mov dx, 0000h out dx, al L5: - dec cx jz L6 inc si jmp L3 L6: - hlt
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
8279
4-Bit Coun ter 1024KHz F req . D iv ide r 100K Q3 Q0
DP7 8
DP8
Scan C o de D isplay
4-to-8 Decoder
74138
0000, 0002
CS/
8x5K KDR
RL0 RL1 RL2 RL3 RL4 RL5 RL6 RL7
K11
C1 C2
C3
A1
A0(C-D/)
D7-D0
4 IRQ
SR
112a: GM: 0701 : 06/2005
E L E C T R O N I C S
CR
2. Programming Table 1 Keyboard Scan Code Format: CONTROL B7 0 SHIFT B6 0 COLUMN LINES B5 B4 B3 X X X ROW LINES B2 B1 B0 X X X
K13
K63
RESET
1/Expt-13
3. Follow Fig-44.3 and Fill up the following table for the Keypad of the MicroTalk-8086
Key Designation K11 K21 K51 K61 K12 K62 K13 K23 K33 K43 K53 K63 Key Label D/DOP -------------------------------------------------------------------------------------_______________ ---------------------------------------------------------------------------------------------------------Scan Codes (Binary) 00 001 001 -----------------------------------------------------------------------------------------______________ -------------------------------------------------------------------------------------------------------------Scan Codes (Hex) 09H -----------------------------------------------------------------------------------_______________ ----------------------------------------------------------------------------------------------------------
4. Programming Table-2
Control Byte 40H
L1: L2: L3:
5. Pseudo Codes for the solution of the problem ([Link]) Flow Chart for the Pseudo Codes:
nothing SR0 al if (al0 = 1) Closed Key is there; Go to L4 Else no closed key; goto L2 Scan_Code al [Cbyte(40H) CR(0002h); KDR(0000h) al] go to L6 convert 1-Byte Scan Code to 2-Bytes 7-Segment codes for the purpose of display (al 0044Eh; call F000:F47C) display the converted data of label-6 on the D2D1 position; blank D7D6D5D4D3 positions (00h 00444h 0044Ah s call F000:FFB6) go to L2
L1:
Entry
L2:
Read Status Register
N L4:
L7:
L7:
Convert 1-Byte S can Code to 2-Bytes 7-seg
L6:
L8:
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 [Link], which similar to F05B0h
2/Expt-13
3/Expt-13
Experiment 13B
Example-13B.3: [Terminologies] Scan Code: A key has two pins and it becomes an operational key when its two terminals are placed between a row and a column as is shown in Fig-44.1. When a key is pressed down, the associated electronics around that key generates an 8-bit code, which is termed as Scan Code = scode). The value of the scode depends on the row and column across which the key is placed. Thus, the scan codes of the keys of a keypad are always different from each other. Example-44.4: [Hardware Block Diagram of the MDA-8086 Keyboard]
Decoder: U16
CS/: 01h WR/ RD/ BHE/ M-IO/
KRS/ KRD/
U25
S/
Status Signal
DB-sig: 33m S
R/
IRQ
U24
OE/
Key Pad
DB-Sig 0V Q4 Q3 Q2 Q1 Q0 G0 12 + 15 14 : 10
STP 11 REG 13
D15-D8
B7 B6 B5 Q7-Q0 B4 B3 B2 B1 B0
541
DA 16 AD 17
C 0C 8 08 4 04 0 00
D 0D 9 09 5 05 1 01
E 0E A 0A 6 06 2 02
F 0F B 0B 7 07 3 03
Figure13B.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 Us numbers correspond to the actual Us of the circuit diagram of the keyboard as depicted in the MDA-8086 users 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: L2: out in test jnz and mov out jmp KRS(01H), 00h al, KRD(01h) al, 10000000B L2 al, 00011111B BYTE PTR KBUF, al KRS(01h), 00h -------; keyboard is reset ; read the raw scan code ; checking if B7-bit is 0 ; ne key is pressed down ; closed key found and save in KBUF ; KBUF is a memory location of DSM (say, 03010h) ; reset the keyboard ; take action as needed against the closed key.
L3: L4:
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: L2: out in test jnz and mov out jmp KRR(01H), 00h al, KDR(01h) al, 10000000B L2 al, 00011111B BYTE PTR ds: [3100h], al KRS(01h), 00h F000:FFFFh (EA FF FF 00 F0) ; keyboard is reset ; read the raw scan code ; checking if B7-bit is 0 ; no key is pressed down ; closed key found and save in KBUF [upper 3-bits 0] ; scode is saved at memory location : 0000:3100 ; reset the keyboard ; the goes to the prompt (the ready mode).
L3: L4:
Example-13B.7: The scode of the Task-44.6 has been stored at memory location 0000:1100 by executing the instruction: mov BYTE PTR ds:[3100h], al. Verify that the following instruction can also be used to store the scode at the memory location: 0000:3100. mov bx, 3100h mov BYTE PTR ds:[bx] Exercise-13B.8: Modify the program of Task-44.6 so that the CPU will respond (it will go to Ready Prompt) when and only when you press the REG key. All other keys will be ignored. Scode is saved at: 03100h. Solution Hints: The solution of Exercise-44.8 is given below in the form of Pseudo Code and Flow Chart. Convert it into machine codes. Enter the program codes into the CSM starting at 0000:1000 and execute it. Pseudo Codes: Flow Chart: L0: entry L1: xxh KRS (01h) ; reset keyboard L0: L2: al KRD (01h) ; read raw scan code Entry L3: if (a7 = 1) ; checking the status bit L1: goto L2 ; key not closed Reset the Keyboard L4: if (al != 13h) ; is it REG key? goto L2 ; it is not REG key L2: L5: al 03100h ; saving Scan code for REG. Read Scan Code L6: goto F000:FFFFh (EA FF FF 00 F0)
L3:
Assembly Codes: 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
Y
N
N
B7 = 1
L4:
Scode=13h ?
Y L5:
Exit to Prom pt
542
Figure-44.2: Flow Chart for Exercise-44.8 Exercise-13B.9: Modify the program of Exercise-44.8 so that the CPU will now exit to the Ready Prompt when either the GO or STP key is pressed down.
6/Expt-13B
Exercise-13B.10: Rewrite and execute the program of Task-44.6 by assigning variable port addresses for the devices KRS and KRD.
Taks-13B.11: Write, code and execute an 8086 assembly program, which will show the message
Closed key Found on the top line of the LCD when the key GO is pressed down: Solution: 1. Configure the LCD for 8-data lines, 16x2 line, 5x7 dots, display ON and cursor OFF. 2. Manually initialize the message Closed Key Found in the following data structure of DSM:
0000:3200 ASCII Cde of 'C' 0000:3201 ASCII Cde of 'l' 0000:3202 ASCII Cde of 'o' ASCII Cde of 's' ASCII Cde of 'e' ASCII Cde of 'd' Space ASCII Cde of 'K' ASCII Cde of 'e' ASCII Cde of 'y' Space ASCII Cde of 'F' ASCII Cde of 'o' ASCII Cde of 'u' ASCII Cde of 'n' 0000:320F ASCII Cde of 'd' 0000:3210 Mark of End (24h) 543
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 users 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 users manual. Working Principles: The heart of the keyboard circuit is the component U27, which is a Priority Encoder chip. This is the chip, which actually generates the scan codes for the keys of the keypad. However, the transistors, TR1-TR3 also play a great role for generating the scan codes by providing the column lines for the keyboard matrix. The keyboard works in very interesting way. When none of the keys of the keyboard is pressed down, the row lines are isolated from the column lines and the inputs to the U27 are: 00000000B. According to the truth table of the U27 (4532), when the inputs are at 0s, the output E0=LH and GS=0. It is assumed that prior to the operation of the keyboard, the keyboard has been reset by asserting LH at B7 with the execution of the instruction: out KRS(01H), 00h. The LH value of the B7-bit is an indication that none of the keys in the keyboard has been pressed down. When any of the keys of the keypad is pressed down, the b7-bit immediately goes to LL. Thus, the CPU can easily know whether a key has been pressed or not just by monitoring the value of the b7-bit. Say, the key-8 is pressed down. The column line provided by TR2 is shorted with the D7 line of the U27. The voltage at D7 of U27 becomes: 5V VEBTR2 (0.7V) = 4.3V, which is Logic-H. Because, the TR2 is ON, its collector voltage is very close to +5V (LH), which constitutes Bit-3 of the scan code. With the bit pattern as 10000000 at the inputs of U27, the output of U27 would be 111 (Q2Q3Q1). The EO-pin assumes LL and the GS-pin assumes LH. The activity of the EO signal triggers the 33mS-oneshot U26. The 33mS pulse width is intentionally chosen to allow the complete extinction of the denouncing pulses of the mechanical key, key-8. The inverted output of U26 clocks the GS-bit into the latch, U25 after 33mS time delay. This results in putting LL at B7-bit of the scan code. Thus, the scan code for the key-8 stands as: 00001000 (08h). At this moment, if the CPU reads the scan code out of U24, it will find a valid scan code by seeing LL at B7-bit.
6/Expt-13B
544
R8 3.3k TR1
R12 3.3k
+5V TR3
0V
17 15 13 11 8 B7 B6 B5 B4 B3
U24 74244
R9 3.3k 0V
R11 3.3k
R13 3.3k
U27 4532
+5V
5
+5V
R7 : 33k 11 + 3 4
EI
EO D7 D6 D5 D4 D3 D2 D1 GS D0 Q2 Q1 Q0
15
0V
74121
33m S
0 1 2 3 4 5 6 7
8 9 A B C D E F
: STP GO + REG DA AD
04 03 02 01 13 12 11 10
3
14 6 7 9
Reset Enable
CK D
R/
5 6
U25: 7474
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
3 5 7 9 12 14 14 18
Q/
1
RA1: 8x3.3k
WR/
U21 7432
0V
6 4 2
B2 B1 B0
1,19
OE/
IRQ
Read Enable
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
CS/
Jumper
DP0
20mS J3-26
NMI
PZC
B
J2-19
HRS MIN
Hr
SEC
Min
Sec
739abx
T12
00450 0044F 0044E Running HRS D3D4 MIN D5D6 SEC D7D8 BCD Time
T13
D3 00447 HRS D4 00446 D5 00445 MIN D6 00444 D7 00443 SEC D8 00442 Running CC Time
7-Seg Display
CCX8279 F000:FFB8
BCD2CC
F000:F47C
739abx
1. 2. 3. 4.
Initial BCD Time is entered into the indicated memory locations of T11 using the keyboard of the MicroTalk-8086 trainer. 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). At every 1-sec, the CPU updated the Running BCD Time and is converted to Running CC Time using ROM-based subroutine BCD2CC. 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 [..\[Link]]
; Converting MicroTalk-8086 into a 24-Hr Clock System: Dated: 8/1/2009 by Golam Mostafa START: nop mov cl, 00h ; counter L1: mov mov mov mov mov mov mov mov call mov mov or or call L3: jmp bx, 0000h ; Link ISRNMI with NMIITC WORD PTR [bx+08h], OFFSET ISRNMI WORD PTR [bx+0Ah], SEG ISRNMI bx, 0400h ax, WORD PTR [bx+74h] WORD PTR [bx+4Eh], ax al, BYTE PTR [bx+76h] BYTE PTR [bx+50h], al BCD2CC WORD PTR WORD PTR BYTE PTR BYTE PTR CCX8279 L3 ;Transfer Initial BCD Time from T11 into T12
L2:
[bx+48h], 0000h [bx+4Ah], 0000h [bx+44h], 80h ; place point [bx+46h], 80h ; xfering CCTIME into 8279
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 mov add daa cmp je mov jmp mov mov add daa cmp je mov jmp mov mov add daa cmp je mov jmp mov mov call mov mov or or call iret BCD2CC: mov mov mov call ret CCX8279:mov mov mov call ret cl, 00h ; counter Reset al, BYTE PTR [bx+4Eh] al, 01h al, 60h ISR3 BYTE PTR [bx+4Eh], al ISR6 BYTE PTR [bx+4Eh], 00h al, BYTE PTR [bx+4Fh] al, 01h al, 60h ISR4 BYTE PTR [bx+4Fh], al ISR6 BYTE PTR [bx+4Fh], 00h al, BYTE PTR [bx+50h] al, 01h al, 24h ISR5 BYTE PTR [bx+50h], al ISR6 WORD PTR [bx+4Eh], 0000h BYTE PTR [bx+50h], 00h BCD2CC WORD PTR WORD PTR BYTE PTR BYTE PTR CCX8279 [bx+48h], [bx+4Ah], [bx+44h], [bx+46h], 0000h 0000h 80h 80h
ISR3:
ISR4:
ISR5: ISR6:
di, 0F00h WORD PTR [di], 0F47Ch WORD PTR [di+02h], 0F000h DWORD PTR [di] di, 0F00h WORD PTR [di], 0FFB6h WORD PTR [di+02h], 0F000h DWORD PTR [di]
1/Expt-14A
MYCODE
ENDS END
START
1/Expt-14A
Experiment - 9
i.
mul
al, byte_data
ii. mul
ax, word_data
04FFF
: Multiplicand : Multiplier
r1r0
r7r6
--
r5''''r4''''
-Carry Carry
Product (R esult)
Multiplicand
Multiplier
Output
DSM
Inputs
Carry
01000
00000
559b
CSM
L1:
L2:
1/Expt-9
L2D: 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: r5r4 + C r5r4 jmp L3B L3D: al r3r2 ; we have : [r5r4 r3r2] for L3: [x1x0] x [y3y2] - 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 r5r4 ; we have : [r7r6 r5r4] for L4: [x3x2] x [y3y2] - now add the three components of r3r2 of L1, L2 and L3 mov ah, 00h ; ah-register will accumulate the carries [r3r2 + r3r2] al jc L5A jmp L5B L5A: ah + 01h ah L5B: al + r3r2 al jc L5C jmp L5D L5C: ah + 01 ah L5D: al r3r2 ; the value of ah-register will be added with r5r4 components - now add the three r5r4 components of L2, L3 and L4. mov cl, 00h; ; cl-register will accumulate the carries [r5r4 + ah ] al jc L6A jmp L6B L5A: cl + 01h cl L5B: al + r5r4 al jc L6C jmp L6D L5C: cl + 01 cl
L4:
L5:
L6:
2/Expt-9
L6D:
al + r5r4 al Jc L6E Jmp L6F cl + 01h cl al r5r4 ; the value of cl-register will be added with r7r6
- now add r7r6 with cl-register r7r6 + cl r7r6 - 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\[Link]. 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(); [Link][0] = r1r0; [Link][1] = r3r2; [Link][2] = r5r4; [Link][3] = r7r6; printf("\n%lx ", ([Link])); getch(); }
3/Expt-9
void bmult() { // x3x2 = 12; x1x0 = 34h, y3y2 =AB; y1y0=CDh BM: asm asm asm L1A: asm asm L1B: asm asm asm L1C: asm asm L1D: asm asm asm asm asm L2A: asm asm L2B: asm asm asm L2C: asm asm L2D: asm asm asm asm asm L3A: asm asm L3B: asm asm asm L3C: asm asm L3D: asm asm asm asm asm L4A: asm asm L4B: asm mov mov mov add jc dec jnz jmp inc jmp mov mov mov mov mov add jc dec jnz jmp inc jmp mov mov mov mov mov add jc dec jnz jmp inc jmp mov mov mov mov mov add jc dec bl, 0x00 al, 0x00 ah, 0x34 // y1y0 ; y3y2y1y0=1234h al, 0xCD // x1x0; X3x2x1x0=ABCDh L1C ah L1A L1D bl L1B r1r0, al // r3r2_1, r1r0 r3r2_1, bl // 29A4h bl, 0x00 al, 0x00 ah, 0x34 // y1y0; y3y2y1y0=1234 al, 0xAB //x3x2 ; x3x2x1x0=ABCD L2C ah L2A L2D bl L2B r3r2_2, al // r5r4_2, r3r2_2 r5r4_2, bl // 22BCh bl, 0x00 al, 0x00 ah, 0x12 // y3y2; y3y2y1y0 = 1234h al, 0xCD // x1x0l x3x2x1x0=ABCDh L3C ah L3A L3D bl //r5r4_3 L3B r3r2_3, al // r5r4_3, r3r2_3 r5r4_3, bl // 0E6Ah bl, 0x00 al, 0x00 ah, 0x12 // y3y2 ; y3y2y1y0=1234h al, 0xAB // x3x2; x3x2x1x0=ABCDh L4C ah
4/Expt-9
asm asm L4C: asm asm L4D: asm asm asm asm asm asm asm asm L5A: asm L5B: asm asm asm asm L5C: asm L5D: asm asm asm asm asm asm asm L6A: asm L6B: asm asm asm asm L6C: asm L6D: asm asm asm asm L6E: asm L6F: asm L7: asm } L6: L5:
jnz jmp inc jmp mov mov mov mov mov add jc jmp inc mov add jc jmp inc mov mov mov mov add jc jmp inc mov add jc jmp inc mov add jc jmp inc mov add
L4A L4D bl //r7r6 L4B r5r4_4, al // r7r6, r5r4_4 r7r6, bl //0C06h ah, 0x00 bl, r3r2_1 al, r3r2_2 al, bl L5A L5B ah bl, r3r2_3 al, bl L5C L5D ah r3r2, al // r3r2=5Ah; al, ah ah, 0x00 bl, r5r4_2 al, bl L6A L6B ah bl, r5r4_3 al, bl L6C L6D ah bl, r5r4_4 al, bl L6E L6F ah r5r4, al r7r6, ah
5. Assemble the program: [Link] 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: [Link]] 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: L1: nop al y1y0 al x BYTE PTR [1402h] al r1r0 ah r3r2 al y1y0 al x BYTE PTR [1403h] al + r3r2 r3r2 jnc L2A inc ah ah r5r4 al y3y2 al x BYTE PTR [1402h] al + r3r2 r3r2 jnc L3A inc ah ah + r5r4 r5r4 jnc L4 r7r6 + 01h r7r6 al y3y2 al x BYTE PTR [1403h] al + r5r4 r5r4 jnc L4A inc ah ah + r7r6 r7r6 ; (x1x0) x (y1y0)
L2:
; (x3x2) x (y1y0)
L2A: L3:
; (x1x0) x (y3y2)
L3A:
L4:
; (x3x2) x (y3y2)
L4A:
6/Expt-9
Product Advertisement
Microprocessor/Microcontroller Learning/Development Systems
(Accompanied with Rich Documentation)
Designed to Meet the Learning and Research Needs of the Students, Teachers, Scientists, Technocrats and Engineers MicroTalk-8085 MicroTalk-8086
I88, D90, B92, M05
MicroTalk-80286
I96, D99, B99, M?
MicroTalk-8x51
I93, D95, B99, M05
16-Bit Protected Virtual Address Mode Microprocessor Learning /Dev System using Intel 80286 High Perfomance Arch.
8-Bit Microcontroller Learning /Dev System using Intel /Atmel 8x51 Architecture
MicroTalk-80386
I02, D03, B?, M?
32-Bit Protected Virtual Address Mode Microprocessor Learning /Dev System using Intel 80386DX High Perfomance Architecture
Users List: BUET, KUET, RUET, DUET, ITU, DU, JU, AUST, IUBAT, QU, AIUB, AUB,
Mohila Polytechnic, Ctg. Polytechnic, Zamuna Fertilizer, Cybernetic Systems