LAB MANUAL Lab
1 List of Practical’s Lab No. LAB 1 LAB 2 LAB 3 LAB 4
LAB 5 LAB 6 LAB 7 LAB 8
LAB 9 LAB 10 LAB 11 LAB 12 LAB 13
Topic Part-I: Debug Utility To study and use DEBUG use DEBUG utility DEBUG utility To study more commands of DEBUG To study more DEBUG more DEBUG commands. To study more DEBUG more DEBUG commands Part-II: Assembly Language Programming To study and use the arithmetic instructions To study and use the BCD arithmetic. To study string operations. To study the data conversions in assembly language Part-III: Using the SK-80386 Trainer To study SK-80386N trainer. To study machine language programming on trainer To study I/O interfacing and controlling of stepper motor Mini Project: Multiplexing 8 alphanumeric displays using the trainer Mini Project: Continued
Using Debug-I OBJECTIVES
To study and use DEBUG utility. Monitor a program’s execution for debugging purposes. Examine and alter register and memory contents. INTRODUCTION
Microprocessor Microprocessor & Assembly Language Debug is part of ‘Disk Operating System’ (DOS) which is used to enter an assembly language program into PC, execute the program, examine the results and debug any errors. In this lab you will be familiarized with debug environment and commands to examine or modify the MPU’s internal registers. Before using debug make sure that you are in DOS shell. In Windows follow these steps: 1.
Start > Run > CMD (Press En Enter)
2.
debug at the command prompt and record your observations. Type debug at _____________________________________________________________________
3.
Type q at the appeared prompt to quit. _____________________________________________________________________
The first command we will use in debug is called ‘Register’ command. Upon execution of register command the content of all the internal registers of MPU’s are displayed on the screen. 4.
After step 1, type r or r or R R to view the register dump. First line: ____________________________________ ___________________________________________________________ _______________________ Second line: ___________________________________ _________________________________________________________ ______________________ Third line: __________________________________ ___________________________________________________________ _________________________
5.
Writ Wr itee the the cont conten ents ts of the the gen gener eral al purp purpos osee reg regis iste ters rs in the the fir first st line line.. _____________________________________________________________________
6.
Write rite the conte ontent ntss of of the the seg segment ment regi egiste sters. _____________________________________________________________________
Note: Don’t try to change the contents of the segment registers. These have been set by the operating system.
Modifying Register Contents:
7.
Type ‘r’ ‘r’ followed followed by a register name. E.g. Type -r - r ax What are the contents of AX? _____________________________________________________________________
8.
Ente nter a new new valu valuee for AX at the colo colon n prom promp pt. : 12AB Type ‘r’ again to verify the contents of AX. What is the new value in the AX? _____________________________________________________________________
9.
Try the thesse va value lues and and reco record rd your our obs obser erva vati tio ons: ns: -R DX
FICT, BUITEMS
Microprocessor Microprocessor & Assembly Language Debug is part of ‘Disk Operating System’ (DOS) which is used to enter an assembly language program into PC, execute the program, examine the results and debug any errors. In this lab you will be familiarized with debug environment and commands to examine or modify the MPU’s internal registers. Before using debug make sure that you are in DOS shell. In Windows follow these steps: 1.
Start > Run > CMD (Press En Enter)
2.
debug at the command prompt and record your observations. Type debug at _____________________________________________________________________
3.
Type q at the appeared prompt to quit. _____________________________________________________________________
The first command we will use in debug is called ‘Register’ command. Upon execution of register command the content of all the internal registers of MPU’s are displayed on the screen. 4.
After step 1, type r or r or R R to view the register dump. First line: ____________________________________ ___________________________________________________________ _______________________ Second line: ___________________________________ _________________________________________________________ ______________________ Third line: __________________________________ ___________________________________________________________ _________________________
5.
Writ Wr itee the the cont conten ents ts of the the gen gener eral al purp purpos osee reg regis iste ters rs in the the fir first st line line.. _____________________________________________________________________
6.
Write rite the conte ontent ntss of of the the seg segment ment regi egiste sters. _____________________________________________________________________
Note: Don’t try to change the contents of the segment registers. These have been set by the operating system.
Modifying Register Contents:
7.
Type ‘r’ ‘r’ followed followed by a register name. E.g. Type -r - r ax What are the contents of AX? _____________________________________________________________________
8.
Ente nter a new new valu valuee for AX at the colo colon n prom promp pt. : 12AB Type ‘r’ again to verify the contents of AX. What is the new value in the AX? _____________________________________________________________________
9.
Try the thesse va value lues and and reco record rd your our obs obser erva vati tio ons: ns: -R DX
FICT, BUITEMS
Microprocessor Microprocessor & Assembly Language DX 0000 : FF _____________________________________________________________________
-R DX DX 00FF : 12345 _____________________________________________________________________
-R DX DX 00FF : NAV _____________________________________________________________________
-R DH _____________________________________________________________________
Modifying Flags
In addition to modify the internal register contents, debug can also be used to modify MPU flags. Notations used for displaying the status flags are given in table below: Flag
Meaning
Set
Reset
OF
Overflow
OV
NV
DF
Direction
DN
UP
IF
Interrupt
EI
DI
SF
Sign
NG
PL
ZF
Zero
ZR
NZ
AF
Auxiliary Carry
AC
NA
PF
Parity
PE
PO
CF
Carry
CY
NC
FICT, BUITEMS
Microprocessor Microprocessor & Assembly Language
10. To show current flag status type: -R F Name the flags which are set: _____________________________________________________________________
To modify flags just type in new states of all flags separated by spaces and depress enter key. Note that the new flag states can be entered in any order. What will you enter to set ‘Carry’ and ‘Zero’ flag? _____________________________________________________________________ How would you use register command to set the parity flag to even parity? _____________________________________________________________________
CONCLUSION
What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
FICT, BUITEMS
Microprocessor & Assembly Language Lab: 02
Using Debug-II
Lab
2
INTRODUCTION:
In the previous lab we were dealing with internal registers of MPU. This lab is focused on examining and modifying the memory contents. There are six commands which are used to examine or modify the contents of storage locations in memory. These commands are Dump, Enter, Fill, Move, Compare and Search. In this lab we will discuss Dump command. The DUMP Command: The DUMP (D) command allows us to examine the contents of a memory location or a block of consecutive memory locations. On the debug prompt, type:
D
This will cause 128 consecutive bytes starting at offset 0100H from the current value in DS to be displayed. Note that 16 bytes of data are displayed per line, and only the address of the first byte is shown at the left. What is the Physical Address of the first location? ____________________________________________________________________________ What type of information is displayed in the third column? ____________________________________________________________________________
The DUMP command can also be issued by specifying the starting address of the memory block. As we have discussed in class that physical address is combination of base address stored in one of segment registers and offset address stored in IP, DI, SI, BP etc. to dump the memory contents you can enter: D DS: 100
or: D 1342: 100
or: D 100
Note that if no segment base register is specified, then data segment will be taken as default.
What happens if ‘D’ is entered repeatedly? ____________________________________________________________________________
FICT, BUITEMS
Microprocessor & Assembly Language Lab: 02 You can also specify the size of block by providing a third parameter in DUMP command. For example:
D DS: 200 201
What is result of above command? __________________________________________________________ What would be the command to display the contents of 32 bytes of memory located at offset 0300H in the current data segment? __________________________________________________________ Is it possible that the memory contents of segments other than data segment (like code, stack etc) can be displayed? If yes then what would the parameters? __________________________________________________________ __________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 03
Lab
Using Debug-III
3
The ENTER Command Enter command can be used to modify the memory contents. The format of Enter command is given below:
E
[Address]
[List]
The address part of the Enter command is entered in the same manner as that of Dump command. The List that follows the address is the data that gets loaded into memory. For example, following command will load five consecutive bytes to memory locations starting at address DS: 100 with the value ‘AA’? E
DS: 100
AA
AA
AA
AA
AA
You can verify the results of above command by issuing Dump command: D
DS: 100
104
Note that we have also given the ending address of the memory block which is to be dumped. Instead of loading a list of data into memory, we can also use Enter command to modify the memory locations one by one. This can be done if you don’t provide the List in Enter command as shown below: E
DS: 200
(enter)
Above command causes the value at DS: 200 to be displayed. Note that the cursor will be blinking at the end of the data value. At this point you can either enter new value which will replace the existing data or you can depress the return key to terminate the Enter command. Doing this will not affect the existing data in memory. After executing Enter command without providing the List, depress ‘Space’ key. What will happen? ______________________________________________________________________ Start a data entry sequence by examining the contents of address DS: 100 and then, without entering new data, depress the “– “key. What happens? ______________________________________________________________________
In addition to above methods of modifying memory contents, you can also enter ASCII data using Enter command. E
DS: 300
“YOUR_NAME”
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 03
The above command will cause the ASCII data for letters of your name to be stored in memory. The FILL Command: Fill command is used to modify the contents of a large block of memory. It would be time consuming to use Enter command to modify a large memory block since you have to modify each location one by one. To clarify this point, let’s assume that you have to enter the value ‘BB’ at fifty consecutive memory locations starting at address DS: 400. If you choose Enter command for this purpose then you will be entering ‘BB’ fifty times. Fortunately Fill command is available in Debug to help us. The format of Fill command is shown below:
F
[Starting Address]
[Ending Address]
[List]
The above problem can be solved easily using Fill command: F
400
431
BB
You can try Enter command to notice the difference between Fill and Enter commands. The MOVE Command:
In debug, the Move command signifies a ‘Copy-Paste’ operation. Move command can be used to copy a block of data from memory to another part. The format of Move command is given below: M
[Starting Address]
[Ending Address]
[Destination Address]
Fill each storage location in the block of memory from addresses DS: 600 through DS: 61F with the value 11. Then copy this block of data to a destination block starting at DS: 660. Verify that the block move is correctly done. ______________________________________________________________________ ______________________________________________________________________ The COMPARE Command: Sometime it is required to compare two blocks of memory to determine if they are same or not. Such type of comparison can be done by using Compare command. The format of Compare command is given below:
C
[Starting Address]
[Ending Address]
[Destination Address]
For example, to verify the correct movement of block of data we moved previously, following command sequence can be issued in Debug: C
600
61F
660
During the execution of above command, the contents of memory location 600 will be compared to 660, 601 to 661 and so on. Each time unequal elements are found, the address and contents of that byte in both blocks will be displayed. No address will be displayed if the two data are same. You can enter a destination address other than 660 in above command to understand this point. The Search Command:
The Search command is used to scan through a block of data in memory to determine whether or not it contains specific value. The general form of Search command is given below: S
[Starting Address]
[Ending Address]
[List]
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 03
To understand the use of Search command, type following command sequence: F S
100 100
16F 17F
22 33
33
How many memory locations contained 33?
What are the addresses? ______________________________________________________________________ ______________________________________________________________________
Hexadecimal Addition and Subtraction: Debug has ability to add and subtract hexadecimal numbers. Both operations are performed with a single command known as the ‘Hexadecimal’ command. The format of Hexadecimal command is shown below:
H
[Num 1]
[Num 2]
When executed, both sum and differences of Num 1 and Num 2 are displayed on the screen, sum being displayed first. Using Hexadecimal command, write down the command sequence you will issue to calculate the Physical Address of next instruction to be executed? ______________________________________________________________________
Find the negative of 6H using Hexadecimal command. ______________________________________________________________________
EXERCIES: Write a sequence of commands that will fill the first six storage locations starting at address CS: 100 with 11, the second six with 22, the third six with 33, the fourth six with 44, and the fifth six with 55; change the contents of storage locations CS: 105 and CS: 113 to FF; display the first 30 bytes of memory starting at CS: 100; and then use a search command on this 30 byte block of memory to find those storage locations that contain FF.
Name: ___________________________
Roll No.:_________________________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Date: ____________________________
Lab: 03
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Using Debug-IV
Lab: 04
Lab
4
Entering and Running Programs
Use Assemble command –A to enter Assembly Language instructions into memory. Starting address will be the offset into the code segment by default. Type: -A 100 0B12:0100
MOV AX,1
0B12:0103
MOV BX,2
0B12:0106
MOV CX,3
0B12:0109
ADD AX,BX
0B12:010B
ADD AX,BX
0B12:010D
INT 3
Note: Do not assemble beginning at an offset lower than 0100, as the first 256 bytes (100H) are reserved by DOS.Difference between Debug programming and Assembly programming are that numbers are hexadecimal by default in Debug, whereas in Assembly an H had to be appended at the end of a number to enter it in hexadecimal. To view the machine code, use the Unassemble command U in any one of the following ways: -U -U -U L -U To view the 32 bytes beginning at CS:IP
Type the following and give your observations: -U 100 10D _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ To execute the instructions, use the Go command G, as: -G <=staring address>
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 04
If no addresses are given then execution starts at CS:IP and continues till a breakpoint e.g. INT 3, is reached. -R _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Then type: -G _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ To trace through the execution of a program, use the trace command T as: -T <=starting address> Type: -T=100 2 _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ -T 3 _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
CONCLUSION
What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________ Signature of Instructor: ______________ ____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 04
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Assembly Language Programming-I
Lab: 05
Lab
5
OBJECT To study and use the arithmetic instructions. THEORY ADD (unsigned addition) The format of the ADD instruction is: ADD destination, source
; destination = destination + source
The destination operand can be a register or a memory location. The source operand can be a register, a memory location, or an immediate operand. Destination and source both cannot be memory locations at the same time Any of the flags ZF, SF, AF, CF, OR PF bits can b e changed after an arithmetic or
logic operation ADC (add with carry) ADC destination, source
; destination = destination + source + carry flag
SUB (unsigned subtraction) SUB destination, source ; destination = destination −source SBB (subtraction with borrow) SBB destination, source ; destination = destination −source −carry flag EXERCISE & OBSERVATIONS 1. Open Notepad and write down the following code:
TITLE ADDITION OF 5 BYTES .MODEL TINY
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language .DATA COUNT DATA1 SUM DW .CODE .STARTUP MOV MOV MOV AGAIN: JNC INC LOC1: DEC JNZ MOV .EXIT END
EQU DB ?
Lab: 05
5 126,233,189,67,57
CX,COUNT SI,OFFSET DATA1 AX,0 ADD AL,[SI] LOC1 AH INC SI CX AGAIN SUM,AX
2. Save the file with some name e.g. myfile.asm 3. Assemble the file and link with ML.exe program available with MASM 6.11 version or higher using: path:\>ml myfile.asm
4. Run the exe file that is generated. 5. Open the exe file in DEBUG and trace it to have a closer look at the execution.
PRACTICE EXERCISES 1. Rewrite the same program using full-segment definitions. 2. Write an assembly program that shows the use of ADC, SUB, and SBB instructions. CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 05
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Assembly Language Programming-II
Lab: 06
Lab
6
OBJECT To study and use the BCD arithmetic instructions. EXERCISE & OBSERVATIONS 1. Open Notepad and write down the following code: TITLE
BCD Addition of two 2-digit numbers
.MODEL TINY .DATA NUM1 DB ? NUM2 DB ? RESULT DB ? .CODE .STARTUP MOV BX,2 AGAIN: MOV AH,01 ;Read the Keyboard INT 21H SUB AL,30H ;convert from ASCII to BCD DEC BX JZ CONT MOV CL,4 SHL AL,CL MOV DL,AL JMP AGAIN ;Repeat for 2 digits CONT: ADD AL,DL ;2 digit packed BCD no. is in AL MOV NUM2,AL MOV NUM1,00010101B ADD AL,NUM1 DAA
;BCD addition of two nos.
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language MOV RESULT,AL
Lab: 06
;Store the result in memory location
; Now to display the packed BCD result in AL to screen MOV MOV SHR ADD MOV INT
DL,RESULT CL,4 DL,CL DL,30H ;Convert to ASCII AH,2 ;Display to screen DOS function 21H ;DOS function call
; Display the other digit MOV DL,RESULT AND DL,0FH ;Clear off the left most 4 bits ADD DL,30H INT 21H .EXIT END
2. Save the file with some name e.g. bcd.asm 3. Run the .com file that is generated. 4. Give a 2-digit input and monitor the output to verify the addition of the given number with 15. Note: The result should be within 2 digits.
PRACTICE EXERCISES 1. Write a program to use BCD subtraction. CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 06
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Assembly Language Programming-III
Lab: 07
Lab
7
OBJECT To study string operations. THEORY LODS, STOS, MOVS, SCAS, COMPS. PROCEDURE 1. Open Notepad and write down the following code: TITLE
String input and output by Byte
.model small .data MES DB 'Please enter your name',13,10 ;13 for carriage return, 10 for line feed MES2 DB 13,10,'You typed: $' BUF DB 256 DUP (?) ;to store the string typed by the user .code .startup MOV AX,DS MOV ES,AX
;Make DS and ES point to same data segment ;because STOS uses ES:DI and LODS uses DS:SI
CLD
;select increment mode for SI and DI
MOV SI,OFFSET MES AGAIN: LODSB MOV DL,AL MOV AH,02H INT 21H ;to display the message; can also use dos ;function call AH=09H CMP AL,10
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 07
JNE AGAIN ;now to take input MOV DI,OFFSET BUF MOV AH,1 AGAIN2: INT 21H STOSB CMP AL,13 JNE AGAIN2 ;if enter is pressed then stop MOV MOV MOV INT MOV INT
BYTE PTR [DI-1],'$' AH,9 DX,OFFSET MES2 21H DX,OFFSET BUF 21H
.exit end
2. Save the file with some name e.g. string.asm 3. Run the .exe file that is generated, give inputs and monitor the output.
OBSERVATIONS Paste the output of the program here.
EXERCISES 1. Write a program to use SCASB, CMPSB and MOVSB instructions. CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 07
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Assembly Language Programming-IV
Lab: 08
Lab
8
OBJECT To study data conversions THEORY So far we have discussed the arithmetic operations i.e. ADD, ADC, SUB, SBB, MUL, IMUL, DIV, IDIV, and other logic operations, and we have applied these instructions on hard coded data. But what is required is that data must be taken as input from the user as integers, and results given back again as integers. But we know that when INT 21H is called with AH=01, 06, 07, and a few other values, then we get the character from the keyboard in ASCII form. Now the conversion from ASCII to binary has to be done for multi-digit input as well. In today’s lab session, we shall study a procedure that co nverts the given data from ASCII to binary and another procedure that converts from binary to ASCII before the data can be displayed to the standard output device. PROCEDURE 1. Open Notepad and write down the following code: ;A program that reads two decimal numbers from the keyboard and ;stores the binary values at NUM1 and NUM2 .model small .data NUM1 DW ? NUM2 DW ? SUM DW ? DIFF DW ? PROD DD ? .code .startup CALL READNCONVERT MOV NUM1, AX CALL NEXTLINE
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language CALL MOV CALL ADD MOV CALL CALL MOV SUB MOV CALL CALL MOV MUL MOV MOV CALL
Lab: 08
READNCONVERT NUM2, AX NEXTLINE AX, NUM1 ;add num1 and num2 SUM, AX CONVERTNDISPLAY NEXTLINE AX, NUM1 AX, NUM2 DIFF, AX CONVERTNDISPLAY NEXTLINE AX, NUM1 NUM2 WORD PTR PROD, AX WORD PTR PROD+1, DX CONVERTNDISPLAY
.exit ;Using USES directive ;automatic push of BX of them at the end of registers and thereby
with the procedure definition below makes and CX registers to stack, and automatic ;pop procedure. The procedure will use ;these overwrite the previous values .
READNCONVERT PROC MOV CX, 10 MOV BX, 0
NEAR
NEXT: MOV INT
;read key with echo ;the input character will be in AL
AH, 1 21H
CMP AL, '0' JB LAST CMP AL, '9' JA LAST ;above 4 instructions was not a digit SUB AL,'0' MOV AH, 0 PUSH AX MOV AX, BX MUL CX MOV BX, AX POP AX ADD BX, AX JMP NEXT LAST: MOV RET
USES
BX CX
jump to the end of procedure if the key ;typed ;convert to binary of the digit ;now the binary digit is in AX
;multiply previous digit by 10
;and add to the current digit ;input next digit
AX, BX
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
READNCONVERT
Lab: 08
ENDP
CONVERTNDISPLAY PROC NEAR USES BX CX DX MOV BX, 10 ;we will use divide by 10 repeatedly to separate MOV CX, 0 ;the digits in the number to be displayed AGAIN: MOV DX, 0 DIV BX ;divide DX-AX by BX so quotient in AX & remainder in DX PUSH DX ;save remainder INC CX CMP AX, 0 ;if quotient is zero JNE AGAIN MOV AH, 02 AGAIN2: POP DX ADD DL, 30H INT 21H LOOP AGAIN2 RET CONVERTNDISPLAY ENDP NEXTLINE MOV MOV INT MOV INT RET NEXTLINE
PROC NEAR AH,2 DL, 0AH 21H DL, 0DH 21H
;now display each digit in ASCII form
USES
AX ;line feed ;carriage return
ENDP
End
2. Save the file with some name e.g. convert.asm 3. Run the .exe file that is generated, give inputs and monitor the output.
OBSERVATIONS Paste the output of the program here.
EXERCISES 1. Use .LISTALL directive in start and generate the list file. View the list file in notepad and paste it. 2. Use .repeat, .if , etc. directives in the above program wherever applicable and rewrite it. ____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 08
3. Use division also. CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 08
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
SK-80386 Trainer-I
Lab: 09
Lab
9
OBJECT To study the SK-80386 trainer. THEORY
The SK-80386N microcomputer trainer is a microprocessor controlled educational system, based on Intel 80386 microprocessor. It has been specifically designed and manufactured for training engineers in designing, use and maintenance of microprocessor systems. It is an excellent support for programming in Assembly. It helps studying microprocessor system programming, hardware structure, memories, and interfaces to external devices. Trainer Specifications:
The SK-80386N trainer board contains all the necessary components for the study of Microprocessor based systems. A brief description of the components and their technical characteristics is given in the following table. Component
Specification
CPU ROM
80386 / 8032 (Dual CPU) 128 KBYTE (27C256) USER: 64KBYTE Monitor: 64KBYTE 128KBYTE (62256) 2 Ports (8251) SIO-1 RS-232C SIO-2 RS-232C, RS-422 Four 16Bit Ports (8255) PPI-2, PPI-3 Three 8Bit Ports (8255) CENTRONICS (PPI 8255) 16Bit, 3 Channels (8253) Address, Data, Control, I/O Selector 3 Color 8 x 8 Matrix 1.8 Deg. / Step (200 Steps) 168 x 64 LCD with Backlight 28 Keys Input: 110 / 220V
RAM Serial Port
Parallel Port
Printer Port Counter / Timer External I/O Bus Dot Matrix Step Motor Display Keypad Power Supply
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 09
Output: +12V 1A / -12V 0.75A / +5V 2A
Memory Unit:
Memory includes ROM, RAM, and user expansion area. The overall address range in realmode is from 00000H to FFFFFH. The Trainer only uses a small subset of this potential range of memory. The Memory Map is given in the following table. Addresses
Description
00000 000FF 00100 004FF 01000 (100:0000) 1FFFF 20000 3FFFF 40000 4FFFF 50000 5FFFF 60000 6FFFF
Interrupt Vector Table Stack Area
RAM BANK 0
Serial Download Program Open
OPEN
User ROM
ROM BANK 0
Open
OPEN
Serial Monitor Program
ROM BANK 6
I/O Space:
The following table shows the available I/O ranges in SK-80386N. Addresses 0020 0024
LSB PPI-1 PORT_A
MSB
Remarks 8255 P I/O EXTERNAL
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 09
Keypad:
There are two keypads in SK-80386N. One is for entering, verifying and executing a program (called Operator Keypad), and the other is for entering numeric values for any running program (called HEX Keypad). Operator Keypad The Operator Keypad consists of 28 keys (7 x 4). The individual position of each key is shown in the following figure.
RES
NMI
IRQ
C PRN
D MOV
E FILL
F
GO
REG
TRC
8 IB
9 IW
A ID
B
<
>
F1
4 OB
5 OW
6 OD
7
:
,
ENT
0 EDIT
1 CRT
2 LCD
3
Key Functions
The brief operation of each key is given below.
Key RES NMI
Operation System Reset. Non Mask able Interrupt
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language IRQ GO REG TRACE < > F1 : , ENT PRN MOV FILL IB IW ID OB OW OD EDIT CRT LCD O-F
Lab: 09
Software Interrupt To execute a program from CS:IP address To check and correct register contents Invokes Step-by-Step program execution from CS:IP address Backspace Space Shows the built-in program names and addresses Colon Comma Enter Key (Carriage Return) To Print to printer attached to Centronics Port To copy a memory block To fill a memory block Input a byte from the specified port address Input a word from the specified port address Input a Double word from specified port address Output a Byte to specified port address Output a Word to specified port address Output a Double word to specified port address To check and correct contents of a memory location CRT Mode, (when connected with a PC) LCD Mode, (to work on trainer) To enter numeric values
CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 09
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 10
SK-80386 Trainer-II
Lab
10
OBJECT To study the machine language programming on the trainer. THEORY In this lab session, we will learn to operate SK-80386N in LCD mode. SK-80386N can be operated in two modes, LCD and CRT. LCD mode means that there is no PC connected with the trainer and user will be using ‘Operator Keypad’ to enter, verify and execute programs. PROCEDURE When the power is turned ON, following message appears on the LCD. Meanwhile ‘386’ appears on the dot matrix. In order to operate SK-80386N in LCD mode, press ‘2’ on the operator keypad.
Pressing ‘2’ on the operator keypad, clears ‘386’ on the dot matrix and the following screen appears on the LCD.
SYSTEMKIT SK-80386 Ver 1.2
1:CRT
2:LCD
TUTOR MODE
Press Enter To Start __
SK-80386N is now in LCD mode. ‘SK-80386\>’ prompt appears on the LCD.
________________________________________________________________________________ _ 33 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language
Lab: 10
SK-80386 \>__
Running Demo Programs
Press F1 to check the built in ‘Demo’ programs. Pressing F1 shows following LCD screen: Demo Program Addresses 6000:130=Dot matrix 6000:140=LED 6000:150=Button 6000:160=Step Motor 6000:170=EXT.PPI Press ENT to return__
You can execute any demo program from this list. For example if you want to execute ‘Dot Matrix’ demo program, then press ‘G’ (GO command key) and enter the starting address of the program, i.e. 6000:130.
SK-80386 \>G=6000:130__ Note: To separate segment base and offset address, use ‘colon’ key on the operator keypad. After performing above steps, following message appears on the LCD:
SK-80386 \>G=6000:130 Program To Run From 6000:130 OK? (Y/N)__
Press ‘ENT’ key for YES. ‘386’ appears on the dot matrix. ________________________________________________________________________________ _ 34 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language
Lab: 10
Note that the message on dot matrix is same as that of turning power ON.
Terminating a Program
In order to terminate a program, Press ‘NMI’ or ‘RST’ key. Since all demo programs are executed in infinite loop, therefore pressing ‘RST’ key resets the trainer, terminating program execution. Alternatively you can use ‘NMI’ key. Entering and verifying Register Contents
On the ‘SK-80386’ prompt, press ‘REG’ key to display all the registers on LCD.
SK-80386 \> Pressing “REG” key shows following screen on the LCD:
0=AX 4=SP 8=DS C=IP
1=BX 2=CX 3=DX 5=BP 6=SI 7=DI 9=ES A=SS B=CS D=FL Press No___
Select the desired register by pressing corresponding key (0 – F). When the corresponding number is
entered following dialog box appears.
EAX=00000000 EBX=00000000 ________________________________________________________________________________ _ 35 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language
ECX=00000000 EDX=00000000 ESP =000004FF EBP =00000000 ESI =00000000 EDI =00000000
Lab: 10
Next__
For next page, press ‘ENT’. We can change the value of the register as follows. EAX=00000000 :1234__
Go back to “REG” command and verify the entered value of the register.
0=AX 4=SP 8=DS C=IP
1=BX 2=CX 3=DX 5=BP 6=SI 7=DI 9=ES A=SS B=CS D=FL Press No___
The new value of the register is shown by pressing the respective number of the register. If you don’t want to alter the register contents, then simply press ‘ENT’ after seeing the following screen:
EAX=00001234 :__________
Input Machine Language code and data from the HEX Keypad
You can take input from the HEX keypad by pressing one of IB, IW or ID keys on the operator keypad. The port address for the HEX keypad is ‘74H’. For example if you want to input a ‘Byte’ data from the HEX keypad, then press ‘IB’ key on operator keypad. Enter ‘74’, then comma and then press ‘ENT’ key, as shown in figure below:
________________________________________________________________________________ _ 36 / 42 Faculty of Computer & Emerging Sciences, SK-80386 \> BUITMS. IB 74
Microprocessor & Assembly Language
Lab: 10
Note: You must be pressing the desired keys on the HEX keypad while you press ‘ENT’, because microprocessor will read the port as soon as IB command is executed. Also note that the HEX keypad works in ‘Reverse’ order, means that when you press a key on HEX keypad, it will send a ‘0 (zero)’ to the microprocessor. For example if you have entered ‘80’ by pressing ‘8’ and ‘0’ hex keys during execution of IB command, then the ‘FEFE’ would be read by microprocessor, as shown in following figure:
SK-80386 \> IB FEFE
74
Similarly you can use ‘IW’ and ‘ID’ commands to enter word and double word data respectively. Output Data to LEDs
SK-80386N also has 16 LEDs, which are mounted just above the HEX keypad. The address of the LEDs is ‘’80H’. Lets send a byte data ‘08’ to the LEDs, it will cause the fourth LED to turn ON, while all other LEDs would be turned OFF. To do this, press ‘OB’, then ‘8’, then ‘0’, then ‘comma’, then ‘0’, and finally ‘8’, and press ‘ENT’ key as shown in figure below:
SK-80386 \> OB
80, 08
You can also use ‘OW’ and ‘OD’ commands to send a word and double word respectively. Entering Machine Codes
In this section, you will learn how to enter ‘Machine Codes’ of an ‘Assembly Language Program’ into SK-80386N for execution. Keep in mind that the ‘Code Segment’ starts from address 100:0000. The first step of entering a program for execution is to have the machine codes of assembly language mnemonics. You can do this be using Intel Microprocessor’s data sheet, or by simply taking machine codes from ‘Listing’ file (.LST). Following is a program whose machine code would be entered into SK-80386N for execution: ________________________________________________________________________________ _ 37 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language Memory Addresses Machine Codes 0000 B8 0001 0003 E7 08 0005 D1 C0 0007 EB FA
Lab: 10 Assembly Language Mnemonics MOV AX, 01 L1: OUT 80H, AX ROL AX, 01 JMP L1
Above program can be entered by using ‘EDIT’ command. Follow the steps given in table below: Key Press EDIT 100:0 ENT
Function Start Entering Program Starting Address of CS Execute Edit Command
B8 01 00 E7 Key Press 80 D1 C0 EB FA ENT
Machine Code Machine Code Machine Code Machine Code Function Machine Code Machine Code Machine Code Machine Code Machine Code Terminate EDIT
LCD Shows SK-80386\> E SK-80386\> E 100:0 SK-80386\> E 100:0 0100:0000 FF _ 0100:0000 FF B8 0100:0001 FF 01 0100:0002 FF 00 0100:0003 FF E7 LCD Shows 0100:0004 FF 80 0100:0005 FF D1 0100:0006 FF C0 0100:0007 FF EB 0100:0008 FF FA 0100:0008 FF
Note: while entering word data 0001, the lowest byte ‘01’ is entered first, and then the upper byte ‘00’ is entered. In order to execute above program, you have to execute ‘GO’ command. For doing this, press ‘GO’ key, then give the starting address of the Code Segment (i.e. 0100:0), and then press ‘ENT’ key. SK-80386N will prompt you for a ‘YES/NO’ option. Press ‘ENT’ key again to start execution.
SK-80386 \> GO = 0100:0000 As soon as the program execution starts, all the LEDs on the HEX keypad seems to be turned ON, however, LEDs are actually being rotated. This is because microprocessor is running on a very high frequency, and human eyes can only differentiate between states if the frequency is below 25Hz. In order to see the actual rotate process, use ‘TRC (TRACE)’ command. For this press start pressing TRC key, and after some key presses you will note that the first LED is turned ON. This continues as you keep pressing TRC. ________________________________________________________________________________ _ 38 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language
Lab: 10
CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
Name: ___________________________
Roll No.:_________________________
Date: ____________________________
Signature of Instructor: ______________
________________________________________________________________________________ _ 39 / 42 Faculty of Computer & Emerging Sciences, BUITMS.
Microprocessor & Assembly Language
Lab: 11
Lab
SK-80386 TrainerIII
11
OBJECT To study the I/O interfacing on the trainer. THEORY In this section we will use a PC to download ‘Assembly Language Programs’ using serial communication. PROCEDURE To begin, load ‘IC.EXE (InterComm.EXE) program in the PC and connect PC with the trainer using NULL Modem. After resetting the trainer, press ‘1’ in order to select CRT mode.
SYSTEMKIT SK-80386 Ver 1.2
1:CRT
2:LCD
The default setting of the serial port are 19200bps baud rate), 8 data bits, No parity, and 1 stop bit. The following contents will be displayed on the LCD. When ‘IC.EXE’ is loaded in PC an d communication between PC and trainer is established, following dialog box appears: __ PC/inter comm. V2.04 Fe-Setup F10=Exit/F Call 3:32 C 0:00 Now you are ready to download program into trainer. While working in ‘IC’, press ‘L (LOAD)’ on the SK-80386\> prompt on the PC, a nd then specify the full path of the file you want to download.
____________________________________________________________________________ FICT, BUITEMS
Microprocessor & Assembly Language
Lab: 11
SK-80386\> L __Sending your file in the HEX format __Ready to Send? (Y/N) Y
After executing ‘Load’ command, press ‘ALT + T’ (shortcut for Transmit command in IC) in order to transmit file to trainer. __Send Now ALT+T (Instruction for sending the file code in HEX form) Name of the file to transmit : _ Note: The file should be in HEX (*.HEX) format, since Intel Microprocessors understand only HEX files. To do this, use ‘EXE2BIN.EXE’ program to convert an executable file into ‘Binary’ file. Then use ‘BIN2HEX.EXE’ program to convert a Binary file into HEX file. You should give the full path of the file you want to download to trainer. For example, if you want to download ‘dot_3861.hex’, then you should give its full path. After entering the full path, the specified program will be downloaded into trainer, and following message will be displayed on the PC screen if the transmission was successful. ……………………
Thanking for your cooperation.
You can execute the program by using either ‘GO’ or ‘TRC’ command.
SK-80386\>G
Program to run from 100:0000 OK? Y
Output would be shown on the dot matrix. ____________________________________________________________________________ FICT, BUITEMS