Вы находитесь на странице: 1из 6

Microprocessor Systems (EE 271)

Lab Manual #1

4th Semester (Session 2011)

Name: ________________________________________Reg. #:2011 -EE-_________ _Date: _______________________

Overview of Input and Output operations of 8086/8088 Assembly Language


INTRODUCTION The objective of this lab session is to introduce the students with taking input and output using DOS INT 21H function calls and get another step further in learning the structure of assembly language by learning the usage of 1. Variable declaration using: DB, DW, DD 2. Constant declaration using: EQU 3. Offset operator 4. Familiarization with friendly Emulator, Emu8086. After this lab you will be able to Take input from key board using functions calls 01 and 08 of INT 21H Show output on the screen using function calls 02 and 09 of INT 21H Familiar with the usage of emulator 8086. OVERVIEW The instruction INT 21h stands for Call Interrupt no. 21. For the time being lets take interrupts like a function or a subroutine placed in memory and being called from another program. The parameters to that function or subroutine are passed by using different CPU registers mostly AH, AL or DX. Functionality of that subroutine depends upon those parameters;
Functionality Output in Value of AH Function Call No.

Reads a character from keyboard, stores it in AL and display it (echoes it) on screen. Display the content of register DL on screen in ASCII form. Read character from keyboard without echoing it on screen Display the string that is terminated by$ sign.

AL Screen AL Screen

01h 02h 08h 09h

01h 02h 08h 09h

DOS Function02h: To display a single ASCII character at the current cursor position, use the following sequence of instructions.
MOV AH, 02H MOV DL, Character Code INT 21H

The Character Code may be the ASCII code of the character taken from the ASCII table or the character itself written between quotes.

1/6

Microprocessor Systems (EE 271)


MOV AH, 02H MOV DL, 32H INT 21H

Lab Manual #1

4th Semester (Session 2011)

The following code displays number 2 using its ASCII code:

This code also displays 2:


MOV AH, 02H MOV DL, 2 INT 21H

Function 01H and 08H: To read single character and have it echoed (displayed) on the screen, use the following code:
MOV AH, 01H INT 21H

AL contains now the ASCII code of the character read from the keyboard. If the character is to be read without echo, such as reading a password, use the following code:
MOV AH, 08H INT 21H

AL contains now the ASCII code of the character read. DOS Functions 09h: This function is used to display a string of characters ended with a $ sign. The following code displays the string MESSAGE defined as:
.DATA MESSAGE DB .CODE MOV DX, OFFSET MESSAGE MOV AH, 09H INT 21H This is the Message to be displayed, $

Or
.DATA MESSAGE DB .CODE LEA DX,, MESSAGE MOV AH, 09H INT 21H This is the Message to be displayed, $

2/6

Microprocessor Systems (EE 271)

Lab Manual #1

4th Semester (Session 2011)

Introduction to emu8086
a) Open the emu8086 present on your desktop. Following window will appear

b) Select "new" from the above window. A new small window will appear. Select "empty work space" and press OK. c) A code window will appear. Just write your specific code in this space.

3/6

Microprocessor Systems (EE 271)

Lab Manual #1

4th Semester (Session 2011)

d) After writing your code, go to the file menu and save your code with an appropriate name (The .asm extension is by default, you don't have to write it explicitly). e) After saving your code, compile by pressing compile menu and remove the errors if there are any. Otherwise click "close".

f)

Now emulate your program from the menu and see the values of registers step by step and also get familiar with relevant things shown by the emulator.

g) Now you can use "single step" or "run" option.

4/6

Microprocessor Systems (EE 271) Program1:


.MODEL SMALL .STACK 100H .CODE MOV AH, 01H INT 21H MOV BL, AL MOV AH, 02H MOV DL, 0DH INT 21H MOV DL, 0AH INT 21H MOV DL, BL INT 21H MOV AH, 4CH INT 21H END

Lab Manual #1

4th Semester (Session 2011)

; Character input with echo ; Character in AL ; Save in BL ; Display character function ; carriage return ; line feed ; Get character stored in BL and display

Program2:
.MODEL SMALL .STACK 100H .DATA CR EQU 0DH LF EQU 0AH MSG1 DB 'ENTER A LOWER CASE LETTER: $' MSG2 DB 0DH, 0AH,'IN UPPER CASE IT IS:' CHAR DB '?','$' .CODE MAIN PROC MOV AX,@DATA MOV DS, AX LEA DX, MSG1 MOV AH, 9 INT 21H MOV AH, 1 INT 21H ; get first message ; display string function

; read character function

5/6

Microprocessor Systems (EE 271)


SUB AL, 20H MOV CHAR, AL LEA DX, MSG2 MOV AH, 9 INT 21H MOV AH, 4CH INT 21H MAIN ENDP END MAIN

Lab Manual #1

4th Semester (Session 2011)

; convert it to upper case ; store in AL ; get second message ; display string

Lab Assignment: a) Write an assembly language program that prompts you to enter a password of 3 characters in length. The password should not be echoed to the screen rather it should show xxx. The program then displays your name and ID number on the screen (Which you have to display by simple LEA instruction). b) Write a program to read one of the hex digits A-F, and display on the next line in decimal. Sample: Enter a hex digit: A In decimal it is: 10 Note: Go through this lab manual before coming into lab.

6/6

Вам также может понравиться