Interrupt Assembly
-
Upload
kristian-maulana -
Category
Documents
-
view
216 -
download
0
Transcript of Interrupt Assembly
-
7/30/2019 Interrupt Assembly
1/7
Appendix A - List of Interrupts
The following is a small portion of thesoftware 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
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
2/7
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 diff erent error set.
Floppy Status Byte
Bits Set Hex Value Description
7 80Drive did not complete handshaking procedure in required time
(time-out error)
6 40 Seek failure - unable to access requested track/sector
5 20 Controller unable to complete command (possible chip malfunction)
4 10 Bad CRC detected (read only) - bits lost (media damage ordemagnitization)
3,0 09 DMA error, segment register must be changed
3 08 DMA overrun
3,2 06 Floppy disk drive empty or door not closed
2 04 Bad sector/sector not found
1,0 03 Write attempt on write-protected disk
1 02 Bad sector ID (address mark)
0 01 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.
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
3/7
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
numberdata
0 track number
1 head number
2 sector number
3 sector-size code: bytes/sector
00 128
01 256
02512
(standard)
03 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)
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
4/7
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 = 01hAL = 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 forCOM1:) 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)
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
5/7
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 StatusEntry:
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 (cfINT 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. Bothinterrupts (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
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
6/7
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 readDX = 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
Assemblers http://physics.concordia.ca/~eddy/391/A
8/25/2011
-
7/30/2019 Interrupt Assembly
7/7
.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 = 40hBX = 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.
Assemblers http://physics.concordia.ca/~eddy/391/A