Anda di halaman 1dari 7

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

Appendix A - List of Interrupts


The following is a small portion of the software interrupts available up to DOS 6.22. This list contains the interrupts most useful in this course. Students are not restricted to this list, of course ...

INT 10h, Service 00h - Set Video Mode


Note that many applications ignore the video interrupts and deal directly with the video hardware installed in a particular machine (by means of video drivers supplied by manufacturer). One can do many clever and fun things with this interrupt, but none of that is really required in this course. The simple I/O of INT 21h, service 1,2,8,9,0Bh, etc. will probably do everything required for simple data entry and display.

INT 11h - Get Equipment Status


(Seldom used, since the amount of equipment available has outstripped this interrupt's capability.)

INT 12h - Get Memory Size


Exit
On exit, AX = # memory blocks (1K each)

INT 13h, Service 00h - Reset Disk Drives


Entry:
AH = 00h DL = Drive number, zero based (0 = A:, 1=B:, 2=C:, etc.)

Exit
Registers unchanged

Comments
Drive head moved out to track 0 (outer track).

INT 13h, Service 01h - Get Disk Drive Status

1 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

Entry:
AH = 01h DL = Drive number (0 based)

Exit
AH = status byte - floppy disk drive only (see following table). 00 = no error. Hard drives generate a somewhat different error set.

Floppy Status Byte


Bits Set Hex Value 7 6 5 4 3,0 3 3,2 2 1,0 1 0 80 40 20 10 09 08 06 04 03 02 01 Description Drive did not complete handshaking procedure in required time (time-out error) Seek failure - unable to access requested track/sector Controller unable to complete command (possible chip malfunction) Bad CRC detected (read only) - bits lost (media damage or demagnitization) DMA error, segment register must be changed DMA overrun Floppy disk drive empty or door not closed Bad sector/sector not found Write attempt on write-protected disk Bad sector ID (address mark) Bad controller chip command

INT 13h, Service 02h - Read Disk Sector(s) INT 13h, Service 03h - Write Sectors to Disk INT 13h, Service 04h - Verify Disk Sectors INT 13h, Service 05h - Format Disk Tracks
Entry:
AH = 02, 03, 04 or 05 AL = number of sectors to read CH = Track (cylinder) number CL = Sector number (unused if AH=05) DH = head number (side of diskette, 0 or 1) DL = Drive number, zero based ES:BX = buffer address of DTA (disk transfer area). Unused if AH=04.
2 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

Exit
CF=0 if no error, AH = status byte (see above table). If AH=05, ES:BX = 4-byte address field entries, 1 per sector: byte data number 0 track number 1 head number 2 3 sector number sector-size code: bytes/sector 00 128 01 256 02 03 512 (standard) 1024

Comments
Always check status byte before reading/writing data.

INT 14h, Service 00h - Initialize Communications Port


Entry:
AH = 00h AL = Initialization data (see Comments below) DX = Communications port number (0 = COM1:, 1 = COM2:, etc.)

Exit
AH = Line status* AL = Modem status**

Comments/Warning
A typical setting is AL = E3h (9600 bd, no parity, 1 stop bit and an 8-bit data character length).

*Line Status Register (8 bits) b7 = 1: Time-out error b6 = 1: Transfer Shift Register (TSR) empty b5 = 1: Transfer Holding Register (THR) empty b4 = 1: Break Interrupt Detected (data line is held in non-idle state for several character times)

3 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

b3 = 1: Framing error (character does not have start bit and stop bit) b2 = 1: Parity error (if even parity, character did not have an even number of bits set to one) b1 = 1: Overrun error (character not read out of UART before next character's arrival) b0 = 1: Data ready to be read out. **Modem Status Register (8 bits) b7 = 1: Data Terminal Ready (DTR) detected b6 = 1: Ring indicator b5 = 1: Data Set Ready (DSR) b4 = 1: Clear To Send (CTS) b3 - b0: Seldom used in normal operation

INT 14h, Service 01h - Send (Write) Character


Entry:
AH = 01h AL = ASCII character DX = Communications port number

Exit
AH = Error code (MSB clear means transmission successful)

Comments/Warnings
UART must have been initialized before transmission of first character. Check Line Status Register (03FD for COM1:) for value 60h, which indicates no character is waiting to be read, the Transmit Holding Register is awaiting data, and the Transmitter is empty (last character has been sent). 61h means a character has arrived and needs to be read. Reading data from UART has the highest priority, because a second character could overwrite the first. Details of error code following transmission attempt may be found in Wyatt, for example (p.532).

INT 14h, Service 02h - Receive Character


Entry:
AH = 02h DX = Communications port number (0 = COM1:, 1 = COM2:, etc.)

Exit
AH = Error code AL = Incoming character (ASCII)

4 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

Comments/Warning
Line status register with b0 = 1 means a character has arrived. The LSR data is placed in AH, so the instruction BT AH,1 sets the carry flag (CF = 1) if the LSR = 61h.

INT 14h, Service 03h - Get Communications Port Status


Entry:
AH = 03h DX = Communications port number (0 = COM1:, 1 = COM2:, etc.)

Exit
AH = Line status AL = Modem status

Comments/Warning

INT 21h, Service 3Ch - Create File


Entry:
AH = 3Ch CX = File attribute (cf INT 21/ service 43) DX = Offset address of path name (label used in .DATA segment to specify file name) DS = Segment address of path name (.DATA address)

Exit
AX = error code (use INT 21h, AH=59 for display of error codes)

Comments/Warning
This interrupt function will destroy an existing file. Use service 5Bh if you wish to avoid this possibility. 5B (not available before DOS 3.0) is identical to 3C, but returns an error code if the file already exists. Both interrupts (3C and 5B) leave the file open (contents partially in RAM). Remember to close the file (INT 21/3E) before terminating the program.

INT 21h, Service 3Dh - Open File


Entry:
AH = 3Dh

5 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

AL = File attribute DX = Offset address of path name DS = Segment address of path name (.DATA address)

Exit
Success: AX = file handle (simple digit) Failure: AX = error code (use INT 21h, AH=59 for display of error codes)

Comments
DS:DX point to label used in .DATA segment to specify file name as ASCIZ (null-terminated ASCII) string. This opens file (contents partially in RAM). Remember to close file (INT 21/3E) before terminating program.

INT 21h, Service 3Eh - Close File


Entry:
AH = 3Eh BX = File handle (simple digit produced in AX by Open File command)

Exit
Success: carry bit clear Failure: carry bit set, AX = error code (use INT 21h, AH=59 for display of error codes)

Comments
Failure to close file may result in its complete destruction! Always place Close File command as close behind last file operation (read or write) as possible, in case program fails to exit properly while file open

INT 21h, Service 3Fh - Read File


Entry:
AH = 3Fh BX = File handle CX = # bytes to read DX = Offset address buffer DS = Segment address of buffer (.DATA address, presumably)

Exit
Success: AX = number of bytes read. If AX < CX or AX = 0, one has hit end-of-file. Failure: AX = error code (use INT 21h, AH=59 for display of error codes)

Comments

6 of 7

8/25/2011 12:22 PM

The Assemblers

http://physics.concordia.ca/~eddy/391/AppA.html

.Data read from file begins at location pointed to by DS:DX. For this reason, one must be sure number of bytes read does not exceed memory allocation made in data segment.

INT 21h, Service 40h - Write File


Entry:
AH = 40h BX = File handle CX = # bytes to write DX = Offset address buffer DS = Segment address of buffer (.DATA address, presumably)

Exit
Success: CF=0, AX = CX = number of bytes read. Failure: CF = 1, AX = error code. If AX != CX an error (e.g. disk full) has occurred, even though CF=0.

Comments
.Data read from file begins at location pointed to by DS:DX. For this reason, one must be sure number of bytes read does not exceed memory allocation made in data segment.

7 of 7

8/25/2011 12:22 PM

Anda mungkin juga menyukai