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

Last change on this file since 287 was 287, checked in by aitotat@…, 12 years ago

Changes to Assembly Library:

  • Hopefully fixed a problem of wrong sized MDA cursor.
  • Some minor improvements.
File size: 1.5 KB
Line 
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_GetPreciseEventTimerTicksToAX to get event duration
32;
33; SystemTimer_GetPreciseEventTimerTicksToAX
34;   Parameters:
35;       Nothing
36;   Returns:
37;       AX:     Event duration in timer ticks
38;   Corrupts registers:
39;       Nothing
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42SystemTimer_GetPreciseEventTimerTicksToAX:
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    ret
Note: See TracBrowser for help on using the repository browser.