Changed most of the library sources to use .CAP instead of .CPU.

This commit is contained in:
Kugel Fuhr
2025-07-01 07:25:32 +02:00
parent f333b300f1
commit c72126e68f
59 changed files with 122 additions and 232 deletions

View File

@@ -9,14 +9,13 @@
.importzp sreg
.include "cbm.inc"
.macpack cpu
.proc _clock
; Some accelerator adaptors have CMOS ICs.
.if (.cpu & ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg + 1
.else
lda #$00 ; Byte 3 always is zero

View File

@@ -7,8 +7,6 @@
.include "errno.inc"
.macpack cpu
; ----------------------------------------------------------------------------
; int __fastcall__ __directerrno (unsigned char code);
; /* Set errno to a specific error code, clear __oserror, and return -1. Used
@@ -18,7 +16,7 @@
___directerrno:
jsr ___seterrno ; Set errno (returns with .A = 0)
sta ___oserror ; Clear ___oserror
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_INA)
dec a
.else
lda #$FF ; Return -1

View File

@@ -12,7 +12,6 @@
.include "_heap.inc"
.macpack generic
.macpack cpu
;-----------------------------------------------------------------------------
; Code
@@ -39,7 +38,7 @@ ___heapblocksize:
ldy #usedblock::size+1
lda (ptr2),y
tax
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (ptr2)
.else
dey

View File

@@ -8,7 +8,6 @@
.include "errno.inc"
.macpack generic
.macpack cpu
; ----------------------------------------------------------------------------
; int __fastcall__ __mappederrno (unsigned char code);
@@ -24,7 +23,7 @@ ___mappederrno:
bze ok ; Branch if no
jsr ___osmaperrno ; Map OS error into errno code
jsr ___seterrno ; Save in errno (returns with .A = 0)
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_INA)
dec a
.else
lda #$FF ; Return -1 if error

View File

@@ -13,7 +13,6 @@
.import _strlower, _strlen
.macpack generic
.macpack cpu
; ----------------------------------------------------------------------------
; We will store variables into the register bank in the zeropage. Define
@@ -38,7 +37,7 @@ FCount = ptr2
GetFormatChar:
ldy #0
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (Format)
.else
lda (Format),y
@@ -115,7 +114,7 @@ GetIntArg:
lda (ArgList),y
tax
dey
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (ArgList)
.else
lda (ArgList),y
@@ -274,7 +273,7 @@ Save: lda regbank,y
; Initialize the output counter in the output descriptor to zero
lda #0
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (OutData)
ldy #$01
sta (OutData),y
@@ -353,7 +352,7 @@ MainLoop:
sta (c_sp),y
dey
lda FCount
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (c_sp)
.else
sta (c_sp),y
@@ -570,7 +569,7 @@ CheckCount:
jsr GetIntArg
sta ptr1
stx ptr1+1 ; Get user supplied pointer
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (OutData) ; Low byte of OutData->ccount
sta (ptr1)
ldy #1

View File

@@ -16,8 +16,6 @@
.include "time.inc"
.macpack cpu
__time_t_to_tm:
; Divide number of seconds since epoch, in ptr1:sreg,
; by 86400 to get the number of days since epoch, and
@@ -80,7 +78,7 @@ __time_t_to_tm:
; Zero the two high bytes of the divisor and the high byte
; of the dividend.
.if .cpu .bitand CPU_ISET_65SC02
.if .cap(CPU_HAS_STZ)
stz ptr4
stz ptr4+1
stz sreg+1

View File

@@ -9,8 +9,6 @@
.importzp ptr1
.include "time.inc"
.macpack cpu
; ------------------------------------------------------------------------
; Special values
@@ -24,7 +22,7 @@ MAX_BUF_LEN = 38
_asctime:
; Backup timep
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_PUSHXY)
pha
phx
.else
@@ -48,7 +46,7 @@ _asctime:
jsr pushax
; Restore timep
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_PUSHXY)
plx
pla
.else

View File

@@ -10,8 +10,6 @@
.include "errno.inc"
.macpack cpu
; ---------------------------------------------------------------------------
.proc _atexit
@@ -41,7 +39,7 @@
jsr ___seterrno
ldx #$FF ; Return -1
txa
rts
Exit: rts
.endproc
@@ -54,7 +52,7 @@
.proc doatexit
ldy exitfunc_index ; Get index
beq @L9 ; Jump if done
beq _atexit::Exit ; Jump if done
dey
lda exitfunc_table,y
tax
@@ -62,14 +60,12 @@
lda exitfunc_table,y
sty exitfunc_index
jsr callax ; Call the function
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_BRA8)
bra doatexit
.else
jmp doatexit ; Next one
.endif
@L9: rts
.endproc

View File

@@ -12,8 +12,6 @@
.include "stdio.inc"
.include "_file.inc"
.macpack cpu
_fgetc:
sta ptr1
stx ptr1+1
@@ -22,7 +20,7 @@ _fgetc:
jsr checkferror
bne ret_eof
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_BITIMM)
bit #_FPUSHBACK ; Check for pushed back char
beq do_read
.else

View File

@@ -14,12 +14,10 @@
.include "stdio.inc"
.include "_file.inc"
.macpack cpu
terminate_ptr:
lda #$00
tax
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (ptr4)
.else
tay
@@ -41,7 +39,7 @@ _fgets:
sta buf
stx buf+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz didread
.else
lda #$00 ; We have read nothing yet
@@ -79,7 +77,7 @@ read_loop:
ldy #$01
sty didread ; We read at least one char
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (ptr4)
.else
dey

View File

@@ -20,7 +20,6 @@
.include "_file.inc"
.macpack generic
.macpack cpu
; ------------------------------------------------------------------------
; Code
@@ -48,7 +47,7 @@
ldy #_FILE::f_flags
lda (file),y
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_BITIMM)
bit #_FOPEN ; Is the file open?
.else
and #_FOPEN ; Is the file open?
@@ -57,7 +56,7 @@
; Check if the stream is in an error state
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_BITIMM)
bit #_FERROR
.else
lda (file),y ; get file->f_flags again
@@ -74,17 +73,15 @@
; Remember if we have a pushed back character and reset the flag.
@L2: .if (.cpu .bitand ::CPU_ISET_65SC02)
@L2: .if .cap(CPU_HAS_BITIMM)
ldx #$00
bit #_FPUSHBACK
beq @L3
.else
tax ; X = 0
lda (file),y
and #_FPUSHBACK
.endif
beq @L3
.if (.not .cpu .bitand ::CPU_ISET_65SC02)
lda (file),y
.endif
and #<~_FPUSHBACK
@@ -135,7 +132,7 @@
; Copy the buffer pointer into ptr1, and increment the pointer value passed
; to read() by one, so read() starts to store data at buf+1.
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
sta ptr1
add #1
@@ -159,7 +156,7 @@
ldy #_FILE::f_pushback
lda (file),y
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (ptr1) ; *buf = file->f_pushback;
.else
ldy #0

View File

@@ -16,8 +16,6 @@
.include "errno.inc"
.include "_file.inc"
.macpack cpu
; ------------------------------------------------------------------------
; Code
@@ -34,7 +32,7 @@
ldy #_FILE::f_flags
lda (ptr1),y
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_BITIMM)
bit #_FOPEN
.else
and #_FOPEN ; Is the file open?
@@ -50,7 +48,7 @@
; Check if the stream is in an error state
@L2: .if (.not .cpu .bitand ::CPU_ISET_65SC02)
@L2: .if .not .cap(CPU_HAS_BITIMM)
lda (ptr1),y ; get file->f_flags again
.endif
and #_FERROR

View File

@@ -10,8 +10,6 @@
.import __hextab, __longminstr
.importzp sreg, ptr1, ptr2, ptr3, tmp1
.macpack cpu
.code
;
@@ -64,7 +62,7 @@ L2: txa ; get high byte
bpl ultoa
lda #'-'
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (ptr2)
.else
ldy #0

View File

@@ -8,7 +8,6 @@
.export _strcat
.import popax
.importzp ptr1, ptr2, tmp3
.macpack cpu
_strcat:
sta ptr1 ; Save src
@@ -16,7 +15,7 @@ _strcat:
jsr popax ; Get dest
sta tmp3 ; Remember for function return
tay
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz ptr2
.else
lda #0

View File

@@ -8,14 +8,13 @@
.export _strchr
.import popax
.importzp ptr1, tmp1
.macpack cpu
_strchr:
sta tmp1 ; Save c
jsr popax ; get s
tay ; low byte of pointer to y
stx ptr1+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz ptr1
.else
lda #0

View File

@@ -12,8 +12,6 @@
.import _strlen_ptr4, _malloc, _memcpy, pushax
.export _strdup
.macpack cpu
_strdup:
; Get length (and store source in ptr4)
sta ptr4
@@ -22,7 +20,7 @@ _strdup:
jsr _strlen_ptr4 ; strlen may increment
; Add null byte for terminator
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_INA)
inc a
.else
clc

View File

@@ -8,7 +8,6 @@
.export _strncat
.import popax, popptr1
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack cpu
_strncat:
inx
@@ -24,7 +23,7 @@ _strncat:
stx ptr3+1
stx ptr2+1
tay ; low byte as offset in Y
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz ptr2
.else
ldx #0

View File

@@ -8,13 +8,12 @@
.export _cputsxy, _cputs
.import gotoxy, _cputc
.importzp ptr1, tmp1
.macpack cpu
_cputsxy:
sta ptr1 ; Save s for later
stx ptr1+1
jsr gotoxy ; Set cursor, pop x and y
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_BRA8)
bra L0 ; Same as cputs...
.else
jmp L0 ; Same as cputs...
@@ -24,7 +23,7 @@ _cputs: sta ptr1 ; Save s
stx ptr1+1
L0:
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (ptr1) ; (5)
.else
ldy #0 ; (2)

View File

@@ -10,8 +10,6 @@
.import screensize
.importzp ptr1, ptr2
.macpack cpu
.proc _screensize
sta ptr2 ; Store the y pointer
@@ -20,7 +18,7 @@
jsr screensize ; Get screensize into X/Y
tya ; Get Y size into A
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (ptr2)
txa
sta (ptr1)

View File

@@ -10,7 +10,6 @@
.importzp c_sp, ptr1, ptr2, ptr3, tmp1
.macpack generic
.macpack cpu
.data
@@ -74,7 +73,7 @@ out: jsr popax ; count
; Loop outputting characters
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND, CPU_HAS_BRA8)
@L1: dec outdesc+6
beq @L4

View File

@@ -11,14 +11,12 @@
.export tosadda0, tosaddax
.importzp c_sp, tmp1
.macpack cpu
tosadda0:
ldx #0
tosaddax:
clc ; (2)
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (c_sp) ; (7)
tay ; (9)

View File

@@ -8,12 +8,10 @@
.import addysp1
.importzp c_sp, ptr4
.macpack cpu
tosanda0:
ldx #$00
tosandax:
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte
ldy #1
.else

View File

@@ -18,8 +18,6 @@
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
.macpack cpu
; --------------------------------------------------------------------------
; Initialize library modules

View File

@@ -7,11 +7,10 @@
.export incax1
.macpack generic
.macpack cpu
.proc incax1
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_INA)
ina ; 65C02 version
bne @L9
.else

View File

@@ -7,8 +7,6 @@
.export popax, incsp2
.importzp c_sp
.macpack cpu
; Pop a/x from stack. This function will run directly into incsp2
.proc popax
@@ -16,7 +14,7 @@
ldy #1
lda (c_sp),y ; get hi byte
tax ; into x
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp) ; get lo byte
.else
dey

View File

@@ -8,8 +8,6 @@
.import addysp1
.importzp c_sp, sreg, tmp1
.macpack cpu
; EAX = TOS + EAX
tosadd0ax:
@@ -19,7 +17,7 @@ tosadd0ax:
tosaddeax:
clc
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (c_sp) ; 65SC02 version - saves 2 cycles
ldy #1
.else

View File

@@ -11,8 +11,6 @@
.export laddeq1, laddeqa, laddeq
.importzp sreg, ptr1, tmp1
.macpack cpu
laddeq1:
lda #$01
@@ -24,7 +22,7 @@ laddeqa:
laddeq: sty ptr1+1 ; Store high byte of address
clc
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (ptr1)
sta (ptr1)
ldy #$01 ; Address byte 1

View File

@@ -9,10 +9,8 @@
.import addysp1
.importzp c_sp, sreg, tmp1
.macpack cpu
tosand0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -22,7 +20,7 @@ tosand0ax:
.endif
tosandeax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
and (c_sp) ; byte 0
ldy #1
.else

View File

@@ -7,8 +7,6 @@
.export ldau00sp, ldau0ysp
.importzp c_sp, ptr1
.macpack cpu
ldau00sp:
ldy #1
ldau0ysp:
@@ -18,7 +16,7 @@ ldau0ysp:
lda (c_sp),y
sta ptr1
ldx #0
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)

View File

@@ -14,8 +14,6 @@
.import addysp
.importzp c_sp
.macpack cpu
leave00:
lda #0
leave0: ldx #0
@@ -28,7 +26,7 @@ leavey0:
leavey:
jsr addysp ; drop stack frame
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
leave: tay ; save A a sec
lda (c_sp) ; that's the pushed arg size

View File

@@ -11,10 +11,8 @@
.import poplsargs, udiv32, negeax
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
.macpack cpu
tosmod0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else

View File

@@ -9,11 +9,9 @@
.import addysp1
.importzp c_sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
.macpack cpu
tosmul0ax:
tosumul0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -26,7 +24,7 @@ tosmuleax:
tosumuleax:
mul32: sta ptr1
stx ptr1+1 ; op2 now in ptr1/sreg
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
ldy #1
.else

View File

@@ -9,10 +9,8 @@
.import addysp1
.importzp c_sp, sreg, tmp1
.macpack cpu
tosor0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -22,7 +20,7 @@ tosor0ax:
.endif
tosoreax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
ora (c_sp)
ldy #1
.else

View File

@@ -9,8 +9,6 @@
.import incsp4
.importzp c_sp, sreg
.macpack cpu
popeax: ldy #3
lda (c_sp),y
sta sreg+1
@@ -20,7 +18,7 @@ popeax: ldy #3
dey
lda (c_sp),y
tax
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
.else
dey

View File

@@ -12,13 +12,11 @@
.import decsp4
.importzp c_sp, sreg
.macpack cpu
pushl0:
lda #0
tax
push0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -39,7 +37,7 @@ pusheax:
txa
sta (c_sp),y
pla
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (c_sp)
.else
dey

View File

@@ -12,10 +12,8 @@
.import addysp1
.importzp c_sp, sreg, tmp1
.macpack cpu
tosrsub0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -26,7 +24,7 @@ tosrsub0ax:
tosrsubeax:
sec
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sbc (c_sp)
ldy #1
.else

View File

@@ -11,10 +11,8 @@
.import addysp1
.importzp c_sp, sreg
.macpack cpu
tossub0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -26,7 +24,7 @@ tossub0ax:
tossubeax:
sec
eor #$FF
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (c_sp) ; 65SC02 version - saves 2 cycles
ldy #1
.else

View File

@@ -11,8 +11,6 @@
.export lsubeq1, lsubeqa, lsubeq
.importzp sreg, ptr1
.macpack cpu
lsubeq1:
lda #$01
@@ -25,7 +23,7 @@ lsubeq: sty ptr1+1 ; Store high byte of address
sec
eor #$FF
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (ptr1) ; Subtract byte 0
sta (ptr1)
ldy #$01 ; Address byte 1

View File

@@ -9,10 +9,8 @@
.import addysp1
.importzp c_sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
.macpack cpu
tosudiv0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -38,7 +36,7 @@ getlop: sta ptr3 ; Put right operand in place
lda sreg+1
sta ptr4+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
ldy #1
.else

View File

@@ -9,10 +9,8 @@
.import getlop, udiv32
.importzp sreg, tmp3, tmp4, ptr2
.macpack cpu
tosumod0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else

View File

@@ -9,10 +9,8 @@
.import addysp1
.importzp c_sp, sreg, tmp1
.macpack cpu
tosxor0ax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz sreg
stz sreg+1
.else
@@ -22,7 +20,7 @@ tosxor0ax:
.endif
tosxoreax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
eor (c_sp) ; byte 0
ldy #1
.else

View File

@@ -9,12 +9,10 @@
.import addysp1
.importzp c_sp, tmp1
.macpack cpu
tosora0:
ldx #$00
tosorax:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
ora (c_sp)
ldy #1
.else

View File

@@ -7,11 +7,9 @@
.export popa
.importzp c_sp
.macpack cpu
.proc popa
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
.else
ldy #0 ; (2)

View File

@@ -8,14 +8,12 @@
.import incsp2
.importzp c_sp, ptr1
.macpack cpu
.proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved)
ldy #1
lda (c_sp),y ; get hi byte
sta ptr1+1 ; into ptr hi
dey ; dey even for for 65C02 here to have Y=0 at exit!
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp) ; get lo byte
.else
lda (c_sp),y ; get lo byte

View File

@@ -8,14 +8,12 @@
.import incsp2
.importzp c_sp, sreg
.macpack cpu
popsreg:
pha ; save A
ldy #1
lda (c_sp),y ; get hi byte
sta sreg+1 ; store it
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp) ; get lo byte
.else
dey

View File

@@ -7,8 +7,6 @@
.export pusha0sp, pushaysp, pusha
.importzp c_sp
.macpack cpu
; Beware: The optimizer knows about this function!
pusha0sp:

View File

@@ -7,8 +7,6 @@
.export push0, pusha0, pushax
.importzp c_sp
.macpack cpu
push0: lda #0
pusha0: ldx #0
@@ -31,7 +29,7 @@ pusha0: ldx #0
sta (c_sp),y ; (27)
pla ; (31)
dey ; (33)
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (c_sp) ; (37)
.else
sta (c_sp),y ; (38)

View File

@@ -8,8 +8,6 @@
.import pushax
.importzp ptr1
.macpack cpu
pushbidx:
sty ptr1
clc
@@ -19,7 +17,7 @@ pushbidx:
pushb: sta ptr1
stx ptr1+1
ldx #0 ; Load index/high byte
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (ptr1) ; Save one cycle for the C02
.else
lda (ptr1,x)

View File

@@ -9,8 +9,6 @@
.import addysp1
.importzp c_sp, tmp1
.macpack cpu
;
; AX = AX - TOS
;
@@ -19,7 +17,7 @@ tosrsuba0:
ldx #0
tosrsubax:
sec
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sbc (c_sp)
ldy #1
.else

View File

@@ -15,8 +15,6 @@
.import popax
.importzp tmp1
.macpack cpu
tosshlax:
tosaslax:
sta tmp1 ; Save shift count
@@ -55,7 +53,7 @@ L2: pla
; Shift count is exactly 8
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_PUSHXY)
L3: plx ; Low byte from stack into X
rts ; A is already zero
.else

View File

@@ -9,8 +9,6 @@
.import incsp2
.importzp c_sp, tmp1, ptr1
.macpack cpu
.proc staxspidx
sty tmp1 ; Save Y
@@ -18,7 +16,7 @@
ldy #1
lda (c_sp),y
sta ptr1+1
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
.else
dey

View File

@@ -21,7 +21,6 @@
; Use macros for better readability
.macpack generic
.macpack cpu
; ----------------------------------------------------------------------------
@@ -39,7 +38,7 @@
lda c_sp+1
sta initialsp+1
sbc #>__STACKSIZE__
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_INA)
ina ; Add 256 bytes safety area
.else
add #1 ; Add 256 bytes safety area

View File

@@ -8,8 +8,6 @@
.import addysp1
.importzp c_sp
.macpack cpu
; AX = TOS - AX
tossuba0:
@@ -17,7 +15,7 @@ tossuba0:
tossubax:
sec
eor #$FF
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
adc (c_sp)
ldy #1
.else

View File

@@ -8,8 +8,6 @@
.export swapstk
.importzp c_sp, ptr4
.macpack cpu
swapstk:
sta ptr4
stx ptr4+1
@@ -18,7 +16,7 @@ swapstk:
tax
lda ptr4+1
sta (c_sp),y
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
tay
lda ptr4

View File

@@ -8,14 +8,12 @@
.import incsp2
.importzp c_sp
.macpack cpu
; Convert TOS from long to int by cutting of the high 16bit
.proc tosint
pha
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
lda (c_sp)
.else
ldy #0

View File

@@ -8,8 +8,6 @@
.import decsp2
.importzp c_sp
.macpack cpu
; Convert TOS from int to long
tosulong:
@@ -17,7 +15,7 @@ tosulong:
jsr decsp2 ; Make room
ldy #2
lda (c_sp),y
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (c_sp) ; 65C02 version
iny ; Y = 3
.else
@@ -43,7 +41,7 @@ toslong:
jsr decsp2 ; Make room
ldy #2
lda (c_sp),y
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
sta (c_sp) ; 65C02 version
iny ; Y = 3
.else

View File

@@ -9,8 +9,6 @@
.include "zeropage.inc"
.macpack cpu
;---------------------------------------------------------------------------
; 8x16 => 24 unsigned multiplication routine. Because the overhead for a
; 8x16 => 16 unsigned multiplication routine is small, we will tag it with
@@ -31,7 +29,7 @@ umul8x16r16:
umul8x16r24m:
umul8x16r16m:
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_STZ)
stz ptr1+1
stz sreg
.else

View File

@@ -9,12 +9,10 @@
.import addysp1
.importzp c_sp, tmp1
.macpack cpu
tosxora0:
ldx #$00
tosxorax:
.if (.cpu .bitand CPU_ISET_65SC02)
.if .cap(CPU_HAS_ZPIND)
eor (c_sp)
ldy #1
.else

View File

@@ -9,8 +9,6 @@
.import umul8x16r24
.import popa, popax
.macpack cpu
;-----------------------------------------------------------------------------
; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
; unsigned char dir, unsigned char font);
@@ -82,7 +80,7 @@ process_onedim:
; Disallowing characters larger than 256 pixels, we just drop the high byte
; and remember the low 16 bit as size in 8.8 format.
.if (.cpu .bitand ::CPU_ISET_65SC02)
.if .cap(CPU_HAS_PUSHXY)
phy ; Save Y
jsr umul8x16r24
ply ; Restore Y