source: xtideuniversalbios/trunk/Assembly_Library/Src/Time/Delay.asm@ 574

Last change on this file since 574 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 2.2 KB
Line 
1; Project name : Assembly Library
2; Description : Delay functions.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Delay is always at least one millisecond since
25; RTC resolution is 977 microsecs.
26;
27; Delay_MicrosecondsFromAX
28; Parameters:
29; AX: Number of microsecs to wait
30; Returns:
31; Nothing
32; Corrupts registers:
33; AX
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36Delay_MicrosecondsFromAX:
37 push dx
38 push cx
39
40 xor cx, cx
41 xchg dx, ax ; Microsecs now in CX:DX
42 mov ah, EVENT_WAIT ; Event Wait
43 int BIOS_SYSTEM_INTERRUPT_15h
44 sti ; XT BIOSes return with interrupt disabled
45
46 pop cx
47 pop dx
48 mov ax, 1 ; Prepare to wait 1 timer tick
49 jc SHORT Delay_TimerTicksFromAX ; Event Wait was unsupported or busy
50 ret
51
52
53;--------------------------------------------------------------------
54; First tick might take 0...54.9 ms and remaining ticks
55; will occur at 54.9 ms intervals.
56;
57; Delay_TimerTicksFromAX
58; Parameters:
59; AX: Number of timer ticks to wait
60; Returns:
61; Nothing
62; Corrupts registers:
63; AX
64;--------------------------------------------------------------------
65ALIGN JUMP_ALIGN
66Delay_TimerTicksFromAX:
67 push dx
68
69 sti ; Make sure that interrupts are enabled
70 xchg dx, ax
71 call TimerTicks_ReadFromBdaToAX
72 add dx, ax ; DX = end time
73.WaitLoop:
74 call TimerTicks_ReadFromBdaToAX
75 cmp ax, dx
76 jb SHORT .WaitLoop ; Loop until end time is reached
77
78 pop dx
79 ret
Note: See TracBrowser for help on using the repository browser.