1 | ; Project name : Assembly Library |
---|
2 | ; Description : Functions to operate with |
---|
3 | ; 8254 Programmable Interval Timer. |
---|
4 | |
---|
5 | ; |
---|
6 | ; XTIDE Universal BIOS and Associated Tools |
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
8 | ; |
---|
9 | ; This program is free software; you can redistribute it and/or modify |
---|
10 | ; it under the terms of the GNU General Public License as published by |
---|
11 | ; the Free Software Foundation; either version 2 of the License, or |
---|
12 | ; (at your option) any later version. |
---|
13 | ; |
---|
14 | ; This program is distributed in the hope that it will be useful, |
---|
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | ; GNU General Public License for more details. |
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
19 | ; |
---|
20 | |
---|
21 | ; Section containing code |
---|
22 | SECTION .text |
---|
23 | |
---|
24 | ;-------------------------------------------------------------------- |
---|
25 | ; SystemTimer_IntializePreciseEventTimer |
---|
26 | ; Parameters: |
---|
27 | ; Nothing |
---|
28 | ; Returns: |
---|
29 | ; Nothing |
---|
30 | ; Corrupts registers: |
---|
31 | ; AX |
---|
32 | ;-------------------------------------------------------------------- |
---|
33 | ALIGN JUMP_ALIGN |
---|
34 | SystemTimer_IntializePreciseEventTimer: |
---|
35 | STOP_PRECISE_EVENT_TIMER |
---|
36 | OUTPUT_COUNTER_COMMAND_TO TIMER_2, READ_OR_WRITE_LSB_THEN_MSB, MODE_0_SINGLE_TIMEOUT, BINARY_COUNTER |
---|
37 | xor ax, ax |
---|
38 | WRITE_COUNT_FROM_AX_TO TIMER_2 |
---|
39 | ret |
---|
40 | |
---|
41 | |
---|
42 | ;-------------------------------------------------------------------- |
---|
43 | ; This is how to use precise event timer: |
---|
44 | ; 1. Call SystemTimer_IntializePreciseEventTimer |
---|
45 | ; 2. Use START_PRECISE_EVENT_TIMER macro to start timer |
---|
46 | ; 3. Use STOP_PRECISE_EVENT_TIMER to stop timer (optional) |
---|
47 | ; 4. Call SystemTimer_GetPreciseEventTimerTicksToAX to get event duration |
---|
48 | ; |
---|
49 | ; SystemTimer_GetPreciseEventTimerTicksToAX |
---|
50 | ; Parameters: |
---|
51 | ; Nothing |
---|
52 | ; Returns: |
---|
53 | ; AX: Event duration in timer ticks |
---|
54 | ; Corrupts registers: |
---|
55 | ; Nothing |
---|
56 | ;-------------------------------------------------------------------- |
---|
57 | ALIGN JUMP_ALIGN |
---|
58 | SystemTimer_GetPreciseEventTimerTicksToAX: |
---|
59 | OUTPUT_COUNTER_COMMAND_TO TIMER_2, LATCH, MODE_0_SINGLE_TIMEOUT, BINARY_COUNTER |
---|
60 | READ_COUNT_TO_AX_FROM TIMER_2 |
---|
61 | neg ax ; 0 - count (Mode 0 counts toward zero) |
---|
62 | ret |
---|