⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dos.inc

📁 mas for 8086 microprocessor
💻 INC
📖 第 1 页 / 共 3 页
字号:
; DOS Interface Macros - Version 1.3 - for Microsoft Macro Assembler 6.1
; (C) Copyright Microsoft Corporation, 1987, 1988, 1989, 1990, 1993

; Typedefs for testing pointers
NPVOID  TYPEDEF NEAR PTR
FPVOID  TYPEDEF FAR  PTR


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  For more information on the following structures refer to
;  the Microsoft MS-DOS Programmer's Reference for Version 5.0
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BOOTSECTOR STRUCT 1t
    bsJump          DB 3 DUP(?)
    bsOemName       DB '????????'
    bsBytesPerSec   DW ?
    bsSecPerClust   DB ?
    bsResSectors    DW ?
    bsFATs          DB ?
    bsRootDirEnts   DW ?
    bsSectors       DW ?
    bsMedia         DB ?
    bsFATsecs       DW ?
    bsSecPerTrack   DW ?
    bsHeads         DW ?
    bsHiddenSecs    DD ?
    bsHugeSectors   DD ?
    bsDriveNumber   DB ?
    bsReserved1     DB ?
    bsBootSignature DB ?
    bsVolumeID      DD ?
    bsVolumeLabel   DB 11 DUP(?)
    bsFileSysType   DB 8 DUP(?)
BOOTSECTOR ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 440Dh Minor Code 60h
;             Interrupt 21h Function 440Dh Minor Code 40h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DEVICEPARAMS STRUCT 1t
    dpSpecFunc      DB ?
    dpDevType       DB ?
    dpDevAttr       DW ?
    dpCylinders     DW ?
    dpMediaType     DB ?
    dpBytesPerSec   DW ?
    dpSecPerClust   DB ?
    dpResSectors    DW ?
    dpFATs          DB ?
    dpRootDirEnts   DW ?
    dpSectors       DW ?
    dpMedia         DB ?
    dpFATsecs       DW ?
    dpSecPerTrack   DW ?
    dpHeads         DW ?
    dpHiddenSecs    DD ?
    dpHugeSectors   DD ?
    dpReserved1     DB 6 DUP(?) ;; A documentation error in the
    dpTrkLayoutCnt  DW ?        ;; MS-DOS Programmer's Reference 5.0
DEVICEPARAMS ENDS               ;; omits these last two fields.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 11h
;             Interrupt 21h Function 12h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DIRENTRY STRUCT 1t
    deName          DB '????????'
    deExtension     DB '???'
    deAttributes    DB ?
    deReserved1     DB 10 DUP(?)
    deTime          DW ?
    deDate          DW ?
    deStartCluster  DW ?
    deFileSize      DD ?
DIRENTRY ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 25h
;             Interrupt 26h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DISKIO STRUCT 1t
    diStartSector   DD ?
    diSectors       DW ?
    diBuffer        DD ?
DISKIO ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 1Fh
;             Interrupt 21h Function 32h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DPB STRUCT 1t
    dpbDrive        DB ?
    dpbUnit         DB ?
    dpbSectorSize   DW ?
    dpbClusterMask  DB ?
    dpbClusterShift DB ?
    dpbFirstFAT     DW ?
    dpbFATCount     DB ?
    dpbRootEntries  DW ?
    dpbFirstSector  DW ?
    dpbMaxCluster   DW ?
    dpbFATSize      DW ?
    dpbDirSector    DW ?
    dpbDriverAddr   DD ?
    dpbMedia        DB ?
    dpbFirstAccess  DB ?
    dpbNextDPB      DD ?
    dpbNextFree     DW ?
    dpbFreeCnt      DW ?
DPB ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 11h
;             Interrupt 21h Function 12h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EXTENDEDFCB STRUCT 1t
    extSignature    DB 0FFh
    extReserved1    DB 5 DUP(0)
    extAttribute    DB ?
    extDriveID      DB ?
    extFileName     DB '????????'
    extExtent       DB '???'
    extCurBlockNo   DW ?
    extRecSize      DW ?
    extFileSize     DB 4 DUP(?)
    extFileDate     DW ?
    extFileTime     DW ?
    extReserved2    DB 8 DUP(?)
    extCurRecNo     DB ?
    extRandomRecNo  DB 4 DUP(?)
EXTENDEDFCB ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 11h
;             Interrupt 21h Function 12h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EXTHEADER STRUCT 1t
    ehSignature     DB 0FFh
    ehReserved      DB 5 DUP(?)
    ehSearchAttrs   DB ?
EXTHEADER ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 0Fh
;             Interrupt 21h Function 10h
;             Interrupt 21h Function 11h
;             Interrupt 21h Function 12h
;             Interrupt 21h Function 13h
;             Interrupt 21h Function 14h
;             Interrupt 21h Function 15h
;             Interrupt 21h Function 16h
;             Interrupt 21h Function 17h
;             Interrupt 21h Function 1Bh
;             Interrupt 21h Function 1Ch and @ChkDrv MACRO
;             Interrupt 21h Function 21h
;             Interrupt 21h Function 22h
;             Interrupt 21h Function 23h
;             Interrupt 21h Function 24h
;             Interrupt 21h Function 27h
;             Interrupt 21h Function 28h
;             Interrupt 21h Function 29h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FCB STRUCT 1t
    fcbDriveID      DB ?
    fcbFileName     DB '????????'
    fcbExtent       DB '???'
    fcbCurBlockNo   DW ?
    fcbRecSize      DW ?
    fcbFileSize     DB 4 DUP(?)
    fcbFileDate     DW ?
    fcbFileTime     DW ?
    fcbReserved1    DB 8 DUP(?)
    fcbCurRecNo     DB ?
    fcbRandomRecNo  DB 4 DUP(?)
FCB ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 4Eh and @GetFirst MACRO
;             Interrupt 21h Function 4Fh and @GetNext MACRO
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FILEINFO STRUCT 1t
    fiReserved1     DB 21 DUP(?)
    fiAttribute     DB ?
    fiFileTime      DW ?
    fiFileDate      DW ?
    fiSize          DD ?
    fiFileName      DB 13 DUP(?)
FILEINFO ENDS

; This structure declaration is included for compatability with earlier
; versions of DOS.INC.  The structure declaration above, which matches 
; the MS-DOS Programmer's Reference 5.0, should be used for new code.
FILE_INFO STRUCT
  pad           BYTE    21 DUP (?)      ; pad to 43 bytes
  Attrib        BYTE    ?               ; file attribute
  Time          WORD    ?               ; file time
  Date          WORD    ?               ; file date
  Len           DWORD   ?               ; file size
  FName         BYTE    13 DUP (?)      ; file name
FILE_INFO ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 440Dh Minor Code 42h
;             Interrupt 21h Function 440Dh Minor Code 62h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FVBLOCK STRUCT 1t
    fvSpecFunc      DB 0
    fvHead          DW ?
    fvCylinder      DW ?
FVBLOCK ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 440Dh Minor Code 66h
;             Interrupt 21h Function 440Dh Minor Code 46h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MID STRUCT 1t
    midInfoLevel    DW 0
    midSerialNum    DD ?
    midVolLabel     DD 11 DUP(?)
    midFileSysType  DB 8 DUP(?)
MID ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 440Dh Minor Code 41h
;             Interrupt 21h Function 440Dh Minor Code 61h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PARTENTRY STRUCT 1t
    peBootable      DB ?
    peBeginHead     DB ?
    peBeginSector   DB ?
    peBeginCylinder DB ?
    peFileSystem    DB ?
    peEndHead       DB ?
    peEndSector     DB ?
    peEndCylinder   DB ?
    peStartSector   DD ?
    peSectors       DD ?
PARTENTRY ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 17h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RENAMEFCB STRUCT 1t
    renDriveID      DB ?
    renOldName      DB '????????'
    renOldExtent    DB '???'
    renReserved1    DB 5 DUP(?)
    renNewName      DB '????????'
    renNewExtent    DB '???'
    renReserved2    DB 9 DUP(?)
RENAMEFCB ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Used with: Interrupt 21h Function 440Dh Minor Code 61h
;             Interrupt 21h Function 440Dh Minor Code 41h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RWBLOCK STRUCT 1t
    rwSpecFunc      DB 0
    rwHead          DW ?
    rwCylinder      DW ?
    rwFirstSector   DW ?
    rwSectors       DW ?
    rwBuffer        DD ?
RWBLOCK ENDS


; Internal
__LdAdr MACRO reg:REQ, adr:REQ
    IF (OPATTR (adr)) AND 00010000y
        mov     reg, adr               ;; Register
    ELSEIF (OPATTR (adr)) AND 00000100y
        mov     reg, adr               ;; Constant
    ELSEIF (TYPE (adr) EQ BYTE)  OR (TYPE (adr) EQ SBYTE)
        mov    reg, OFFSET adr         ;; Bytes
    ELSEIF (TYPE (adr) EQ NPVOID) OR (TYPE (adr) EQ WORD)
        mov    reg, adr                ;; Near pointer
    ELSEIF (TYPE (adr) EQ FPVOID) OR (TYPE (adr) EQ DWORD)
        mov    reg, WORD PTR adr[0]    ;; Far pointer
        mov    ds,  WORD PTR adr[2]
    ELSE
        .ERR <Illegal argument>
    ENDIF
ENDM


; Internal
__LdSeg MACRO dest:REQ, src:REQ
    IFIDNI <src>, <es>                 ;; Segment register
        mov     ax, src
        mov     dest, ax
    ELSEIFIDNI <src>, <ss>
        mov     ax, src
        mov     dest, ax
    ELSEIFIDNI <src>, <ds>
        mov     ax, src
        mov     dest, ax
    ELSEIFIDNI <src>, <cs>
        mov     ax, src
        mov     dest, ax
    ELSEIF (OPATTR (src)) AND 00000100y ;; Constant
        mov     ax, src
        mov     dest, ax
    ELSE                                ;; Memory or general register
        mov     dest, src
    ENDIF
ENDM

; Internal
__LdDub MACRO dub:REQ
    IF ((OPATTR (dub)) AND 00000100y)
        IF ((dub) LE 0FFFFh)
             sub  cx, cx
             mov  dx, dub
        ELSE
             sub  cx, HIGWORD dub
             mov  dx, LOWWORD dub
        ENDIF
    ELSEIF   TYPE (dub) EQ 2
        sub  cx, cx
        mov  dx, dub
    ELSEIF TYPE (dub) EQ 4
        mov  cx, dub[2]
        mov  dx, dub[0]
    ELSEIF TYPE (dub) EQ 0
        sub     cx, cx
        mov     dx, dub
    ELSE
        .ERR
        ECHO Illegal argument
    ENDIF
ENDM

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Syntax:    @GetChar [echo] [,[break] [,clearbuf]]
;
;  Summary:   Gets a keystroke from the keyboard
;
;  Arguments: <echo>         Nonzero to echo keystroke; default yes.
;                            Must be a constant.
;
;             <break>        Nonzero to accept CTRL+C; default yes. Must
;                            be a constant.
;
;             <clearbuf>     Nonzero to clear keyboard buffer; default
;                            no. Must be a constant.
;
;             NOTE: Arguments can be omitted to get defaults.
;
;  Returns:   ASCII code of key in AL
;
;  Modifies:  AX, else DL used if echo on and CTRL+C off
;
;  Uses:      Interrupt 21h Function 01h, 07h, 08h, 0Ch
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@GetChar MACRO ech:=<1>, cc:=<1>, clear:=<0>
    LOCAL   funct, disp
    disp    = 1
    IF  ech
        IF  cc
            funct   = 01h       ;; Echo with break checking
        ELSE
            funct   = 07h       ;; Echo without break checking
            disp    = 02h       ;; Need separate call to echo
        ENDIF
    ELSE
        IF  cc
            funct   = 08h       ;; No echo with break checking
        ELSE
            funct   = 07h       ;; No echo without break checking
        ENDIF
    ENDIF
    IFE clear
        mov     ah, funct       ;; Load function directly
    ELSE
        mov     ah, 0Ch         ;; If clear set, call function
        mov     al, funct       ;;  indirectly with function 0Ch
    ENDIF
    int     21h                 ;; Call DOS
    IF disp EQ 02h              ;; Separate call for echo without
        mov     dl, al          ;;  break checking
        mov     ah, disp
        int     21h
    ENDIF
ENDM

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Syntax:    @GetStr buffer [,[terminator] [,[limit] [,segment]]]
;
;  Summary:   Gets a string from the keyboard
;
;  Arguments: <buffer>         Offset of buffer for string. Must be an
;                              offset address.
;
;                              Byte 1    Maximum length of string before
;                                        call.
;                              Byte 2    Actual length of string after
;                                        call.
;                              Byte 3+   Bytes of string.
;
;             <terminator>     Terminating byte: null (0) or $ (24h).
;                              May be a constant or register, but not memory.
;
;             <limit>          Maximum length of string. Must be a
;                              constant. If not given as an argument,
;                              must be in buffer before call.
;
;             <segment>        Segment of buffer; DS if not given.
;
;  Returns:   Pointer to string in SI, length of string in BX
;
;  Modifies:  AX, DX, BX, SI
;
;  Uses:      Interrupt 21h Function 0Ah
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@GetStr MACRO ofset:REQ, terminator, limit, segmnt
    __LdAdr dx, <ofset>
    IFNB    <segmnt>
        __LdSeg ds, <segmnt>
    ENDIF
    mov     ah, 0Ah
    mov     si, dx
    IFNB    <limit>
        mov     BYTE PTR [si], limit
    ENDIF
    int     21h
    inc     si
    mov     bl, [si]
    sub     bh, bh
    inc     si
    IFNB    <terminator>
        mov     BYTE PTR [bx+si], terminator
    ENDIF
ENDM

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  Syntax:    @ShowChar char [,char]...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -