0% found this document useful (0 votes)
61 views

Computer Organization and Assembly Language Lab Manual (Lab 03)

This document provides instructions for a computer organization and assembly language lab, outlining objectives to introduce input/output instructions using DOS service routines and the INT instruction, and listing tasks to get character input and display output using functions like GETCHE, GETCH, PUTCH, and PUTS. Sample code is provided to read and display characters and strings, as well as perform data movement and arithmetic operations.

Uploaded by

Muhammad Anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Computer Organization and Assembly Language Lab Manual (Lab 03)

This document provides instructions for a computer organization and assembly language lab, outlining objectives to introduce input/output instructions using DOS service routines and the INT instruction, and listing tasks to get character input and display output using functions like GETCHE, GETCH, PUTCH, and PUTS. Sample code is provided to read and display characters and strings, as well as perform data movement and arithmetic operations.

Uploaded by

Muhammad Anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer Organization and Assembly

Language
Lab Manual (Lab 03)

Topic: DOS/ IO service Routine, INT Instruction, How to read Character input
with Echo, How to display a Character, How to read character input without Echo,
How to Display String, Data movement and arithmetic instruction

Course Instructor: Engr. Tanzeela Shakeel


Lab Instructor: Maham Saleem

Session: Fall 2021

School of Systems and Technology


UMT Lahore Pakistan
Objectives: INTRODUCTION to INPUT / OUTPUT INSRTUCTION

Some concepts and sample codes

8086 Input /Output Instructions


DOS /IO service Routines

CPU communication with peripherals device through I/O registers called I/O ports.
They are two instructions, IN and OUT, that access the ports directly. These Instructions are
used when a program needs to directly communication with peripherals like when fast I/O
needed.
These are two categories of I/O service routines

(i) BIOS Routines

BIOS routines are stored in ROM and communication directly with I/O ports.

(ii) DOS Routines

The DOS routines actually use The BIOS routines to perform direct I/O operation. They Can carry
out the more Complex tasks; for example printing a character string, getting inputs from key
board etc.

INT instruction

To invoke DOS or BIOS routine, the INT (interrupt) instruction is used, it has the format

INT interrupt number

When Interrupt number is number that specifies a routine, for example INT 16h invokes a BIOS
routine that performs keyboard input. INT 21h may be used to invoke a large number of DOS
function.

Interrupts Recommended:

1) INT 21H, Function 04CH terminate the code properly and return to the DOS Prompt.
2) INT 21H, Function 02H Display a number or character on the screen.
3) INT 21H, Function 09H Display the string on the screen
4) INT 21H, Function 01H Get Character input with Echo.
5) INT 21h, function 08H Get Character input without Echo.
Function 01 - Read a character input with Echo from keyboard

Reads a character from the standard input device and echoes it to the standard output device.
If no character is ready it waits until one is available.

To get input from the keyboard executes the following instruction.

MOV ah, 01H; input key function

INT 21H; get ASCII code in AL

On entry: Ah= 01H


Returns: AL= 8 bit data input.

When a character is pressed, AL will contain its ASCII code if any other key is pressed, such as
an arrow key or F0-F10 and so on, AL will contain 0.
Function 02 - Display a Character on Screen
To display a character “A‟ on screen execute the following instruction, actually DL must contain
the ASCII code of Character that is to be displayed. In this example DL will contain ASCI code
of “A‟.

MOV AH, 2; display character function


MOV DL, “A‟; character is “A
INT 21H ; display character
On entry: AH = 02h
DL = 8 bit data (usually ASCII character)
Returns: Nothing

Function 08 - Read a character input without Echo from keyboard


Reads a character from the standard input device without copying it to the display. If no
character is ready it waits until one is available.
MOV AH, 08h ; Input key function
INT 21h ; get ASCII code in AL.
On entry: Ah= 08H
Returns: AL= 8 bit data input.

Function 09 - Display a string on Screen


To display a String execute the following instruction, DX register must contain the starting offset
Address of string that to be displayed

LEA DX, msg; get offset address of msg

OR

MOV DX, offset msg ; get offset address of msg.


MOV AH, 9; string Display function
Int 21h; Display msg

On entry Ah= 09H


DS: DX = segment: offset of string

Returns: Nothing.

Where msg is string define in Data Segment as

Msg db ‟hello world‟, 0Ah, 0Dh, “$‟ or


Msg db “hello world” ,13h,10h,24h

The string must be terminated by the $ character (24h), which is not transmitted. Any ASCII
codes can be embedded within the string.

Data movement and Arithmetic instruction


In 8086 General purpose registers are:

ax, bx, cx, dx

These four 16-bit registers can also be treated as eight 8-bit registers:

ah, al, bh, bl, ch, cl, dh, dl

Assignment

In C, assignment takes the form:

C Syntax Assembly syntax

x = 42 ; mov x,42

y = 24; mov y, 24

z = x + y; add z,x

add z ,y

In assembly language we carry out the same operation but we use an instruction to denote the
assignment operator ("=" in C).
OPCODE destination, source
Operation Operand, Operand

MOV Register, register


MOV register, immediate value
Add register, register
Add register, immediate value
LAB TASK

Lab Task# 1

Write an ALP to perform following functions:

o GETCHE()
o GETCH()
o PUTCH()
o PUTS()

Lab Task # 2:
1. Prompt User to Enter 1st (1-digit) number
2. Prompt User to Enter 2nd (1-digit) number
3. Add two numbers
4. Display result in the following format:

“The sum of 2 and 7 is 9”

Lab Task # 3:
1. Prompt user to enter a lower case letter character
2. Convert it into Upper Case character
3. Output the result in the following format:

“Lower case f converted to upper case F”

You might also like