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

  1. Title   DateHack.ASM - Shows/Sets Computer Date - Calls TimeHack
  2. _TEXT   SEGMENT
  3.         ASSUME CS:_TEXT,DS:_TEXT,ES:_TEXT,SS:_TEXT
  4.         ORG     100H
  5. Main    Proc    Far
  6.         Jmp     Start
  7. Program DB  13,"Date Hack Version 1.0 Copyright (c) 1988"
  8. Useage  DB  13,10," for NON-Commercial Use ONLY!"
  9.         DB  13,10," Use and distribution without change"
  10.         DB  13,10,"  IS authorized and encouraged by"
  11. Author  DB  13,10,9,"Tom Gilbert's Heart&Mind",26
  12. Path    DB  "PATH=",128 DUP (0)
  13. File4B  DB  "TimeHack.COM"                          ; TimeHack Program
  14. MDTbl   DB  0,31,28,31,30,31,30,31,31,30,31,30,31   ; Days / Month
  15. Days    DB  "   Sunday","   Monday","  Tuesday"     ; Day and
  16.         DB  "Wednesday"," Thursday","   Friday"," Saturday"
  17. Mons    DB  "  January"," February","    March"     ; Month Name Tables
  18.         DB  "    April","      May","     June","     July"
  19.         DB  "   August","September","  October"," November"," December"
  20. Msg_St  DB  10,"Use RtLf Arrows to change Month, "
  21.         DB  "UpDn to change Day of Month and +/- for Year"
  22.         DB  13,10,9,9,9,9," <== ESC to EXIT or ENTER to SET this date"
  23. Date    DB  13,32 DUP(32),36            ; CRDayName, MonthName dd, yyyy$
  24. CRLF    DB  13,10,36                                ; New Line String
  25. OldCX   DW  ?                                       ; Entry Year
  26. OldDX   DW  ?                                       ; Month/Day
  27. NewDX   DW  ?                                       ; Month/Day
  28. NewCX   DW  ?                                       ; Year to SET
  29. SStack  DW  ?,?                                     ; Stack Storage
  30. PBlock  DW  0,80h,?,5Ch,?,6Ch,?                     ; Parameter Block
  31. Start:  Mov     AH,9                    ; Display
  32.         Mov     DX,OFFSET Msg_St        ; Complete
  33.         Int     21h                     ; Message
  34.         Mov     AH,2Ah                  ; Get DOS
  35.         Int     21h                     ; Date and
  36.         Mov     OldCX,CX                ; Store Year,
  37.         Mov     OldDX,DX                ; Month & Day
  38.         Mov     NewCX,CX                ; Copy for
  39.         Mov     NewDX,DX                ; Display
  40. ShoDL:  Call    ShowDate
  41.         Call    DoWhat                  ; Process Input
  42.         Cmp     AL,27                   ; If NOT ESCape Key
  43.         Jnz     CkCR                    ; Then Check <ENTER>
  44.         Mov     AH,2Bh                  ; Else Set Date
  45.         Mov     CX,OldCX                ; From Old Year
  46.         Mov     DX,OldDX                ; Month and Day
  47.         Int     21h
  48.         Mov     AH,2Ah                  ; Get Date and
  49.         Int     21h                     ; Day Name to
  50.         Mov     NewCX,CX                ; Restore Year
  51.         Mov     NewDX,DX                ; Month and Day
  52.         Call    ShowDate                ; Display Old Data
  53.         Jmp     SHORT Exit              ; and Exit Unchanged
  54. CkCR:   Cmp     AL,13                   ; If <ENTER>
  55.         Jz      IsCR                    ; Then SET
  56.         Mov     AH,2Ah                  ; Else Get
  57.         Int     21h                     ; DOS Date
  58.         Jnz     ShoDL                   ; and Loop
  59. IsCR:   Call    DoNew                   ; Set Date
  60.         Mov     DL,13                   ; Carriage
  61.         Mov     AH,2                    ; Return
  62.         Int     21h
  63.         Mov     AH,4Ah                  ; Modify Memory
  64.         Mov     BX,4096                 ;  to 64k Block
  65.         Int     21h                     ; If Fails
  66.         Jc      Exit                    ; Then Don't EXEC
  67.         Mov     PBlock[04],AX           ; Else Store Program
  68.         Mov     PBlock[08],AX           ; Segment Address in
  69.         Mov     PBlock[10],AX           ; Parameter Block
  70.         Push    DS                      ; Preserve
  71.         Push    ES                      ; Segments
  72.         Mov     CS:SStack[2],SS         ; and Stack
  73.         Mov     CS:SStack[0],SP         ; Pointer
  74.         Mov     AX,4B00h                ; EXECute with
  75.         Mov     BX,OFFSET PBlock        ; Parameter Block
  76.         Mov     DX,OFFSET File4B        ; TimeHack.COM
  77.         Int     21h
  78.         Mov     SS,CS:SStack[2]         ; Restore Stack
  79.         Mov     SP,CS:SStack[0]         ; Pointer and
  80.         Pop     ES                      ; Segment Registers
  81.         Pop     DS                      ; If EXEC was Ok
  82.         Jnc     Term                    ; Then Terminate
  83. Exit:   Mov     DX,OFFSET CRLF          ; Else End Line
  84.         Mov     AH,9                    ; so Blank Line
  85.         Int     21h                     ; before prompt
  86. Term:   Mov     AX,4C00h                ; Zero Error Level
  87.         Int     21h                     ; Exit to MS-DOS
  88. Main    EndP
  89. MaxDays     Proc
  90.             Mov     AX,NewDX            ; Get Day of Month
  91.             Mov     BL,AH               ; as an Offset to
  92.             Xor     BH,BH               ; Maximum Days
  93.             Add     BX,OFFSET MDTbl     ; per Month Table
  94.             Mov     BL,[BX]             ; Read Day Limit
  95.             Cmp     AH,2                ; If NOT February
  96.             Jnz     Compare             ; Then Compare to BL
  97.             Mov     AX,NewCX            ; Else Get Year Value
  98.             Mov     CX,4                ; Long Division by 4
  99.             Xor     DX,DX               ; Puts Remainder in DX
  100.             Div     CX                  ; If Remainder
  101.             Or      DX,DX               ; Then NOT a
  102.             Jnz     Compare             ; Leap Year
  103.             Inc     BL                  ; Else Leap
  104. Compare:    Cmp     Byte Ptr NewDX,BL   ; If Day Ok
  105.             Jle     MaxDayX             ; Then Exit
  106.             Mov     Byte Ptr NewDX,BL   ; Else Reset
  107.             Call    Beep                ; Ring Bell
  108.             Cmp     Byte Ptr NewDX,BL   ; Zero Flag
  109. MaxDayX:    Ret                         ; and Exit
  110. MaxDays     EndP
  111. DoWhat      Proc
  112.             Mov     AH,7                ; Get a Key
  113.             Int     21h                 ; Without Echo
  114.             Cmp     AL,27               ; If NOT ESCape
  115.             Jnz     DoCR                ; Then Do<ENTER>
  116.             Jmp     DoWx                ; Else Exit
  117. DoCR:       Cmp     AL,13               ; If NOT <ENTER>
  118.             Jnz     AddY                ; Then Try "+"
  119.             Jmp     DoWx                ; Else Exit
  120. AddY:       Cmp     AL,43               ; If "+"
  121.             Jz      Plus                ; Or If a
  122.             Cmp     AL,45               ; Minus "-"
  123.             Jz      Minus               ; Then Process
  124.             Or      AL,AL               ; Else If NOT 0
  125.             Jnz     DoWhat              ; Then Get Again
  126.             Mov     AH,7                ; Else Get the
  127.             Int     21h                 ; Extended Code
  128.             Cmp     AL,72               ; If NOT UpArrow
  129.             Jnz     CkDn                ; Then Check Down
  130.             Call    MaxDays             ; Else If Day Limit
  131.             Jz      DoNew               ; Then Ignore Key
  132.             Inc     Byte Ptr NewDX      ; Else Increment
  133.             Jmp     SHORT DoNew         ; Day of Month
  134. CkDn:       Cmp     AL,80               ; If NOT Dn Arrow
  135.             Jnz     CkRt                ; Then Check Right
  136.             Cmp     Byte Ptr NewDX,1    ; Else If NOT Limit
  137.             Jnz     DoDn                ; Then Sub a Day
  138.             Call    Beep                ; Else Sound Bell
  139.             Jmp     SHORT DoWhat        ;  and Reject Key
  140. DoDn:       Dec     Byte Ptr NewDX      ; Decrement
  141.             Jmp     SHORT DoNew         ; Day of Month
  142. CkRt:       Cmp     AL,77               ; If NOT Right
  143.             Jnz     CkLf                ; Then Check Left
  144.             Cmp     Byte Ptr NewDX[1],12; Else If NOT Limit
  145.             Jnz     IncM                ; Then Increment
  146.             Call    Beep                ; Else Sound Bell
  147.             Jmp     SHORT DoWhat        ;  and Reject Key
  148. IncM:       Inc     Byte Ptr NewDX[1]   ; Increase Month
  149.             Call    MaxDays             ; CheckUp on Day
  150.             Jmp     SHORT DoNew         ; and Reset Date
  151. CkLf:       Cmp     AL,75               ; If NOT Left
  152.             Jnz     DoWhat              ; Then Reject Key
  153.             Cmp     Byte Ptr NewDX[1],1 ; Else If NOT Limit
  154.             Jnz     DecM                ; Then Decrement
  155.             Call    Beep                ; Else Sound Bell
  156.             Jmp     SHORT DoWhat        ;  and Reject Key
  157. DecM:       Dec     Byte Ptr NewDX[1]   ; Decrement Month
  158.             Call    MaxDays             ; CheckUp on Day
  159.             Jmp     SHORT DoNew         ; and Reset Date
  160. Plus:       Cmp     NewCX,2099          ; If NOT Limit
  161.             Jnz     UpYr                ; Then Add Year
  162.             Call    Beep                ; Else Sound Bell
  163.             Jmp     DoWhat              ;  and Reject Key
  164. UpYr:       Inc     NewCX               ; Increment Year
  165.             Jmp     SHORT DoNew         ; Set New Date
  166. Minus:      Cmp     NewCX,1980          ; If NOT Limit
  167.             Jnz     DnYr                ; Then Sub Year
  168.             Call    Beep                ; Else Sound Bell
  169.             Jmp     DoWhat              ;  and Reject Key
  170. DnYr:       Dec     NewCX               ; Decrement Year
  171. DoNew:      Mov     AH,2Bh              ; Set New Date
  172.             Mov     CX,NewCX            ; Using New Year
  173.             Mov     DX,NewDX            ; and Month/Day
  174.             Int     21h
  175. DoWx:       Ret
  176. DoWhat      EndP
  177. Beep        Proc
  178.             Mov     DL,7                ; Ring
  179.             Mov     AH,2                ; Console
  180.             Int     21h                 ; Bell
  181.             Ret
  182. Beep        EndP
  183. BinToDec    Proc
  184.             Mov     CX,10               ; Set Divisor
  185. GetDigit:   Sub     DX,DX               ; Clear Top
  186.             Div     CX                  ; Get Decimal
  187.             Add     DL,"0"              ; ASCII Digit
  188.             Dec     BX                  ; Back-Up Index
  189.             Mov     DS:[DI+BX],DL       ; and Store Digit
  190.             Jnz     GetDigit            ; Until BX Stored
  191.             Ret
  192. BinToDec    EndP
  193. ShowDate    Proc
  194.             Mov     CX,9                ; Calculate
  195.             Mul     CL                  ; Day Offset
  196.             Mov     SI,OFFSET Days      ; Point to Sunday
  197.             Add     SI,AX               ; and add Offset
  198.             Mov     DI,OFFSET Date+1    ; Transfer Day
  199.             Rep     MovSB               ; Name to Date
  200.             Mov     AX," ,"             ; Add a Comma
  201.             StoSW                       ; and a Space
  202.             Mov     AX,NewDX            ; Get Month
  203.             Mov     AL,AH               ; Number as
  204.             Xor     AH,AH               ; Word Value
  205.             Dec     AX                  ; Zero Based
  206.             Mov     CX,9                ; Calculate
  207.             Mul     CL                  ; Month Offset
  208.             Mov     SI,OFFSET Mons      ; Point to January
  209.             Add     SI,AX               ; and add Offset
  210.             Rep     MovSB               ; Transfer MonthName
  211.             Inc     DI                  ; Advance Pointer
  212.             Mov     AX,NewDX            ; Get Day of Date
  213.             Xor     AH,AH               ; and Convert to
  214.             Aam                         ; Two Bytes as
  215.             Add     AX,"00"             ; ASCII Digits
  216.             Xchg    AH,AL               ; in Hi/Lo order
  217.             StoSW                       ; to put in string
  218.             Mov     AX," ,"             ; plus a Comma
  219.             StoSW                       ; and a Space
  220.             Mov     AX,NewCX            ; Get Year
  221.             Mov     BX,4                ; for four
  222.             Call    BinToDec            ; Digit Storage
  223.             Mov     AH,9                ; Display the
  224.             Mov     DX,OFFSET Date      ; Date String
  225.             Int     21h
  226.             Ret
  227. ShowDate    EndP
  228. _TEXT       EndS
  229.             End     Main
  230.