Skip to content

Commit e62bcdd

Browse files
committed
This is a HACK to include the "time.inc" functions directly into "bar.occ". This is because "time.module" is missing in the Transterpreter build being used for the course at Kent. Hopefully, this fix is only temporary ...
1 parent af82a59 commit e62bcdd

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

modules/course/examples/bar.occ

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,55 @@
2020
--
2121

2222
#INCLUDE "course.module"
23-
#INCLUDE "time.module"
23+
--#INCLUDE "time.module"
24+
25+
--{{{ FUNCTION seconds
26+
--* Convert seconds to timer ticks.
27+
-- @param s Time in seconds
28+
-- @return Time in timer ticks
29+
INT INLINE FUNCTION seconds (VAL INT s)
30+
INT ticks:
31+
VALOF
32+
#IF TARGET.BITS.PER.WORD = 16
33+
ticks := s * 1000
34+
#ELSE
35+
ticks := s * 1000000
36+
#ENDIF
37+
RESULT ticks
38+
:
39+
--}}}
40+
41+
--{{{ FUNCTION milliseconds
42+
--* Convert milliseconds to timer ticks.
43+
-- @param ms Time in milliseconds
44+
-- @return Time in timer ticks
45+
INT INLINE FUNCTION milliseconds (VAL INT ms)
46+
INT ticks:
47+
VALOF
48+
#IF TARGET.BITS.PER.WORD = 16
49+
ticks := ms
50+
#ELSE
51+
ticks := ms * 1000
52+
#ENDIF
53+
RESULT ticks
54+
:
55+
--}}}
56+
57+
--{{{ FUNCTION microseconds
58+
--* Convert microseconds to timer ticks.
59+
-- @param us Time in microseconds
60+
-- @return Time in timer ticks
61+
INT INLINE FUNCTION microseconds (VAL INT us)
62+
INT ticks:
63+
VALOF
64+
#IF TARGET.BITS.PER.WORD = 16
65+
ticks := us / 1000
66+
#ELSE
67+
ticks := us
68+
#ENDIF
69+
RESULT ticks
70+
:
71+
--}}}
2472

2573
--{{{ O.REQ protocol
2674
PROTOCOL O.REQ

0 commit comments

Comments
 (0)