60 lines
2.1 KiB
ArmAsm
60 lines
2.1 KiB
ArmAsm
; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
; See https://llvm.org/LICENSE.txt for license information.
|
|
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
;
|
|
; iigsToolboxExtra.s — hand-written toolbox wrappers that don't fit the
|
|
; standard genToolbox.py shape and therefore aren't auto-generated.
|
|
; Anything in this file is preserved across regenerations of
|
|
; iigsToolbox.s.
|
|
;
|
|
; Keep it small. Each wrapper should justify its custom existence in
|
|
; the leading comment block (typically: struct-returning toolbox call
|
|
; whose Pascal-on-stack result needs explicit memcpy into a caller
|
|
; buffer).
|
|
|
|
.text
|
|
|
|
; iigsReadTimeHex(unsigned char *buf8) -> void
|
|
; tool 0x0D03, set 0x03 (MiscTools). Returns 8 bytes of broken-down
|
|
; time via a stack-allocated result area: second, minute, hour, (pad),
|
|
; year-1900, day, month, weekday. ORCA's misctool.h declares this as
|
|
; returning a TimeRec struct, so genToolbox.py skips it (no inline()
|
|
; macro on the prototype). We expose a C-friendly wrapper that copies
|
|
; the 8 bytes into a caller-provided buffer.
|
|
;
|
|
; ABI: arg0 (the destination pointer) arrives in A/X (lo word in A,
|
|
; hi word in X), matching the LLVM W65816 first-arg-in-AX convention.
|
|
; We stash A/X to DP $E0..$E3 to form a 32-bit pointer and use
|
|
; sta [dp],y (DP-indirect-long-Y) so writes reach the buffer's bank.
|
|
.section .text.iigsReadTimeHex,"ax"
|
|
.globl iigsReadTimeHex
|
|
iigsReadTimeHex:
|
|
; --- stash arg0 (destination pointer) at DP $E0..$E3 ---
|
|
sta 0xE0 ; A -> $E0:$E1 (lo16 of pointer)
|
|
stx 0xE2 ; X -> $E2:$E3 (hi16; only $E2 = bank used)
|
|
; --- 8-byte result space (4 words) ---
|
|
pea 0
|
|
pea 0
|
|
pea 0
|
|
pea 0
|
|
ldx #0x0D03
|
|
jsl 0xe10000
|
|
; --- copy 8 bytes from stack into the caller's buffer ---
|
|
; PLA at M=16 pops the 4 result words in reverse push order, which
|
|
; is the same order as the TimeRec layout (lowest-addr word first).
|
|
ldy #0
|
|
pla
|
|
sta [0xE0], y ; bytes 0,1: second, minute
|
|
iny
|
|
iny
|
|
pla
|
|
sta [0xE0], y ; bytes 2,3: hour, pad
|
|
iny
|
|
iny
|
|
pla
|
|
sta [0xE0], y ; bytes 4,5: year-1900, day
|
|
iny
|
|
iny
|
|
pla
|
|
sta [0xE0], y ; bytes 6,7: month, weekday
|
|
rtl
|