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

📄 rxdosstr.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        ;  Based On:                                                    ;
        ;                                                               ;
        ;   jdn = (long)(d - 32076)                                     ;
        ;       + 1461L * (y + 4800L + (m - 14) / 12) / 4               ;
        ;       + 367 * (m - 2 - (m - 14) / 12 * 12) / 12               ;
        ;       - 3 * ((y + 4900L + (m - 14) / 12) / 100) / 4           ;
        ;       + 1;            /* correction by rdg */                 ;
        ;                                                               ;
        ;...............................................................;

getDaysSince1980:

        Entry
        def _year, cx
        def _month, 0000
        def _day, 0000
        def _m14_12, 0000
        ddef _daysSince

        push bx
        push cx
        push dx

        mov byte ptr [ _month ][ bp ], dh
        mov byte ptr [ _day   ][ bp ], dl

        dec dh
        jnz getDaysSince1980_06
        mov word ptr [ _m14_12 ][ bp ], -1

getDaysSince1980_06:
        xor dx, dx
        mov ax, word ptr [ _m14_12 ][ bp ]
        mov cx, 12
        mul cx                                  ; *12
        inc ax
        inc ax                                  ; 2
        sub ax, word ptr [ _month ][ bp ]
        neg ax                                  ; - m_14
        mov cx, 367
        mul cx
        
        xor dx, dx
        mov cx, 12
        div cx
        mov word ptr [ _daysSince. _Low ][ bp ], ax
        mov word ptr [ _daysSince. _High ][ bp ], 0000

        mov ax, word ptr [ _m14_12 ][ bp ]
        add ax, 4900
        add ax, word ptr [ _year ][ bp ]

        xor dx, dx
        mov cx, 100
        div cx

        mov cx, 3
        mul cx

        shr ax, 1
        shr ax, 1                               ; / 4
        dec ax
        sub word ptr [ _daysSince. _Low  ][ bp ], ax
        sbb word ptr [ _daysSince. _High ][ bp ], 0000

        mov ax, word ptr [ _m14_12 ][ bp ]
        add ax, 4800
        add ax, word ptr [ _year ][ bp ]

        mov cx, 1461
        mul cx

    ; do a long shift here
        shr dx, 1
        rcr ax, 1
        shr dx, 1                               ; / 4
        rcr ax, 1
        add word ptr [ _daysSince. _Low  ][ bp ], ax
        adc word ptr [ _daysSince. _High ][ bp ], dx  

        xor dx, dx
        mov ax, word ptr [ _day ][ bp ]
        sub ax, 32076
        sbb dx, 0000
        add ax, word ptr [ _daysSince. _Low  ][ bp ]
        adc dx, word ptr [ _daysSince. _High ][ bp ]

        sub ax, 4BD0h
        sbb dx, 25h

getDaysSince1980_12:
        pop dx
        pop cx
        pop bx
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get System Date, Day of Week from Year, Month, Day           ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   cx     year                                                 ;
        ;   dh     month                                                ;
        ;   dl     day                                                  ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   dx     system day                                           ;
        ;   al     day of week (Sunday = 0, ... )                       ;
        ;...............................................................;

getSystemDateValue:

        Entry
        def  _year, cx                                  ; not adjusted
        def  _month                                     ; adjusted
        def  _day                                       ; adjusted
        def  _Totaldays

        push bx

        xor ax, ax
        mov al, dh
        storarg _month, ax

        mov al, dl
        storarg _day, ax

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        mov ax, 365
        sub cx, 1980
        mul cx                                          ; * 365
        storarg _Totaldays, ax

        or cx, cx                                       ; 1980 ?
        jz getSystemDateValue_06                        ; yes -->

        dec cx                                          ; adjust for current year
        shr cx, 1
        shr cx, 1                                       ; years / 4
        inc cx                                          ; adjust for 1980 (leap year)
        add word ptr [ _Totaldays ][ bp ], cx

     ;  or cx, cx                                       ; 1980 ?
     ;  jz getSystemDateValue_06                        ; yes -->
     ;  inc word ptr [ _Totaldays ][ bp ]               ; adjust days for 1980

getSystemDateValue_06:
     ;  xor dx, dx
     ;  mov ax, cx
     ;  mov bx, 100
     ;  div bx
     ;  sub word ptr [ _Totaldays ][ bp ], ax
        
     ;  shr ax, 1
     ;  shr ax, 1                                       ; years / 400
     ;  add word ptr [ _Totaldays ][ bp ], ax

        mov bx, word ptr [ _month ][ bp ]
        dec bx
        add bx, bx
        mov ax, word ptr cs:[ AccumDaysPerMonthTable ][ bx ]

        cmp word ptr [ _month ][ bp ], 2
        jle getSystemDateValue_08

        test word ptr [ _year ][ bp ], 11b
        jnz getSystemDateValue_08
        inc ax                                          ; adjust for leap year        

getSystemDateValue_08:
        add ax, word ptr [ _day ][ bp ]
        add ax, word ptr [ _Totaldays ][ bp ]
        push ax                                         ; save days

        xor dx, dx
        inc ax
        mov cx, 7
        div cx
        pop ax
        xchg ax, dx

        pop bx
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get System Date and Time In Dir Format                       ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     time of day                                          ;
        ;   dx     date                                                 ;
        ;...............................................................;

getSysDateinDirFormat:

        call getExpandedDateTime                        ; get system date

    ; date

        push cx
        push dx
        call getMonthDayYear                            ; conv sys day to [cx] = year, [dx] = mo/ day.
        call convSysDatetoDirDate                       ; convert [cx/dx] to [ax] date in dir format

    ; time

        pop dx
        pop cx                                          ; recall time
        push ax                                         ; save dir date
        call convSysTimetoDirTime                       ; convert time to dir format

        pop dx                                          ; date to dx
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Convert cx/dx date to Dir Date.                              ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   cx     year ( 1980 + )                                      ;
        ;   dh     month                                                ;
        ;   dl     day                                                  ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     date in dir format                                   ;
        ;...............................................................;

convSysDatetoDirDate:

        sub cx, 1980
        mov ax, cx
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1                                       ; shift over to get month

        or al, dh                                       ; month
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1

        or al, dl                                       ; day
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Convert cx/dx date to Dir Date.                              ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   ch     hours                                                ;
        ;   cl     minutes                                              ;
        ;   dh     seconds                                              ;
        ;   dl     hundredths of seconds                                ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     time in dir format                                   ;
        ;...............................................................;

convSysTimetoDirTime:

        mov al, ch                                      ; hours
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1

        or al, cl                                       ; minutes
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1
        shl ax, 1

        shr dh, 1
        or al, cl                                       ; seconds
        ret

RxDOS   ENDS
        END

⌨️ 快捷键说明

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