mirror of
https://github.com/cc65/cc65.git
synced 2024-06-17 16:29:32 +00:00
41 lines
698 B
ArmAsm
41 lines
698 B
ArmAsm
; Copyright (c) 2023 Rumbledethumps
|
|
;
|
|
; SPDX-License-Identifier: Zlib
|
|
; SPDX-License-Identifier: BSD-3-Clause
|
|
; SPDX-License-Identifier: Unlicense
|
|
|
|
; CC65 will promote variadic char arguments to int. It will not demote longs.
|
|
; int __cdecl__ xreg(char device, char channel, unsigned char address, ...);
|
|
|
|
.export _xreg
|
|
.importzp sp
|
|
.import addysp, _ria_call_int_errno
|
|
|
|
.include "rp6502.inc"
|
|
|
|
.code
|
|
|
|
.proc _xreg
|
|
|
|
; save variadic size in X
|
|
tya
|
|
tax
|
|
|
|
@copy: ; copy stack
|
|
dey
|
|
lda (sp),y
|
|
sta RIA_XSTACK
|
|
tya
|
|
bne @copy
|
|
|
|
; recover variadic size and move sp
|
|
txa
|
|
tay
|
|
jsr addysp
|
|
|
|
; run RIA operation
|
|
lda #RIA_OP_XREG
|
|
jmp _ria_call_int_errno
|
|
|
|
.endproc
|