LAB5
Objective: students will learn how to write program using the interrupts. INT 21H
and INT 10H is used in this program.
Lab Work:
The following programme firstly it clears the screen then set cursor position (in this
example row=5 column=8). After setting cursor, it displays some message.
; --- CLEAR MACRO
MOV AX,0600H MOV BH,07 MOV CX,0000 MOV DX,184FH INT 10H
ENDM
; --- --- CURSOR MACRO Col, Row
MOV AH,02 MOV BH,00 MOV D L,Col MOV DH,R ow INT 10H ENDM
; --- DIS P MACRO ME S
MOV AH,09
MOV DX,OFFSET MES INT 21H
ENDM
; ---
.MO DEL S MALL .STACK 64H .DAT A
MES1 DB 'There is a m es sage for yo u ' DB ' To read it ent er R ','$' MES2 DB 'Hi ! This lab is about '
.CO DE
MAIN: MOV AX,@DATA MOV DS , AX CLEAR
CURSOR 05,08 DIS P MES1 MOV AH, 07
INT 21H
CMP AL,'R ' JZ NEXT CMP AL, 'r' JZ NEXT
CURSOR 05 ,09
DIS P MES3
JMP EXIT NEXT: CURSO R 0 5,0 9 DIS P M ES2 EX IT: MOV AH , 4CH
INT 21H END MAI N
H.W. 5
1. Write a programme that it will read some numbers from the keyboard, if we input a random number
then corresponding message should be the output from the following messages:
If the number <50 ‘fail’
If the number >50 and <60 ‘satisfactory’
If the number >60 and <70 ‘good’
If the number >70 and <80 ‘ very good’
If the number >80 and < 99 ‘ excellent’
When the input is a letter then the program must be terminated, all the messages will be Output at the
center of the screen. When a new number has been entered the screen should be cleared before
org 100h
CLEAR MACRO
MOV AX, 0600H
MOV BH, 07
MOV CX, 0000
MOV DX, 184FH
INT 10H
ENDM
CURSOR MACRO Col, Row
MOV AH, 02
MOV BH, 00
MOV DL, Col
MOV DH, Row
INT 10H
ENDM
DISP MACRO MES
MOV AH, 09
MOV DX, OFFSET MES
INT 21H
ENDM
.MODEL SMALL
.DATA
MES1 DB 'Enter the tenth position of a number between 00-99 ','$'
MES2 DB 'Enter the unit position of a number between 00-99 ','$'
MES3 DB 'Fail', '$'
MES4 DB 'Pass','$'
MES5 DB 'Good','$'
MES6 DB 'Very Good','$'
.CODE
MAIN: MOV AX,@DATA
MOV DS, AX
CLEAR
CURSOR 06, 10
DISP MES1
MOV AH, 07
INT 21H
MOV BL, AL
CURSOR 06, 11
DISP MES2
MOV AH, 07
INT 21H
MOV BH, AL
MOV AL, BL
CMP AL, '0'
JB EXIT
CMP AL, '4'
JA LABEL1
CURSOR 06, 12
DISP MES3
LABEL1: CMP AL, '5'
JNZ LABEL2
CURSOR 06, 12
DISP MES4
LABEL2: CMP AL, '6'
JNZ LABEL3
CURSOR 06, 12
DISP MES5
LABEL3: CMP AL, '7'
CURSOR 06, 12
DISP MES6
LABEL4: CMP AL, '8'
JNZ LABEL5
CURSOR 06, 12
DISP MES7
LABEL5: CMP AL, '9'
JNZ EXIT
CURSOR 06, 12
DISP MES7
EXIT: MOV AH, 4CH
INT 21H
END MAIN
Ret
.MODEL SMALL
.DATA
MES1 DB 'Enter the tenth position of a number between 00-99 ','$'
MES2 DB 'Enter the unit position of a number between 00-99 ','$'
MES3 DB 'Fail', '$'
MES4 DB 'Pass','$'
MES5 DB 'Good','$'
MES6 DB 'Very Good','$'
MES7 DB 'Excellent','$'
DATA1 DB 3,?,3 DUP(?)
.CODE
MAIN: MOV AX,@DATA
MOV DS, AX
CURSOR 06, 10
DISP MES1
MOV AH, 0AH
MOV DX,OFFSET DATA1
INT 21H
MOV BP,DX
MOV BX,[BP+2]
;CURSOR 06, 11
; DISP MES2
; MOV AH, 07
; INT 21H
; MOV BH, AL
MOV AL, BL
CMP AL, '0'
JB EXIT
CMP AL, '4'
JA LABEL1
CURSOR 06, 12
DISP MES3
LABEL1: CMP AL, '5'
JNZ LABEL2
CURSOR 06, 12
DISP MES4
LABEL2: CMP AL, '6'
JNZ LABEL3
CURSOR 06, 12
DISP MES5
LABEL3: CMP AL, '7'
JNZ LABEL4
CURSOR 06, 12
LABEL4: CMP AL, '8'
JNZ LABEL5
CURSOR 06, 12
DISP MES7
LABEL5: CMP AL, '9'
JNZ EXIT
CURSOR 06, 12
DISP MES7
EXIT: MOV AH, 4CH
INT 21H
END MAIN
ret
2. Develop an assembly language program to read the following test message from the data segment
‘Vertical Text Test’ and display the message from up to down. The display device is assumed to be in
the text mode with 25 x 80 resolution.
Hint: INT 10H AH=02 sets cursor location and assumes row in DH and column in DL.
INT 21H AH=02 outputs a character to the monitor. Assumes the character in DL (ASCII).
DOS INT 21h - DOS Function Codes
AH Description AH Description
01 Read character from STDIN 02 Write character to STDOUT
05 Write character to printer 06 Console Input/Output
07 Direct char read (STDIN), no echo 08 Char read from STDIN, no echo
09 Write string to STDOUT 0A Buffered input
0B Get STDIN status 0C Flush buffer for STDIN
0D Disk reset 0E Select default drive
19 Get current default drive 25 Set interrupt vector
2A Get system date 2B Set system date
2C Get system time 2D Set system time
35 Get Interrupt vector
36 Get free disk space 39 Create subdirectory
3A Remove subdirectory 3B Set working directory
3C Create file 3D Open file
3E Close file 3F Read file
40 Write file 41 Delete file
42 Seek file 43 Get/Set file attributes
47 Get current directory 4C Exit program
4D Get return code 54 Get verify flag
56 Rename file 57 Get/Set file date
BIOS interrupt INT10H
Function Function
code Parameters Return
Set video mode AH=00h AL = video mode AL = video mode flag / CRT
controller mode byte
shape Normally a character cell has 8 scan lines, 0-7. So, CX=0607h is a normal underline cursor, CX=0007h is a full-block cursor. If bit 5 of CH is set, that often means "Hide cursor". So CX=2607h is an invisible cursor.
Some video cards have 16 scan lines, 00h-0Fh.
Some video cards don't use bit 5 of CH. With these, make Start>End (e.g. CX=0706h)
Set cursor position AH=02h BH = Page Number, DH = Row, DL = Column
Get cursor position and
shape AH=03h BH = Page Number
AX = 0, CH = Start scan line, CL = End scan line, DH = Row, DL = Column
Read light penposition (Does not work on VGAsystems)
AH=04h
AH = Status (0=not triggered, 1=triggered), BX = Pixel X, CH = Pixel Y, CX = Pixel line number for modes 0Fh-10h, DH = Character Y, DL = Character X
Select active display
page AH=05h AL = Page Number
Scroll up window AH=06h
AL = lines to scroll (0 = clear, CH, CL, DH, DL are used),
BH = Background Color and Foreground color. BH = 43h, means that background color is red and foreground color is cyan. Refer the BIOS color attributes
CH = Upper row number, CL = Left column number, DH = Lower row number, DL = Right column number
Scroll down window AH=07h like above
Read character and attribute at cursor position
AH=08h BH = Page Number AH = Color, AL = Character
Write character and attribute at cursor position
AH=09h
Write character only at
cursor position AH=0Ah
AL = Character, BH = Page Number, CX = Number of times to print character
Set background/border color
AH=0Bh, BH = 00h
BL = Background/Border color (border only in text modes)
Set palette AH=0Bh,
BH = 01h
BL = Palette ID (was only valid in CGA, but newer cards support it in many or all graphics modes)
Write graphics pixel AH=0Ch AL = Color, BH = Page Number, CX = x, DX = y
Read graphics pixel AH=0Dh BH = Page Number, CX = x, DX = y AL = Color
Teletype output AH=0Eh AL = Character, BH = Page Number, BL = Color (only in graphic mode)
Get current video mode AH=0Fh AL = Video Mode
Write string (EGA+, meaning PC
ATminimum)
AH=13h