source: xtideuniversalbios/trunk/Assembly_Library/Src/TimerTest.asm@ 274

Last change on this file since 274 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 : Tests for Assembly Library.
3
4; Include .inc files
5%define INCLUDE_DISPLAY_LIBRARY
6%define INCLUDE_TIME_LIBRARY
7%include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
8
9
10; Section containing code
11SECTION .text
12
13; Program first instruction.
14ORG 100h ; Code starts at offset 100h (DOS .COM)
15Start:
16 jmp TimerTest_Start
17
18; Include library sources
19%include "AssemblyLibrary.asm"
20
21
22;--------------------------------------------------------------------
23; Program start
24;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26TimerTest_Start:
27 CALL_DISPLAY_LIBRARY InitializeDisplayContext
28
29 call SystemTimer_IntializePreciseEventTimer
30
31 START_PRECISE_EVENT_TIMER
32 mov ax, MICROSECONDS_TO_WAIT
33 call Delay_MicrosecondsFromAX
34 STOP_PRECISE_EVENT_TIMER
35
36 call SystemTimer_ReadNanosecsToDXAXfromPreciseEventTimer
37 call PrintNanosecsFromDXAX
38
39 ; Exit to DOS
40 mov ax, 4C00h ; Exit to DOS
41 int 21h
42
43
44ALIGN JUMP_ALIGN
45PrintNanosecsFromDXAX:
46 mov cx, 1000
47 div cx ; AX = us waited
48
49 mov bp, sp
50 ePUSH_T cx, MICROSECONDS_TO_WAIT
51 push ax
52 mov si, g_szMicrosecsWaited
53 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
54 ret
55
56
57
58; Section containing initialized data
59SECTION .data
60
61MICROSECONDS_TO_WAIT EQU 7000
62
63g_szMicrosecsWaited:
64 db "Was supposed to wait %u us but actually waited %u us.",LF,CR,NULL
65g_szDashForZero: db "- ",NULL
66
67
68
69; Section containing uninitialized data
70SECTION .bss
Note: See TracBrowser for help on using the repository browser.