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 |
---|
11 | SECTION .text |
---|
12 | |
---|
13 | ; Program first instruction. |
---|
14 | ORG 100h ; Code starts at offset 100h (DOS .COM) |
---|
15 | Start: |
---|
16 | jmp TimerTest_Start |
---|
17 | |
---|
18 | ; Include library sources |
---|
19 | %include "AssemblyLibrary.asm" |
---|
20 | |
---|
21 | |
---|
22 | ;-------------------------------------------------------------------- |
---|
23 | ; Program start |
---|
24 | ;-------------------------------------------------------------------- |
---|
25 | ALIGN JUMP_ALIGN |
---|
26 | TimerTest_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 | |
---|
44 | ALIGN JUMP_ALIGN |
---|
45 | PrintNanosecsFromDXAX: |
---|
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 |
---|
59 | SECTION .data |
---|
60 | |
---|
61 | MICROSECONDS_TO_WAIT EQU 7000 |
---|
62 | |
---|
63 | g_szMicrosecsWaited: |
---|
64 | db "Was supposed to wait %u us but actually waited %u us.",LF,CR,NULL |
---|
65 | g_szDashForZero: db "- ",NULL |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | ; Section containing uninitialized data |
---|
70 | SECTION .bss |
---|