这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......
include DOSMAC.ASM
IF2
%OUT DOSSYM in Pass 2
ENDIF
IFNDEF ALTVECT
ALTVECT EQU 0 ;FALSE
ENDIF
BREAK <Control character definitions>
c_DEL EQU 7Fh ; ASCII rubout or delete previous char
c_BS EQU 08h ; ^H ASCII backspace
c_CR EQU 0Dh ; ^M ASCII carriage return
c_LF EQU 0Ah ; ^J ASCII linefeed
c_ETB EQU 17h ; ^W ASCII end of transmission
c_NAK EQU 15h ; ^U ASCII negative acknowledge
c_ETX EQU 03h ; ^C ASCII end of text
c_HT EQU 09h ; ^I ASCII tab
BREAK <BPB Definition>
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; ;
; C A V E A T P R O G R A M M E R ;
; ;
; Certain structures, constants and system calls below are private to ;
; the DOS and are extremely version-dependent. They may change at any ;
; time at the implementors' whim. As a result, they must not be ;
; documented to the general public. If an extreme case arises, they ;
; must be documented with this warning. ;
; ;
; Those structures and constants that are subject to the above will be ;
; marked and bracketed with the flag: ;
; ;
; C A V E A T P R O G R A M M E R ;
; ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
BREAK <Bios Parameter Block>
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; C A V E A T P R O G R A M M E R ;
; ;
; Bios Parameter Block definition
; This structure is used to build a full DPB
BPBLOCK STRUC
BPSECSZ DW ? ; Size in bytes of physical sector
BPCLUS DB ? ; Sectors/Alloc unit
BPRES DW ? ; Number of reserved sectors
BPFTCNT DB ? ; Number of FATs
BPDRCNT DW ? ; Number of directory entries
BPSCCNT DW ? ; Total number of sectors
BPMEDIA DB ? ; Media descriptor byte
BPFTSEC DW ? ; Number of sectors taken up by one FAT
BPBLOCK ENDS
; ;
; C A V E A T P R O G R A M M E R ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
BREAK <Disk I/O Buffer Header>
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; C A V E A T P R O G R A M M E R ;
; ;
; Field definition for I/O buffer information
BUFFINFO STRUC
NEXTBUF DD ? ; Pointer to next buffer in list
; The next two items are often refed as a word
BUFDRV DB ? ; Logical drive # assoc with buffer FF = free
BUFDIRTY DB ? ; Dirty flag
BUFPRI DB ? ; Buffer selection priority (see EQUs below)
VISIT DB ? ; Visit flag for buffer pool scans
BUFSECNO DW ? ; Sector number of buffer
; The next two items are often refed as a word
BUFWRTCNT DB ? ; For FAT sectors, # times sector written out
BUFWRTINC DB ? ; " " " , # sectors between each write
BUFDRVDP DD ? ; Pointer to drive parameters
BUFFINFO ENDS
BUFINSIZ EQU SIZE BUFFINFO
; Size of structure in bytes
FREEPRI EQU 0
LBRPRI EQU 2 ; Last byte of buffer read
LBWPRI EQU 4 ; Last byte written
RPRI EQU 6 ; Read but not last byte
WPRI EQU 8 ; Written but not last byte
DIRPRI EQU 15 ; Directory Sector
FATPRI EQU 30 ; FAT sector
; ;
; C A V E A T P R O G R A M M E R ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
BREAK <User stack inside of system call>
; Location of user registers relative user stack pointer
user_environ STRUC
user_AX DW ?
user_BX DW ?
user_CX DW ?
user_DX DW ?
user_SI DW ?
user_DI DW ?
user_BP DW ?
user_DS DW ?
user_ES DW ?
user_IP DW ?
user_CS DW ?
user_F DW ?
user_environ ENDS
BREAK <interrupt definitions>
INTTAB EQU 20H
INTBASE EQU 4 * inttab
ENTRYPOINT EQU INTBASE+40H
IF ALTVECT
ALTTAB EQU 0F0H
ALTBASE EQU 4 * ALTTAB
ENDIF
;
; interrupt assignments
;
IF NOT ALTVECT
int_abort EQU INTTAB ; abort process
int_command EQU int_abort+1 ; call MSDOS
int_terminate EQU int_abort+2 ; int to terminate address
int_ctrl_c EQU int_abort+3 ; ^c trapper
int_fatal_abort EQU int_abort+4 ; hard disk error
int_disk_read EQU int_abort+5 ; logical sector disk read
int_disk_write EQU int_abort+6 ; logical sector disk write
int_keep_process EQU int_abort+7 ; terminate program and stay resident
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; C A V E A T P R O G R A M M E R ;
; ;
int_spooler EQU int_abort+8 ; spooler call
int_fastcon EQU int_abort+9 ; fast CON interrupt
; ;
; C A V E A T P R O G R A M M E R ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
ELSE
int_abort EQU INTTAB ; abort process
int_command EQU int_abort+1 ; call MSDOS
int_terminate EQU ALTTAB ; int to terminate address
int_ctrl_c EQU int_terminate+1 ; ^c trapper
int_fatal_abort EQU int_terminate+2 ; hard disk error
int_disk_read EQU int_abort+5 ; logical sector disk read
int_disk_write EQU int_abort+6 ; logical sector disk write
int_keep_process EQU int_abort+7 ; terminate program and stay resident
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; C A V E A T P R O G R A M M E R ;
; ;
int_spooler EQU int_terminate+3 ; spooler call
int_fastcon EQU int_abort+9 ; fast CON interrupt
; ;
; C A V E A T P R O G R A M M E R ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
ENDIF
addr_int_abort EQU 4 * int_abort
addr_int_command EQU 4 * int_command
addr_int_terminate EQU 4 * int_terminate
addr_int_ctrl_c EQU 4 * int_ctrl_c
addr_int_fatal_abort EQU 4 * int_fatal_abort
addr_int_disk_read EQU 4 * int_disk_read
addr_int_disk_write EQU 4 * int_disk_write
addr_int_keep_process EQU 4 * int_keep_process
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
; C A V E A T P R O G R A M M E R ;
; ;
addr_int_spooler EQU 4 * int_spooler
addr_int_fastcon EQU 4 * int_fastcon
; ;
; C A V E A T P R O G R A M M E R ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
BREAK <Disk map>
; MSDOS partitions the disk into 4 sections:
;
; phys sector 0: +-------------------+
; | | boot/reserved |
; | +-------------------+
; | | File allocation |
; v | table(s) |
; | (multiple copies |
; | are kept) |
; +-------------------+
; | Directory |
; +-------------------+
; | File space |
; +-------------------+
; | Unaddressable |
; | (to end of disk) |
; +-------------------+
;
; All partition boundaries are sector boundaries. The size of the FAT is
; adjusted to maximize the file space addressable.
BREAK <Directory entry>
;
; +---------------------------+
; | (12 BYTE) filename/ext | 0 0
; +---------------------------+
; | (BYTE) attributes | 11 B
; +---------------------------+
; | (10 BYTE) reserved | 12 C
; +---------------------------+
; | (WORD) time of last write | 22 16
; +---------------------------+
; | (WORD) date of last write | 24 18
; +---------------------------+
; | (WORD) First cluster | 26 1A
; +---------------------------+
; | (DWORD) file size | 28 1C
; +---------------------------+
;
; First byte of filename = E5 -> free directory entry
; = 00 -> end of allocated directory
; Time: Bits 0-4=seconds/2, bits 5-10=minute, 11-15=hour
; Date: Bits 0-4=da