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

📄 jacts.asm

📁 工欲善其事
💻 ASM
📖 第 1 页 / 共 4 页
字号:
update_display  PROC hWnd:HWND
;_______________________________________________________________________
;Uses tseconds.dwHighDateTime & tseconds.dwLowDateTime
;   this 64 bit number contains the number of seconds until the alarm
;   expires.  Divide the number by 3600 to calculate the number of hours
;   remaining, the remainder-(minutes)-is divided by 60 to calculate
;   the number of seconds remaining.  Display Hours:minutes:seconds!
;If def_acorr == 'P' show final time with decimal seconds
LOCAL   rhours:FILETIME     ;Max = 2^64 / 3600 = 5.1241 x 10 ^ 15
;                                = 5,124,100,000,000,000    possible 22 chars long with commas
LOCAL   rmins:DWORD         ;Max = 59
LOCAL   rsecs:DWORD         ;Max = 59
LOCAL   rmsecs:DWORD        ;Max = 999
LOCAL   secs_p_hours        ;Set to 3600 for secs, 3600000 for msecs
LOCAL   dhours[22]:BYTE
LOCAL   dmins[3]:BYTE
LOCAL   dsecs[3]:BYTE
LOCAL   dmsecs[4]:BYTE
LOCAL   stat_str[60]:BYTE
LOCAL   jact[5]:BYTE
    cld
    mov al, 0
    mov ecx, sizeof stat_str
    lea edi, stat_str
    rep stosb
    mov ecx, sizeof dhours
    lea edi, dhours
    rep stosb               ;make sure space for hour string is blank
    mov ecx, sizeof dmins
    lea edi, dmins
    rep stosb               ;make sure space for minute string is blank
    mov ecx, sizeof dsecs
    lea edi, dsecs
    rep stosb               ;make sure space for second string is blank
    mov ecx, sizeof dmsecs
    lea edi, dmsecs
    rep stosb               ;make sure space for milli-second string is blank
    .if (def_acorr != 'P')  ;tseconds structure holds # of seconds to display
        mov rmins, 3600
        mov rsecs, 60
        fild    tseconds    ;dividend
        fidiv   rmins
        frndint
        fistp   rhours      ;store hour number in rhours
        fild    rmins
        fild    tseconds
        fprem               ;remainder in st(0)? this is minutes & seconds
        ffree   st(1)
        fild    rsecs
        fxch    st(1)
        fld     st(1)       ;make a copy for the remainder
        fld     st(1)
        fdivrp  st(1),st(0) ;divide minutes & seconds by 60
        frndint
        fistp   rmins
        fprem
        fistp   rsecs
        ffree   st(0)
    .else                   ;tseconds structure holds # of milliseconds to display
        mov rmins, 3600000  ;msecs / hour
        mov rsecs, 60000    ;msecs / minute
        mov rmsecs, 1000    ;msecs / sec
        fild    tseconds
        fidiv   rmins       ;divides msecs by msecs/hour to give hours
        frndint             ;rounds down to lower integer
        fistp   rhours      ;store hour number in rhours
        fild    rmins
        fild    tseconds
        fprem               ;remainder in st(0)? this is minutes & seconds remaining in msecs
        ffree   st(1)
        fild    rsecs       ;loads msecs/minute
        fxch    st(1)       ;swaps st(0) & st(1) - msecs/minute in 1 remainder in 0
        fld     st(1)       ;make a copy for the remainder
        fld     st(1)
        fdivrp  st(1),st(0) ;divide minutes & seconds by 60000
        frndint             ;rounds down to lower integer
        fistp   rmins       ;store rmins
        fprem               ;remainder in st(0) - seconds in msecs
        ffree   st(1)
        fild    rmsecs      ;loads msecs/sec
        fxch    st(1)       ;swaps st(0) & st(1)
        fld     st(1)       ;make a copy for the remainder
        fld     st(1)
        fdivrp  st(1),st(0) ;divide seconds & millisecond by 1000
        frndint             ;rounds down to lower integer
        fistp   rsecs       ;store rsecs
        fprem               ;remainder in st(0) - msecs
        fistp   rmsecs
        ffree   st(0)
    .endif
    fwait
;At this point the # of Hours is in the Qword @ rhours
;              the # of Minutes is in the Dword @ rmins
;              the # of Seconds is in the Dword @ rsec
    cmp rhours.dwHighDateTime, 0
    je  @F
    mov dhours, 'M'
    mov dhours+1, 'a'
    mov dhours+2, 'n'
    mov dhours+3, 'y'
    mov dhours+4, '!'
    mov dhours+5, 0
    jmp print_d
@@: invoke dwtoa, rhours.dwLowDateTime, addr dhours
    invoke dwtoa, rmins, addr dmins
    invoke dwtoa, rsecs, addr dsecs
    .if (def_acorr != 'P')
        mov rmsecs, 0
    .endif
    invoke  dwtoa, rmsecs, addr dmsecs
print_d:
    lea edi, stat_str
    push    edi
    invoke  s_length, addr dhours
    mov ecx, eax
    pop edi
    lea esi, dhours
    cld
    rep movsb
    lea esi, hour_str
    mov ecx, sizeof hour_str
    cld
    rep movsb
    mov word ptr [edi], '  '
    add edi, 2
    push edi
    invoke  s_length, addr dmins
    mov ecx, eax
    pop edi
    lea esi, dmins
    cld
    rep movsb
    lea esi, minute_str
    mov ecx, sizeof minute_str
    cld
    rep movsb
    mov word ptr [edi], '  '
    add edi, 2
    push    edi
    invoke  s_length, addr dsecs
    mov ecx, eax
    pop edi
    lea esi, dsecs
    cld
    rep movsb
    lea esi, second_str
    mov ecx, sizeof second_str
    cld
    rep movsb
    .if (def_acorr == 'P')
        mov word ptr [edi], '  '
        add edi, 2
        push    edi
        invoke  s_length, addr dmsecs
        mov ecx, eax
        pop edi
        lea esi, dmsecs
        cld
        rep movsb
        lea esi, msec_str
        mov ecx, sizeof msec_str
        cld
        rep movsb
    .endif
    mov byte ptr[edi], 0
    invoke  SendMessage, stat_handle, SB_SETTEXT, 0, addr stat_str
    mov byte ptr jact, 'J'
    mov byte ptr jact+1, 'A'
    mov byte ptr jact+2, 'C'
    mov byte ptr jact+3, 'T'
    mov byte ptr jact+4, ' '
    invoke  SetWindowText, hWnd, addr jact
    ret
update_display ENDP

; -------------------------------------------------------------------
dwtoa proc public uses esi edi dwValue:DWORD, lpBuffer:PTR BYTE
;____________________________________________________________________
    ; -----------------------------------------
    ; This procedure was written by Tim Roberts
    ; -----------------------------------------
    ; Modified slightly by Farrier to return a '0' when dwValue = 0
    ; -------------------------------------------------------------
    ; convert DWORD to ascii string
    ; dwValue is value to be converted
    ; lpBuffer is the address of the receiving buffer
    ; EXAMPLE:
    ; invoke dwtoa,edx,addr buffer
    ;
    ; Uses: eax, ecx, edx.
    ; -------------------------------------------------------------

    mov eax, dwValue
    mov edi, [lpBuffer]
    .if (eax == 0)
        mov byte ptr [edi], '0'
        inc edi
        mov byte ptr [edi], 0
        ret
    .endif
    ; Is the value negative?
    .if (sdword ptr eax < 0)
      mov byte ptr [edi], '-'   ;store a minus sign
      inc edi
      neg eax                   ;and invert the value
    .endif
    mov esi, edi                ;save pointer to first digit
    mov ecx, 10
    .while (eax > 0)            ;while there is more to convert...
      xor edx, edx
      div ecx                   ;put next digit in edx
      add dl, '0'               ;convert to ASCII
      mov [edi], dl             ;store it
      inc edi
    .endw
    mov byte ptr [edi], 0       ;terminate the string
    ; We now have all the digits, but in reverse order.
    .while (esi < edi)
      dec edi
      mov al, [esi]
      mov ah, [edi]
      mov [edi], al
      mov [esi], ah
      inc esi
    .endw
    ret
dwtoa endp

;-----------------------------
s_length PROC s_addr:PTR BYTE
;_____________________________
    mov edi, [s_addr]
    xor al, al
    mov ecx, -1
    cld
    repne   scasb
    not ecx
    dec ecx
    mov eax, ecx
    ret
s_length ENDP

;-----------------------------------------------------
recalc PROC
;_____________________________________________________
LOCAL ft_comp:DWORD
;uses alarm_time - time_now FILETIME structures to calculate the number of seconds left
    invoke  GetLocalTime, addr system_time
    .if (def_acorr == 'S')             ;StopWatch Function
        invoke  SystemTimeToFileTime, addr system_time, addr alarm_time
    .elseif (def_acorr == 'P')         ;Final StopWatch recalc
        invoke  SystemTimeToFileTime, addr system_time, addr alarm_time
    .else
        invoke  SystemTimeToFileTime, addr system_time, addr time_now
    .endif
;Subtract Time_Now from Alarm_time to calculate the number of seconds to time
    mov eax, alarm_time.dwLowDateTime
    sub eax, time_now.dwLowDateTime
    mov tseconds.dwLowDateTime, eax
    mov eax, alarm_time.dwHighDateTime
    sbb eax, time_now.dwHighDateTime
    jb  @f
    mov tseconds.dwHighDateTime, eax    ;tseconds now contains # of 100 nanoseconds remaining
    .if (def_acorr == 'P')              ;leave tseconds with milliseconds
        mov ft_comp, 10000              ;correction factor for 100 nanoseconds to msecs
    .else
        mov ft_comp, 10000000           ;correction factor for 100 nanoseconds to seconds
    .endif
    fild    qword ptr tseconds          ;load tseconds into FPU
    fidiv   ft_comp                     ;divide by correction factor
    frndint                             ;round down to next lowest integer
    fistp   qword ptr tseconds          ;store result in seconds back to tseconds
    fwait                               ;make sure all floating point ops are done
    ret
@@: mov tseconds.dwHighDateTime, 0      ;we're here if time has expired
    mov tseconds.dwLowDateTime, 0       ;so set everything to zero
    ret
recalc ENDP

end start

⌨️ 快捷键说明

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