2 ; Stefan Haubenthal, 27.7.2009
3 ; Oliver Schmidt, 14.8.2018
5 ; int clock_gettime (clockid_t clk_id, struct timespec *tp);
13 .importzp sreg, tmp1, tmp2
14 .import pushax, pusheax, tosmul0ax, steaxspidx, incsp1, return0
18 ;----------------------------------------------------------------------------
33 @L1: inx ; Get PM flag
51 jsr steaxspidx ; Pops address pushed by 2. pushax
53 lda #<(100 * 1000 * 1000 / $10000)
54 ldx #>(100 * 1000 * 1000 / $10000)
57 lda #<(100 * 1000 * 1000)
58 ldx #>(100 * 1000 * 1000)
64 ldy #timespec::tv_nsec
65 jsr steaxspidx ; Pops address pushed by 1. pushax
72 ;----------------------------------------------------------------------------
73 ; dec = (((BCD>>4)*10) + (BCD&0xf))
92 ;----------------------------------------------------------------------------
93 ; Constructor that writes to the 1/10 sec register of the TOD to kick it
94 ; into action. If this is not done, the clock hangs. We will read the register
95 ; and write it again, ignoring a possible change in between.
112 ;----------------------------------------------------------------------------
113 ; TM struct with date set to 1970-01-01