Академический Документы
Профессиональный Документы
Культура Документы
Lab Manual #1
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
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
Lab Manual #1
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
Lab Manual #1
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
Lab Manual #1
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.
4/6
Lab Manual #1
; 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
5/6
Lab Manual #1
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