Changeset 491 in xtideuniversalbios for trunk/Assembly_Library/Src/Time/TimerTicks.asm


Ignore:
Timestamp:
Dec 15, 2012, 2:46:29 PM (11 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Added a new define (USE_UNDOC_INTEL) that enables optimizations possible by using undocumented instructions available on all Intel processors and truly compatible clones. AFAIK the only exceptions are the NEC V-series and the Sony CXQ70108 processors so this option should be safe for use on the AT builds.
  • Building BIOSDRVS or the BIOS without MODULE_STRINGS_COMPRESSED would fail due to the recent code exclusions so I changed them a bit. Also fixed the mistaken change to Main.asm
  • Changed the Tandy specific info in Configuration_FullMode.txt so it matches the info in the Wiki.
  • Optimizations and fixes in general.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Time/TimerTicks.asm

    r489 r491  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
    19 
    20 ; System timer ticks 18.2 times per second = 54.9 ms / tick
    21 TICKS_PER_HOUR          EQU     65520
     18;
     19
     20; With a PIT input clock of 1193181.6666... Hz and a maximum
     21; 16 bit divisor of 65536 (if PIT programmed with 0) we get:
     22;
     23; Clock / Divisor = ~18.2065 ticks per second
     24; Clock * SecondsPerMinute / Divisor = ~1092 ticks per minute
     25; Clock * SecondsPerHour / Divisor = ~65543 ticks per hour
     26;
     27; Since 65543 can't fit in a 16 bit register we use the
     28; maximum possible instead and disregard the last ~8 ticks.
     29
     30TICKS_PER_HOUR          EQU     65535
    2231TICKS_PER_MINUTE        EQU     1092
    2332TICKS_PER_SECOND        EQU     18
     
    2837
    2938;--------------------------------------------------------------------
    30 ; TimerTicks_GetHoursToAXfromTicksInDXAX
    31 ; TimerTicks_GetMinutesToAXfromTicksInDX
    32 ; TimerTicks_GetSecondsToAXfromTicksInDX
     39; TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX
     40; TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX
     41; TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX
    3342;   Parameters
    3443;       DX(:AX):    Timer ticks to convert
     
    4251%ifndef EXCLUDE_FROM_XTIDECFG
    4352ALIGN JUMP_ALIGN
    44 TimerTicks_GetHoursToAXfromTicksInDXAX:
     53TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX:
    4554    mov     cx, TICKS_PER_HOUR
    4655    div     cx      ; Divide DX:AX by CX, Hours to AX, remainder ticks to DX
     
    4958
    5059ALIGN JUMP_ALIGN
    51 TimerTicks_GetMinutesToAXfromTicksInDX:
     60TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX:
    5261    xor     ax, ax
    5362    xchg    ax, dx  ; Ticks now in DX:AX
     
    5766%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
    5867
    59 %ifdef INCLUDE_MENU_LIBRARY
    60 ALIGN JUMP_ALIGN
    61 TimerTicks_GetSecondsToAXfromTicksInDX:
     68%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
     69ALIGN JUMP_ALIGN
     70TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX:
     71    ; This procedure can handle at most 4607 ticks in DX (almost 256 seconds)
     72    ; More than 4607 ticks will generate a divide overflow exception!
    6273    xchg    ax, dx  ; Ticks now in AX
    6374    mov     cl, TICKS_PER_SECOND
     
    6879%endif
    6980
     81
     82%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
     83    %ifndef MODULE_BOOT_MENU
     84        %define EXCLUDE
     85    %endif
     86%endif
     87;--------------------------------------------------------------------
     88; TimerTicks_GetSecondsToAXfromTicksInDX
     89;   Parameters
     90;       DX:         Timer ticks to convert
     91;   Returns:
     92;       AX:         Seconds
     93;   Corrupts registers:
     94;       DX
     95;--------------------------------------------------------------------
     96%ifndef EXCLUDE ; 1 of 3
     97ALIGN JUMP_ALIGN
     98TimerTicks_GetSecondsToAXfromTicksInDX:
     99    mov     ax, 3600    ; Approximately 65536 / (Clock / Divisor)
     100    mul     dx
     101    xchg    dx, ax
     102    ret
     103%endif
     104
     105
    70106;--------------------------------------------------------------------
    71107; First tick might take 0...54.9 ms and remaining ticks
     
    82118;       AX
    83119;--------------------------------------------------------------------
    84 %ifdef INCLUDE_MENU_LIBRARY     
     120%ifndef EXCLUDE ; 2 of 3
    85121ALIGN JUMP_ALIGN
    86122TimerTicks_InitializeTimeoutFromAX:
     
    90126    ret
    91127%endif
     128
    92129
    93130;--------------------------------------------------------------------
     
    102139;       Nothing
    103140;--------------------------------------------------------------------
    104 %ifdef INCLUDE_MENU_LIBRARY     
     141%ifndef EXCLUDE ; 3 of 3
    105142ALIGN JUMP_ALIGN
    106143TimerTicks_GetTimeoutTicksLeftToAXfromDSBX:
     
    114151%endif
    115152
     153%undef EXCLUDE
     154
     155
    116156;--------------------------------------------------------------------
    117157; TimerTicks_GetElapsedToAXandResetDSBX
     
    134174%endif
    135175
     176
    136177;--------------------------------------------------------------------
    137178; TimerTicks_GetElapsedToAXfromDSBX
     
    161202;       Nothing
    162203;--------------------------------------------------------------------
     204%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
     205    %ifndef MODULE_BOOT_MENU OR MODULE_HOTKEYS
     206        %define EXCLUDE
     207    %endif
     208%endif
     209
     210%ifndef EXCLUDE
    163211ALIGN JUMP_ALIGN
    164212TimerTicks_ReadFromBdaToAX:
     
    170218    pop     ds
    171219    ret
     220%endif
     221%undef EXCLUDE
Note: See TracChangeset for help on using the changeset viewer.