汇编源码系列之hdr

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

    PAGE  60, 132
TITLE  HDR   22-Feb-85    Device Driver Header          |
;-----------------------------------------------------------------------|
;                                    |
;    Device Driver Library                      |
;        Device Driver Header                  |
;                                    |
;-----------------------------------------------------------------------|
;    REVISION HISTORY                        |
;                                    |
; Number  DD-MMM-YY       WHO          WHY       |
;-------|---------------|-----------------------|-----------------------|
; 0.0  |  22-Feb-85  | Frank Whaley     | Initial Release    |
;-----------------------------------------------------------------------|
    PAGE
;-----------------------------------------------------------------------|
;    Equates                             |
;-----------------------------------------------------------------------|
StkSiz EQU   2048          ; local stack size
    PAGE
;-----------------------------------------------------------------------|
;    Group Selection                         |
;-----------------------------------------------------------------------|
PGROUP Group  PROG, TAIL
DGROUP Group  DATA, DTAIL
PROG  Segment Para Public 'PROG'
PROG  EndS
DATA  Segment Para Public 'DATA'   ; define first
DATA  EndS
    Assume CS:PROG, DS:DATA, ES:DATA, SS:DATA
    PAGE
;-----------------------------------------------------------------------|
;    Program Segment                         |
;-----------------------------------------------------------------------|
PROG  Segment Para Public 'PROG'
    Extrn  Init:Near,   MediaChe:Near, BuildBPB:Near
    Extrn  IoCtlIn:Near,  Input:Near,   ndInput:Near
    Extrn  InputSta:Near, InputFlu:Near, Output:Near
    Extrn  OutVerif:Near, OutStatu:Near, OutFlush:Near
    Extrn  IoCtlOut:Near, DevOpen:Near,  DevClose:Near
    Extrn  RemMedia:Near
    ORG   0
HDR   Proc  Far
;-----------------------------------------------------------------------|
;    Device Header                          |
;-----------------------------------------------------------------------|
    DD   -1           ; -> next device
;    DW   theAttribute      ; you must enter attribute field
    DW   8000H          ; character only device
    DW   Strategy        ; -> device strategy
    DW   Interrupt        ; -> device interrupt
;    DB   theName         ; you must put something here
    DB   "MON   "       ; mono
;-----------------------------------------------------------------------|
;    Code Segment Variables                     |
;-----------------------------------------------------------------------|
RHptr  DD   (?)           ; -> Request Header
ssEntry DW   (?)           ; entry SS
spEntry DW   (?)           ; entry SP
    PAGE
;-----------------------------------------------------------------------|
;    Device Strategy                         |
;                                    |
;    ENTRY : ES:BX -> Request Header                 |
;                                    |
;    EXIT : Request Header copied to ReqHdr             |
;        all registers preserved                 |
;                                    |
;-----------------------------------------------------------------------|
Strategy:
    MOV   Word Ptr CS:RHptr,BX  ; save request header ptr
    MOV   Word Ptr CS:RHptr + 2,ES
    PUSHF              ; (+1) save the world
    PUSH  ES           ; (+2)
    PUSH  DS           ; (+3)
    PUSH  SI           ; (+4)
    PUSH  DI           ; (+5)
    PUSH  CX           ; (+6)
    PUSH  BX           ; (+7)
    MOV   SI,BX
    MOV   BX,ES
    MOV   DS,BX          ; DS:SI -> Request Header
    MOV   BX,Offset PGROUP:TAIL
    MOV   CL,4
    SHR   BX,CL
    MOV   CX,CS
    ADD   BX,CX
    MOV   ES,BX
    MOV   DI,Offset DGROUP:ReqHdr ; ES:DI -> ReqHdr
    CLD
    XOR   CH,CH
    MOV   CL,[SI]
    REP   MOVSB          ; copy Request Header
    POP   BX           ; (+6) restore
    POP   CX           ; (+5)
    POP   DI           ; (+4)
    POP   SI           ; (+3)
    POP   DS           ; (+2)
    POP   ES           ; (+1)
    POPF              ; (+0)
    RET
    PAGE
;-----------------------------------------------------------------------|
;    Device Interrupt                        |
;                                    |
;    ENTRY : anything                        |
;                                    |
;    EXIT : all registers preserved                 |
;                                    |
;-----------------------------------------------------------------------|
Interrupt:
    PUSH  DS           ; (+1) save the world
    PUSH  ES           ; (+2)
    PUSH  AX           ; (+3)
    PUSH  BX           ; (+4)
    PUSH  CX           ; (+5)
    PUSH  DX           ; (+6)
    PUSH  SI           ; (+7)
    PUSH  DI           ; (+8)
    PUSH  BP           ; (+9)
    MOV   CS:ssEntry,SS      ; save entry SS
    MOV   CS:spEntry,SP      ; and SP
    MOV   AX,Offset PGROUP:TAIL  ; set our DS, SS, BP, and SP
    MOV   CL,4
    SHR   AX,CL
    MOV   CX,CS
    ADD   AX,CX
    MOV   BX,Offset DGROUP:MyStack
    MOV   DS,AX
    MOV   ES,AX
    MOV   SS,AX
    MOV   SP,BX
    MOV   BP,BX
    ;
    ; call our function
    ;
    MOV   AL,ReqHdr + 2      ; AL = Command Code
    SHL   AL,1
    CBW
    MOV   SI,Offset DGROUP:FuncTab
    ADD   SI,AX
    CALL  Word Ptr [SI]
    ;
    ; copy back Request Header
    ;
    LES   DI,RHptr        ; ES:DI -> original space
    MOV   SI,Offset DGROUP:ReqHdr ; DS:SI -> our (updated) copy
    CLD
    XOR   CH,CH
    MOV   CL,[SI]
    REP   MOVSB          ; copy Request Header
    MOV   SS,CS:ssEntry      ; restore original stuff
    MOV   SP,CS:spEntry
    POP   BP           ; (+8) restore
    POP   DI           ; (+7)
    POP   SI           ; (+6)
    POP   DX           ; (+5)
    POP   CX           ; (+4)
    POP   BX           ; (+3)
    POP   AX           ; (+2)
    POP   ES           ; (+1)
    POP   DS           ; (+0)
    RET
HDR   EndP
PROG  EndS
TAIL  Segment Public 'PROG'      ; for finding end of code segment
TAIL  EndS
    PAGE
;-----------------------------------------------------------------------|
;    Data Segment                          |
;-----------------------------------------------------------------------|
DATA  Segment Para Public 'DATA'
    Public ReqHdr
    DB   StkSiz DUP (?)     ; our stack, overflows into code
MyStack Label  Word
FuncTab Label Word
    DW   Offset PGROUP:Init
    DW   Offset PGROUP:MediaChe
    DW   Offset PGROUP:BuildBPB
    DW   Offset PGROUP:IoCtlIn
    DW   Offset PGROUP:Input
    DW   Offset PGROUP:ndInput
    DW   Offset PGROUP:InputSta
    DW   Offset PGROUP:InputFlu
    DW   Offset PGROUP:Output
    DW   Offset PGROUP:OutVerif
    DW   Offset PGROUP:OutStatu
    DW   Offset PGROUP:OutFlush
    DW   Offset PGROUP:IoCtlOut
    DW   Offset PGROUP:DevOpen
    DW   Offset PGROUP:DevClose
    DW   Offset PGROUP:RemMedia
ReqHdr DB   256 DUP (?)       ; copy of Request Header
DATA  EndS
DTAIL  Segment Public 'DATA'      ; for finding end of data segment
DTAIL  EndS
    END   HDR           ; of HDR.ASM

时间: 2024-10-28 01:08:46

汇编源码系列之hdr的相关文章

汇编源码系列之dev

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name dev page 60,132 title 'DEV --- Report installed device drivers'; DEV --- a utility to report device header information for; all installed device drivers;; Requires P

汇编源码系列之clear

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clear page 55,132 title 'CLEAR --- control PC display';; CLEAR Utility to clear display; and set character attributes;; Ray Duncan, Uncopyright (u) August 1983; This

汇编源码系列之clock

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... CGROUP GROUP VECTOR,CODESEGVECTOR SEGMENT AT 0H DB 6CH DUP(?) ;FILLERTIME_LO DW ? ;DOS TIMETIME_HI DW ? ;DOS TIMEVEC_IP DW ;CLOCK UPDATE VECTOR IPVEC_CS DW ;CLOCK UPDATE

汇编源码系列之charop

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... title MSDOS 2.00 Function Library for Lattice Csubttl -;;;;FUNCTION: Sets and returns switch char-;; acter and device availability.;;;;;;CALL:;;;; ret= _charop(al,dl);; i

汇编源码系列之clean

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clean page 55,132 title 'CLEAN --- Filter text file';; CLEAN --- a utility to filter text files.; This program removes all control codes except; for line feeds, carr

汇编源码系列之cleanf

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name cleanf page 55,132 title 'CLEANF - Filter text file';; CLEANF - a DOS 2.0 filter for word processing document files.;; CLEAN.ASM Originally written by Ray Duncan; Co

汇编源码系列之burnout

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... COMMENT * Demo (and semi-useful) program to read/set burnout device parameters. Usage: burnout [ticks] [C+-] [V+-] [H+-] Parameters can be separated by almost anything. W

汇编源码系列之calc

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... PAGE ,132 TITLE CALCCGROUP GROUP CODESEGCODESEG SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CGROUP,DS:CGROUP,ES:CGROUP PUBLIC CALC ORG 100HCALC PROC FAR JMP START;--------------

汇编源码系列之char

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... ctable segment para public 'DATA db 9 dup(' ') db 9,10,' ',12,13 db 13 dup(' ') db 27 db 4 dup(' ') db ' !"#$%&',39,'()*+,-./0123456789:;<=>?@' db 'ABCDEFGHIJKL