forked from Lephenixnoir/fxdoc
103 lines
3.3 KiB
Plaintext
103 lines
3.3 KiB
Plaintext
Syscall %03b RTC_GetTicks() from Graph 35+E II OS 3.10
|
|
|
|
<%03b RTC_GetTicks>
|
|
Returns the number of 128-Hz ticks elapsed since midnight.
|
|
r0: Number of ticks (between 0 and 11059200)
|
|
|
|
80013c80: 2f86 mov.l r8, @-r15
|
|
80013c82: 2f96 mov.l r9, @-r15
|
|
80013c84: 2fa6 mov.l r10, @-r15
|
|
80013c86: 2fb6 mov.l r11, @-r15
|
|
80013c88: 2fc6 mov.l r12, @-r15
|
|
80013c8a: 2fd6 mov.l r13, @-r15
|
|
80013c8c: 4f12 sts.l macl, @-r15
|
|
|
|
# r9 is 128*60*60, ie. the number of ticks per hour
|
|
80013c8e: db79 mov.l 0xa413fedc RTC.RCR1, r11
|
|
80013c90: ecfc mov #-4, r12
|
|
80013c92: e807 mov #7, r8
|
|
80013c94: d978 mov.l 0x00070800, r9
|
|
80013c96: 6db3 mov r11, r13
|
|
80013c98: 7de4 add #-28, r13
|
|
|
|
# Clear the carry flag and carry interrupt in RCR1
|
|
80013c9a: 67b0 mov.b @r11, r7
|
|
80013c9c: 6073 mov r7, r0
|
|
80013c9e: c909 and #9, r0
|
|
80013ca0: 6a03 mov r0, r10
|
|
80013ca2: 2ba0 mov.b r10, @r11
|
|
|
|
# r5 = RSECCNT (binary) * 128 + R64CNT
|
|
80013ca4: 61d0 mov.b @r13, r1
|
|
80013ca6: 84d2 mov.b @(2,r13), r0
|
|
80013ca8: 631c extu.b r1, r3
|
|
80013caa: 6403 mov r0, r4
|
|
80013cac: c970 and #112, r0
|
|
80013cae: 40cc shad r12, r0
|
|
80013cb0: 6503 mov r0, r5
|
|
80013cb2: 4508 shll2 r5
|
|
80013cb4: 350c add r0, r5
|
|
80013cb6: 6043 mov r4, r0
|
|
80013cb8: 4500 shll r5
|
|
80013cba: c90f and #15, r0
|
|
80013cbc: 350c add r0, r5
|
|
80013cbe: 84d4 mov.b @(4,r13), r0
|
|
80013cc0: 458d shld r8, r5
|
|
80013cc2: 353c add r3, r5
|
|
|
|
# r6 = RMINCNT (binary)
|
|
80013cc4: 6603 mov r0, r6
|
|
80013cc6: 6203 mov r0, r2
|
|
80013cc8: 84d6 mov.b @(6,r13), r0
|
|
80013cca: 6103 mov r0, r1
|
|
80013ccc: 6063 mov r6, r0
|
|
80013cce: c970 and #112, r0
|
|
80013cd0: 40cc shad r12, r0
|
|
80013cd2: 6603 mov r0, r6
|
|
80013cd4: 4608 shll2 r6
|
|
80013cd6: 360c add r0, r6
|
|
80013cd8: 6023 mov r2, r0
|
|
80013cda: 4600 shll r6
|
|
80013cdc: c90f and #15, r0
|
|
80013cde: 360c add r0, r6
|
|
|
|
# r2 = RHRCNT (binary), r4 = r6 * (60*128)
|
|
80013ce0: 6013 mov r1, r0
|
|
80013ce2: c930 and #48, r0
|
|
80013ce4: 6463 mov r6, r4
|
|
80013ce6: 40cc shad r12, r0
|
|
80013ce8: 4408 shll2 r4
|
|
80013cea: 4408 shll2 r4
|
|
80013cec: 6203 mov r0, r2
|
|
80013cee: 3468 sub r6, r4
|
|
80013cf0: 4208 shll2 r2
|
|
80013cf2: 4418 shll8 r4
|
|
80013cf4: 320c add r0, r2
|
|
80013cf6: 6013 mov r1, r0
|
|
80013cf8: 4400 shll r4
|
|
80013cfa: 4200 shll r2
|
|
80013cfc: c90f and #15, r0
|
|
80013cfe: 320c add r0, r2
|
|
|
|
# Combine these together to form the number of ticks elapsed since midnight:
|
|
# r4 = 60*60*128*RHRCNT + 60*128*RMINCNT + 128*RSECCNT + R64CNT (binary)
|
|
# Restart if the carry is set.
|
|
80013d00: 60b0 mov.b @r11, r0
|
|
80013d02: 0927 mul.l r2, r9
|
|
80013d04: c880 tst #-128, r0
|
|
80013d06: 345c add r5, r4
|
|
80013d08: 051a sts macl, r5
|
|
80013d0a: 8fca bf.s <80013ca2>
|
|
80013d0c: 345c add r5, r4
|
|
80013d0e: 2b70 mov.b r7, @r11
|
|
|
|
80013d10: 6043 mov r4, r0
|
|
80013d12: 4f16 lds.l @r15+, macl
|
|
80013d14: 6df6 mov.l @r15+, r13
|
|
80013d16: 6cf6 mov.l @r15+, r12
|
|
80013d18: 6bf6 mov.l @r15+, r11
|
|
80013d1a: 6af6 mov.l @r15+, r10
|
|
80013d1c: 69f6 mov.l @r15+, r9
|
|
80013d1e: 000b rts
|
|
80013d20: 68f6 mov.l @r15+, r8
|