Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
02/21/15
02/21/15
C8000
System area
C0000
B0000
REAL
MEMORY
A0000
9FFFF
9FFF0
08E30
08490
Video RAM(Graphics)
MS DOS program
Free TPA
COMMAND.COM
01160
Device drivers
such as MOUSE.SYS
MSDOS program
00700
IO.SYS program
00500
00400
00000
Interrupt vectors
02530
02/21/15
INT Instruction
The INT instruction executes a software interrupt.
The code that handles the interrupt is called an
interrupt handler.
Syntax:
INT number
(number = 0..FFh)
The Interrupt Vector Table (IVT) holds a 32-bit segmentoffset address for each possible interrupt handler.
Interrupt Service Routine (ISR) is another name for interrupt
handler.
02/21/15
02/21/15
Common Interrupts
INT 10h Video Services
INT 16h Keyboard Services
INT 17h Printer Services
INT 1Ah Time of Day
INT 1Ch User Timer Interrupt
INT 21h MS-DOS Services
Input-output
File handling
Memory management
02/21/15
DOS
Entry
INT 21H
02/21/15
Explanation
Exit
AH
DL
AL
01
---
ASCII
char
06
or
07
0FFH
(or)
ASCII
char
ASCII
char
0A
DS:DX =
addr. of
KB I/P
buffer
--
MOV AH,1
INT 21H
OR AL,AL
JZ BACK
MOV AH,4CH
INT 21H
KEY ENDP
END
D:\>EX715.EXE
R
D:\>
02/21/15
D:\>EX715.EXE
D:\>
02/21/15
02/21/15
10
DB 257 DUP(?)
.CODE
.STARTUP
MOV BUF1,255
LEA DX, BUF1
MOV AH,0AH
INT 21H
MOV AH,4CH
INT 21H
END
D:\>EX717.EXE
HELLO WORLD!
D:\>
02/21/15
11
DOS
Entry
INT 21H
02/21/15
Explanation
Exit
AH
DL
AL
02
(or)
06
0FFH
(or)
ASCII
char
ASCII
char
09
DS:DX =
addr. of
KB I/P
buffer
--
12
Programs that display a carriage return and a lined feed using the DISP macro
DISP MACRO A
DISP MACRO A
MOV AH,06H
MOV AH,06H
MOV DL,A
MOV DL,A
INT 21H
INT 21H
ENDM
. MODEL SMALL
.CODE
ENDM
.MODEL TINY
.CODE
DISP 0DH
MOV AH,4CH
INT 21H
END
DISP 0AH
LINE FEED
MOV AH,4CH
INT 21H
CARRIAGE
RETURN
END
D:\MASMEX>EX718.EXE
D:\MASMEX>EX718.EXE
D:\MASMEX>
02/21/15
D:\MASMEX>
13
OUTPUT
D:\MASMEX>EX719
THIS IS A TEST LINE.
D:\MASMEX>
.CODE
MOV AH,9
LEA DX, MSG
INT 21H
MOV AH,4CH
INT 21H
END
02/21/15
14
AH
Description
Parameters
INT 10H
02H
AL=Mode
DH=rows
DL =columns
BH=Page number
INT 10H
03H
DH=rows
DL =columns
BH=Page number
CH =Start line (cursor size)
CL=Ending line (cursor size)
02/21/15
15
rows
Page 0
24
02/21/15
16
CUR MACRO
MOV AH,2
MOV BH,0
MOV DX,0
INT 10H
ENDM
.MODEL TINY
.CODE
CUR
MOV AH,4CH
INT 21H
END
02/21/15
17
02/21/15
18
Interrupt
DOS
Entry
AH=2Ah
INT 21H
Exit
AL=day of the week
CX=year
DH=month
DL=day of the month
AH=2Bh
CX=year
DH=month
DL=day of the month
AH=2Ch
AH=2Dh
CH=hours(0-23)
CL=minutes
DH=seconds
DL=hundredth of second
02/21/15
Description
CH=hours(0-23)
CL=minutes
DH=seconds
DL=hundredth of second
19
INT 21H
.STARTUP
.EXIT
MOV AH,2CH
END
INT 21H
.EXIT
END
02/21/15
20
02/21/15
21
Write to a
file
Entry
AH =3CH
5AH(UNIQUE)
5B(DOS FILE)
CX=File attributes
AX=Error code if file is not created C=1 (Refer Appendix A)
5B is similar to 5A but displays error code if file is already existing
AH=40H
Bx=file handle
CX=number of bytes to be written DS:DX=address of the area to be
written to the disk
AH=3DH
Opening File
Reading File
AH=3FH
Closing File
AH=3EH
DELETE
AH=41H
File pointer
AH=42H
02/21/15
Bx=file handle
CX=number of bytes to be written
DS:DX=location of a memory area where the data are store
22
File Attributes
Bit Position
Value
Attribute
Function
01H
Read Only
02H
Hidden
04H
System
08H
Volume
10H
Subdirectory
20H
Archive
02/21/15
23
Program that opens FILE.NEW and appends it with 256 bytes of data from BUF
.MODEL SMALL
.DATA
FILEN DB FILE.TXT,0
.CODE
MOV AX,3CH
File Name
Open FILE.NEW
02/21/15
24
02/21/15
25