Changeset 491 in xtideuniversalbios for trunk/Assembly_Library/Src/Time
- Timestamp:
- Dec 15, 2012, 2:46:29 PM (12 years ago)
- google:author:
- krille_n_@hotmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Time/TimerTicks.asm
r489 r491 3 3 4 4 ; 5 ; XTIDE Universal BIOS and Associated Tools 5 ; XTIDE Universal BIOS and Associated Tools 6 6 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. 7 7 ; … … 10 10 ; the Free Software Foundation; either version 2 of the License, or 11 11 ; (at your option) any later version. 12 ; 12 ; 13 13 ; This program is distributed in the hope that it will be useful, 14 14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 ; 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. 17 17 ; 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 30 TICKS_PER_HOUR EQU 65535 22 31 TICKS_PER_MINUTE EQU 1092 23 32 TICKS_PER_SECOND EQU 18 … … 28 37 29 38 ;-------------------------------------------------------------------- 30 ; TimerTicks_GetHoursToAX fromTicksInDXAX31 ; TimerTicks_GetMinutesToAX fromTicksInDX32 ; TimerTicks_GetSecondsToAX fromTicksInDX39 ; TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX 40 ; TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX 41 ; TimerTicks_GetSecondsToAXandRemainderTicksToDXfromTicksInDX 33 42 ; Parameters 34 43 ; DX(:AX): Timer ticks to convert … … 42 51 %ifndef EXCLUDE_FROM_XTIDECFG 43 52 ALIGN JUMP_ALIGN 44 TimerTicks_GetHoursToAX fromTicksInDXAX:53 TimerTicks_GetHoursToAXandRemainderTicksToDXfromTicksInDXAX: 45 54 mov cx, TICKS_PER_HOUR 46 55 div cx ; Divide DX:AX by CX, Hours to AX, remainder ticks to DX … … 49 58 50 59 ALIGN JUMP_ALIGN 51 TimerTicks_GetMinutesToAX fromTicksInDX:60 TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX: 52 61 xor ax, ax 53 62 xchg ax, dx ; Ticks now in DX:AX … … 57 66 %endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS 58 67 59 %ifdef INCLUDE_MENU_LIBRARY 60 ALIGN JUMP_ALIGN 61 TimerTicks_GetSecondsToAXfromTicksInDX: 68 %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG 69 ALIGN JUMP_ALIGN 70 TimerTicks_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! 62 73 xchg ax, dx ; Ticks now in AX 63 74 mov cl, TICKS_PER_SECOND … … 68 79 %endif 69 80 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 97 ALIGN JUMP_ALIGN 98 TimerTicks_GetSecondsToAXfromTicksInDX: 99 mov ax, 3600 ; Approximately 65536 / (Clock / Divisor) 100 mul dx 101 xchg dx, ax 102 ret 103 %endif 104 105 70 106 ;-------------------------------------------------------------------- 71 107 ; First tick might take 0...54.9 ms and remaining ticks … … 82 118 ; AX 83 119 ;-------------------------------------------------------------------- 84 %if def INCLUDE_MENU_LIBRARY120 %ifndef EXCLUDE ; 2 of 3 85 121 ALIGN JUMP_ALIGN 86 122 TimerTicks_InitializeTimeoutFromAX: … … 90 126 ret 91 127 %endif 128 92 129 93 130 ;-------------------------------------------------------------------- … … 102 139 ; Nothing 103 140 ;-------------------------------------------------------------------- 104 %if def INCLUDE_MENU_LIBRARY141 %ifndef EXCLUDE ; 3 of 3 105 142 ALIGN JUMP_ALIGN 106 143 TimerTicks_GetTimeoutTicksLeftToAXfromDSBX: … … 114 151 %endif 115 152 153 %undef EXCLUDE 154 155 116 156 ;-------------------------------------------------------------------- 117 157 ; TimerTicks_GetElapsedToAXandResetDSBX … … 134 174 %endif 135 175 176 136 177 ;-------------------------------------------------------------------- 137 178 ; TimerTicks_GetElapsedToAXfromDSBX … … 161 202 ; Nothing 162 203 ;-------------------------------------------------------------------- 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 163 211 ALIGN JUMP_ALIGN 164 212 TimerTicks_ReadFromBdaToAX: … … 170 218 pop ds 171 219 ret 220 %endif 221 %undef EXCLUDE
Note:
See TracChangeset
for help on using the changeset viewer.