Computer Organization and Assembly Language Lab Manual (Lab 03)
Computer Organization and Assembly Language Lab Manual (Lab 03)
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
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
BIOS routines are stored in ROM and communication directly with I/O ports.
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
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.
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‟.
OR
Returns: Nothing.
The string must be terminated by the $ character (24h), which is not transmitted. Any ASCII
codes can be embedded within the string.
These four 16-bit registers can also be treated as eight 8-bit registers:
Assignment
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
Lab Task# 1
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:
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: