Anda di halaman 1dari 42

LAB MANUAL

1
Lab
List of Practicals 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 utility To study more commands of DEBUG utility To study more DEBUG commands. To study 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 programs execution for debugging purposes. Examine and alter register and memory contents.

INTRODUCTION

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 MPUs internal registers. Before using debug make sure that you are in DOS shell. In Windows follow these steps: 1. 2. 3. Start > Run > CMD (Press Enter) Type debug at the command prompt and record your observations. _____________________________________________________________________ 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 MPUs are displayed on the screen. 4. After step 1, type r or R to view the register dump. First line: ___________________________________________________________ Second line: _________________________________________________________ Third line: ___________________________________________________________ 5. 6. Write the contents of the general purpose registers in the first line. _____________________________________________________________________ Write the contents of the segment registers. _____________________________________________________________________ Note: Dont try to change the contents of the segment registers. These have been set by the operating system. Modifying Register Contents:

7.

Type r followed by a register name. E.g. Type -r ax What are the contents of AX? _____________________________________________________________________

8.

Enter a new value for AX at the colon prompt. : 12AB Type r again to verify the contents of AX. What is the new value in the AX? _____________________________________________________________________

9.

Try these values and record your observations: -R DX

FICT, BUITEMS

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 OF DF IF SF ZF AF PF CF Meaning Overflow Direction Interrupt Sign Zero Auxiliary Carry Parity Carry Set OV DN EI NG ZR AC PE CY Reset NV UP DI PL NZ NA PO NC

FICT, BUITEMS

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

2
Lab

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

Using Debug-III

3
Lab
[List] AA AA AA AA AA 104 (enter)

The ENTER Command Enter command can be used to modify the memory contents. The format of Enter command is given below: E [Address]

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

You can verify the results of above command by issuing Dump command: D DS: 100

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 dont provide the List in Enter command as shown below: E DS: 200

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

Lab: 04

Using Debug-IV

Entering and Running Programs

4
Lab

Use Assemble command A <starting address> to enter Assembly Language instructions into memory. Starting address will be the offset into the code segment by default. Type: -A 100 0B12:0100 0B12:0103 0B12:0106 0B12:0109 0B12:010B 0B12:010D MOV AX,1 MOV BX,2 MOV CX,3 ADD AX,BX ADD AX,BX 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 <starting address> -U <starting address> <ending address> -U <starting address> L <number of bytes > -U <RETURN> 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> <stop address(es)>

____________________________________________________________________________ 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> <number of instructions> 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

Lab: 05

Assembly Language Programming-I


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

5
Lab

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 be changed after an arithmetic or logic operation ; destination = destination + source + carry flag

ADC (add with carry) ADC destination, source

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

Lab: 05

EQU DB ?

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: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 05

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 06

Assembly Language Programming-II


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

6
Lab

.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 ;Store the result in memory location

Lab: 06

; 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: ___________________________ Date: ____________________________ Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 06

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 07

Assembly Language Programming-III


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

7
Lab

.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 CLD ;Make DS and ES point to same data segment ;because STOS uses ES:DI and LODS uses DS:SI ;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


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

Lab: 07

.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: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 07

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 08

Assembly Language Programming-IV


OBJECT To study data conversions THEORY

8
Lab

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 todays lab session, we shall study a procedure that converts 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 .exit ;Using USES directive ;automatic push of BX of them at the end of registers and thereby 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

Lab: 08

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 NEAR USES BX CX MOV CX, 10 MOV BX, 0 NEXT: MOV INT AH, 1 21H ;read key with echo ;the input character will be in AL

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 AX, BX

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

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 08

READNCONVERT

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 End ;now display each digit in ASCII form

PROC NEAR USES AX AH,2 DL, 0AH ;line feed 21H DL, 0DH ;carriage return 21H ENDP

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 3. Use division also. CONCLUSION

Lab: 08

What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

Name: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 08

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 09

SK-80386 Trainer-I

OBJECT To study the SK-80386 trainer. THEORY

9
Lab

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
CPU ROM RAM Serial Port Parallel Port Printer Port Counter / Timer External I/O Bus Dot Matrix Step Motor Display Keypad Power Supply

Specification
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

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language


Output: +12V 1A / -12V 0.75A / +5V 2A

Lab: 09

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
00000 000FF 00100 004FF 01000 (100:0000) 1FFFF 20000 3FFFF 40000 4FFFF 50000 5FFFF 60000 6FFFF

Description
Interrupt Vector Table Stack Area Serial Download Program Open User ROM Open Serial Monitor Program OPEN ROM BANK 0 OPEN ROM BANK 6 RAM BANK 0

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

GO

REG

TRC

8 IB

9 IW

A ID

<

>

F1

4 OB

5 OW

6 OD

ENT

0 EDIT

1 CRT

2 LCD

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

Lab: 09

CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

Name: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 09

____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 10

SK-80386 Trainer-II

OBJECT To study the machine language programming on the trainer. THEORY

10
Lab

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. SYSTEMKIT SK-80386 Ver 1.2 1:CRT 2:LCD

Pressing 2 on the operator keypad, clears 386 on the dot matrix and the following screen appears on the LCD.

TUTOR MODE Press Enter To Start __

SK-80386N is now in LCD mode. SK-80386\> prompt appears on the LCD.

________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 33 / 42

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. ________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 34 / 42

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 ________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 35 / 42

Microprocessor & Assembly Language ECX=00000000 EDX=00000000 ESP =000004FF EBP =00000000 ESI =00000000 EDI =00000000 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.

Lab: 10

Next__

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

________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 36 / 42 SK-80386 \> 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 Microprocessors 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: ________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 37 / 42

Microprocessor & Assembly Language Memory Addresses 0000 0003 0005 0007 Machine Codes B8 0001 E7 08 D1 C0 EB FA Assembly Language Mnemonics MOV AX, 01 L1: OUT 80H, AX ROL AX, 01 JMP L1

Lab: 10

Above program can be entered by using EDIT command. Follow the steps given in table below: Key Press EDIT 100:0 ENT B8 01 00 E7 Key Press 80 D1 C0 EB FA ENT Function Start Entering Program Starting Address of CS Execute Edit Command 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. ________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 38 / 42

Microprocessor & Assembly Language

Lab: 10

CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

Name: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

________________________________________________________________________________ _ Faculty of Computer & Emerging Sciences, BUITMS. 39 / 42

Microprocessor & Assembly Language

Lab: 11

SK-80386 TrainerIII
OBJECT To study the I/O interfacing on the trainer. THEORY

11
Lab

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 and 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, and 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 <default is>: _ 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\N> Y

Output would be shown on the dot matrix. ____________________________________________________________________________ FICT, BUITEMS

Microprocessor & Assembly Language

Lab: 11

CONCLUSION What have you learnt in this session? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

Name: ___________________________ Date: ____________________________

Roll No.:_________________________ Signature of Instructor: ______________

____________________________________________________________________________ FICT, BUITEMS

Anda mungkin juga menyukai