Skip to content

Commit

Permalink
[KERNAL] add extapi16 #0 test reflector call
Browse files Browse the repository at this point in the history
  • Loading branch information
mooinglemur committed Mar 10, 2024
1 parent ed39545 commit 8e90247
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions kernal/x16/65c816/extapi16.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
; Comments in this source file use this nomenclature
; For registers, a dot and capital letters, for example: .X .Y .A .P .C
; For processor flags, a lowercase letter, for example: x m c z n

.import stack_push, stack_pop
.import stack_enter_kernal_stack, stack_leave_kernal_stack

Expand All @@ -12,31 +16,43 @@
.A16
.I16

; This API call expects and requires m=0, x=0, e=0
; This API call expects and requires m=0, e=0
; Some calls require x=0, some allow x=1
extapi16:
php ; preserve flags
set_carry_if_65c816
bcc unsupported
phx ; preserve X parameter
asl ; translate API call number to jump table entry
tax
lda apitbl,x
plx ; restore old X
plp ; restore flags
pha ; push api address-1 onto stack
rts ; jump to api
php ; preserve flags
set_carry_if_65c816
bcc unsupported
phx ; preserve X parameter
asl ; translate API call number to jump table entry
tax
lda apitbl,x
plx ; restore old X
plp ; restore flags
pha ; push api address-1 onto stack
rts ; jump to api

unsupported:
plp
plp
secrts:
sec
rts
sec
rts

apitbl:
.word secrts-1 ; slot 0 is reserved
.word stack_push-1 ; API 1
.word stack_pop-1 ; API 2
.word stack_enter_kernal_stack-1 ; API 3
.word stack_leave_kernal_stack-1 ; API 4


.word addition_test-1 ; API 0 (x=0 or x=1)
.word stack_push-1 ; API 1 (x=0)
.word stack_pop-1 ; API 2 (x=0)
.word stack_enter_kernal_stack-1 ; API 3 (x=0)
.word stack_leave_kernal_stack-1 ; API 4 (x=0)


addition_test: ; add .X to .Y, no carry, return in .C, used in the jsrfar unit tests
php
rep #$31
.A16
.I16
phx
tya
adc $01,S
plx
plp
rts

0 comments on commit 8e90247

Please sign in to comment.