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

📄 rxdosstr.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        cmp al, ';'
        jz __convfilename_28                            ; semicolon is end of name -->
        jmp __convfilename_20

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

__convfilename_26:
        dec si
        xor ax, ax                                      ; invalid term ends with null

__convfilename_28:
        cmp al, '.'                                     ; last character parsed a period ?
        pop di
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Convert FCB Name to ASCIZ                                    ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   arg    FCB                                                  ;
        ;   arg    expanded name buffer                                 ;
        ;                                                               ;
        ;...............................................................;

convFCBNametoASCIZ:

        Entry 4
        darg _source
        darg _destination

        SaveSegments di, si, dx

        getdarg ds, si, _source
        push word ptr [ si ]                            ; drive code from fcb
        call getActualDrive                             ; convert to actual
        mov al, dl                                      ; in case of error, restore value
        
        mov ah, ':'
        add al, 'a'

        getdarg es, di, _destination
        stosw

        mov si, word ptr [ _source. _pointer ][ bp ]
        lea si, offset fcbName [ si ]
        mov cx, sizefnName

convFCBName_08:
        lodsb                                           ; get character
        cmp al, ' '+1
        jc convFCBName_12
        stosb                                           ; copy filename
        loop convFCBName_08

convFCBName_12:
        mov cx, sizefnExtension
        mov si, word ptr [ _source. _pointer ][ bp ]
        lea si, offset fcbExtension [ si ]
        cmp byte ptr [ si ], ' '+1
        jc convFCBName_20

        mov al, '.'                                     ; place a period after
        stosb

convFCBName_14:
        lodsb
        cmp al, ' '+1
        jc convFCBName_20
        stosb                                           ; copy extension
        loop convFCBName_14

convFCBName_20:
        mov byte ptr es:[ di ], 0                       ; NULL terminator
        restoreSegments dx, si, di
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Convert al byte to es:[di]                                   ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   al     byte                                                 ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   [di]   two byte ascii contents of [al]                      ;
        ;...............................................................;

__ascii_stosb:
        push ax
        mov ah, al
        shr al, 1
        shr al, 1
        shr al, 1
        shr al, 1
        and ax, 0f0fh                                   ; mask off extra bits
        add ax, 'AA'                                    ; convert to ascii
        stosw                                           ; save
        pop ax                                          ; restore ax
        ret

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

getMonthDayYear:

        push bx

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  compute year
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        xor dx, dx
        mov cx, 365
        div cx                                          ; expected years

        mov cx, ax                                      ; year to cx
        test cx, 11b                                    ; leap year ?
        jz getMonthDayYear_08                           ; yes -->
        dec dx                                          ; adjust days left in year
        call _daysAdjust                                ; adjust for days in year

getMonthDayYear_08:
        shr cx, 1
        shr cx, 1                                       ; divide by 4
        sub dx, cx                                      ; day this year
        jnc getMonthDayYear_10                          ; this year -->
        call _daysAdjust                                ; adjust for days in year

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  compute month
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getMonthDayYear_10:
        xor ch, ch
        xor bx, bx
        xchg ax, dx                                     ; day this year

getMonthDayYear_12:
        mov cl, byte ptr ss:[ DaysInMonthTable ][ bx ]
        test dx, 11b                                    ; leap year ?
        jnz getMonthDayYear_14                          ; no -->
        cmp bl, 1                                       ; is this february ?
        jnz getMonthDayYear_14                          ; no -->
        inc cl

getMonthDayYear_14:
        cmp ax, cx                                      ; this month ?
        jc getMonthDayYear_20                           ; yes -->

        sub ax, cx                                      ; account for this month
        inc bx
        jmp getMonthDayYear_12

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  dx year, bx month, ax day
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getMonthDayYear_20:
        mov cx, dx
        add cx, 1980                                    ; year

        mov dh, bl                                      ; month
        mov dl, al                                      ; day
        add dx, 0101h                                   ; within proper range

        call getDayOfWeek
        pop bx
        ret

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  adjust for undeflow in year/ day
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_daysAdjust:

        or dx, dx                                       ; days left negative ?
        jge _daysAdjust_08                              ; no -->

        dec ax                                          ; convert to days
        add dx, 365                                     ; if wrap around error, 
        test ax, 11b                                    ; leap year ?
        jnz _daysAdjust_08                              ; no -->
        inc dx                                          ; if leap year

_daysAdjust_08:
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Day of Week                                              ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   cx     year   ( 1980 ... )                                  ;
        ;   dh     month  ( 1 - 12)                                     ;
        ;   dl     day    ( 1 - 31)                                     ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     day of week (Sunday = 0, ... )                       ;
        ;...............................................................;

getDayOfWeek:

        Entry
        def dayofweek

        push bx
        push cx
        push dx
        mov bx, dx
        sub bh, 2                                       ; past february ?
        jg getDayOfWeek_08                              ; yes -->

        add bh, 12                                      ; rotate full year
        dec cx                                          ; adjust year

getDayOfWeek_08:
        mov ax, 13                                      ;
        mul bh                                          ; months * 13
        dec ax                                          ; 13 * months - 1 
        mov dh, 5
        div dh                                          ; (13 * months - 1)/5
        xor ah, ah                                      ; ignore remainder

        add al, bl                                      ; add days
        storarg dayofweek, ax                           ; save interim value

        xor dx, dx
        mov ax, cx                                      ; copy years
        mov cx, 100                                     ; century
        div cx                                          ; centuries in ax/ years in dx

        add word ptr [ dayofweek ][ bp ], dx            ; add year

        shr dx, 1        
        shr dx, 1        
        add word ptr [ dayofweek ][ bp ], dx            ; add year/4

        mov dx, ax
        shr dx, 1        
        shr dx, 1        
        add word ptr [ dayofweek ][ bp ], dx            ; add century/4

        add ax, ax                                      ; 2 * century
        sub word ptr [ dayofweek ][ bp ], ax            ; sub 2*century

        xor dx, dx
        getarg ax, dayofweek
        mov cx, 7
        div cx                                          ; divide by 7

        mov dx, ax
        add ax, ax                                      ; x2
        add dx, ax                                      ; x3
        add ax, ax                                      ; x4
        add dx, ax                                      ; x7
        
        getarg ax, dayofweek
        sub ax, dx                                      ; real day of week
        jge getDayOfWeek_12                             ; if ok -->
        add ax, 7                                       ; else warp around day of week

getDayOfWeek_12:
        pop dx
        pop cx
        pop bx
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Days Since 1980                                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   cx     year   ( 1980 ... )                                  ;
        ;   dh     month  ( 1 - 12)                                     ;
        ;   dl     day    ( 1 - 31)                                     ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ax     days since 1980 format                               ;
        ;                                                               ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;

⌨️ 快捷键说明

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