Programmering - Assembler - INT - INT 21 : DOS functions
| Character I/O |
INT21.DOC
MASM: Qbasic - INT21
QBasic: INT21
00: Terminate Program
01: Read Keyboard with Echo
02: Display Character
03: Auxiliary Input
04: Auxiliary Output
05: Print Character
06: Direct Console I/O
07: Direct Console Input
08: Read Keyboard without Echo
09: Display String
0A: Buffered Keyboard Input
0B: Check Keyboard Status
0C: Flush Buffer, Read Keyboard
0D: Reset Drive
0E: Set Default Drive
0F: Open File with FCB
10: Close File with FCB
11: Find First File with FCB
12: Find Next File with FCB
13: Delete File with FCB
14: Sequential Read
15: Sequential Write
16: Create File with FCB
17: Rename File with FCB
19: Get Default Drive
1A: Set Disk Transfer Address (DTA)
1B: Get Default Drive Data
1C: Get Drive Data
1F: Get Default DPB
21: Random Read
22: Random Write
23: Get File Size
24: Set Random Record Number
25: Set Interrupt Vector
26: Create New PSP
27: Random Block Read
28: Random Block Write
29: Parse Filename
2A: Get Date
2B: Set Date
2C: Get Time
2D: Set Time
2E: Set/Reset Verify Flag
2F: Get Disk Transfer Address
30: Get Version Number
31: Keep Program
32: Get DPB
3300: Get Ctrl-C Check Flag
3301: Set Ctrl-C Check Flag
3305: Get Startup Drive
3306: Get MS-DOS Version
34: Get InDOS Flag Address
35: Get Interrupt Vector
36: Get Disk Free Space
38: Get/Set Country Information
39: Create Directory
3A: Remove Directory
3B: Change Current Directory
3C: Create File with Handle
3D: Open File with Handle
3E: Close File with Handle
3F: Read File or Device
40: Write File or Device
41: Delete File
42: Move File Pointer
4300: Get File Attributes
4301: Set File Attributes
4400: Get Device Data
4401: Set Device Data
4402: Receive CD Control Data
4403: Send CD Control Data
4404: Receive BD Control Data
4405: Send BD Control Data
4406: Check Device Input Status
4407: Check Device Output Status
4408: Check Removeable Media
4409: Is Device Remote
440A: Is File or Device Remote
440B: Set Sharing Retry Count
440C: IOCTL for Char. Devices
440D: IOCTL for Block Devices
440E: Get Logical Drive Map
440F: Set Logical Drive Map
4410: Query IOCTL Handle
4411: Query IOCTL Device
45: Duplicate File Handle
46: Force Duplicate File Handle
47: Get Current Directory
48: Allocate Memory
49: Free Allocated Memory
4A: Set Memory Block Size
4B00: Load and Execute Program
4B01: Load Program
4B03: Load Overlay
4B05: Set Execution State
4C: Terminate
4D: Get Child-Program Return Value
4E: Find First File
4F: Find Next File
50: Set PSP Address
51: Get PSP Address
54: Get Verify State
56: Rename File
5700: Get File Date and Time
5701: Set File Date and Time
5800: Get Allocation Strategy
5801: Set Allocation Strategy
5802: Get Upper-Memory Link
5803: Set Upper-Memory Link
59: Get Extended Error
5A: Create Temporary File
5B: Create New File
5C: Lock/Unlock File
5D0A: Set Extended Error
5E00: Get Machine Name
5E02: Set Printer Setup
5E03: Get Printer Setup
5F02: Get Assign-List Entry
5F03: Make Network Connection
5F04: Delete Network Connection
6501: Get Extended Country Information
6502: Get Uppercase Table
6504: Get Filename Uppercase Table
6505: Get Filename Character Table
6506: Get Collate Sequence Table
6507: Get Double-Byte Character Set
6520: Convert Character
6521: Convert String
6522: Convert AsciiZ String
6601: Get Global Code Page
6602: Set Global Code Page
67: Set Maximum Handle Count
68: Commit File
6C: Extended Open/Create
File management (Handles)
3C: Create File with Handle
3D: Open File with Handle
3E: Close File with Handle
3F: Read File or Device
40: Write File or Device
41: Delete File
42: Move File Pointer
4300: Get File Attributes
4301: Set File Attributes
45: Duplicate File Handle
46: Force Duplicate File Handle
56: Rename File
5700: Get File Date and Time
5701: Set File Date and Time
5A: Create Temporary File
5B: Create New File
67: Set Maximum Handle Count
68: Commit File
6C: Extended Open/Create
Directory management
39: Create Directory
3A: Remove Directory
3B: Change Current Directory
41: Delete File
47: Get Current Directory
4E: Find First File
4F: Find Next File
56: Rename File
Drive management
0D: Reset Drive
0E: Set Default Drive
19: Get Default Drive
1A: Set Disk Transfer Address (DTA)
1B: Get Default Drive Data
1C: Get Drive Data
1F: Get Default DPB
2F: Get Disk Transfer Address
32: Get DPB
3305: Get Startup Drive
36: Get Disk Free Space
File Control Blocks (FCBs)
0F: Open File with FCB
10: Close File with FCB
11: Find First File with FCB
12: Find Next File with FCB
13: Delete File with FCB
14: Sequential Read
15: Sequential Write
16: Create File with FCB
17: Rename File with FCB
21: Random Read
22: Random Write
23: Get File Size
24: Set Random Record Number
27: Random Block Read
28: Random Block Write
29: Parse Filename
I/O control (IOCTL)
4400: Get Device Data
4401: Set Device Data
4402: Receive CD Control Data
4403: Send CD Control Data
4404: Receive BD Control Data
4405: Send BD Control Data
4406: Check Device Input Status
4407: Check Device Output Status
4408: Check Removeable Media
4409: Is Device Remote
440A: Is File or Device Remote
440B: Set Sharing Retry Count
440C: IOCTL for Char. Devices
45: Set Iteration Count
4A: Select Code Page
4C: Start Code Page Prepare
4D: End Code Page Prepare
5F: Set Display Mode
65: Get Iteration Count
6A: Query Selected Code Page
6B: Query Code Page Prepare List
7F: Get Display Mode
440D: IOCTL for Block Devices
40: Set Device Parameters
41: Write Track on Logical Drive
42: Format Track on Logical Drive
46: Set Media ID
60: Get Device Parameters
61: Read Track on Logical Drive
62: Verify Track on Logical Drive
66: Get Media ID
68: Sense Media Type
440E: Get Logical Drive Map
440F: Set Logical Drive Map
4410: Query IOCTL Handle
4411: Query IOCTL Device
Character I/O
01: Read Keyboard with Echo
02: Display Character
03: Auxiliary Input
04: Auxiliary Output
05: Print Character
06: Direct Console I/O
07: Direct Console Input
08: Read Keyboard without Echo
09: Display String
0A: Buffered Keyboard Input
0B: Check Keyboard Status
0C: Flush Buffer, Read Keyboard
40: Write File or Device
Memory management
48: Allocate Memory
49: Free Allocated Memory
4A: Set Memory Block Size
5800: Get Allocation Strategy
5801: Set Allocation Strategy
5802: Get Upper-Memory Link
5803: Set Upper-Memory Link
Program management
00: Terminate Program
26: Create New PSP
31: Keep Program
34: Get InDOS Flag Address
4B00: Load and Execute Program
4B01: Load Program
4B03: Load Overlay
4B05: Set Execution State
4C: Terminate (End Program)
4D: Get Child-Program Return Value
50: Set PSP Address
51: Get PSP Address
59: Get Extended Error
5D0A: Set Extended Error
Networks
4409: Is Device Remote
440A: Is File or Device Remote
5E00: Get Machine Name
5E02: Set Printer Setup
5E03: Get Printer Setup
5F02: Get Assign-List Entry
5F03: Make Network Connection
5F04: Delete Network Connection
National language support (NLS)
38: Get/Set Country Information
6501: Get Extended Country Information
6502: Get Uppercase Table
6504: Get Filename Uppercase Table
6505: Get Filename Character Table
6506: Get Collate Sequence Table
6507: Get Double-Byte Character Set
6520: Convert Character
6521: Convert String
6522: Convert AsciiZ String
6601: Get Global Code Page
6602: Set Global Code Page
System Management
25: Set Interrupt Vector
2A: Get Date
2B: Set Date
2C: Get Time
2D: Set Time
2E: Set/Reset Verify Flag
30: Get Version Number
3300: Get Ctrl-C Check Flag
3301: Set Ctrl-C Check Flag
3306: Get MS-DOS Version
35: Get Interrupt Vector
54: Get Verify State
File Sharing
440B: Set Sharing Retry Count
5C: Lock/Unlock File
DOS 1.0
00: Terminate Program
01: Read Keyboard with Echo
02: Display Character
03: Auxiliary Input
04: Auxiliary Output
05: Print Character
06: Direct Console I/O
07: Direct Console Input
08: Read Keyboard without Echo
09: Display String
0A: Buffered Keyboard Input
0B: Check Keyboard Status
0C: Flush Buffer, Read Keyboard
0D: Reset Drive
0E: Set Default Drive
0F: Open File with FCB
10: Close File with FCB
11: Find First File with FCB
12: Find Next File with FCB
13: Delete File with FCB
14: Sequential Read
15: Sequential Write
16: Create File with FCB
17: Rename File with FCB
19: Get Default Drive
1A: Set Disk Transfer Address
21: Random Read
22: Random Write
23: Get File Size
24: Set Random Record Number
25: Set Interrupt Vector
26: Create New PSP
27: Random Block Read
28: Random Block Write
29: Parse Filename
2A: Get Date
2B: Set Date
2C: Get Time
2D: Set Time
2E: Set/Reset Verify Flag
DOS 2.0
1B: Get Default Drive Data
1C: Get Drive Data
2F: Get Disk Transfer Address
30: Get Version Number
31: Keep Program
3300: Get Ctrl-C Check Flag
3301: Set Ctrl-C Check Flag
3305: Get Startup Drive
34: Get InDOS Flag Address
35: Get Interrupt Vector
36: Get Disk Free Space
38: Get/Set Country Information
39: Create Directory
3A: Remove Directory
3B: Change Current Directory
3C: Create File with Handle
3D: Open File with Handle
3E: Close File with Handle
3F: Read File or Device
40: Write File or Device
41: Delete File
42: Move File Pointer
4300: Get File Attributes
4301: Set File Attributes
4400: Get Device Data
4401: Set Device Data
4402: Receive CD Control Data
4403: Send CD Control Data
4404: Receive BD Control Data
4405: Send BD Control Data
4406: Check Device Input Status
4407: Check Device Output Status
45: Duplicate File Handle
46: Force Duplicate File Handle
47: Get Current Directory
48: Allocate Memory
49: Free Allocated Memory
4A: Set Memory Block Size
4B00: Load and Execute Program
4B01: Load Program
4B03: Load Overlay
4C: Terminate
4D: Get Child-Program Return Value
4E: Find First File
4F: Find Next File
50: Set PSP Address
51: Get PSP Address
54: Get Verify State
56: Rename File
5700: Get File Date and Time
5701: Set File Date and Time
5C: Lock/Unlock File
DOS 3.0
4408: Check Removeable Media
5800: Get Allocation Strategy
5801: Set Allocation Strategy
59: Get Extended Error
5A: Create Temporary File
5B: Create New File
DOS 3.1
4409: Is Device Remote
440A: Is File or Device Remote
440B: Set Sharing Retry Count
5E00: Get Machine Name
5E02: Set Printer Setup
5E03: Get Printer Setup
5F02: Get Assign-List Entry
5F03: Make Network Connection
5F04: Delete Network Connection
DOS 3.2
440D: IOCTL for Block Devices
40: Set Device Parameters
41: Write Track on Logical Drive
42: Format Track on Logical Drive
60: Get Device Parameters
61: Read Track on Logical Drive
62: Verify Track on Logical Drive
440E: Get Logical Drive Map
440F: Set Logical Drive Map
DOS 3.3
440C: IOCTL for Char. Devices
45: Set Iteration Count
4A: Select Code Page
4C: Start Code Page Prepare
4D: End Code Page Prepare
65: Get Iteration Count
6A: Query Selected Code Page
6B: Query Code Page Prepare List
6501: Get Extended Country Information
6502: Get Uppercase Table
6504: Get Filename Uppercase Table
6505: Get Filename Character Table
6506: Get Collate Sequence Table
6507: Get Double-Byte Character Set
6520: Convert Character
6521: Convert String
6522: Convert AsciiZ String
6601: Get Global Code Page
6602: Set Global Code Page
67: Set Maximum Handle Count
68: Commit File
DOS 4.0
440C: IOCTL for Char. Devices
5F: Set Display Mode
7F: Get Display Mode
440D: IOCTL for Block Devices
46: Set Media ID
66: Get Media ID
5D0A: Set Extended Error
6C: Extended Open/Create
DOS 5.0
1F: Get Default DPB
32: Get DPB
3306: Get MS-DOS Version
440D: IOCTL for Block Devices
68: Sense Media Type
4410: Query IOCTL Handle
4411: Query IOCTL Device
4B05: Set Execution State
5802: Get Upper-Memory Link
5803: Set Upper-Memory Link
 
;load registers
mov ah,function
int 21h
 
INT 21, 19 : Get Default Drive
AH = 19
AL = DriveNumber (0 = A, 1 = B, 2 = C, ...)
>0E: Set Default Drive
>Qbasic: INT21 - Current Drive and Directory
 
INT 21, 25 : Set Interupt Vector
AH = 25h
AL = int no.
DS:DX = new vector
 
Update INT 9: BIOS Keyboard Handler (PCPB.64):
push ds  ;preserve DS
mov dx,offset Handler
push cs
pop ds
mov al,9
mov ah,25h
int 21h
pop ds
 
Update INT 60h (PCPB.64)
mov dx,seg INT60Handler
mov ds,dx
mov dx,offset INT60Handler
mov al,60h
mov ah,25h
int 21h
 
INT 21, 2A : Get Date
Returns current system date
AH = 2Ah
AL = WeekDay (0 = sunday, 1 = monday, .., 6 = saturday)
CX = Year (1980..2099)
DH = Month (1 = january, .., 12 = december)
DL = Day (1..31)
>2B: Set Date
>2C: Get Time
>5700: Get File Date and Time
>Qbasic: INT21 - Get Date
 
INT 21, 2C : Get Time
Returns current system time
AH = 2Ch
CH = Hour (0..23)
CL = Minutes (0..59)
DH = Seconds (0..59)
DL = 100th of a second (0..99)
>2A: Get Date
>2D: Set Time
>5700: Get File Date and Time
>Qbasic: INT21 - Get Time
 
INT 21, 47 : Get Current Directory
Returns path of current directory on specified drive
AH = 47h
DL = Drive (0=default, 1=A, 2=B, 3=C, ..)
DS:SI -> buffer (>=64 bytes)
CF = 0: no error, path in buffer
CF = 1: AX = error code:
             000F : ERROR_INVALID_DRIVE
The returned string
- does not include the drive lettet
- separates subdirectories with '\' - but starts with a name
- is zero-terminated
>3B: Change Current Directory
>Qbasic: INT21 - Current Drive and Directory
 
INT 21, 4C : Terminate
AH = 4Ch
AL = 'errornr' (used by ERRORLEVEL)
MOV AX,4C00h
INT 21h