home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / HARDWARE / AT_TCLK.ZIP / CLOCKDEV.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-03-21  |  4.1 KB  |  115 lines

  1. TITLE        DEVICE    DRIVER FOR AT&T 6300 CLOCK
  2.  
  3. CODE        SEGMENT
  4.         ORG    0
  5.  
  6.         ASSUME    CS:CODE,DS:NOTHING,ES:NOTHING
  7. ;------------------------------------------------------------------------------
  8. NEXTDEV     DD    0FFFFFFFFH       ; Header for MSDOS
  9. ATTRIB        DW    8008H           ; Device driver
  10. STRATEGY    DW    OFFSET STRAT
  11. INTENTRY    DW    OFFSET INTERRUPT
  12. DEVICENAME    DB    'CLOCK$  '
  13. PARMBLOCK    DD    ?           ; Parameter block address
  14. STARTYEAR    DW    1           ; Number of 4 year blocks
  15.                        ; since 1980.. Increment
  16.                        ; every 4 years ( make this
  17.                        ; value 2 in 1988 )
  18.                        ; Value 1 valid for 1984 to 87
  19. ;------------------------------------------------------------------------------
  20. ;Strategy routine for device driver
  21. ;------------------------------------------------------------------------------
  22. STRAT        PROC    FAR
  23.         MOV    WORD PTR CS:(PARMBLOCK+2),ES  ; Save the parameter
  24.         MOV    WORD PTR CS:PARMBLOCK,BX   ; block address and return
  25.         RET
  26. ;------------------------------------------------------------------------------
  27. ;Interrupt routine for device driver
  28. ;------------------------------------------------------------------------------
  29. STRAT        ENDP
  30. INTERRUPT    PROC    FAR
  31.         PUSH    SI       ; Save registers which might be
  32.         PUSH    AX       ; trashed..
  33.         PUSH    CX
  34.         PUSH    DX
  35.         PUSH    DI
  36.         PUSH    DS
  37.         PUSH    ES
  38.         PUSH    BX
  39.         LDS    BX,CS:PARMBLOCK  ; Point DS:BX to parameter block
  40.         MOV    AL,[BX+02]
  41.         LES    DI,[BX+0EH]      ; ES:DI has address of data now
  42.         PUSH    CS
  43.         POP    DS
  44.         OR    AL,AL
  45.         JNZ    NOTINIT      ; If function 0 then initialize
  46.         JMP    INIT         ; device driver
  47. NOTINIT:    CMP    AL,0CH
  48.         JA    ERROR         ; If function > 12 then error
  49.         CMP    AL,3
  50.         JB    DONOTHING     ; Functions 1 & 2 are not relevant
  51.         JZ    IOCTL_READ     ; If 3 then it's an IO_CTL_READ
  52.         CMP    AL,4
  53.         JZ    READ         ; If 4 then it's read from clock
  54.         CMP    AL,8
  55.         JB    DONOTHING     ; 5,6 and 7 are not relevant too..
  56.         JZ    WRITE         ; 8 and 9 are Write to clock
  57.         CMP    AL,9         ; commands.. use same code for
  58.         JZ    WRITE         ; both... Verify not implemented
  59.         JA    DONOTHING     ; All other codes are irrelevant
  60. IOCTL_READ:    XOR    AX,AX         ; This device does not process
  61.         LDS    BX,CS:PARMBLOCK  ; IO Control strings
  62.         MOV    [BX+12H],AX    ; Hence set data count to 0
  63. ERROR:        MOV    AX,8103H       ; Return "Unknown Command"
  64.         JMP    SHORT FINISH   ; Status
  65. ;--------------------------------------------------------------------------
  66. DONOTHING:    MOV    AH,01         ; Return "Done" status
  67. FINISH:     LDS    BX,CS:PARMBLOCK ; Move appropriate value into
  68.         MOV    [BX+3],AX     ;  Parameter block status byte
  69.         POP    BX          ; Retrieve registers from
  70.         POP    ES          ; stack and Return
  71.         POP    DS
  72.         POP    DI
  73.         POP    DX
  74.         POP    CX
  75.         POP    AX
  76.         POP    SI
  77.         RET
  78. ;--------------------------------------------------------------------------
  79. WRITE:        MOV    AX,ES:[DI]   ; Get number of days since 1-1-1980
  80.         XOR    DX,DX
  81.         MOV    BX,1461      ; 1461 days is 4 years
  82.         DIV    BX         ; Get number of 4 year blocks
  83.         MOV    STARTYEAR,AX ; Update value of STARTYEAR
  84.         MOV    BX,DX         ; BX holds days modulus 1461
  85.         MOV    CH,ES:[DI+3] ; Get hours
  86.         MOV    CL,ES:[DI+2] ; and minutes
  87.         MOV    AH,0FFH      ; And use BIOS call
  88.         INT    1AH         ; INT 1A to set clock/calender
  89.         STI             ; Enable interrupts
  90.         JMP    DONOTHING    ; and Jump to returncode
  91. ;--------------------------------------------------------------------------
  92. READ:        MOV    AH,0FEH      ; Use BIOS call INT 1A
  93.         INT    1AH         ; to read from clock/calender
  94.         PUSH    DX
  95.         MOV    AX,1461      ; Correct number of days using
  96.         MUL    WORD PTR STARTYEAR  ; value of STARTYEAR
  97.         POP    DX
  98.         ADD    BX,AX
  99.         MOV    ES:[DI],BX   ; Store number of days since 1-1-80
  100.         MOV    ES:[DI+3],CH ; hours,
  101.         MOV    ES:[DI+2],CL ; minutes,
  102.         MOV    ES:[DI+5],DH ; seconds,
  103.         MOV    ES:[DI+04],DL ; and hundredths of seconds into
  104.                       ; Parameter block data area
  105.         JMP    DONOTHING     ; and jump to return code
  106. ;--------------------------------------------------------------------------
  107. INIT:        LDS    BX,PARMBLOCK  ; Nothing to initialize
  108.         MOV    WORD PTR [BX+14],OFFSET INIT ; except
  109.         MOV    [BX+16],CS    ; Indicate end of device driver
  110.         JMP    DONOTHING     ; code to DOS and exit
  111. INTERRUPT    ENDP
  112. ;----------------------------------------------------------------------------
  113. CODE        ENDS
  114. END
  115.