home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / OKTIMDAT.ZIP / ET.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-11-23  |  6.7 KB  |  143 lines

  1. Title   ET.ASM - Measures Elapsed Time
  2.  
  3. CODE    SEGMENT PUBLIC  'CODE'
  4.         ASSUME  CS:CODE,DS:CODE,ES:Nothing,SS:CODE
  5.         ORG     100H
  6. BEGIN:  JMP     START
  7. ADJUST  DB      24,60,60,100,13         ; Hr, Min, Sec.00 +CR
  8.  
  9. Program DB  "Elapsed Time "             ; 13 byte Signon
  10. Version     DB  "1.0 "
  11. Copyright   DB  13,10,"(c) 1988"
  12. Author      DB  13,10,"By: Tom Gilbert's Heart&Mind"
  13. Usage       DB  13,10,"for NON-Commercial Use ONLY!",13,10
  14.             DB  "Use and distribution without charge",13,10
  15.             DB  " IS authorized and encouraged.",26
  16.  
  17. Report  DB  "started NOW",13            ; 12 byte Report
  18. Failed  DB  "ICA in use",7              ; 11 byte Over-Write
  19.  
  20. ETHM    DB  "ETHM"      ; ElapsedTimeHeart&Mind Signature at
  21. ICA0   EQU   0F0h       ; Beginning of Inter-application
  22. ICA4   EQU   0F4h       ; Communication Area - ET uses 8 bytes
  23.  
  24. START:  Mov     AX,40h                  ; Point to
  25.         Mov     ES,AX                   ; Lo-Mem
  26.         Mov     DI,ICA0                 ;  I C A
  27.         Cmp     Byte Ptr DS:[80h],0     ; If NO Command
  28.         Jz      CkICA                   ; Then Check ICA
  29.         And     Word Ptr DS:[82h],5F5Fh ; Else If UPPER
  30.         Cmp     Word Ptr DS:[82h],"MH"  ; Case "HM" found
  31.         Jz      FIRST                   ; Then ReStart
  32. CkICA:  Mov     SI,OFFSET ETHM          ; Else If "ETHM"
  33.         Mov     CX,4                    ; Signature
  34.         Rep     CmpSB                   ; Begins ICA
  35.         Je      NEXT                    ; Then Continue
  36.         Mov     CX,4                    ; Else If Four
  37.         Xor     AX,AX                   ; Null Words
  38.         Mov     DI,ICA0                 ; mean ICA
  39.         Rep     ScaSW                   ; NOT in Use
  40.         Je      FIRST                   ; Then Start ET
  41.         Mov     CX,11                   ; Else 11 Byte
  42.         Mov     SI,OFFSET Failed        ; Over-Write
  43.         Push    DS                      ; Data
  44.         Pop     ES                      ; Segment
  45.         Mov     DI,OFFSET Report        ; Report and
  46.         Rep     MovSB                   ; Report In Use
  47.         Jmp     Exit                    ; on Error Exit
  48.  
  49. FIRST:  Mov     DI,ICA0                 ; Point to
  50.         Mov     SI,ICA4                 ; ICA and
  51.         Mov     AH,2Ch                  ; Get Current
  52.         Int     21h                     ; DOS Time and
  53.         Mov     ES:[SI+0],CH            ; Store Hours
  54.         Mov     ES:[SI+1],CL            ; Minutes,
  55.         Mov     ES:[SI+2],DH            ; Seconds and
  56.         Mov     ES:[SI+3],DL            ; Hundredths
  57.         Jmp     SHORT DoSig             ; ETHM & Exit
  58.  
  59. NEXT:   Mov     DI,ICA0                 ; Set ICA
  60.         Mov     SI,ICA4                 ; Pointers and
  61.         Mov     BP,3                    ; Borrow Level
  62.         Mov     AH,2Ch                  ; Get Current
  63.         Int     21h                     ; MS-DOS Time
  64.         Mov     ES:[DI+0],CH            ; Store Hours
  65.         Mov     ES:[DI+1],CL            ; Minutes,
  66.         Mov     ES:[DI+2],DH            ; Seconds and
  67.         Mov     ES:[DI+3],DL            ; Hundredths
  68.         Mov     CX,4                    ; Four Items
  69.  
  70. ETLp:   Mov     AL,ES:[DI+BP]           ; If Current
  71.         Cmp     AL,ES:[SI+BP]           ; Is => Start
  72.         Jnc     ETOk                    ; Then Ok to Sub
  73.         Add     AL,DS:[ADJUST+BP]       ; Else Adjust
  74.         Call    ETB                     ; by Borrowing
  75. ETOk:   Sub     AL,ES:[SI+BP]           ; Calculate Elapsed
  76.         Mov     ES:[DI+BP],AL           ; Value and Store It
  77.         Dec     BP                      ; Move Left and Loop
  78.         Loop    ETLp                    ; Until Hours are Done
  79.  
  80.         Mov     SI,OFFSET Report        ; Point to Report
  81.         Mov     AL,ES:[DI+0]            ; Get Elapsed Hours
  82.         Call    AL2ASC                  ; ASCII Decimal Digits
  83.         Mov     [SI+0],AX               ; and Store in Report
  84.         Mov     Byte Ptr [SI+2],":"     ; plus ":" separator
  85.         Mov     AL,ES:[DI+1]            ; Get Elapsed Minutes
  86.         Call    AL2ASC                  ; ASCII Decimal Digits
  87.         Mov     [SI+3],AX               ; and Store in Report
  88.         Mov     Byte Ptr [SI+5],":"     ; plus ":" separator
  89.         Mov     AL,ES:[DI+2]            ; Get Elapsed Seconds
  90.         Call    AL2ASC                  ; ASCII Decimal Digits
  91.         Mov     [SI+6],AX               ; and Store in Report
  92.         Mov     Byte Ptr [SI+8],"."     ; plus "." separator
  93.         Mov     AL,ES:[DI+3]            ; Get Elapsed Hundredths
  94.         Call    AL2ASC                  ; ASCII Decimal Digits
  95.         Mov     [SI+9],AX               ; and Store in Report
  96. DoSig:  Mov     SI,OFFSET ETHM          ; Restore ET
  97.         Mov     CX,4                    ; Signature
  98.         Rep     MovSB
  99. Exit:   Mov     DX,OFFSET Program       ; Display
  100.         Mov     CX,13                   ; "Elapsed Time "
  101.         Call    StdOut
  102.         Mov     DX,OFFSET Report        ; Display
  103.         Mov     CX,12                   ; Report
  104.         Call    StdOut
  105.         Mov     AL,DS:[Report+10]       ; If Last Byte
  106.         Cmp     AL,7                    ; of Report is Bell
  107.         Jz      ELX                     ; Then Error Level 7
  108.         Xor     AL,AL                   ; Else Zero Error Level
  109. ELX:    Mov     AH,4Ch                  ; Exit to MS-DOS with
  110.         Int     21h                     ; Error Level in AL
  111.  
  112. StdOut: Mov     AH,40h                  ; Output to
  113.         Mov     BX,1                    ; Console
  114.         Int     21h                     ; CX bytes at DX
  115.         Ret
  116.  
  117. ; Borrow from Seconds, Minutes and/or Hours if necessary
  118. ETB:    Sub Byte Ptr ES:[DI+BP-1],1     ; If Borrow Ok
  119.         Jnc ETBX                        ; Then Exit
  120.         Mov DL,DS:[ADJUST+BP-1]         ; Else Increase
  121.         Add ES:[DI+BP-1],DL             ; Next for Borrow
  122.         Cmp DL,24                       ; If was Hours
  123.         Jz  ETBX                        ; Then Done
  124.         Sub Byte Ptr ES:[DI+BP-2],1     ; Else If Next Ok
  125.         Jnc ETBX                        ; Then Exit
  126.         Mov DL,DS:[ADJUST+BP-2]         ; Else Increase
  127.         Add ES:[DI+BP-2],DL             ; Next for Borrow
  128.         CmP DL,24                       ; If was Hours
  129.         Jz  ETBX                        ; Then Done
  130.         Sub Byte Ptr ES:[DI+BP-3],1     ; Else If Next Ok
  131.         Jnc ETBX                        ; Then Exit
  132.         Mov DL,DS:[ADJUST+BP-3]         ; Else Increase
  133.         Add ES:[DI+BP-3],DL             ; Next for Borrow
  134. ETBX:   Ret
  135.  
  136. AL2ASC: Aam                             ; Make BCD and
  137.         Add     AX,"00"                 ; ASCII Digits
  138.         Xchg    AH,AL                   ; for Storage
  139.         Ret
  140.  
  141. CODE    EndS
  142.         END     BEGIN
  143.