Reading and writing the clock register and the clock control register is not
necessarily the easiest or most proper way of accessing the time. However,
there are tool calls that can perform this function for you. Included in the
Miscelaneous Toolset are 3 routines, two to read and write the time in hex
format and one to read the time in ASCII format. The program below shows how
to use all three.
Here is a summary of the three calls:
_ReadASCIITime reads the IIGS clock and fills a specified buffer with a
string that shows the time and date according to the format described in the
control panel. Before the call, push the long address (4 bytes) of a buffer
on the stack. Place the string in this buffer, a location in memory; the
buffer can vary in size (because of the possible string formats), but it
should be about 22 bytes.
_ReadTimeHex reads the IIGS clock and leaves the time and date on the stack.
Before the call, push 4 words (8 bytes) of space for the result. After the
call, the stack will contain the following information (specified in bytes):
| previous contents |
| weekday | day of the week (0..6, with 0=Sunday, etc.)
| null | unused
| month | 0..11, with Jan=0
| day | 0..30
| year | current year minus 1900
| hour | 0..23
| minute | 0..59
| second | 0..59
| | <--- Stack Pointer
_WriteTimeHex sets the time according to information on the stack. The
information pushed onto the stack should be bytes: month, day, year, hour,
minute, and second - pushed on in that order (after the data is pushed on the
stack, the stack will look similar that returned by _ReadTimeHex). After the
call is completed, the stack will have those parameters removed.