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

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

Changes to Assembly Library:

  • Delay functions are no longer required by reboot functions when building XTIDE Universal BIOS.
File size: 1.5 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Delay functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Delay is always at least one millisecond since
9; RTC resolution is 977 microsecs.
10;
11; Delay_MicrosecondsFromAX
12; Parameters:
13; AX: Number of microsecs to wait
14; Returns:
15; Nothing
16; Corrupts registers:
17; AX
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20Delay_MicrosecondsFromAX:
21 push dx
22 push cx
23
24 xor cx, cx
25 xchg dx, ax ; Microsecs now in CX:DX
26 mov ah, EVENT_WAIT ; Event Wait
27 int BIOS_SYSTEM_INTERRUPT_15h
28 sti ; XT BIOSes return with interrupt disabled
29
30 pop cx
31 pop dx
32 mov ax, 1 ; Prepare to wait 1 timer tick
33 jc SHORT Delay_TimerTicksFromAX ; Event Wait was unsupported or busy
34 ret
35
36
37;--------------------------------------------------------------------
38; First tick might take 0...54.9 ms and remaining ticks
39; will occur at 54.9 ms intervals.
40;
41; Delay_TimerTicksFromAX
42; Parameters:
43; AX: Number of timer ticks to wait
44; Returns:
45; Nothing
46; Corrupts registers:
47; AX
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50Delay_TimerTicksFromAX:
51 push dx
52
[42]53 sti ; Make sure that interrupts are enabled
[41]54 xchg dx, ax
55 call TimerTicks_ReadFromBdaToAX
56 add dx, ax ; DX = end time
57.WaitLoop:
58 call TimerTicks_ReadFromBdaToAX
59 cmp ax, dx
60 jb SHORT .WaitLoop ; Loop until end time is reached
61
62 pop dx
63 ret
Note: See TracBrowser for help on using the repository browser.