source: xtideuniversalbios/trunk/Assembly_Library/Src/Time/SystemTimer.asm@ 269

Last change on this file since 269 was 256, checked in by aitotat@…, 13 years ago

Changes to Assembly Library:

  • Added Precise Event Timer functions.
File size: 1.5 KB
RevLine 
[256]1; Project name : Assembly Library
2; Description : Functions to operate with
3; 8254 Programmable Interval Timer.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; SystemTimer_IntializePreciseEventTimer
10; Parameters:
11; Nothing
12; Returns:
13; Nothing
14; Corrupts registers:
15; AX
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18SystemTimer_IntializePreciseEventTimer:
19 STOP_PRECISE_EVENT_TIMER
20 OUTPUT_COUNTER_COMMAND_TO TIMER_2, READ_OR_WRITE_LSB_THEN_MSB, MODE_0_SINGLE_TIMEOUT, BINARY_COUNTER
21 xor ax, ax
22 WRITE_COUNT_FROM_AX_TO TIMER_2
23 ret
24
25
26;--------------------------------------------------------------------
27; This is how to use precise event timer:
28; 1. Call SystemTimer_IntializePreciseEventTimer
29; 2. Use START_PRECISE_EVENT_TIMER macro to start timer
30; 3. Use STOP_PRECISE_EVENT_TIMER to stop timer (optional)
31; 4. Call SystemTimer_ReadNanosecsToDXAXfromPreciseEventTimer to get event duration
32;
33; SystemTimer_ReadNanosecsToDXAXfromPreciseEventTimer
34; Parameters:
35; Nothing
36; Returns:
37; DX:AX: Event duration in nanosecs
38; Corrupts registers:
39; Nothing
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42SystemTimer_ReadNanosecsToDXAXfromPreciseEventTimer:
43 OUTPUT_COUNTER_COMMAND_TO TIMER_2, LATCH, MODE_0_SINGLE_TIMEOUT, BINARY_COUNTER
44 READ_COUNT_TO_AX_FROM TIMER_2
45 neg ax ; 0 - count (Mode 0 counts toward zero)
46 mov dx, TIMER_CYCLE_TIME
47 mul dx
48 ret
Note: See TracBrowser for help on using the repository browser.