6/Expt-1 Table-A
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’].
LED0 LED7
LED8 LED15
Task-1.5 Execute the program of Table-B for the following set of data. Check that the LEDs
indicate the correct results and the memory location 04000h also contain the correct result.
Data1 Data2 Expected Result LED Status (LED7-LED0) Memory Content (03012h)
ABh 10h BBh 1011 1011 BBh
67h 89h F0h 1111 0000 F0h
FF FF 01FE 1111 1110 FE (01 is missing!)
Task-1.6 Working Principles of Number Addition Program of Table-B
The diagram of Fig-1.5 depicts the ‘Signal Flow’ structure for the problem of adding two numbers 2Ch and 47h of Task-1.4.
8/Expt-1
03000 03010 2C 043FF DSM CPU D ALU al LEDPIO(U23) LD0 LD7 610 03011 47 al ah Result 73 03012 Result D PA R ( 36 00h ) CR ( 360 6h )Figure-1.5: Signal Flow Diagram of the Addition Problem of Task-1.4
Working Principles: The CPU brings the data1 (2Ch) into its al-register. It then brings data2 (47h) into its
ah-register. The contents of the al and ah registers are added in the ALU of the 8086 CPU. The result (73h) is be shown in the output LEDs: LD7-LD0. In Fig-1A.1, we see that the LEDs are connected with the CPU via the interface controller LEDPIO (U23: 8255). Thus, we may say that the CPU sends the result from its al- register into the LEDPIO and from PIO the result automatically goes into the LEDs. The result is also saved at memory location: 03012h of the DSM.
Task-1.7 Getting Machine Codes
In this task, we will get familiar with the procedures of getting the machine codes for the number addition program of Table-B of Task-1.4. We shall use MASM (Macro Assembler) program and the IBM-PC to obtain the machine codes for the assembly instructions of Table-B of Task-1.4. The procedures are:
(a) Check that the D drive of your computer contains the directory (Folder)) named as MTK8086 and then goto Step-b. If the directory doesn’t exit, then copy the folder MTK8086 from the MicroTalkCD into the D drive. The following files (Folders) are the essential components for learning 8086 Assembly Programming.
Sno. File Name Purpose
1 MTK86COM1 Serial Communication Interface for MicroTalk-8086 Trainer 2 LINK.EXE To create relocatable *.EXE file from *.OBJ file
3 LOD186.EXE To create ‘Absolute (*.ABS)’ file from *.obj file 4 MASM.EXE To create *.LST and *.OBJ files form *.ASM file
5 EDIT.EXE To create Assembly Program (Source Code) for 80x86 MPUs 6 EXER <DIR> A Working Directory
(b) Boot the IBM-PC in WIN98/WINXP and then click on the Command Prompt menu by
following the path: Start → All Programs → Accessories → Command Prompt.
(c) Bring the IBM-PC in the following DOS path:
The procedures:
1. Type cd \ and then press enter key. The screen shows: c:>_ 2. Type d: and then press enter key. The screen shows: d:>_
3. Type cd mtk8086 and then press enter key. The screen shows: d:\mtk8086>_ 4. Press Alt-key and then hit Enter-key to enlarge the screen.
(c) Type EDIT at the cursor position of the above DOS prompt. Press Enter key. As a result, a screen appears called DOS Screen will appear.
(d) Type only the labels and the assembly instructions of Table-B of Task-1.4.
(e) Save the screen (what you have typed in the screen) with the file name of: P14.asm. Save the file as: d:\mtk8086\P14.asm
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save As...’ from the menu using the arrow keys. 3. Now type the file name: P14.asm and then press Enter key.
(f) Type the following 3 lines (called Assembler Statements) at the top of your program.
MYCODE SEGMENT
ASSUME cs: MYCODE
ORG 1000h
(g) Type the following assembler statements at the end of your assembly program.
MYCODE ENDS
END START
(h) Update your file (P14.asm) in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Save’ from the menu using the arrow keys. 3. Now press Enter key.
(i) Now leave the screen and come back to the DOS prompt in the following ways:
The Procedures:
1. Press Alt key and then release. And then press Enter key.
2. Choose ‘Exit’ from the menu using the arrow keys and then press Enter key. (j) Type cls and press Enter key for clearing up the screen.
(k) Now, convert the source codes of your program d:\mtk8086\P14.asm into machine codes in the following ways: This is known as assembling.
The Procedures:
1. Type MASM at the cursor position of the DOS prompt. Press Enter key. 2. Type P14.asm (assembly) and press Enter key
3. Type P14.obj (object) and then Press Enter key 4. Type P14.lst (list) and press Enter key. 5. Press Enter key
(l) You are back to the DOS prompt. Your assembly program has already been converted into machine codes and has been saved in the path: d:\mtk8086\P14.lst. Show the error messages (if any) to the teacher. Remember that there should not be any error in the program. If there are errors, take help from teacher and correct these and go to Step-k.
(m) Open the P14.lst file in the following ways to see its contents:
The Procedures:
10/Expt-1
4. Use ‘tab’ key and ‘arrow’ key to choose the file, P14.lst from the menu. Press Enter. 5. Now the machine codes of your program are in the screen and they look like:
MYCODE SEGMENT
ASSUME cs:MYCODE
1000 ORG 1000h
1000 90 START: nop
1001 BB 3000 L1: mov bx, 3000h
1004 8A 47 10 mov al, BYTE PTR [bx+10h] 1007 8A 67 11 mov ah, BYTE PTR [bx+11h] 100A 02 C4 L2: add al, ah
100C 88 87 1000 L3: mov BYTE PTR [bx+1000h], al 1010 8A E0 L4: mov ah, al 1012 B0 80 mov al, 80h 1014 BA 3606 mov dx, 3606h 1017 EE out dx, al 1018 8A C4 L5: mov al, ah 101A BA 3600 mov dx, 3600h 101D EE out dx, al 101E F4 L6: hlt 101F MYCODE ENDS END START
(n) Pick up the machine codes of your program from the screen. Compare these codes with the machine codes of Table-B of Task-1.4. Write down the codes where they differ.
(o) Power OFF and then ON of the MicroTalk-8086 trainer and then press the RST key. (p) The 7-segmnet display of the trainer shows the following prompt message:
8086 CPU
(q) Use keyboard of the trainer and enter the machine codes of Step-n (P14.lst) in the CSM starting at memory location. 0000:1000. Take help of the lab teacher to know the ways of entering the differing codes in the CSM.
(r) Enter the data 2Ch at RAM location 0000:3010 and 47h at RAM location 0000:3011 of the data segment memory.
(s) Execute the program at location: 0000:1000
(t) Observe that the LED7 – LED0 show the correct result of 73h (0111 0011).
(u) The Task-1.7 is well done.
Task-1.8 In this Task, we will transfer the machine codes of the Step-n of Task-1.7 from the
IBM-PC to the CSM of the MicroTalk-8086 trainer. This method is known as Down Loading. To do it, we will be using the COM1 port of the IBM-PC. This method saves a lot of time while developing a large program. We do not need to enter the data and codes manually in the memory locations. The procedures are:
1. Power down the MicroTalk-8086 trainer. Connect the serial cable of the trainer with the COM1 port of the IBM-PC.