mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-06-09 02:29:32 +00:00
Compare commits
62 Commits
gno-orcali
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
5b04986f08 | ||
|
d9e26d4467 | ||
|
0e519e1e58 | ||
|
49ffb1065b | ||
|
9181b0bd73 | ||
|
7384c82667 | ||
|
16c7952648 | ||
|
9d42552756 | ||
|
bbfad1e299 | ||
|
f1582be5a2 | ||
|
b60c307ee6 | ||
|
bf3a4d7ceb | ||
|
ce87c0e008 | ||
|
3f70daed7d | ||
|
a81a9964c2 | ||
|
a5504be621 | ||
|
6bc1c3741c | ||
|
614af65c68 | ||
|
b21a51ba33 | ||
|
97a295522c | ||
|
afff478793 | ||
|
78a9e1d93b | ||
|
67ae5f7b44 | ||
|
80c0bbc32b | ||
|
34f78fb1f2 | ||
|
578e544174 | ||
|
b7b4182cd2 | ||
|
bdfed3628d | ||
|
2f2d3d2056 | ||
|
cd6131abab | ||
|
fca8c1ef85 | ||
|
de978dab48 | ||
|
68fc475721 | ||
|
3c1f357b0c | ||
|
a4ba2403fe | ||
|
48371dc669 | ||
|
b03e462125 | ||
|
b3f028da2f | ||
|
2540b28ca3 | ||
|
3417a98d10 | ||
|
60d49c7dc3 | ||
|
74de206058 | ||
|
3551644355 | ||
|
506b070439 | ||
|
69765a96ef | ||
|
c4d485e960 | ||
|
44c3078ab3 | ||
|
7e4f067c35 | ||
|
882af9e075 | ||
|
3b0c1c2149 | ||
|
32c5fd94a1 | ||
|
f15caf8096 | ||
|
b302a85fd6 | ||
|
17faeda1de | ||
|
d30ee1a2e5 | ||
|
e2de990f4d | ||
|
4019e9f370 | ||
|
89664d2921 | ||
|
5985e7d774 | ||
|
88e764f72d | ||
|
73ed0778f2 | ||
|
b81b4e1109 |
105
cc.asm
105
cc.asm
|
@ -187,6 +187,7 @@ TAB equ 9 TAB key code
|
||||||
stz ~QuickExitList
|
stz ~QuickExitList
|
||||||
stz ~QuickExitList+2
|
stz ~QuickExitList+2
|
||||||
case on
|
case on
|
||||||
|
stz __useTimeTool do not use Time Tool
|
||||||
jsl ~InitIO reset standard I/O
|
jsl ~InitIO reset standard I/O
|
||||||
case off
|
case off
|
||||||
|
|
||||||
|
@ -243,8 +244,6 @@ lb6 long M
|
||||||
phy
|
phy
|
||||||
sec
|
sec
|
||||||
adc 1,S
|
adc 1,S
|
||||||
ply
|
|
||||||
pha
|
|
||||||
pha
|
pha
|
||||||
pea 0
|
pea 0
|
||||||
pha
|
pha
|
||||||
|
@ -264,20 +263,19 @@ lb7 pl4 argv get the pointer to the area
|
||||||
lda [argv]
|
lda [argv]
|
||||||
sta targv
|
sta targv
|
||||||
stx targv+2
|
stx targv+2
|
||||||
clc get a pointer to the command line string
|
; clc (already clear)
|
||||||
adc start
|
adc start get a pointer to the command line string
|
||||||
bcc lb8
|
bcc lb8
|
||||||
inx
|
inx
|
||||||
lb8 sta argv
|
lb8 sta argv
|
||||||
stx argv+2
|
stx argv+2
|
||||||
short M move the command line string
|
short M move the command line string
|
||||||
ldy #0
|
ldy #-1
|
||||||
lb9 lda [cLine],Y
|
lb9 iny
|
||||||
|
lda [cLine],Y
|
||||||
sta [argv],Y
|
sta [argv],Y
|
||||||
beq lb10
|
bne lb9
|
||||||
iny
|
long M
|
||||||
bra lb9
|
|
||||||
lb10 long M
|
|
||||||
move4 argv,cLine save the pointer
|
move4 argv,cLine save the pointer
|
||||||
move4 targv,argv set up the pointer to argv
|
move4 targv,argv set up the pointer to argv
|
||||||
|
|
||||||
|
@ -363,6 +361,9 @@ start ds 2 start of the command line string
|
||||||
stz ~ExitList+2
|
stz ~ExitList+2
|
||||||
stz ~QuickExitList
|
stz ~QuickExitList
|
||||||
stz ~QuickExitList+2
|
stz ~QuickExitList+2
|
||||||
|
case on
|
||||||
|
stz __useTimeTool do not use Time Tool
|
||||||
|
case off
|
||||||
lda #~RTL set up so exit(), etc. call ~RTL
|
lda #~RTL set up so exit(), etc. call ~RTL
|
||||||
sta ~C_Quit+1
|
sta ~C_Quit+1
|
||||||
|
|
||||||
|
@ -375,6 +376,78 @@ start ds 2 start of the command line string
|
||||||
targv ds 4
|
targv ds 4
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ~CDevCleanup - cleanup code run after a CDev call
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* A+X - CDev result value
|
||||||
|
* 1,S - Original data bank to restore
|
||||||
|
* 2,S - Return address
|
||||||
|
* 5,S - Message code passed to CDev
|
||||||
|
* 7,S - Old user ID from before the call (0 if none)
|
||||||
|
*
|
||||||
|
* Notes:
|
||||||
|
* This routine handles cases where the CDev is going
|
||||||
|
* away and so the user ID allocated for it needs to be
|
||||||
|
* disposed of to avoid being leaked.
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
~CDevCleanup start
|
||||||
|
MachineCDEV equ 1
|
||||||
|
BootCDEV equ 2
|
||||||
|
CloseCDEV equ 5
|
||||||
|
AboutCDEV equ 8
|
||||||
|
|
||||||
|
tay stash low word of result
|
||||||
|
|
||||||
|
lda 5,s if message == CloseCDEV
|
||||||
|
cmp #CloseCDEV
|
||||||
|
beq cleanup
|
||||||
|
cmp #BootCDEV or message == BootCDEV
|
||||||
|
beq cleanup
|
||||||
|
cmp #AboutCDEV or message == AboutCDEV
|
||||||
|
bne lb1
|
||||||
|
lda 7,s and original user ID was 0
|
||||||
|
beq cleanup (i.e. CDev window was not open)
|
||||||
|
bra ret
|
||||||
|
lb1 cmp #MachineCDEV or message == MachineCDEV
|
||||||
|
bne ret
|
||||||
|
tya and return value is 0
|
||||||
|
bne ret
|
||||||
|
txa
|
||||||
|
bne ret
|
||||||
|
|
||||||
|
cleanup pea 0 ...then dispose of user ID
|
||||||
|
jsl >~DAID
|
||||||
|
|
||||||
|
ret tya store return value in result space
|
||||||
|
sta 5,s
|
||||||
|
txa
|
||||||
|
sta 7,s
|
||||||
|
plb restore data bank
|
||||||
|
rtl return to original caller
|
||||||
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ~CheckPtrC - check a pointer to insure it is not null
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* 1,S - return address
|
||||||
|
* 4,S - pointer
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
~CheckPtrC start
|
||||||
|
lda 4,S
|
||||||
|
ora 5,S
|
||||||
|
bne lb1
|
||||||
|
error #1 subrange exceeded
|
||||||
|
lb1 rtl
|
||||||
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* ~CUMul2 - unsigned multiply
|
* ~CUMul2 - unsigned multiply
|
||||||
|
@ -446,10 +519,7 @@ ptr equ 3 pointer to exit routines
|
||||||
;
|
;
|
||||||
; Set up our stack frame
|
; Set up our stack frame
|
||||||
;
|
;
|
||||||
phb
|
ph4 >~ExitList set up our stack frame
|
||||||
phk
|
|
||||||
plb
|
|
||||||
ph4 ~ExitList set up our stack frame
|
|
||||||
phd
|
phd
|
||||||
tsc
|
tsc
|
||||||
tcd
|
tcd
|
||||||
|
@ -498,7 +568,6 @@ lb3 lda >stderr+6 while there is a next file
|
||||||
lb4 pld return
|
lb4 pld return
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
plb
|
|
||||||
rts
|
rts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -516,10 +585,7 @@ ptr equ 3 pointer to exit routines
|
||||||
;
|
;
|
||||||
; Set up our stack frame
|
; Set up our stack frame
|
||||||
;
|
;
|
||||||
phb
|
ph4 >~QuickExitList set up our stack frame
|
||||||
phk
|
|
||||||
plb
|
|
||||||
ph4 ~QuickExitList set up our stack frame
|
|
||||||
phd
|
phd
|
||||||
tsc
|
tsc
|
||||||
tcd
|
tcd
|
||||||
|
@ -556,7 +622,6 @@ lb2 ldy #2 dereference the pointer
|
||||||
lb3 pld return
|
lb3 pld return
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
plb
|
|
||||||
rts
|
rts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
369
fenv.asm
369
fenv.asm
|
@ -1,369 +0,0 @@
|
||||||
keep obj/fenv
|
|
||||||
mcopy fenv.macros
|
|
||||||
case on
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* Fenv - Floating-point environment access
|
|
||||||
*
|
|
||||||
* This code provides routines to query and modify the
|
|
||||||
* floating-point environment.
|
|
||||||
*
|
|
||||||
* Note: This relies on and only works with SANE.
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fenv private dummy segment
|
|
||||||
end
|
|
||||||
|
|
||||||
FE_ALL_EXCEPT gequ $001F
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int feclearexcept(int excepts);
|
|
||||||
*
|
|
||||||
* Clear floating-point exceptions
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* excepts - floating-point exceptions to clear
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
feclearexcept start
|
|
||||||
|
|
||||||
csubroutine (2:excepts),0
|
|
||||||
|
|
||||||
FGETENV get current environment
|
|
||||||
phx
|
|
||||||
|
|
||||||
lda excepts
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
eor #$FFFF mask off excepts to clear
|
|
||||||
xba
|
|
||||||
and 1,S
|
|
||||||
sta 1,S
|
|
||||||
FSETENV clear them
|
|
||||||
|
|
||||||
stz excepts
|
|
||||||
creturn 2:excepts
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fegetexceptflag(fexcept_t *flagp, int excepts);
|
|
||||||
*
|
|
||||||
* Get floating-point exception flags.
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* flagp - pointer to location to store exception flags
|
|
||||||
* excepts - floating-point exceptions to get
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fegetexceptflag start
|
|
||||||
|
|
||||||
csubroutine (4:flagp,2:excepts),0
|
|
||||||
|
|
||||||
FGETENV get current environment
|
|
||||||
tya
|
|
||||||
and excepts get desired exceptions
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
sta [flagp] store them in *flagp
|
|
||||||
|
|
||||||
stz excepts
|
|
||||||
creturn 2:excepts
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int feraiseexcept(int excepts);
|
|
||||||
*
|
|
||||||
* Raise floating-point exceptions
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* excepts - floating-point exceptions to raise
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
feraiseexcept start
|
|
||||||
|
|
||||||
csubroutine (2:excepts),0
|
|
||||||
|
|
||||||
lda excepts
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
beq done
|
|
||||||
pha
|
|
||||||
FSETXCP raise exceptions
|
|
||||||
|
|
||||||
done stz excepts
|
|
||||||
creturn 2:excepts
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fesetexceptflag(fexcept_t *flagp, int excepts);
|
|
||||||
*
|
|
||||||
* Set (but do not raise) floating-point exception flags
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* flagp - pointer to stored exception flags
|
|
||||||
* excepts - floating-point exceptions to set
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
|
|
||||||
fesetexceptflag start
|
|
||||||
|
|
||||||
csubroutine (4:flagp,2:excepts),0
|
|
||||||
|
|
||||||
FGETENV get env with excepts masked off
|
|
||||||
phx
|
|
||||||
lda excepts
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
eor #$FFFF
|
|
||||||
xba
|
|
||||||
and 1,S
|
|
||||||
sta 1,S
|
|
||||||
|
|
||||||
lda [flagp] set new exceptions
|
|
||||||
and excepts
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
xba
|
|
||||||
ora 1,S
|
|
||||||
sta 1,S
|
|
||||||
FSETENV
|
|
||||||
|
|
||||||
stz excepts
|
|
||||||
creturn 2:excepts
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fetestexcept(int excepts);
|
|
||||||
*
|
|
||||||
* Test if floating-point exception flags are set
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* excepts - floating-point exceptions to test for
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Bitwise or of exceptions that are set
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fetestexcept start
|
|
||||||
|
|
||||||
csubroutine (2:excepts),0
|
|
||||||
|
|
||||||
FGETENV get exception flags
|
|
||||||
tya
|
|
||||||
and excepts mask to just the ones we want
|
|
||||||
and #FE_ALL_EXCEPT
|
|
||||||
sta excepts
|
|
||||||
|
|
||||||
creturn 2:excepts
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fegetround(void);
|
|
||||||
*
|
|
||||||
* Get the current rounding direction
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* The current rounding direction
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fegetround start
|
|
||||||
FGETENV get high word of environment
|
|
||||||
tya
|
|
||||||
and #$00C0 just rounding direction
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fesetround(int round);
|
|
||||||
*
|
|
||||||
* Set the current rounding direction
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* round - the rounding direction to set
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fesetround start
|
|
||||||
|
|
||||||
csubroutine (2:round),0
|
|
||||||
|
|
||||||
lda round flip words
|
|
||||||
xba
|
|
||||||
sta round
|
|
||||||
and #$3FFF do nothing if not a valid rounding dir
|
|
||||||
bne done
|
|
||||||
|
|
||||||
FGETENV set the rounding direction
|
|
||||||
txa
|
|
||||||
and #$3FFF
|
|
||||||
ora round
|
|
||||||
pha
|
|
||||||
FSETENV
|
|
||||||
|
|
||||||
stz round
|
|
||||||
done creturn 2:round
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fegetenv(fenv_t *envp);
|
|
||||||
*
|
|
||||||
* Get the current floating-point environment
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* envp - pointer to location to store environment
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fegetenv start
|
|
||||||
|
|
||||||
csubroutine (4:envp),0
|
|
||||||
|
|
||||||
FGETENV get the environment
|
|
||||||
txa
|
|
||||||
sta [envp] store it in *envp
|
|
||||||
|
|
||||||
stz envp
|
|
||||||
creturn 2:envp
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int feholdexcept(fenv_t *envp);
|
|
||||||
*
|
|
||||||
* Get environment, then clear status flags and disable halts
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* envp - pointer to location to store environment
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
feholdexcept start
|
|
||||||
|
|
||||||
csubroutine (4:envp),0
|
|
||||||
|
|
||||||
FGETENV get the environment
|
|
||||||
txa
|
|
||||||
sta [envp] store it in *envp
|
|
||||||
|
|
||||||
and #$E0E0 clear exception flags and disable halts
|
|
||||||
pha
|
|
||||||
FSETENV set the new environment
|
|
||||||
|
|
||||||
stz envp
|
|
||||||
creturn 2:envp
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int fesetenv(const fenv_t *envp);
|
|
||||||
*
|
|
||||||
* Set the floating-point environment
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* envp - pointer to environment to set
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fesetenv start
|
|
||||||
|
|
||||||
csubroutine (4:envp),0
|
|
||||||
|
|
||||||
lda [envp] set the environment
|
|
||||||
pha
|
|
||||||
FSETENV
|
|
||||||
|
|
||||||
stz envp
|
|
||||||
creturn 2:envp
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int feupdateenv(const fenv_t *envp);
|
|
||||||
*
|
|
||||||
* Save exceptions, set environment, then re-raise exceptions
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* envp - pointer to environment to set
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Returns 0 if successful, non-zero otherwise
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
feupdateenv start
|
|
||||||
|
|
||||||
csubroutine (4:envp),0
|
|
||||||
|
|
||||||
lda [envp] set the environment
|
|
||||||
pha
|
|
||||||
FPROCEXIT
|
|
||||||
|
|
||||||
stz envp
|
|
||||||
creturn 2:envp
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* Default floating-point environment
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
__FE_DFL_ENV start
|
|
||||||
dc i2'0'
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* int __get_flt_rounds(void);
|
|
||||||
*
|
|
||||||
* Get the value of FLT_ROUNDS, accounting for rounding mode
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* Current value of FLT_ROUNDS
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
__get_flt_rounds start
|
|
||||||
FGETENV
|
|
||||||
tya get rounding direction in low bits of A
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
xba
|
|
||||||
inc a convert to values used by FLT_ROUNDS
|
|
||||||
and #$0003
|
|
||||||
rtl
|
|
||||||
end
|
|
117
fenv.macros
117
fenv.macros
|
@ -1,117 +0,0 @@
|
||||||
MACRO
|
|
||||||
&lab csubroutine &parms,&work
|
|
||||||
&lab anop
|
|
||||||
aif c:&work,.a
|
|
||||||
lclc &work
|
|
||||||
&work setc 0
|
|
||||||
.a
|
|
||||||
gbla &totallen
|
|
||||||
gbla &worklen
|
|
||||||
&worklen seta &work
|
|
||||||
&totallen seta 0
|
|
||||||
aif c:&parms=0,.e
|
|
||||||
lclc &len
|
|
||||||
lclc &p
|
|
||||||
lcla &i
|
|
||||||
&i seta 1
|
|
||||||
.b
|
|
||||||
&p setc &parms(&i)
|
|
||||||
&len amid &p,2,1
|
|
||||||
aif "&len"=":",.c
|
|
||||||
&len amid &p,1,2
|
|
||||||
&p amid &p,4,l:&p-3
|
|
||||||
ago .d
|
|
||||||
.c
|
|
||||||
&len amid &p,1,1
|
|
||||||
&p amid &p,3,l:&p-2
|
|
||||||
.d
|
|
||||||
&p equ &totallen+4+&work
|
|
||||||
&totallen seta &totallen+&len
|
|
||||||
&i seta &i+1
|
|
||||||
aif &i<=c:&parms,^b
|
|
||||||
.e
|
|
||||||
tsc
|
|
||||||
aif &work=0,.f
|
|
||||||
sec
|
|
||||||
sbc #&work
|
|
||||||
tcs
|
|
||||||
.f
|
|
||||||
phd
|
|
||||||
tcd
|
|
||||||
mend
|
|
||||||
MACRO
|
|
||||||
&lab creturn &r
|
|
||||||
&lab anop
|
|
||||||
lclc &len
|
|
||||||
aif c:&r,.a
|
|
||||||
lclc &r
|
|
||||||
&r setc 0
|
|
||||||
&len setc 0
|
|
||||||
ago .h
|
|
||||||
.a
|
|
||||||
&len amid &r,2,1
|
|
||||||
aif "&len"=":",.b
|
|
||||||
&len amid &r,1,2
|
|
||||||
&r amid &r,4,l:&r-3
|
|
||||||
ago .c
|
|
||||||
.b
|
|
||||||
&len amid &r,1,1
|
|
||||||
&r amid &r,3,l:&r-2
|
|
||||||
.c
|
|
||||||
aif &len<>2,.d
|
|
||||||
ldy &r
|
|
||||||
ago .h
|
|
||||||
.d
|
|
||||||
aif &len<>4,.e
|
|
||||||
ldx &r+2
|
|
||||||
ldy &r
|
|
||||||
ago .h
|
|
||||||
.e
|
|
||||||
aif &len<>10,.g
|
|
||||||
ldy #&r
|
|
||||||
ldx #^&r
|
|
||||||
ago .h
|
|
||||||
.g
|
|
||||||
mnote 'Not a valid return length',16
|
|
||||||
mexit
|
|
||||||
.h
|
|
||||||
aif &totallen=0,.i
|
|
||||||
lda &worklen+2
|
|
||||||
sta &worklen+&totallen+2
|
|
||||||
lda &worklen+1
|
|
||||||
sta &worklen+&totallen+1
|
|
||||||
.i
|
|
||||||
pld
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #&worklen+&totallen
|
|
||||||
tcs
|
|
||||||
aif &len=0,.j
|
|
||||||
tya
|
|
||||||
.j
|
|
||||||
rtl
|
|
||||||
mend
|
|
||||||
MACRO
|
|
||||||
&LAB FGETENV
|
|
||||||
&LAB PEA $03
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSETENV
|
|
||||||
&LAB PEA $01
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSETXCP
|
|
||||||
&LAB PEA $15
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FPROCEXIT
|
|
||||||
&LAB PEA $19
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
116
fpextra.asm
116
fpextra.asm
|
@ -1,116 +0,0 @@
|
||||||
keep obj/fpextra
|
|
||||||
mcopy fpextra.macros
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* FPextra - extra floating-point routines
|
|
||||||
*
|
|
||||||
* This code provides routines dealing with floating-point
|
|
||||||
* numbers that are used only by ORCA/C, supplementing the
|
|
||||||
* ones in SysFloat.
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
fpextra private dummy segment
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~SinglePrecision - limit fp value to single precision & range
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* extended-format real on stack
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~SinglePrecision start
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #4
|
|
||||||
ldy #0
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
FX2S
|
|
||||||
FS2X
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~DoublePrecision - limit fp value to double precision & range
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* extended-format real on stack
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~DoublePrecision start
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #4
|
|
||||||
ldy #0
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
FX2D
|
|
||||||
FD2X
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~CompPrecision - limit fp value to comp precision & range
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* extended-format real on stack
|
|
||||||
*
|
|
||||||
* Note: This avoids calling FX2C on negative numbers,
|
|
||||||
* because it is buggy for certain values.
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~CompPrecision start
|
|
||||||
tsc round to integer
|
|
||||||
clc
|
|
||||||
adc #4
|
|
||||||
pea 0
|
|
||||||
pha
|
|
||||||
FRINTX
|
|
||||||
lda 4+8,s
|
|
||||||
pha save original sign
|
|
||||||
asl a force sign to positive
|
|
||||||
lsr a
|
|
||||||
sta 6+8,s
|
|
||||||
tsc limit precision
|
|
||||||
clc
|
|
||||||
adc #6
|
|
||||||
ldy #0
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
phy
|
|
||||||
pha
|
|
||||||
FX2C
|
|
||||||
FC2X
|
|
||||||
pla restore original sign
|
|
||||||
bpl ret
|
|
||||||
lda 4+8,s
|
|
||||||
ora #$8000
|
|
||||||
sta 4+8,s
|
|
||||||
ret rtl
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
MACRO
|
|
||||||
&LAB FX2S
|
|
||||||
&LAB PEA $0210
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2D
|
|
||||||
&LAB PEA $0110
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2C
|
|
||||||
&LAB PEA $0510
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FC2X
|
|
||||||
&LAB PEA $050E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FD2X
|
|
||||||
&LAB PEA $010E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FS2X
|
|
||||||
&LAB PEA $020E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FRINTX
|
|
||||||
&LAB PEA $0014
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
269
int64.asm
269
int64.asm
|
@ -515,272 +515,3 @@ loop1 asl num1 do the remaining shift
|
||||||
rt0 pld
|
rt0 pld
|
||||||
rtl rtl
|
rtl rtl
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~CnvULongLongReal - convert an unsigned long long integer
|
|
||||||
* into an extended SANE real
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* unsigned long long int on stack
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* extended real on stack
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~CnvULongLongReal start
|
|
||||||
mantissa equ 4 mantissa (integer and fraction)
|
|
||||||
exponent equ mantissa+8 biased exponent and sign bit
|
|
||||||
|
|
||||||
lda 1,S move return value
|
|
||||||
pha
|
|
||||||
lda 4,S
|
|
||||||
sta 2,S
|
|
||||||
tsc set up DP
|
|
||||||
phd
|
|
||||||
tcd
|
|
||||||
|
|
||||||
lda mantissa+2 move 64-bit value to mantissa
|
|
||||||
sta mantissa
|
|
||||||
lda mantissa+4
|
|
||||||
sta mantissa+2
|
|
||||||
lda mantissa+6
|
|
||||||
sta mantissa+4
|
|
||||||
lda mantissa+8
|
|
||||||
sta mantissa+6
|
|
||||||
|
|
||||||
ora mantissa if value is 0 then
|
|
||||||
ora mantissa+2
|
|
||||||
ora mantissa+4
|
|
||||||
beq ret return
|
|
||||||
|
|
||||||
lda #63+16383 set initial exponent (2^63) and sign
|
|
||||||
sta exponent
|
|
||||||
|
|
||||||
lda mantissa+6 if number is normalized (i=1) then
|
|
||||||
bmi ret return
|
|
||||||
|
|
||||||
lp1 dec exponent normalize number
|
|
||||||
asl mantissa
|
|
||||||
rol mantissa+2
|
|
||||||
rol mantissa+4
|
|
||||||
rol mantissa+6
|
|
||||||
bpl lp1
|
|
||||||
|
|
||||||
ret pld
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~CnvLongLongReal - convert a long long integer into
|
|
||||||
* an extended SANE real
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* signed long long int on stack
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* extended real on stack
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~CnvLongLongReal start
|
|
||||||
mantissa equ 4 mantissa (integer and fraction)
|
|
||||||
exponent equ mantissa+8 biased exponent and sign bit
|
|
||||||
|
|
||||||
lda 1,S move return value
|
|
||||||
pha
|
|
||||||
lda 4,S
|
|
||||||
sta 2,S
|
|
||||||
tsc set up DP
|
|
||||||
phd
|
|
||||||
tcd
|
|
||||||
|
|
||||||
lda mantissa+2 move 64-bit value to mantissa
|
|
||||||
sta mantissa
|
|
||||||
lda mantissa+4
|
|
||||||
sta mantissa+2
|
|
||||||
lda mantissa+6
|
|
||||||
sta mantissa+4
|
|
||||||
lda mantissa+8
|
|
||||||
sta mantissa+6
|
|
||||||
|
|
||||||
ora mantissa if value is 0 then
|
|
||||||
ora mantissa+2
|
|
||||||
ora mantissa+4
|
|
||||||
beq ret return
|
|
||||||
|
|
||||||
ldy #0 default sign bit is 0 (positive)
|
|
||||||
lda mantissa+6 if mantissa is negative then
|
|
||||||
bpl lb0
|
|
||||||
negate8 mantissa negate it
|
|
||||||
ldy #$8000 sign bit is 1 (negative)
|
|
||||||
|
|
||||||
lb0 tya set sign
|
|
||||||
ora #63+16383 set initial exponent (2^63)
|
|
||||||
sta exponent
|
|
||||||
|
|
||||||
lda mantissa+6 if number is normalized (i=1) then
|
|
||||||
bmi ret return
|
|
||||||
|
|
||||||
lp1 dec exponent normalize number
|
|
||||||
asl mantissa
|
|
||||||
rol mantissa+2
|
|
||||||
rol mantissa+4
|
|
||||||
rol mantissa+6
|
|
||||||
bpl lp1
|
|
||||||
|
|
||||||
ret pld
|
|
||||||
rtl
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~CnvRealLongLong - convert an extended SANE real into
|
|
||||||
* a long long integer
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* extended real on stack
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* signed long long int on stack
|
|
||||||
*
|
|
||||||
* Note: This avoids calling FX2C on negative numbers,
|
|
||||||
* because it is buggy for certain values.
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~CnvRealLongLong start
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #4
|
|
||||||
pea 0 push src address for fcpxx
|
|
||||||
pha
|
|
||||||
pea llmin|-16 push dst address for fcpxx
|
|
||||||
pea llmin
|
|
||||||
pea 0 push operand address for ftintx
|
|
||||||
pha
|
|
||||||
ftintx round
|
|
||||||
fcpxx compare with LLONG_MIN
|
|
||||||
bne convert
|
|
||||||
|
|
||||||
lda #$8000 if it is LONG_MIN, use that value
|
|
||||||
sta 12,s
|
|
||||||
asl a
|
|
||||||
sta 10,s
|
|
||||||
sta 8,s
|
|
||||||
sta 6,s
|
|
||||||
bra done otherwise
|
|
||||||
|
|
||||||
convert lda 4+8,s
|
|
||||||
pha save original sign
|
|
||||||
asl a force sign to positive
|
|
||||||
lsr a
|
|
||||||
sta 6+8,s
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #6
|
|
||||||
pea 0 push src address for fx2c
|
|
||||||
pha
|
|
||||||
pea 0 push dst address for fx2c
|
|
||||||
inc a
|
|
||||||
inc a
|
|
||||||
pha
|
|
||||||
fx2c convert
|
|
||||||
pla if original value was negative
|
|
||||||
bpl done
|
|
||||||
sec
|
|
||||||
lda #0 negate result
|
|
||||||
sbc 6,s
|
|
||||||
sta 6,s
|
|
||||||
lda #0
|
|
||||||
sbc 6+2,s
|
|
||||||
sta 6+2,s
|
|
||||||
lda #0
|
|
||||||
sbc 6+4,s
|
|
||||||
sta 6+4,s
|
|
||||||
lda #0
|
|
||||||
sbc 6+6,s
|
|
||||||
sta 6+6,s
|
|
||||||
|
|
||||||
done phb move return address
|
|
||||||
pla
|
|
||||||
plx
|
|
||||||
ply
|
|
||||||
phx
|
|
||||||
pha
|
|
||||||
plb
|
|
||||||
rtl
|
|
||||||
|
|
||||||
llmin dc e'-9223372036854775808'
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~CnvRealULongLong - convert an extended SANE real into
|
|
||||||
* an unsigned long long integer
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* extended real on stack
|
|
||||||
*
|
|
||||||
* Outputs:
|
|
||||||
* unsigned long long int on stack
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~CnvRealULongLong start
|
|
||||||
pea 0 initially assume val <= LLONG_MAX
|
|
||||||
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #6
|
|
||||||
pea 0 push src address for fcpxx
|
|
||||||
pha
|
|
||||||
pea llbig|-16 push dst address for fcpxx
|
|
||||||
pea llbig
|
|
||||||
pea 0 push operand address for ftintx
|
|
||||||
pha
|
|
||||||
ftintx round
|
|
||||||
fcpxx compare with LLONG_MAX+1
|
|
||||||
bmi convert
|
|
||||||
|
|
||||||
lda #1 if val > LLONG_MAX:
|
|
||||||
sta 1,S save flag to indicate this
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #6
|
|
||||||
pea llbig|-16 push src address for fsubx
|
|
||||||
pea llbig
|
|
||||||
pea 0 push dst address for fsubx
|
|
||||||
pha
|
|
||||||
fsubx val -= LLONG_MAX+1
|
|
||||||
|
|
||||||
convert tsc
|
|
||||||
clc
|
|
||||||
adc #6
|
|
||||||
pea 0 push src address for fx2c
|
|
||||||
pha
|
|
||||||
pea 0 push dst address for fx2c
|
|
||||||
inc a
|
|
||||||
inc a
|
|
||||||
pha
|
|
||||||
fx2c convert val as comp
|
|
||||||
|
|
||||||
pla if orig val was > LLONG_MAX:
|
|
||||||
beq done
|
|
||||||
lda 12,s
|
|
||||||
eor #$8000
|
|
||||||
sta 12,s result += LLONG_MAX+1
|
|
||||||
|
|
||||||
done phb move return address
|
|
||||||
pla
|
|
||||||
plx
|
|
||||||
ply
|
|
||||||
phx
|
|
||||||
pha
|
|
||||||
plb
|
|
||||||
rtl
|
|
||||||
|
|
||||||
llbig dc e'9223372036854775808'
|
|
||||||
end
|
|
||||||
|
|
43
int64.macros
43
int64.macros
|
@ -1,23 +1,4 @@
|
||||||
macro
|
macro
|
||||||
&l negate8 &n1
|
|
||||||
&l ~setm
|
|
||||||
sec
|
|
||||||
ldy #0
|
|
||||||
tya
|
|
||||||
sbc &n1
|
|
||||||
sta &n1
|
|
||||||
tya
|
|
||||||
sbc &n1+2
|
|
||||||
sta &n1+2
|
|
||||||
tya
|
|
||||||
sbc &n1+4
|
|
||||||
sta &n1+4
|
|
||||||
tya
|
|
||||||
sbc &n1+6
|
|
||||||
sta &n1+6
|
|
||||||
~restm
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l move4 &m1,&m2
|
&l move4 &m1,&m2
|
||||||
lclb &yistwo
|
lclb &yistwo
|
||||||
&l ~setm
|
&l ~setm
|
||||||
|
@ -140,27 +121,3 @@
|
||||||
.d
|
.d
|
||||||
sta 2+&op
|
sta 2+&op
|
||||||
mend
|
mend
|
||||||
MACRO
|
|
||||||
&LAB FTINTX
|
|
||||||
&LAB PEA $0016
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2C
|
|
||||||
&LAB PEA $0510
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCPXX
|
|
||||||
&LAB PEA $0A
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSUBX
|
|
||||||
&LAB PEA 2
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
|
|
4
make
4
make
|
@ -19,7 +19,7 @@ if {#} == 0
|
||||||
unset exit
|
unset exit
|
||||||
end
|
end
|
||||||
|
|
||||||
for i in cc ctype string stdlib time setjmp orca fcntl vars toolglue signal int64 fenv fpextra math2 locale uchar
|
for i in cc ctype string stdlib time setjmp orca fcntl vars toolglue signal int64 locale uchar
|
||||||
Newer obj/{i}.a {i}.asm
|
Newer obj/{i}.a {i}.asm
|
||||||
if {Status} != 0
|
if {Status} != 0
|
||||||
set exit on
|
set exit on
|
||||||
|
@ -40,7 +40,7 @@ delete orcalib
|
||||||
|
|
||||||
set list vars.a assert.a cc.a setjmp.a ctype.a string.a stdlib.a
|
set list vars.a assert.a cc.a setjmp.a ctype.a string.a stdlib.a
|
||||||
set list {list} time.a signal.a toolglue.a orca.a fcntl.a stdio.a int64.a
|
set list {list} time.a signal.a toolglue.a orca.a fcntl.a stdio.a int64.a
|
||||||
set list {list} fenv.a fpextra.a math2.a locale.a uchar.a
|
set list {list} locale.a uchar.a
|
||||||
for i in {list}
|
for i in {list}
|
||||||
echo makelib orcalib +obj/{i}
|
echo makelib orcalib +obj/{i}
|
||||||
makelib orcalib +obj/{i}
|
makelib orcalib +obj/{i}
|
||||||
|
|
654
math2.macros
654
math2.macros
|
@ -1,654 +0,0 @@
|
||||||
macro
|
|
||||||
&l ph4 &n1
|
|
||||||
&l anop
|
|
||||||
aif "&n1"="*",.f
|
|
||||||
lclc &c
|
|
||||||
&c amid &n1,1,1
|
|
||||||
aif "&c"="#",.d
|
|
||||||
aif s:longa=1,.a
|
|
||||||
rep #%00100000
|
|
||||||
.a
|
|
||||||
aif "&c"<>"{",.b
|
|
||||||
&c amid &n1,l:&n1,1
|
|
||||||
aif "&c"<>"}",.g
|
|
||||||
&n1 amid &n1,2,l:&n1-2
|
|
||||||
ldy #2
|
|
||||||
lda (&n1),y
|
|
||||||
pha
|
|
||||||
lda (&n1)
|
|
||||||
pha
|
|
||||||
ago .e
|
|
||||||
.b
|
|
||||||
aif "&c"<>"[",.c
|
|
||||||
ldy #2
|
|
||||||
lda &n1,y
|
|
||||||
pha
|
|
||||||
lda &n1
|
|
||||||
pha
|
|
||||||
ago .e
|
|
||||||
.c
|
|
||||||
aif "&c"<>"<",.c1
|
|
||||||
&n1 amid &n1,2,l:&n1-1
|
|
||||||
pei &n1+2
|
|
||||||
pei &n1
|
|
||||||
ago .e
|
|
||||||
.c1
|
|
||||||
lda &n1+2
|
|
||||||
pha
|
|
||||||
lda &n1
|
|
||||||
pha
|
|
||||||
ago .e
|
|
||||||
.d
|
|
||||||
&n1 amid &n1,2,l:&n1-1
|
|
||||||
pea +(&n1)|-16
|
|
||||||
pea &n1
|
|
||||||
ago .f
|
|
||||||
.e
|
|
||||||
aif s:longa=1,.f
|
|
||||||
sep #%00100000
|
|
||||||
.f
|
|
||||||
mexit
|
|
||||||
.g
|
|
||||||
mnote "Missing closing '}'",16
|
|
||||||
mend
|
|
||||||
MACRO
|
|
||||||
&lab csubroutine &parms,&work
|
|
||||||
&lab anop
|
|
||||||
aif c:&work,.a
|
|
||||||
lclc &work
|
|
||||||
&work setc 0
|
|
||||||
.a
|
|
||||||
gbla &totallen
|
|
||||||
gbla &worklen
|
|
||||||
&worklen seta &work
|
|
||||||
&totallen seta 0
|
|
||||||
aif c:&parms=0,.e
|
|
||||||
lclc &len
|
|
||||||
lclc &p
|
|
||||||
lcla &i
|
|
||||||
&i seta 1
|
|
||||||
.b
|
|
||||||
&p setc &parms(&i)
|
|
||||||
&len amid &p,2,1
|
|
||||||
aif "&len"=":",.c
|
|
||||||
&len amid &p,1,2
|
|
||||||
&p amid &p,4,l:&p-3
|
|
||||||
ago .d
|
|
||||||
.c
|
|
||||||
&len amid &p,1,1
|
|
||||||
&p amid &p,3,l:&p-2
|
|
||||||
.d
|
|
||||||
&p equ &totallen+4+&work
|
|
||||||
&totallen seta &totallen+&len
|
|
||||||
&i seta &i+1
|
|
||||||
aif &i<=c:&parms,^b
|
|
||||||
.e
|
|
||||||
tsc
|
|
||||||
aif &work=0,.f
|
|
||||||
sec
|
|
||||||
sbc #&work
|
|
||||||
tcs
|
|
||||||
.f
|
|
||||||
phd
|
|
||||||
tcd
|
|
||||||
mend
|
|
||||||
MACRO
|
|
||||||
&lab creturn &r
|
|
||||||
&lab anop
|
|
||||||
lclc &len
|
|
||||||
aif c:&r,.a
|
|
||||||
lclc &r
|
|
||||||
&r setc 0
|
|
||||||
&len setc 0
|
|
||||||
ago .h
|
|
||||||
.a
|
|
||||||
&len amid &r,2,1
|
|
||||||
aif "&len"=":",.b
|
|
||||||
&len amid &r,1,2
|
|
||||||
&r amid &r,4,l:&r-3
|
|
||||||
ago .c
|
|
||||||
.b
|
|
||||||
&len amid &r,1,1
|
|
||||||
&r amid &r,3,l:&r-2
|
|
||||||
.c
|
|
||||||
aif &len<>2,.d
|
|
||||||
ldy &r
|
|
||||||
ago .h
|
|
||||||
.d
|
|
||||||
aif &len<>4,.e
|
|
||||||
ldx &r+2
|
|
||||||
ldy &r
|
|
||||||
ago .h
|
|
||||||
.e
|
|
||||||
aif &len<>10,.g
|
|
||||||
ldy #&r
|
|
||||||
ldx #^&r
|
|
||||||
ago .h
|
|
||||||
.g
|
|
||||||
mnote 'Not a valid return length',16
|
|
||||||
mexit
|
|
||||||
.h
|
|
||||||
aif &totallen=0,.i
|
|
||||||
lda &worklen+2
|
|
||||||
sta &worklen+&totallen+2
|
|
||||||
lda &worklen+1
|
|
||||||
sta &worklen+&totallen+1
|
|
||||||
.i
|
|
||||||
pld
|
|
||||||
tsc
|
|
||||||
clc
|
|
||||||
adc #&worklen+&totallen
|
|
||||||
tcs
|
|
||||||
aif &len=0,.j
|
|
||||||
tya
|
|
||||||
.j
|
|
||||||
rtl
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l cmp4 &n1,&n2
|
|
||||||
lclb &yistwo
|
|
||||||
&l ~setm
|
|
||||||
~lda.h &n1
|
|
||||||
~op.h eor,&n2
|
|
||||||
bpl ~a&SYSCNT
|
|
||||||
~lda.h &n2
|
|
||||||
~op.h cmp,&n1
|
|
||||||
bra ~b&SYSCNT
|
|
||||||
~a&SYSCNT ~lda.h &n1
|
|
||||||
~op.h cmp,&n2
|
|
||||||
bne ~b&SYSCNT
|
|
||||||
~lda &n1
|
|
||||||
~op cmp,&n2
|
|
||||||
~b&SYSCNT anop
|
|
||||||
~restm
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~lda &op
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"<>"{",.b
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
&l lda &op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~lda.h &op
|
|
||||||
&l anop
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"="[",.b
|
|
||||||
aif "&c"<>"{",.d
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
aif &yistwo,.c
|
|
||||||
&yistwo setb 1
|
|
||||||
ldy #2
|
|
||||||
.c
|
|
||||||
&op setc "&op,y"
|
|
||||||
lda &op
|
|
||||||
mexit
|
|
||||||
.d
|
|
||||||
aif "&c"<>"#",.e
|
|
||||||
&op amid "&op",2,l:&op-1
|
|
||||||
&op setc "#^&op"
|
|
||||||
lda &op
|
|
||||||
mexit
|
|
||||||
.e
|
|
||||||
lda 2+&op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~op &opc,&op
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"<>"{",.b
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
&l &opc &op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~op.h &opc,&op
|
|
||||||
&l anop
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"="[",.b
|
|
||||||
aif "&c"<>"{",.d
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
aif &yistwo,.c
|
|
||||||
&yistwo setb 1
|
|
||||||
ldy #2
|
|
||||||
.c
|
|
||||||
&op setc "&op,y"
|
|
||||||
&opc &op
|
|
||||||
mexit
|
|
||||||
.d
|
|
||||||
aif "&c"<>"#",.e
|
|
||||||
&op amid "&op",2,l:&op-1
|
|
||||||
&op setc "#^&op"
|
|
||||||
&opc &op
|
|
||||||
mexit
|
|
||||||
.e
|
|
||||||
&opc 2+&op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~restm
|
|
||||||
&l anop
|
|
||||||
aif (&~la+&~li)=2,.i
|
|
||||||
sep #32*(.not.&~la)+16*(.not.&~li)
|
|
||||||
aif &~la,.h
|
|
||||||
longa off
|
|
||||||
.h
|
|
||||||
aif &~li,.i
|
|
||||||
longi off
|
|
||||||
.i
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~setm
|
|
||||||
&l anop
|
|
||||||
aif c:&~la,.b
|
|
||||||
gblb &~la
|
|
||||||
gblb &~li
|
|
||||||
.b
|
|
||||||
&~la setb s:longa
|
|
||||||
&~li setb s:longi
|
|
||||||
aif s:longa.and.s:longi,.a
|
|
||||||
rep #32*(.not.&~la)+16*(.not.&~li)
|
|
||||||
longa on
|
|
||||||
longi on
|
|
||||||
.a
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l inc4 &a
|
|
||||||
&l ~setm
|
|
||||||
inc &a
|
|
||||||
bne ~&SYSCNT
|
|
||||||
inc 2+&a
|
|
||||||
~&SYSCNT ~restm
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l sub4 &m1,&m2,&m3
|
|
||||||
lclb &yistwo
|
|
||||||
lclc &c
|
|
||||||
&l ~setm
|
|
||||||
aif c:&m3,.a
|
|
||||||
&c amid "&m2",1,1
|
|
||||||
aif "&c"<>"#",.a
|
|
||||||
&c amid "&m1",1,1
|
|
||||||
aif "&c"="{",.a
|
|
||||||
aif "&c"="[",.a
|
|
||||||
&c amid "&m2",2,l:&m2-1
|
|
||||||
aif &c>=65536,.a
|
|
||||||
sec
|
|
||||||
~lda &m1
|
|
||||||
~op sbc,&m2
|
|
||||||
~sta &m1
|
|
||||||
bcs ~&SYSCNT
|
|
||||||
~op.h dec,&m1
|
|
||||||
~&SYSCNT anop
|
|
||||||
ago .c
|
|
||||||
.a
|
|
||||||
aif c:&m3,.b
|
|
||||||
lclc &m3
|
|
||||||
&m3 setc &m1
|
|
||||||
.b
|
|
||||||
sec
|
|
||||||
~lda &m1
|
|
||||||
~op sbc,&m2
|
|
||||||
~sta &m3
|
|
||||||
~lda.h &m1
|
|
||||||
~op.h sbc,&m2
|
|
||||||
~sta.h &m3
|
|
||||||
.c
|
|
||||||
~restm
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~sta &op
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"<>"{",.b
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
&l sta &op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l ~sta.h &op
|
|
||||||
&l anop
|
|
||||||
lclc &c
|
|
||||||
&c amid "&op",1,1
|
|
||||||
aif "&c"="[",.b
|
|
||||||
aif "&c"<>"{",.d
|
|
||||||
&c amid "&op",l:&op,1
|
|
||||||
aif "&c"="}",.a
|
|
||||||
mnote "Missing closing '}'",2
|
|
||||||
&op setc &op}
|
|
||||||
.a
|
|
||||||
&op amid "&op",2,l:&op-2
|
|
||||||
&op setc (&op)
|
|
||||||
.b
|
|
||||||
aif &yistwo,.c
|
|
||||||
&yistwo setb 1
|
|
||||||
ldy #2
|
|
||||||
.c
|
|
||||||
&op setc "&op,y"
|
|
||||||
sta &op
|
|
||||||
mexit
|
|
||||||
.d
|
|
||||||
sta 2+&op
|
|
||||||
mend
|
|
||||||
macro
|
|
||||||
&l cmpl &n1,&n2
|
|
||||||
lclb &yistwo
|
|
||||||
&l ~setm
|
|
||||||
~lda.h &n1
|
|
||||||
~op.h cmp,&n2
|
|
||||||
bne ~a&SYSCNT
|
|
||||||
~lda &n1
|
|
||||||
~op cmp,&n2
|
|
||||||
~a&SYSCNT anop
|
|
||||||
~restm
|
|
||||||
mend
|
|
||||||
MACRO
|
|
||||||
&LAB FCLASSS
|
|
||||||
&LAB PEA $021C
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCLASSD
|
|
||||||
&LAB PEA $011C
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCLASSX
|
|
||||||
&LAB PEA $001C
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2S
|
|
||||||
&LAB PEA $0210
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2D
|
|
||||||
&LAB PEA $0110
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCMPX
|
|
||||||
&LAB PEA $0008
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FEXP2X
|
|
||||||
&LAB PEA $000A
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FEXP1X
|
|
||||||
&LAB PEA $000C
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FLN1X
|
|
||||||
&LAB PEA $0004
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FLOG2X
|
|
||||||
&LAB PEA $0002
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FLOGBX
|
|
||||||
&LAB PEA $001A
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2I
|
|
||||||
&LAB PEA $0410
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FTINTX
|
|
||||||
&LAB PEA $0016
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FRINTX
|
|
||||||
&LAB PEA $0014
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FXPWRY
|
|
||||||
&LAB PEA $0012
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FREMX
|
|
||||||
&LAB PEA $000C
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSCALBX
|
|
||||||
&LAB PEA $0018
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSUBX
|
|
||||||
&LAB PEA $0002
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FGETENV
|
|
||||||
&LAB PEA $03
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSETENV
|
|
||||||
&LAB PEA $01
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2C
|
|
||||||
&LAB PEA $0510
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCPXX
|
|
||||||
&LAB PEA $0A
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FNEXTX
|
|
||||||
&LAB PEA $001E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FX2X
|
|
||||||
&LAB PEA $0010
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCPXD
|
|
||||||
&LAB PEA $010A
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FNEXTD
|
|
||||||
&LAB PEA $011E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FD2X
|
|
||||||
&LAB PEA $010E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FS2X
|
|
||||||
&LAB PEA $020E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FNEXTS
|
|
||||||
&LAB PEA $021E
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FCPXS
|
|
||||||
&LAB PEA $020A
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FPROCENTRY
|
|
||||||
&LAB PEA $0017
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FPROCEXIT
|
|
||||||
&LAB PEA $0019
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FTESTXCP
|
|
||||||
&LAB PEA $001B
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FADDS
|
|
||||||
&LAB PEA $0200
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSETXCP
|
|
||||||
&LAB PEA $0015
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FADDX
|
|
||||||
&LAB PEA $0000
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FADDI
|
|
||||||
&LAB PEA $0400
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSUBI
|
|
||||||
&LAB PEA $0402
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FMULX
|
|
||||||
&LAB PEA $0004
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FSQRTX
|
|
||||||
&LAB PEA $0012
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FLNX
|
|
||||||
&LAB PEA $0000
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&lab _SDivide
|
|
||||||
&lab ldx #$0A0B
|
|
||||||
jsl $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FMULI
|
|
||||||
&LAB PEA $0404
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FDIVI
|
|
||||||
&LAB PEA $0406
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FDIVX
|
|
||||||
&LAB PEA $0006
|
|
||||||
LDX #$090A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB FXPWRI
|
|
||||||
&LAB PEA $0010
|
|
||||||
LDX #$0B0A
|
|
||||||
JSL $E10000
|
|
||||||
MEND
|
|
8
orca.asm
8
orca.asm
|
@ -53,7 +53,7 @@ lb1 rtl
|
||||||
*
|
*
|
||||||
enddesk start
|
enddesk start
|
||||||
|
|
||||||
jmp ~ENDDESK
|
brl ~ENDDESK
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -64,7 +64,7 @@ enddesk start
|
||||||
*
|
*
|
||||||
endgraph start
|
endgraph start
|
||||||
|
|
||||||
jmp ~ENDGRAPH
|
brl ~ENDGRAPH
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -119,7 +119,7 @@ id dc 8c' ',i1'0'
|
||||||
*
|
*
|
||||||
startdesk start
|
startdesk start
|
||||||
|
|
||||||
jmp ~STARTDESK
|
brl ~STARTDESK
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -130,7 +130,7 @@ startdesk start
|
||||||
*
|
*
|
||||||
startgraph start
|
startgraph start
|
||||||
|
|
||||||
jmp ~STARTGRAPH
|
brl ~STARTGRAPH
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
|
10
settypes
Normal file
10
settypes
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
filetype -p =.asm src; change -p =.asm asm65816
|
||||||
|
filetype -p =.macros src; change -p =.macros asm65816
|
||||||
|
filetype m16.int64 src; change m16.int64 exec
|
||||||
|
filetype smac src; change smac asm65816
|
||||||
|
filetype backup src; change backup exec
|
||||||
|
filetype make src; change make exec
|
||||||
|
filetype settypes src; change settypes exec
|
||||||
|
filetype LICENSE txt
|
||||||
|
filetype README.md txt
|
||||||
|
filetype obj:README.txt txt
|
|
@ -107,9 +107,8 @@ lb2 asl A get the signal handler address
|
||||||
tay
|
tay
|
||||||
lda >subABRT-2,X
|
lda >subABRT-2,X
|
||||||
bmi lb3 skip if it is SIG_DFL or SIG_IGN
|
bmi lb3 skip if it is SIG_DFL or SIG_IGN
|
||||||
short M set up the call address
|
xba set up the call address
|
||||||
sta >jsl+3
|
sta >jsl+2
|
||||||
long M
|
|
||||||
tya
|
tya
|
||||||
sta >jsl+1
|
sta >jsl+1
|
||||||
ph2 <sig call the user signal handler
|
ph2 <sig call the user signal handler
|
||||||
|
|
667
stdio.asm
667
stdio.asm
|
@ -83,16 +83,13 @@ stdfile equ 7 is this a standard file?
|
||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
|
|
||||||
lda #EOF assume we will get an error
|
|
||||||
sta err
|
|
||||||
ph4 <stream verify that stream exists
|
ph4 <stream verify that stream exists
|
||||||
jsl ~VerifyStream
|
jsl ~VerifyStream
|
||||||
jcs rts
|
jcs rts_err
|
||||||
|
|
||||||
ph4 <stream do any pending I/O
|
ph4 <stream do any pending I/O
|
||||||
jsl fflush
|
jsl fflush
|
||||||
tax
|
sta err initialize err to fflush result
|
||||||
jne rts
|
|
||||||
|
|
||||||
stz stdfile not a standard file
|
stz stdfile not a standard file
|
||||||
lda stream+2 bypass file disposal if the file is
|
lda stream+2 bypass file disposal if the file is
|
||||||
|
@ -110,11 +107,10 @@ lb1 inc stdfile
|
||||||
|
|
||||||
cl0 lla p,stderr+4 find the file record that points to this
|
cl0 lla p,stderr+4 find the file record that points to this
|
||||||
ldy #2 one
|
ldy #2 one
|
||||||
cl1 lda [p]
|
cl1 lda [p],Y
|
||||||
ora [p],Y
|
|
||||||
jeq rts
|
|
||||||
lda [p],Y
|
|
||||||
tax
|
tax
|
||||||
|
ora [p]
|
||||||
|
jeq rts_err
|
||||||
lda [p]
|
lda [p]
|
||||||
cmp stream
|
cmp stream
|
||||||
bne cl2
|
bne cl2
|
||||||
|
@ -128,46 +124,10 @@ cl3 lda [stream] remove stream from the file list
|
||||||
sta [p]
|
sta [p]
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
sta [p],Y
|
sta [p],Y
|
||||||
cl3a ldy #FILE_flag if the file was opened by tmpfile then
|
cl3a ldy #FILE_flag if the buffer was allocated by fopen then
|
||||||
lda [stream],Y
|
|
||||||
and #_IOTEMPFILE
|
|
||||||
beq cl3d
|
|
||||||
ph4 #nameBuffSize p = malloc(nameBuffSize)
|
|
||||||
jsl malloc grPathname = p
|
|
||||||
sta p dsPathname = p+2
|
|
||||||
stx p+2
|
|
||||||
sta grPathname
|
|
||||||
stx grPathname+2
|
|
||||||
clc
|
|
||||||
adc #2
|
|
||||||
bcc cl3b
|
|
||||||
inx
|
|
||||||
cl3b sta dsPathname
|
|
||||||
stx dsPathname+2
|
|
||||||
lda #nameBuffSize p->size = nameBuffSize
|
|
||||||
sta [p]
|
|
||||||
ldy #FILE_file clRefnum = grRefnum = stream->_file
|
|
||||||
lda [stream],Y
|
|
||||||
beq cl3e
|
|
||||||
sta grRefnum
|
|
||||||
GetRefInfoGS gr GetRefInfoGS(gr)
|
|
||||||
bcs cl3c
|
|
||||||
lda grRefnum OSClose(cl)
|
|
||||||
sta clRefNum
|
|
||||||
OSClose cl
|
|
||||||
DestroyGS ds DestroyGS(ds)
|
|
||||||
cl3c ph4 <p free(p)
|
|
||||||
jsl free
|
|
||||||
bra cl3e else
|
|
||||||
cl3d ldy #FILE_file close the file
|
|
||||||
lda [stream],Y
|
|
||||||
beq cl3e
|
|
||||||
sta clRefNum
|
|
||||||
OSClose cl
|
|
||||||
cl3e ldy #FILE_flag if the buffer was allocated by fopen then
|
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
and #_IOMYBUF
|
and #_IOMYBUF
|
||||||
beq cl4
|
beq cl3b
|
||||||
ldy #FILE_base+2 dispose of the file buffer
|
ldy #FILE_base+2 dispose of the file buffer
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
pha
|
pha
|
||||||
|
@ -176,6 +136,47 @@ cl3e ldy #FILE_flag if the buffer was allocated by fopen the
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
pha
|
pha
|
||||||
jsl free
|
jsl free
|
||||||
|
cl3b ldy #FILE_flag if the file was opened by tmpfile then
|
||||||
|
lda [stream],Y
|
||||||
|
and #_IOTEMPFILE
|
||||||
|
beq cl3f
|
||||||
|
ph4 #nameBuffSize p = malloc(nameBuffSize)
|
||||||
|
jsl malloc
|
||||||
|
sta p
|
||||||
|
stx p+2
|
||||||
|
ora p+2 if p == NULL then
|
||||||
|
bne cl3c
|
||||||
|
lda #EOF flag error
|
||||||
|
sta err
|
||||||
|
bra cl3f just close the file
|
||||||
|
cl3c lda p
|
||||||
|
sta grPathname grPathname = p
|
||||||
|
stx grPathname+2
|
||||||
|
clc dsPathname = p+2
|
||||||
|
adc #2
|
||||||
|
bcc cl3d
|
||||||
|
inx
|
||||||
|
cl3d sta dsPathname
|
||||||
|
stx dsPathname+2
|
||||||
|
lda #nameBuffSize p->size = nameBuffSize
|
||||||
|
sta [p]
|
||||||
|
ldy #FILE_file clRefnum = grRefnum = stream->_file
|
||||||
|
lda [stream],Y
|
||||||
|
beq cl4
|
||||||
|
sta grRefnum
|
||||||
|
sta clRefNum
|
||||||
|
GetRefInfoGS gr GetRefInfoGS(gr)
|
||||||
|
bcs cl3e
|
||||||
|
OSClose cl OSClose(cl)
|
||||||
|
DestroyGS ds DestroyGS(ds)
|
||||||
|
cl3e ph4 <p free(p)
|
||||||
|
jsl free
|
||||||
|
bra cl4 else
|
||||||
|
cl3f ldy #FILE_file close the file
|
||||||
|
lda [stream],Y
|
||||||
|
beq cl4
|
||||||
|
sta clRefNum
|
||||||
|
OSClose cl
|
||||||
cl4 lda stdfile if this is not a standard file then
|
cl4 lda stdfile if this is not a standard file then
|
||||||
bne cl5
|
bne cl5
|
||||||
ph4 <stream dispose of the file buffer
|
ph4 <stream dispose of the file buffer
|
||||||
|
@ -189,7 +190,10 @@ cl6 lda [p],Y
|
||||||
dey
|
dey
|
||||||
cpy #2
|
cpy #2
|
||||||
bne cl6
|
bne cl6
|
||||||
cl7 stz err no error found
|
cl7 bra rts no error found
|
||||||
|
|
||||||
|
rts_err lda #EOF
|
||||||
|
sta err
|
||||||
rts plb
|
rts plb
|
||||||
creturn 2:err
|
creturn 2:err
|
||||||
|
|
||||||
|
@ -688,24 +692,26 @@ disp equ 1 disp in s
|
||||||
|
|
||||||
ph4 <stream verify that stream exists
|
ph4 <stream verify that stream exists
|
||||||
jsl ~VerifyStream
|
jsl ~VerifyStream
|
||||||
bcs err1
|
bcs err
|
||||||
ph4 <stream quit with NULL if at EOF
|
stz disp no characters processed so far
|
||||||
jsl feof
|
|
||||||
tax
|
|
||||||
beq lb0
|
|
||||||
err1 stz s
|
|
||||||
stz s+2
|
|
||||||
bra rts
|
|
||||||
lb0 stz disp no characters processed so far
|
|
||||||
lda #0
|
|
||||||
sta [s]
|
|
||||||
dec n leave room for the null terminator
|
dec n leave room for the null terminator
|
||||||
bmi err
|
bmi err
|
||||||
beq err
|
bne lb1
|
||||||
|
short M n = 1: store null terminator only
|
||||||
|
lda #0
|
||||||
|
sta [s]
|
||||||
|
long M
|
||||||
|
bra rts
|
||||||
lb1 ph4 <stream get a character
|
lb1 ph4 <stream get a character
|
||||||
jsl fgetc
|
jsl fgetc
|
||||||
tax quit with error if it is an EOF
|
tax if error or EOF encountered
|
||||||
bpl lb2
|
bpl lb2
|
||||||
|
lda disp if no characters read, return NULL
|
||||||
|
beq err
|
||||||
|
ldy #FILE_flag if error encountered, return NULL
|
||||||
|
lda [stream],Y
|
||||||
|
and #_IOERR
|
||||||
|
beq rts else return s
|
||||||
err stz s
|
err stz s
|
||||||
stz s+2
|
stz s+2
|
||||||
bra rts
|
bra rts
|
||||||
|
@ -1320,11 +1326,10 @@ fprintf start
|
||||||
sta stream+2
|
sta stream+2
|
||||||
phy restore return address/data bank
|
phy restore return address/data bank
|
||||||
phx
|
phx
|
||||||
|
ldx stream
|
||||||
plb
|
plb
|
||||||
lda >stream+2 verify that stream exists
|
pha verify that stream exists
|
||||||
pha
|
phx
|
||||||
lda >stream
|
|
||||||
pha
|
|
||||||
jsl ~VerifyStream
|
jsl ~VerifyStream
|
||||||
bcc lb1
|
bcc lb1
|
||||||
lda #EIO
|
lda #EIO
|
||||||
|
@ -2249,9 +2254,15 @@ disp equ 1 disp in s
|
||||||
|
|
||||||
stz disp no characters processed so far
|
stz disp no characters processed so far
|
||||||
lb1 jsl getchar get a character
|
lb1 jsl getchar get a character
|
||||||
tax quit with error if it is an EOF
|
tax if error or EOF encountered
|
||||||
bpl lb2
|
bpl lb2
|
||||||
stz s
|
lda disp if no characters read, return NULL
|
||||||
|
beq err
|
||||||
|
ph4 >stdin if error encountered, return NULL
|
||||||
|
jsl ferror
|
||||||
|
tax
|
||||||
|
beq rts else return s
|
||||||
|
err stz s
|
||||||
stz s+2
|
stz s+2
|
||||||
bra rts
|
bra rts
|
||||||
lb2 cmp #LF quit if it was a \n
|
lb2 cmp #LF quit if it was a \n
|
||||||
|
@ -3202,9 +3213,8 @@ pr dc i'2' parameter block for OSGet_Prefix
|
||||||
dc i'3'
|
dc i'3'
|
||||||
dc a4'name'
|
dc a4'name'
|
||||||
|
|
||||||
name dc i'16,0' GS/OS name buffer
|
name dc i'17+4,0' GS/OS name buffer
|
||||||
cname ds 26 part of name; also C buffer
|
cname ds 26 part of name; also C buffer
|
||||||
GS_OSname dc i'8' used for OSGet_File_Info
|
|
||||||
syscxxxx dc c'SYSC0000',i1'0' for creating unique names
|
syscxxxx dc c'SYSC0000',i1'0' for creating unique names
|
||||||
|
|
||||||
GIParm dc i'2' used to see if the file exists
|
GIParm dc i'2' used to see if the file exists
|
||||||
|
@ -3320,11 +3330,10 @@ vfprintf start
|
||||||
sta stream+2
|
sta stream+2
|
||||||
phy restore return address/data bank
|
phy restore return address/data bank
|
||||||
phx
|
phx
|
||||||
|
ldx stream
|
||||||
plb
|
plb
|
||||||
lda >stream+2 verify that stream exists
|
pha verify that stream exists
|
||||||
pha
|
phx
|
||||||
lda >stream
|
|
||||||
pha
|
|
||||||
jsl ~VerifyStream
|
jsl ~VerifyStream
|
||||||
bcc lb1
|
bcc lb1
|
||||||
lda #EIO
|
lda #EIO
|
||||||
|
@ -3874,40 +3883,33 @@ argp equ 7 argument pointer
|
||||||
;
|
;
|
||||||
; For signed numbers, if the value is negative, use the sign flag
|
; For signed numbers, if the value is negative, use the sign flag
|
||||||
;
|
;
|
||||||
lda ~isLongLong handle long long values
|
lda ~isLong handle long and long long values
|
||||||
beq sn0
|
|
||||||
ldy #6
|
|
||||||
lda [argp],Y
|
|
||||||
bpl cn0
|
|
||||||
sec
|
|
||||||
lda #0
|
|
||||||
sbc [argp]
|
|
||||||
sta [argp]
|
|
||||||
ldy #2
|
|
||||||
lda #0
|
|
||||||
sbc [argp],Y
|
|
||||||
sta [argp],Y
|
|
||||||
iny
|
|
||||||
iny
|
|
||||||
lda #0
|
|
||||||
sbc [argp],Y
|
|
||||||
sta [argp],Y
|
|
||||||
iny
|
|
||||||
iny
|
|
||||||
lda #0
|
|
||||||
sbc [argp],Y
|
|
||||||
sta [argp],Y
|
|
||||||
bra sn2
|
|
||||||
sn0 lda ~isLong handle long values
|
|
||||||
beq sn0a
|
beq sn0a
|
||||||
ldy #2
|
ldy #2
|
||||||
lda [argp],Y
|
lda ~isLongLong
|
||||||
|
beq sn0
|
||||||
|
ldy #6
|
||||||
|
sn0 lda [argp],Y
|
||||||
bpl cn0
|
bpl cn0
|
||||||
sec
|
sec
|
||||||
lda #0
|
ldx #0
|
||||||
|
txa
|
||||||
sbc [argp]
|
sbc [argp]
|
||||||
sta [argp]
|
sta [argp]
|
||||||
lda #0
|
ldy #2
|
||||||
|
txa
|
||||||
|
sbc [argp],Y
|
||||||
|
sta [argp],Y
|
||||||
|
lda ~isLongLong
|
||||||
|
beq sn2
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
|
sbc [argp],Y
|
||||||
|
sta [argp],Y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
txa
|
||||||
sbc [argp],Y
|
sbc [argp],Y
|
||||||
sta [argp],Y
|
sta [argp],Y
|
||||||
bra sn2
|
bra sn2
|
||||||
|
@ -3957,13 +3959,12 @@ cn1 lda [argp] push an int value
|
||||||
cn1a pha
|
cn1a pha
|
||||||
cn2 ph4 #~str push the string addr
|
cn2 ph4 #~str push the string addr
|
||||||
ph2 #l:~str push the string buffer length
|
ph2 #l:~str push the string buffer length
|
||||||
ph2 #0 do an unsigned conversion
|
|
||||||
lda ~isLongLong do the proper conversion
|
lda ~isLongLong do the proper conversion
|
||||||
beq cn2a
|
beq cn2a
|
||||||
pla
|
|
||||||
jsr ~ULongLong2Dec
|
jsr ~ULongLong2Dec
|
||||||
bra pd1
|
bra pd1
|
||||||
cn2a lda ~isLong
|
cn2a ph2 #0 do an unsigned conversion
|
||||||
|
lda ~isLong
|
||||||
beq cn3
|
beq cn3
|
||||||
_Long2Dec
|
_Long2Dec
|
||||||
bra pd1
|
bra pd1
|
||||||
|
@ -4050,17 +4051,8 @@ pn1 lda ~hexPrefix if there is a hex prefix then
|
||||||
jsl ~putchar
|
jsl ~putchar
|
||||||
ph2 ~hexPrefix+1
|
ph2 ~hexPrefix+1
|
||||||
jsl ~putchar
|
jsl ~putchar
|
||||||
pn1a lda ~paddChar if the number needs 0 padding then
|
pn1a jsr ~ZeroPad pad with '0's if needed
|
||||||
cmp #'0'
|
lda ~precision if the number needs more padding then
|
||||||
bne pn1c
|
|
||||||
lda ~fieldWidth
|
|
||||||
bmi pn1c
|
|
||||||
beq pn1c
|
|
||||||
pn1b ph2 ~paddChar print padd zeros
|
|
||||||
jsl ~putchar
|
|
||||||
dec ~fieldWidth
|
|
||||||
bne pn1b
|
|
||||||
pn1c lda ~precision if the number needs more padding then
|
|
||||||
beq pn3
|
beq pn3
|
||||||
pn2 ph2 #'0' print padd characters
|
pn2 ph2 #'0' print padd characters
|
||||||
jsl ~putchar
|
jsl ~putchar
|
||||||
|
@ -4088,10 +4080,10 @@ pn5 cpy #l:~str quit if we're at the end of the ~str
|
||||||
;
|
;
|
||||||
rn1 lda ~isLongLong
|
rn1 lda ~isLongLong
|
||||||
beq rn2
|
beq rn2
|
||||||
inc argp
|
lda argp
|
||||||
inc argp
|
clc
|
||||||
inc argp
|
adc #4
|
||||||
inc argp
|
sta argp
|
||||||
rn2 lda ~isLong
|
rn2 lda ~isLong
|
||||||
beq rn3
|
beq rn3
|
||||||
inc argp
|
inc argp
|
||||||
|
@ -4237,9 +4229,12 @@ lb1 clc restore the original argp+4
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* ~Format_o - format an octal number
|
* ~Format_o - format an octal number
|
||||||
|
* ~Format_x - format a hexadecimal number (lowercase output)
|
||||||
|
* ~Format_X - format a hexadecimal number (uppercase output)
|
||||||
|
* ~Format_p - format a pointer
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* ~altForm - use a leading '0'?
|
* ~altForm - use a leading '0' (octal) or '0x' (hex)?
|
||||||
* ~fieldWidth - output field width
|
* ~fieldWidth - output field width
|
||||||
* ~paddChar - padd character
|
* ~paddChar - padd character
|
||||||
* ~leftJustify - left justify the output?
|
* ~leftJustify - left justify the output?
|
||||||
|
@ -4253,15 +4248,34 @@ lb1 clc restore the original argp+4
|
||||||
~Format_o private
|
~Format_o private
|
||||||
using ~printfCommon
|
using ~printfCommon
|
||||||
argp equ 7 argument pointer
|
argp equ 7 argument pointer
|
||||||
|
|
||||||
|
lda #3 use 3 bits per output character
|
||||||
|
bra cn0
|
||||||
|
|
||||||
|
~Format_x entry
|
||||||
|
;
|
||||||
|
; Set the "or" value; this is used to set the case of character results
|
||||||
|
;
|
||||||
|
lda #$20*256
|
||||||
|
sta ~orVal
|
||||||
|
bra hx0
|
||||||
|
|
||||||
|
~Format_p entry
|
||||||
|
inc ~isLong
|
||||||
|
~Format_X entry
|
||||||
|
stz ~orVal
|
||||||
|
hx0 lda #4 use 4 bits per output character
|
||||||
|
|
||||||
;
|
;
|
||||||
; Initialization
|
; Initialization
|
||||||
;
|
;
|
||||||
|
cn0 sta bitsPerChar
|
||||||
|
stz ~hexPrefix assume we won't lead with 0x
|
||||||
stz ~sign ignore the sign flag
|
stz ~sign ignore the sign flag
|
||||||
lda #' ' initialize the string to blanks
|
lda #' ' initialize the string to blanks
|
||||||
sta ~str
|
sta ~str
|
||||||
move ~str,~str+1,#l:~str-1
|
move ~str,~str+1,#l:~str-1
|
||||||
stz ~num+2 get the value to convert
|
lda ~isLongLong get the value to convert
|
||||||
lda ~isLongLong
|
|
||||||
beq cn1
|
beq cn1
|
||||||
ldy #6
|
ldy #6
|
||||||
lda [argp],Y
|
lda [argp],Y
|
||||||
|
@ -4272,7 +4286,7 @@ argp equ 7 argument pointer
|
||||||
sta ~num+4
|
sta ~num+4
|
||||||
cn1 lda ~isLong
|
cn1 lda ~isLong
|
||||||
beq cn2
|
beq cn2
|
||||||
cn1a ldy #2
|
ldy #2
|
||||||
lda [argp],Y
|
lda [argp],Y
|
||||||
sta ~num+2
|
sta ~num+2
|
||||||
cn2 lda [argp]
|
cn2 lda [argp]
|
||||||
|
@ -4280,57 +4294,71 @@ cn2 lda [argp]
|
||||||
beq cn2a
|
beq cn2a
|
||||||
and #$00FF
|
and #$00FF
|
||||||
cn2a sta ~num
|
cn2a sta ~num
|
||||||
|
ldx bitsPerChar if doing hex format then
|
||||||
|
cpx #3
|
||||||
|
beq cn2b
|
||||||
|
ldx ~altForm if alt form has been selected then
|
||||||
|
beq cn2b
|
||||||
|
ora ~num+2 if value is not 0 then
|
||||||
|
ora ~num+4
|
||||||
|
ora ~num+6
|
||||||
|
beq cn2b
|
||||||
|
lda #'X0' set hex prefix to '0X' or '0x'
|
||||||
|
ora ~orVal
|
||||||
|
sta ~hexPrefix
|
||||||
;
|
;
|
||||||
; Convert the number to an ASCII string
|
; Convert the number to an ASCII string
|
||||||
;
|
;
|
||||||
short I,M
|
cn2b ldy #l:~str-1 set up the character index
|
||||||
ldy #l:~str-1 set up the character index
|
cn3 lda #' 0' roll off 4 bits
|
||||||
cn3 lda ~num+7 quit if the number is zero
|
ldx bitsPerChar
|
||||||
ora ~num+6
|
cn4 lsr ~num+6
|
||||||
ora ~num+5
|
|
||||||
ora ~num+4
|
|
||||||
ora ~num+3
|
|
||||||
ora ~num+2
|
|
||||||
ora ~num+1
|
|
||||||
ora ~num
|
|
||||||
beq al1
|
|
||||||
lda #0 roll off 3 bits
|
|
||||||
ldx #3
|
|
||||||
cn4 lsr ~num+7
|
|
||||||
ror ~num+6
|
|
||||||
ror ~num+5
|
|
||||||
ror ~num+4
|
ror ~num+4
|
||||||
ror ~num+3
|
|
||||||
ror ~num+2
|
ror ~num+2
|
||||||
ror ~num+1
|
|
||||||
ror ~num
|
ror ~num
|
||||||
ror A
|
ror A
|
||||||
dex
|
dex
|
||||||
bne cn4
|
bne cn4
|
||||||
lsr A form a character
|
xba form a character
|
||||||
lsr A
|
ldx bitsPerChar
|
||||||
lsr A
|
cn4a asl A
|
||||||
lsr A
|
dex
|
||||||
lsr A
|
bne cn4a
|
||||||
ora #'0'
|
cmp #('9'+1)*256+' ' if the character should be alpha then
|
||||||
|
blt cn5
|
||||||
|
clc
|
||||||
|
adc #7*256 adjust it
|
||||||
|
ora ~orVal
|
||||||
|
cn5 dey
|
||||||
sta ~str,Y save the character
|
sta ~str,Y save the character
|
||||||
dey
|
lda ~num+6 loop if the number is not zero
|
||||||
bra cn3
|
ora ~num+4
|
||||||
|
ora ~num+2
|
||||||
|
ora ~num
|
||||||
|
bne cn3
|
||||||
;
|
;
|
||||||
; If a leading zero is required, be sure we include one
|
; If a leading '0x' is required, be sure we include one
|
||||||
;
|
;
|
||||||
al1 cpy #l:~str-1 include a zero if no characters have
|
lda bitsPerChar if doing octal format then
|
||||||
beq al2 been placed in the string
|
cmp #3
|
||||||
lda ~altForm branch if no leading zero is required
|
bne al3
|
||||||
|
lda ~altForm if alt form has been selected then
|
||||||
beq al3
|
beq al3
|
||||||
al2 lda #'0'
|
lda ~precision make sure precision is non-zero
|
||||||
sta ~str,Y
|
bne al2
|
||||||
al3 long I,M
|
inc ~precision
|
||||||
|
al2 lda #'0 ' if the result is not ' 0' then
|
||||||
|
cmp ~str+l:~str-2
|
||||||
|
beq al3
|
||||||
|
sta ~str-1,Y include a zero in the string
|
||||||
;
|
;
|
||||||
; Piggy back off of ~Format_d for output
|
; Piggy back off of ~Format_d for output
|
||||||
;
|
;
|
||||||
stz ~hexPrefix don't lead with 0x
|
al3 brl ~Format_IntOut
|
||||||
brl ~Format_IntOut
|
;
|
||||||
|
; Local data
|
||||||
|
;
|
||||||
|
bitsPerChar ds 2 bits per output character
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -4350,36 +4378,36 @@ al3 long I,M
|
||||||
using ~printfCommon
|
using ~printfCommon
|
||||||
argp equ 7 argument pointer
|
argp equ 7 argument pointer
|
||||||
|
|
||||||
ph4 <argp save the original argp
|
sec set flag for c-string
|
||||||
ldy #2 dereference argp
|
bra lb0
|
||||||
lda [argp],Y
|
|
||||||
tax
|
|
||||||
lda [argp]
|
|
||||||
sta argp
|
|
||||||
stx argp+2
|
|
||||||
short M determine the length of the string
|
|
||||||
ldy #-1
|
|
||||||
lb1 iny
|
|
||||||
lda [argp],Y
|
|
||||||
bne lb1
|
|
||||||
long M
|
|
||||||
tya
|
|
||||||
bra lb1a
|
|
||||||
|
|
||||||
~Format_b entry
|
~Format_b entry
|
||||||
~Format_P entry
|
~Format_P entry
|
||||||
ph4 <argp save the original argp
|
clc set flag for p-string
|
||||||
|
|
||||||
|
lb0 ph4 <argp save the original argp
|
||||||
ldy #2 dereference argp
|
ldy #2 dereference argp
|
||||||
lda [argp],Y
|
lda [argp],Y
|
||||||
tax
|
tax
|
||||||
lda [argp]
|
lda [argp]
|
||||||
sta argp
|
sta argp
|
||||||
stx argp+2
|
stx argp+2
|
||||||
lda [argp] get the length of the string
|
|
||||||
|
bcs lb1 if formatting a p-string then
|
||||||
|
lda [argp] get the length of the string
|
||||||
and #$00FF
|
and #$00FF
|
||||||
inc4 argp
|
inc4 argp
|
||||||
|
bra lb1x else if formatting a c-string then
|
||||||
|
|
||||||
|
lb1 short M compute the length of the string
|
||||||
|
ldy #-1
|
||||||
|
lb1a iny
|
||||||
|
lda [argp],Y
|
||||||
|
bne lb1a
|
||||||
|
long M
|
||||||
|
tya
|
||||||
|
|
||||||
lb1a ldx ~precisionSpecified if the precision is specified then
|
lb1x ldx ~precisionSpecified if the precision is specified then
|
||||||
beq lb2
|
beq lb2
|
||||||
cmp ~precision if the precision is smaller then
|
cmp ~precision if the precision is smaller then
|
||||||
blt lb2
|
blt lb2
|
||||||
|
@ -4408,133 +4436,6 @@ lb4 clc restore and increment argp
|
||||||
brl ~LeftJustify handle left justification
|
brl ~LeftJustify handle left justification
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
* ~Format_x - format a hexadecimal number (lowercase output)
|
|
||||||
* ~Format_X - format a hexadecimal number (uppercase output)
|
|
||||||
* ~Format_p - format a pointer
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* ~altForm - use a leading '0x'?
|
|
||||||
* ~fieldWidth - output field width
|
|
||||||
* ~paddChar - padd character
|
|
||||||
* ~leftJustify - left justify the output?
|
|
||||||
* ~isLong - is the operand long?
|
|
||||||
* ~isLongLong - is the operand long long?
|
|
||||||
* ~precision - precision of output
|
|
||||||
* ~precisionSpecified - was the precision specified?
|
|
||||||
*
|
|
||||||
****************************************************************
|
|
||||||
*
|
|
||||||
~Format_x private
|
|
||||||
using ~printfCommon
|
|
||||||
argp equ 7 argument pointer
|
|
||||||
;
|
|
||||||
; Set the "or" value; this is used to set the case of character results
|
|
||||||
;
|
|
||||||
lda #$20
|
|
||||||
sta orVal
|
|
||||||
bra cn0
|
|
||||||
|
|
||||||
~Format_p entry
|
|
||||||
lda #1
|
|
||||||
sta ~isLong
|
|
||||||
~Format_X entry
|
|
||||||
stz orVal
|
|
||||||
;
|
|
||||||
; Initialization
|
|
||||||
;
|
|
||||||
cn0 stz ~sign ignore the sign flag
|
|
||||||
lda #' ' initialize the string to blanks
|
|
||||||
sta ~str
|
|
||||||
move ~str,~str+1,#l:~str-1
|
|
||||||
stz ~num+2 get the value to convert
|
|
||||||
stz ~num+4
|
|
||||||
stz ~num+6
|
|
||||||
lda ~isLongLong
|
|
||||||
beq cn1
|
|
||||||
ldy #6
|
|
||||||
lda [argp],Y
|
|
||||||
sta ~num+6
|
|
||||||
dey
|
|
||||||
dey
|
|
||||||
lda [argp],Y
|
|
||||||
sta ~num+4
|
|
||||||
cn1 lda ~isLong
|
|
||||||
beq cn2
|
|
||||||
ldy #2
|
|
||||||
lda [argp],Y
|
|
||||||
sta ~num+2
|
|
||||||
cn2 lda [argp]
|
|
||||||
ldx ~isByte
|
|
||||||
beq cn2a
|
|
||||||
and #$00FF
|
|
||||||
cn2a sta ~num
|
|
||||||
ora ~num+2
|
|
||||||
ora ~num+4
|
|
||||||
ora ~num+6
|
|
||||||
bne cn2b
|
|
||||||
stz ~altForm if value is 0, do not print hex prefix
|
|
||||||
cn2b stz ~hexPrefix assume we won't lead with 0x
|
|
||||||
;
|
|
||||||
; Convert the number to an ASCII string
|
|
||||||
;
|
|
||||||
short I,M
|
|
||||||
ldy #l:~str-1 set up the character index
|
|
||||||
cn3 lda #0 roll off 4 bits
|
|
||||||
ldx #4
|
|
||||||
cn4 lsr ~num+7
|
|
||||||
ror ~num+6
|
|
||||||
ror ~num+5
|
|
||||||
ror ~num+4
|
|
||||||
ror ~num+3
|
|
||||||
ror ~num+2
|
|
||||||
ror ~num+1
|
|
||||||
ror ~num
|
|
||||||
ror A
|
|
||||||
dex
|
|
||||||
bne cn4
|
|
||||||
lsr A form a character
|
|
||||||
lsr A
|
|
||||||
lsr A
|
|
||||||
lsr A
|
|
||||||
ora #'0'
|
|
||||||
cmp #'9'+1 if the character should be alpha,
|
|
||||||
blt cn5 adjust it
|
|
||||||
adc #6
|
|
||||||
ora orVal
|
|
||||||
cn5 sta ~str,Y save the character
|
|
||||||
dey
|
|
||||||
lda ~num+7 loop if the number is not zero
|
|
||||||
ora ~num+6
|
|
||||||
ora ~num+5
|
|
||||||
ora ~num+4
|
|
||||||
ora ~num+3
|
|
||||||
ora ~num+2
|
|
||||||
ora ~num+1
|
|
||||||
ora ~num
|
|
||||||
bne cn3
|
|
||||||
;
|
|
||||||
; If a leading '0x' is required, be sure we include one
|
|
||||||
;
|
|
||||||
lda ~altForm branch if no leading '0x' is required
|
|
||||||
beq al3
|
|
||||||
al2 lda #'X' insert leading '0x'
|
|
||||||
ora orVal
|
|
||||||
sta ~hexPrefix+1
|
|
||||||
lda #'0'
|
|
||||||
sta ~hexPrefix
|
|
||||||
al3 long I,M
|
|
||||||
;
|
|
||||||
; Piggy back off of ~Format_d for output
|
|
||||||
;
|
|
||||||
brl ~Format_IntOut
|
|
||||||
;
|
|
||||||
; Local data
|
|
||||||
;
|
|
||||||
orVal ds 2 for setting the case of characters
|
|
||||||
end
|
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* ~Format_Percent - format the '%' character
|
* ~Format_Percent - format the '%' character
|
||||||
|
@ -4662,10 +4563,12 @@ stream equ 3 input stream
|
||||||
*
|
*
|
||||||
* ~LeftJustify - print padd characters for left justification
|
* ~LeftJustify - print padd characters for left justification
|
||||||
* ~RightJustify - print padd characters for right justification
|
* ~RightJustify - print padd characters for right justification
|
||||||
|
* ~ZeroPad - print zeros to pad to field width
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* ~fieldWidth - # chars to print ( <= 0 prints none)
|
* ~fieldWidth - # chars to print ( <= 0 prints none)
|
||||||
* ~leftJustify - left justify the output?
|
* ~leftJustify - left justify the output?
|
||||||
|
* ~paddChar - padding character
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
|
@ -4688,6 +4591,19 @@ lb1 ph2 #' ' write the proper # of padd characters
|
||||||
dec ~fieldWidth
|
dec ~fieldWidth
|
||||||
bne lb1
|
bne lb1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
~ZeroPad entry
|
||||||
|
lda ~paddChar if the number needs 0 padding then
|
||||||
|
cmp #'0'
|
||||||
|
bne zp2
|
||||||
|
lda ~fieldWidth
|
||||||
|
bmi zp2
|
||||||
|
beq zp2
|
||||||
|
zp1 ph2 ~paddChar print padd zeros
|
||||||
|
jsl ~putchar
|
||||||
|
dec ~fieldWidth
|
||||||
|
bne zp1
|
||||||
|
zp2 rts
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -4786,7 +4702,7 @@ lb3 creturn 4:ptr
|
||||||
* -----------------------
|
* -----------------------
|
||||||
*
|
*
|
||||||
* An 'l' indicates that the 'd', 'o', 'u', 'x' or 'X' argument is
|
* An 'l' indicates that the 'd', 'o', 'u', 'x' or 'X' argument is
|
||||||
* long. 'L' and 'u' are also accepted for compliance with ANSI C,
|
* long. 'L' and 'h' are also accepted for compliance with ANSI C,
|
||||||
* but have no effect in this implementation.
|
* but have no effect in this implementation.
|
||||||
*
|
*
|
||||||
* Conversion Specifier
|
* Conversion Specifier
|
||||||
|
@ -4799,12 +4715,14 @@ lb3 creturn 4:ptr
|
||||||
* while 'X' generates uppercase hex digits.
|
* while 'X' generates uppercase hex digits.
|
||||||
* c Character.
|
* c Character.
|
||||||
* s String.
|
* s String.
|
||||||
* p Pascal string.
|
* P,b Pascal string.
|
||||||
|
* p Pointer.
|
||||||
* n The argument is (int *); the number of characters written so
|
* n The argument is (int *); the number of characters written so
|
||||||
* far is written to the location.
|
* far is written to the location.
|
||||||
* f Signed decimal floating point.
|
* f,F Signed decimal floating point.
|
||||||
* e,E Exponential format floating point.
|
* e,E Exponential format floating point.
|
||||||
* g,G Use f,e or E, as appropriate.
|
* g,G Use f,e or E, as appropriate.
|
||||||
|
* a,A Hexadecimal format floating point.
|
||||||
* % Write a '%' character.
|
* % Write a '%' character.
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -4909,20 +4827,20 @@ fm4 cmp #'L' else if *format in ['L','h'] then
|
||||||
inc ~isByte
|
inc ~isByte
|
||||||
fm5 inc4 format ++format
|
fm5 inc4 format ++format
|
||||||
lda [format] find the proper format character
|
lda [format] find the proper format character
|
||||||
and #$00FF
|
|
||||||
fm6 inc4 format
|
fm6 inc4 format
|
||||||
ldx #fListEnd-fList-4
|
short M,I
|
||||||
|
ldx #fListEnd-fList-3
|
||||||
fm7 cmp fList,X
|
fm7 cmp fList,X
|
||||||
beq fm8
|
beq fm8
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
dex
|
|
||||||
bpl fm7
|
bpl fm7
|
||||||
|
long M,I
|
||||||
brl ps1 none found - continue
|
brl ps1 none found - continue
|
||||||
fm8 pea ps1-1 push the return address
|
fm8 long M,I
|
||||||
|
pea ps1-1 push the return address
|
||||||
inx call the subroutine
|
inx call the subroutine
|
||||||
inx
|
|
||||||
jmp (fList,X)
|
jmp (fList,X)
|
||||||
;
|
;
|
||||||
; Flag - Read and process a flag character
|
; Flag - Read and process a flag character
|
||||||
|
@ -4933,23 +4851,23 @@ Flag lda [format] get the character
|
||||||
and #$00FF
|
and #$00FF
|
||||||
cmp #'-' if it is a '-' then
|
cmp #'-' if it is a '-' then
|
||||||
bne fl1
|
bne fl1
|
||||||
lda #1 left justify the output
|
sta ~leftJustify left justify the output
|
||||||
sta ~leftJustify
|
lda #' ' pad with spaces (ignore any '0' flag)
|
||||||
|
sta ~paddChar
|
||||||
bra fl5
|
bra fl5
|
||||||
|
|
||||||
fl1 cmp #'0' if it is a '0' then
|
fl1 cmp #'0' if it is a '0' then
|
||||||
bne fl2
|
bne fl2
|
||||||
sta ~paddChar padd with '0' characters
|
ldx ~leftJustify if not left justifying then
|
||||||
|
bne fl5
|
||||||
|
sta ~paddChar padd with '0' characters
|
||||||
bra fl5
|
bra fl5
|
||||||
|
|
||||||
fl2 cmp #'+' if it is a '+' or ' ' then
|
fl2 cmp #'+' if it is a '+' or ' ' then
|
||||||
beq fl3
|
beq fl3
|
||||||
cmp #' '
|
cmp #' '
|
||||||
bne fl4
|
bne fl4
|
||||||
ldx ~sign
|
fl3 tsb ~sign set the sign flag ('+' overrides ' ')
|
||||||
cpx #'+'
|
|
||||||
beq fl5
|
|
||||||
fl3 sta ~sign set the sign flag
|
|
||||||
bra fl5
|
bra fl5
|
||||||
|
|
||||||
fl4 cmp #'#' if it is a '#' then
|
fl4 cmp #'#' if it is a '#' then
|
||||||
|
@ -4979,8 +4897,10 @@ GetSize stz val assume a value of 0
|
||||||
bne fv0
|
bne fv0
|
||||||
eor #$ffff negative field width is like
|
eor #$ffff negative field width is like
|
||||||
inc a positive with - flag
|
inc a positive with - flag
|
||||||
ldx #1
|
ldx #'-'
|
||||||
stx ~leftJustify
|
stx ~leftJustify
|
||||||
|
ldx #' '
|
||||||
|
stx ~paddChar
|
||||||
bra fv1
|
bra fv1
|
||||||
fv0 lda #0 negative precision is ignored
|
fv0 lda #0 negative precision is ignored
|
||||||
stz ~precisionSpecified
|
stz ~precisionSpecified
|
||||||
|
@ -5013,27 +4933,27 @@ val ds 2 value
|
||||||
;
|
;
|
||||||
; List of format specifiers and the equivalent subroutines
|
; List of format specifiers and the equivalent subroutines
|
||||||
;
|
;
|
||||||
fList dc c'%',i1'0',a'~Format_Percent' %
|
fList dc c'%',a'~Format_Percent' %
|
||||||
dc c'a',i1'0',a'~Format_e' a (not formatted correctly)
|
dc c'a',a'~Format_a' a
|
||||||
dc c'A',i1'0',a'~Format_E' A (not formatted correctly)
|
dc c'A',a'~Format_A' A
|
||||||
dc c'f',i1'0',a'~Format_f' f
|
dc c'f',a'~Format_f' f
|
||||||
dc c'F',i1'0',a'~Format_f' F
|
dc c'F',a'~Format_F' F
|
||||||
dc c'e',i1'0',a'~Format_e' e
|
dc c'e',a'~Format_e' e
|
||||||
dc c'E',i1'0',a'~Format_E' E
|
dc c'E',a'~Format_E' E
|
||||||
dc c'g',i1'0',a'~Format_g' g
|
dc c'g',a'~Format_g' g
|
||||||
dc c'G',i1'0',a'~Format_G' G
|
dc c'G',a'~Format_G' G
|
||||||
dc c'n',i1'0',a'~Format_n' n
|
dc c'n',a'~Format_n' n
|
||||||
dc c's',i1'0',a'~Format_s' s
|
dc c's',a'~Format_s' s
|
||||||
dc c'b',i1'0',a'~Format_b' b
|
dc c'b',a'~Format_b' b
|
||||||
dc c'P',i1'0',a'~Format_P' P
|
dc c'P',a'~Format_P' P
|
||||||
dc c'p',i1'0',a'~Format_p' p
|
dc c'p',a'~Format_p' p
|
||||||
dc c'c',i1'0',a'~Format_c' c
|
dc c'c',a'~Format_c' c
|
||||||
dc c'X',i1'0',a'~Format_X' X
|
dc c'X',a'~Format_X' X
|
||||||
dc c'x',i1'0',a'~Format_x' x
|
dc c'x',a'~Format_x' x
|
||||||
dc c'o',i1'0',a'~Format_o' o
|
dc c'o',a'~Format_o' o
|
||||||
dc c'u',i1'0',a'~Format_u' u
|
dc c'u',a'~Format_u' u
|
||||||
dc c'd',i1'0',a'~Format_d' d
|
dc c'd',a'~Format_d' d
|
||||||
dc c'i',i1'0',a'~Format_d' i
|
dc c'i',a'~Format_d' i
|
||||||
fListEnd anop
|
fListEnd anop
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5067,8 +4987,9 @@ fListEnd anop
|
||||||
;
|
;
|
||||||
; Work buffers
|
; Work buffers
|
||||||
;
|
;
|
||||||
~num ds 8 long long integer
|
~num ds 8 long long integer (must be 0 after each conversion)
|
||||||
~numChars ds 2 number of characters printed with this printf
|
~numChars ds 2 number of characters printed with this printf
|
||||||
|
~orVal ds 2 value to 'or' with to set case of characters
|
||||||
~str ds 83 string buffer
|
~str ds 83 string buffer
|
||||||
;
|
;
|
||||||
; Real formatting
|
; Real formatting
|
||||||
|
@ -5951,13 +5872,9 @@ ps stz ~assignments no assignments yet
|
||||||
stz ~scanCount no characters scanned
|
stz ~scanCount no characters scanned
|
||||||
stz ~scanError no scan error so far
|
stz ~scanError no scan error so far
|
||||||
stz ~eofFound eof was not the first char
|
stz ~eofFound eof was not the first char
|
||||||
jsl ~getchar test for eof
|
|
||||||
cmp #EOF
|
|
||||||
bne ps0
|
|
||||||
sta ~eofFound
|
|
||||||
ps0 jsl ~putback
|
|
||||||
|
|
||||||
ps1 lda ~scanError quit if a scan error has occurred
|
ps1 lda ~scanError quit if a scan error has occurred
|
||||||
|
ora ~eofFound
|
||||||
bne rm1
|
bne rm1
|
||||||
lda [format] get a character
|
lda [format] get a character
|
||||||
and #$00FF
|
and #$00FF
|
||||||
|
@ -6117,7 +6034,7 @@ fm2b inc ~size
|
||||||
fm2c inc ~size
|
fm2c inc ~size
|
||||||
bra fm4
|
bra fm4
|
||||||
fm3 cmp #'h' 'h' specifies short int
|
fm3 cmp #'h' 'h' specifies short int
|
||||||
bne fm5
|
bne fm6
|
||||||
inc4 format unless it is 'hh' for char types
|
inc4 format unless it is 'hh' for char types
|
||||||
lda [format]
|
lda [format]
|
||||||
and #$00FF
|
and #$00FF
|
||||||
|
@ -6126,21 +6043,21 @@ fm3 cmp #'h' 'h' specifies short int
|
||||||
dec ~size
|
dec ~size
|
||||||
fm4 inc4 format ignore the character
|
fm4 inc4 format ignore the character
|
||||||
|
|
||||||
fm5 lda [format] find the proper format character
|
lda [format] find the proper format character
|
||||||
and #$00FF
|
|
||||||
fm6 inc4 format
|
fm6 inc4 format
|
||||||
ldx #fListEnd-fList-4
|
short M,I
|
||||||
|
ldx #fListEnd-fList-3
|
||||||
fm7 cmp fList,X
|
fm7 cmp fList,X
|
||||||
beq fm8
|
beq fm8
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
dex
|
|
||||||
bpl fm7
|
bpl fm7
|
||||||
|
long M,I
|
||||||
brl ps1 none found - continue
|
brl ps1 none found - continue
|
||||||
fm8 pea ps1-1 push the return address
|
fm8 long M,I
|
||||||
|
pea ps1-1 push the return address
|
||||||
inx call the subroutine
|
inx call the subroutine
|
||||||
inx
|
|
||||||
jmp (fList,X)
|
jmp (fList,X)
|
||||||
;
|
;
|
||||||
; GetSize - get a numeric value
|
; GetSize - get a numeric value
|
||||||
|
@ -6182,28 +6099,28 @@ val ds 2 value
|
||||||
;
|
;
|
||||||
; List of format specifiers and the equivalent subroutines
|
; List of format specifiers and the equivalent subroutines
|
||||||
;
|
;
|
||||||
fList dc c'd',i1'0',a'~Scan_d' d
|
fList dc c'd',a'~Scan_d' d
|
||||||
dc c'i',i1'0',a'~Scan_i' i
|
dc c'i',a'~Scan_i' i
|
||||||
dc c'u',i1'0',a'~Scan_u' u
|
dc c'u',a'~Scan_u' u
|
||||||
dc c'o',i1'0',a'~Scan_o' o
|
dc c'o',a'~Scan_o' o
|
||||||
dc c'x',i1'0',a'~Scan_x' x
|
dc c'x',a'~Scan_x' x
|
||||||
dc c'X',i1'0',a'~Scan_x' X
|
dc c'X',a'~Scan_x' X
|
||||||
dc c'p',i1'0',a'~Scan_p' p
|
dc c'p',a'~Scan_p' p
|
||||||
dc c'c',i1'0',a'~Scan_c' c
|
dc c'c',a'~Scan_c' c
|
||||||
dc c's',i1'0',a'~Scan_s' s
|
dc c's',a'~Scan_s' s
|
||||||
dc c'b',i1'0',a'~Scan_b' b
|
dc c'b',a'~Scan_b' b
|
||||||
dc c'P',i1'0',a'~Scan_P' P
|
dc c'P',a'~Scan_P' P
|
||||||
dc c'n',i1'0',a'~Scan_n' n
|
dc c'n',a'~Scan_n' n
|
||||||
dc c'a',i1'0',a'~Scan_f' a
|
dc c'a',a'~Scan_f' a
|
||||||
dc c'A',i1'0',a'~Scan_f' A
|
dc c'A',a'~Scan_f' A
|
||||||
dc c'f',i1'0',a'~Scan_f' f
|
dc c'f',a'~Scan_f' f
|
||||||
dc c'F',i1'0',a'~Scan_f' F
|
dc c'F',a'~Scan_f' F
|
||||||
dc c'e',i1'0',a'~Scan_f' e
|
dc c'e',a'~Scan_f' e
|
||||||
dc c'E',i1'0',a'~Scan_f' E
|
dc c'E',a'~Scan_f' E
|
||||||
dc c'g',i1'0',a'~Scan_f' g
|
dc c'g',a'~Scan_f' g
|
||||||
dc c'G',i1'0',a'~Scan_f' G
|
dc c'G',a'~Scan_f' G
|
||||||
dc c'%',i1'0',a'~Scan_percent' %
|
dc c'%',a'~Scan_percent' %
|
||||||
dc c'[',i1'0',a'~Scan_lbrack' [
|
dc c'[',a'~Scan_lbrack' [
|
||||||
fListEnd anop
|
fListEnd anop
|
||||||
;
|
;
|
||||||
; Other local data
|
; Other local data
|
||||||
|
|
128
stdlib.asm
128
stdlib.asm
|
@ -37,7 +37,7 @@ abort start
|
||||||
ph2 #SIGABRT
|
ph2 #SIGABRT
|
||||||
jsl raise
|
jsl raise
|
||||||
lda #-1
|
lda #-1
|
||||||
jmp ~C_QUIT
|
brl ~C_QUIT
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -333,6 +333,10 @@ addr equ 13 address of array element of index test
|
||||||
|
|
||||||
csubroutine (4:key,4:base,4:count,4:size,4:compar),16
|
csubroutine (4:key,4:base,4:count,4:size,4:compar),16
|
||||||
|
|
||||||
|
lda count if count is 0 then
|
||||||
|
ora count+2
|
||||||
|
jeq lb5 just return a null pointer
|
||||||
|
|
||||||
lda compar patch the call address
|
lda compar patch the call address
|
||||||
sta >jsl+1
|
sta >jsl+1
|
||||||
lda compar+1
|
lda compar+1
|
||||||
|
@ -436,14 +440,14 @@ exit start
|
||||||
_exit entry
|
_exit entry
|
||||||
_Exit entry
|
_Exit entry
|
||||||
lda 4,S
|
lda 4,S
|
||||||
jmp ~C_QUIT
|
brl ~C_QUIT
|
||||||
end
|
end
|
||||||
|
|
||||||
quick_exit start
|
quick_exit start
|
||||||
|
|
||||||
jsr ~QUICKEXIT
|
jsr ~QUICKEXIT
|
||||||
lda 4,S
|
lda 4,S
|
||||||
jmp ~C_QUIT
|
brl ~C_QUIT
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -700,13 +704,14 @@ ret stx n
|
||||||
qsort start
|
qsort start
|
||||||
|
|
||||||
csubroutine (4:base,4:count,4:size,4:compar),0
|
csubroutine (4:base,4:count,4:size,4:compar),0
|
||||||
phb
|
|
||||||
phk
|
|
||||||
plb
|
|
||||||
|
|
||||||
lda count nothing to do if count is 0
|
lda count nothing to do if count is 0
|
||||||
ora count+2
|
ora count+2
|
||||||
beq done
|
beq done
|
||||||
|
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
dec4 count set count to the addr of the last entry
|
dec4 count set count to the addr of the last entry
|
||||||
mul4 count,size
|
mul4 count,size
|
||||||
add4 count,base
|
add4 count,base
|
||||||
|
@ -717,12 +722,13 @@ qsort start
|
||||||
lda compar+1
|
lda compar+1
|
||||||
sta jsl1+2
|
sta jsl1+2
|
||||||
sta jsl2+2
|
sta jsl2+2
|
||||||
|
plb
|
||||||
|
|
||||||
ph4 <count do the sort
|
ph4 <count do the sort
|
||||||
ph4 <base
|
ph4 <base
|
||||||
jsl rsort
|
jsl rsort
|
||||||
|
|
||||||
done plb
|
done creturn
|
||||||
creturn
|
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -765,26 +771,31 @@ right equ 5 right address
|
||||||
|
|
||||||
csubroutine (4:first,4:last),8
|
csubroutine (4:first,4:last),8
|
||||||
|
|
||||||
phb
|
sr0 phb
|
||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
sr0 lda last+2 if last <= first then quit
|
lda last+2 if last <= first then quit
|
||||||
|
bmi sr1a
|
||||||
cmp first+2
|
cmp first+2
|
||||||
bne sr1
|
bne sr1
|
||||||
lda last
|
lda last
|
||||||
cmp first
|
cmp first
|
||||||
sr1 bgt sr1a
|
sr1 bgt sr1b
|
||||||
plb
|
sr1a plb
|
||||||
creturn
|
creturn
|
||||||
|
|
||||||
sr1a move4 last,right right = last
|
sr1b move4 last,right right = last
|
||||||
move4 first,left left = first
|
move4 first,left left = first
|
||||||
bra sr3
|
bra sr3
|
||||||
sr2 add4 left,lsize inc left until *left >= *last
|
sr2 add4 left,lsize inc left until *left >= *last
|
||||||
sr3 ph4 <last
|
sr3 plb
|
||||||
|
ph4 <last
|
||||||
ph4 <left
|
ph4 <left
|
||||||
jsl1 entry
|
jsl1 entry
|
||||||
jsl jsl1
|
jsl jsl1
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
tax
|
tax
|
||||||
bmi sr2
|
bmi sr2
|
||||||
sr4 lda right quit if right = first
|
sr4 lda right quit if right = first
|
||||||
|
@ -794,10 +805,14 @@ sr4 lda right quit if right = first
|
||||||
cmp first+2
|
cmp first+2
|
||||||
beq sr4b
|
beq sr4b
|
||||||
sr4a sub4 right,lsize dec right until *right <= *last
|
sr4a sub4 right,lsize dec right until *right <= *last
|
||||||
|
plb
|
||||||
ph4 <last
|
ph4 <last
|
||||||
ph4 <right
|
ph4 <right
|
||||||
jsl2 entry
|
jsl2 entry
|
||||||
jsl jsl2
|
jsl jsl2
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
dec A
|
dec A
|
||||||
bpl sr4
|
bpl sr4
|
||||||
sr4b ph4 <left swap left/right entries
|
sr4b ph4 <left swap left/right entries
|
||||||
|
@ -815,11 +830,24 @@ sr5 blt sr2
|
||||||
ph4 <left swap left/last entries
|
ph4 <left swap left/last entries
|
||||||
ph4 <last
|
ph4 <last
|
||||||
jsr swap
|
jsr swap
|
||||||
sub4 left,lsize,right sort left part of array
|
sub4 left,lsize,right calculate bounds of subarrays
|
||||||
ph4 <right
|
add4 left,lsize (first..right and left..last)
|
||||||
|
add4 first,last,mid calculate midpoint of range being sorted
|
||||||
|
lsr mid+2
|
||||||
|
ror mid
|
||||||
|
cmpl right,mid if right < mid then
|
||||||
|
bge sr6
|
||||||
|
plb
|
||||||
|
ph4 <right sort left subarray recursively
|
||||||
ph4 <first
|
ph4 <first
|
||||||
jsl rsort
|
jsl rsort
|
||||||
add4 left,lsize,first sort right part of array
|
move4 left,first sort right subarray via tail call
|
||||||
|
brl sr0
|
||||||
|
sr6 plb else
|
||||||
|
ph4 <last sort right subarray recursively
|
||||||
|
ph4 <left
|
||||||
|
jsl rsort
|
||||||
|
move4 right,last sort left subarray via tail call
|
||||||
brl sr0
|
brl sr0
|
||||||
;
|
;
|
||||||
; swap - swap two entries
|
; swap - swap two entries
|
||||||
|
@ -830,8 +858,9 @@ r equ 7 right entry
|
||||||
swap tsc set up addressing
|
swap tsc set up addressing
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
ldx lsize+2 move 64K chunks
|
lda lsize+2 move 64K chunks
|
||||||
beq sw2
|
beq sw2
|
||||||
|
sta banks
|
||||||
ldy #0
|
ldy #0
|
||||||
sw1 lda [l],Y
|
sw1 lda [l],Y
|
||||||
tax
|
tax
|
||||||
|
@ -844,7 +873,7 @@ sw1 lda [l],Y
|
||||||
bne sw1
|
bne sw1
|
||||||
inc l+2
|
inc l+2
|
||||||
inc r+2
|
inc r+2
|
||||||
dex
|
dec banks
|
||||||
bne sw1
|
bne sw1
|
||||||
sw2 lda lsize if there are an odd number of bytes then
|
sw2 lda lsize if there are an odd number of bytes then
|
||||||
lsr A
|
lsr A
|
||||||
|
@ -893,6 +922,8 @@ sw6 pld
|
||||||
;
|
;
|
||||||
lsize entry
|
lsize entry
|
||||||
ds 4 local copy of size
|
ds 4 local copy of size
|
||||||
|
banks ds 2 number of whole banks to swap
|
||||||
|
mid ds 4 midpoint of the elements being sorted
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -968,9 +999,10 @@ rtl equ 7 return address
|
||||||
val equ 3 value
|
val equ 3 value
|
||||||
negative equ 1 is the number negative?
|
negative equ 1 is the number negative?
|
||||||
|
|
||||||
pea 0 make room for & initialize val
|
lda #0
|
||||||
pea 0
|
pha make room for & initialize val
|
||||||
pea 0 make room for & initialize negative
|
pha
|
||||||
|
pha make room for & initialize negative
|
||||||
tsc set up direct page addressing
|
tsc set up direct page addressing
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
|
@ -1095,10 +1127,11 @@ foundOne equ 1 have we found a number?
|
||||||
ldx #1
|
ldx #1
|
||||||
|
|
||||||
init pea 1 make room for & initialize rangeOK
|
init pea 1 make room for & initialize rangeOK
|
||||||
pea 0 make room for & initialize negative
|
lda #0
|
||||||
pea 0 make room for & initialize val
|
pha make room for & initialize negative
|
||||||
pea 0
|
pha make room for & initialize val
|
||||||
pea 0 make room for & initialize foundOne
|
pha
|
||||||
|
pha make room for & initialize foundOne
|
||||||
tsc set up direct page addressing
|
tsc set up direct page addressing
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
|
@ -1286,13 +1319,14 @@ retptr equ 11 pointer to location for return value
|
||||||
val equ 3 value
|
val equ 3 value
|
||||||
negative equ 1 is the number negative?
|
negative equ 1 is the number negative?
|
||||||
|
|
||||||
pea 0 make room for & initialize retptr
|
lda #0
|
||||||
|
pha make room for & initialize retptr
|
||||||
phx
|
phx
|
||||||
pea 0 make room for & initialize val
|
pha make room for & initialize val
|
||||||
pea 0
|
pha
|
||||||
pea 0
|
pha
|
||||||
pea 0
|
pha
|
||||||
pea 0 make room for & initialize negative
|
pha make room for & initialize negative
|
||||||
tsc set up direct page addressing
|
tsc set up direct page addressing
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
|
@ -1435,15 +1469,16 @@ foundOne equ 1 have we found a number?
|
||||||
~strtoull entry alt entry point called from strtoll
|
~strtoull entry alt entry point called from strtoll
|
||||||
ldy #1
|
ldy #1
|
||||||
|
|
||||||
init pea 0 make room for & initialize retptr
|
init lda #0
|
||||||
|
pha make room for & initialize retptr
|
||||||
phx
|
phx
|
||||||
pea 1 make room for & initialize rangeOK
|
pea 1 make room for & initialize rangeOK
|
||||||
pea 0 make room for & initialize negative
|
pha make room for & initialize negative
|
||||||
pea 0 make room for & initialize val
|
pha make room for & initialize val
|
||||||
pea 0
|
pha
|
||||||
pea 0
|
pha
|
||||||
pea 0
|
pha
|
||||||
pea 0 make room for & initialize foundOne
|
pha make room for & initialize foundOne
|
||||||
tsc set up direct page addressing
|
tsc set up direct page addressing
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
|
@ -1549,16 +1584,13 @@ cn3 cmp base branch if the digit is too big
|
||||||
cn3a clc add in the new digit
|
cn3a clc add in the new digit
|
||||||
adc val
|
adc val
|
||||||
sta val
|
sta val
|
||||||
lda val+2
|
|
||||||
adc #0
|
|
||||||
sta val+2
|
|
||||||
lda val+4
|
|
||||||
adc #0
|
|
||||||
sta val+4
|
|
||||||
lda val+6
|
|
||||||
adc #0
|
|
||||||
sta val+6
|
|
||||||
bcc cn4
|
bcc cn4
|
||||||
|
inc val+2
|
||||||
|
bne cn4
|
||||||
|
inc val+4
|
||||||
|
bne cn4
|
||||||
|
inc val+6
|
||||||
|
bne cn4
|
||||||
stz rangeOK
|
stz rangeOK
|
||||||
cn4 inc4 str next char
|
cn4 inc4 str next char
|
||||||
bra cn1
|
bra cn1
|
||||||
|
|
|
@ -734,3 +734,15 @@
|
||||||
&l bne *+5
|
&l bne *+5
|
||||||
brl &bp
|
brl &bp
|
||||||
mend
|
mend
|
||||||
|
macro
|
||||||
|
&l cmpl &n1,&n2
|
||||||
|
lclb &yistwo
|
||||||
|
&l ~setm
|
||||||
|
~lda.h &n1
|
||||||
|
~op.h cmp,&n2
|
||||||
|
bne ~a&SYSCNT
|
||||||
|
~lda &n1
|
||||||
|
~op cmp,&n2
|
||||||
|
~a&SYSCNT anop
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
|
117
string.asm
117
string.asm
|
@ -244,8 +244,8 @@ lb3 lda [p1],Y scan until the end of memory is reached
|
||||||
dex
|
dex
|
||||||
bne lb3
|
bne lb3
|
||||||
|
|
||||||
ldx #0 memory matches
|
; ldx #0
|
||||||
bra lb5
|
bra lb5 memory matches
|
||||||
|
|
||||||
lb4 blt less memory differs - set the result
|
lb4 blt less memory differs - set the result
|
||||||
ldx #1
|
ldx #1
|
||||||
|
@ -253,9 +253,9 @@ lb4 blt less memory differs - set the result
|
||||||
|
|
||||||
less ldx #-1
|
less ldx #-1
|
||||||
|
|
||||||
lb5 long M
|
lb5 lda rtl remove the parameters from the stack
|
||||||
lda rtl remove the parameters from the stack
|
|
||||||
sta len+1
|
sta len+1
|
||||||
|
long M
|
||||||
lda rtl+1
|
lda rtl+1
|
||||||
sta len+2
|
sta len+2
|
||||||
pld
|
pld
|
||||||
|
@ -303,8 +303,8 @@ rtl equ 1 return address
|
||||||
short M move 1 byte now
|
short M move 1 byte now
|
||||||
lda [p2]
|
lda [p2]
|
||||||
sta [p1]
|
sta [p1]
|
||||||
long M
|
|
||||||
dec len
|
dec len
|
||||||
|
long M
|
||||||
inc4 p1
|
inc4 p1
|
||||||
inc4 p2
|
inc4 p2
|
||||||
lb1 anop endif
|
lb1 anop endif
|
||||||
|
@ -436,11 +436,11 @@ lb10 lda [p2],Y
|
||||||
dex
|
dex
|
||||||
bne lb9
|
bne lb9
|
||||||
|
|
||||||
lb11 long M
|
lb11 ply get the original source pointer
|
||||||
ply get the original source pointer
|
|
||||||
plx
|
plx
|
||||||
lda rtl remove the parameters from the stack
|
lda rtl remove the parameters from the stack
|
||||||
sta len+1
|
sta len+1
|
||||||
|
long M
|
||||||
lda rtl+1
|
lda rtl+1
|
||||||
sta len+2
|
sta len+2
|
||||||
pld
|
pld
|
||||||
|
@ -482,19 +482,19 @@ rtl equ 1 return address
|
||||||
|
|
||||||
ph4 <p save the pointer
|
ph4 <p save the pointer
|
||||||
|
|
||||||
short M
|
short I,M
|
||||||
lda val form a 2 byte value
|
ldx val form a 2 byte value
|
||||||
sta val+1
|
stx val+1
|
||||||
|
|
||||||
lda len if there are an odd # of bytes then
|
lda len if there are an odd # of bytes then
|
||||||
lsr A
|
lsr A
|
||||||
bcc lb1
|
bcc lb1
|
||||||
lda val set 1 byte now
|
txa set 1 byte now
|
||||||
sta [p]
|
sta [p]
|
||||||
long M
|
|
||||||
dec len
|
dec len
|
||||||
|
long I,M
|
||||||
inc4 p
|
inc4 p
|
||||||
lb1 long M endif
|
lb1 long I,M endif
|
||||||
|
|
||||||
lda val set len bytes
|
lda val set len bytes
|
||||||
ldx len+2 set full banks
|
ldx len+2 set full banks
|
||||||
|
@ -616,7 +616,9 @@ lb2 long M
|
||||||
clc
|
clc
|
||||||
adc s1
|
adc s1
|
||||||
sta s1
|
sta s1
|
||||||
short M copy characters 'til the null is found
|
bcc lb2a
|
||||||
|
inc s1+2
|
||||||
|
lb2a short M copy characters 'til the null is found
|
||||||
ldy #0
|
ldy #0
|
||||||
lb3 lda [s2],Y
|
lb3 lda [s2],Y
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
|
@ -627,9 +629,9 @@ lb3 lda [s2],Y
|
||||||
inc s2+2
|
inc s2+2
|
||||||
bra lb3
|
bra lb3
|
||||||
|
|
||||||
lb4 long M return to the caller
|
lb4 lda rtl return to the caller
|
||||||
lda rtl
|
|
||||||
sta s2+1
|
sta s2+1
|
||||||
|
long M
|
||||||
lda rtl+1
|
lda rtl+1
|
||||||
sta s2+2
|
sta s2+2
|
||||||
ldx rval+2
|
ldx rval+2
|
||||||
|
@ -749,9 +751,9 @@ less ldx #-1 It wasn't, so *s1 < *s2
|
||||||
lb3 blt less the strings differ - set the result
|
lb3 blt less the strings differ - set the result
|
||||||
ldx #1
|
ldx #1
|
||||||
|
|
||||||
lb4 long M
|
lb4 lda rtl remove the parameters from the stack
|
||||||
lda rtl remove the parameters from the stack
|
|
||||||
sta s2+1
|
sta s2+1
|
||||||
|
long M
|
||||||
lda rtl+1
|
lda rtl+1
|
||||||
sta s2+2
|
sta s2+2
|
||||||
pld
|
pld
|
||||||
|
@ -828,9 +830,9 @@ lb1 lda [s2],Y
|
||||||
inc s2+2
|
inc s2+2
|
||||||
bra lb1
|
bra lb1
|
||||||
|
|
||||||
lb2 long M return to the caller
|
lb2 lda rtl return to the caller
|
||||||
lda rtl
|
|
||||||
sta s2+1
|
sta s2+1
|
||||||
|
long M
|
||||||
lda rtl+1
|
lda rtl+1
|
||||||
sta s2+2
|
sta s2+2
|
||||||
ldx rval+2
|
ldx rval+2
|
||||||
|
@ -956,9 +958,12 @@ str equ 4 pointer to the string
|
||||||
tcd
|
tcd
|
||||||
|
|
||||||
ldy #0 advance s1 to point to the terminating
|
ldy #0 advance s1 to point to the terminating
|
||||||
ldx #0 null
|
tyx null
|
||||||
short M
|
short M
|
||||||
lb1 lda [str],Y
|
lb1 lda [str],Y
|
||||||
|
beq lb2
|
||||||
|
iny
|
||||||
|
lda [str],Y
|
||||||
beq lb2
|
beq lb2
|
||||||
iny
|
iny
|
||||||
bne lb1
|
bne lb1
|
||||||
|
@ -966,10 +971,10 @@ lb1 lda [str],Y
|
||||||
inc str+2
|
inc str+2
|
||||||
bra lb1
|
bra lb1
|
||||||
|
|
||||||
lb2 long M
|
lb2 pld remove str from the stack
|
||||||
pld remove str from the stack
|
lda 3,S
|
||||||
lda 2,S
|
sta 7,S
|
||||||
sta 6,S
|
long M
|
||||||
pla
|
pla
|
||||||
sta 3,S
|
sta 3,S
|
||||||
pla
|
pla
|
||||||
|
@ -1013,27 +1018,35 @@ lb2 long M
|
||||||
clc
|
clc
|
||||||
adc s1
|
adc s1
|
||||||
sta s1
|
sta s1
|
||||||
short M copy characters 'til the null is found
|
bcc lb2a
|
||||||
|
inc s1+2
|
||||||
|
lb2a ldx n copy characters 'til the null is found
|
||||||
|
bne lb2b
|
||||||
|
lda n+2
|
||||||
|
beq lb6
|
||||||
|
lb2b short M
|
||||||
ldy #0
|
ldy #0
|
||||||
ldx n
|
|
||||||
beq lb4
|
|
||||||
bmi lb4
|
|
||||||
lb3 lda [s2],Y
|
lb3 lda [s2],Y
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
beq lb4
|
beq lb5
|
||||||
iny
|
iny
|
||||||
dex
|
bne lb3a
|
||||||
|
inc s1+2
|
||||||
|
inc s2+2
|
||||||
|
lb3a dex
|
||||||
bne lb3
|
bne lb3
|
||||||
lda n+2
|
ldx n+2
|
||||||
beq lb4
|
beq lb4
|
||||||
dec n+2
|
dex
|
||||||
|
stx n+2
|
||||||
|
ldx #0
|
||||||
bra lb3
|
bra lb3
|
||||||
|
|
||||||
lb4 lda #0 write the terminating null
|
lb4 lda #0 write the terminating null
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
long M return to the caller
|
lb5 long M return to the caller
|
||||||
|
|
||||||
creturn 4:rval
|
lb6 creturn 4:rval
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -1060,7 +1073,6 @@ flag equ 1 return flag
|
||||||
|
|
||||||
ldy #0 scan until the end of string is reached
|
ldy #0 scan until the end of string is reached
|
||||||
ldx n+2 or a difference is found
|
ldx n+2 or a difference is found
|
||||||
bmi equal
|
|
||||||
bne lb0
|
bne lb0
|
||||||
ldx n
|
ldx n
|
||||||
beq equal
|
beq equal
|
||||||
|
@ -1072,9 +1084,11 @@ lb1 lda [s1],Y
|
||||||
bne lb3
|
bne lb3
|
||||||
dex
|
dex
|
||||||
bne lb1a
|
bne lb1a
|
||||||
lda n+2
|
ldx n+2
|
||||||
beq equal
|
beq equal
|
||||||
dec n+2
|
dex
|
||||||
|
stx n+2
|
||||||
|
ldx #0
|
||||||
lb1a iny
|
lb1a iny
|
||||||
bne lb1
|
bne lb1
|
||||||
inc s1+2
|
inc s1+2
|
||||||
|
@ -1189,20 +1203,19 @@ lb1 lda [s],Y
|
||||||
short M
|
short M
|
||||||
bra lb1
|
bra lb1
|
||||||
|
|
||||||
lb2 long I,M no match found -> return NULL
|
lb2 ldx #0 no match found -> return NULL
|
||||||
ldx #0
|
|
||||||
txy
|
txy
|
||||||
|
long I,M
|
||||||
bra lb4
|
bra lb4
|
||||||
|
|
||||||
lb3 long I,M increment s by Y and load the value
|
lb3 long I,M increment s by Y and load the value
|
||||||
tya
|
tya
|
||||||
and #$00FF
|
|
||||||
clc
|
clc
|
||||||
adc s
|
adc s
|
||||||
tay
|
tay
|
||||||
lda s+2
|
ldx s+2
|
||||||
adc #0
|
bcc lb4
|
||||||
tax
|
inx
|
||||||
|
|
||||||
lb4 lda rtl+1 remove the parameters
|
lb4 lda rtl+1 remove the parameters
|
||||||
sta set+2
|
sta set+2
|
||||||
|
@ -1252,10 +1265,10 @@ lb1 lda [str],Y
|
||||||
|
|
||||||
lb2 ldy #-1 no match found -> return -1
|
lb2 ldy #-1 no match found -> return -1
|
||||||
|
|
||||||
lb3 long M
|
lb3 pld remove parameters from the stack
|
||||||
pld remove parameters from the stack
|
lda 3,S
|
||||||
lda 2,S
|
sta 9,S
|
||||||
sta 8,S
|
long M
|
||||||
pla
|
pla
|
||||||
sta 5,S
|
sta 5,S
|
||||||
pla
|
pla
|
||||||
|
@ -1363,10 +1376,10 @@ lb2 cmp #0
|
||||||
iny
|
iny
|
||||||
bpl lb1
|
bpl lb1
|
||||||
|
|
||||||
lb3 long M
|
lb3 pld remove parameters from the stack
|
||||||
pld remove parameters from the stack
|
lda 3,S
|
||||||
lda 2,S
|
sta 9,S
|
||||||
sta 8,S
|
long M
|
||||||
pla
|
pla
|
||||||
sta 5,S
|
sta 5,S
|
||||||
pla
|
pla
|
||||||
|
|
613
time.asm
613
time.asm
|
@ -19,7 +19,18 @@
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
Time start dummy segment
|
Time private dummy segment
|
||||||
|
|
||||||
|
; struct tm fields
|
||||||
|
tm_sec gequ 0 seconds 0..59
|
||||||
|
tm_min gequ tm_sec+2 minutes 0..59
|
||||||
|
tm_hour gequ tm_min+2 hours 0..23
|
||||||
|
tm_mday gequ tm_hour+2 day 1..31
|
||||||
|
tm_mon gequ tm_mday+2 month 0..11
|
||||||
|
tm_year gequ tm_mon+2 year 69..205 (1900=0)
|
||||||
|
tm_wday gequ tm_year+2 day of week 0..6 (Sun = 0)
|
||||||
|
tm_yday gequ tm_wday+2 day of year 0..365
|
||||||
|
tm_isdst gequ tm_yday+2 daylight savings? 1 = yes, 0 = no
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -30,15 +41,15 @@ Time start dummy segment
|
||||||
*
|
*
|
||||||
TimeCommon privdata
|
TimeCommon privdata
|
||||||
;
|
;
|
||||||
; For conversion to/from seconds since 1970
|
; For conversion to/from seconds since 13 Nov 1969
|
||||||
;
|
;
|
||||||
year ds 4 year 0..99
|
year ds 4 year (years since 1900)
|
||||||
month ds 4 month 1..12
|
month ds 4 month 0..11
|
||||||
day ds 4 day 1..31
|
day ds 4 day 1..31
|
||||||
hour ds 4 hour 0..23
|
hour ds 4 hour 0..23
|
||||||
minute ds 4 minute 0..59
|
minute ds 4 minute 0..59
|
||||||
second ds 4 second 0..59
|
second ds 4 second 0..59
|
||||||
count ds 4 seconds since 1 Jan 1970
|
count ds 8 seconds since 13 Nov 1969
|
||||||
t1 ds 4 work variable
|
t1 ds 4 work variable
|
||||||
t2 ds 4 work variable
|
t2 ds 4 work variable
|
||||||
|
|
||||||
|
@ -225,63 +236,260 @@ mk1 inx
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* factor - compute the seconds since 1 Jan 1970 from date
|
* factor - compute the seconds since 13 Nov 1969 from date
|
||||||
|
*
|
||||||
|
* factor_second32 - alt entry point taking second as a
|
||||||
|
* signed 32-bit input value
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* year,month,day,hour,minute,second - time to convert
|
* year,month,day,hour,minute,second - time to convert
|
||||||
|
* (each treated as a signed 16-bit value, with the
|
||||||
|
* exception of second when using factor_second32)
|
||||||
*
|
*
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* count - seconds since 1 Jan 1970
|
* count - seconds since 13 Nov 1969 (signed 64-bit value)
|
||||||
|
*
|
||||||
|
* Note: Input values outside their normal ranges are allowed.
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
factor private
|
factor private
|
||||||
using TimeCommon
|
using TimeCommon
|
||||||
|
|
||||||
;
|
;
|
||||||
; compute the # of days since 1 Jan 1970
|
; sign-extend time components to 4 bytes
|
||||||
;
|
;
|
||||||
mul4 year,#365,count count := 365*year + day + 31*(month-1)
|
|
||||||
|
stz second+2
|
||||||
|
lda second
|
||||||
|
bpl lb0
|
||||||
|
dec second+2
|
||||||
|
factor_second32 entry
|
||||||
|
lb0 stz year+2
|
||||||
|
lda year
|
||||||
|
bpl lb0a
|
||||||
|
dec year+2
|
||||||
|
lb0a stz month+2
|
||||||
|
stz day+2
|
||||||
|
lda day
|
||||||
|
bpl lb0b
|
||||||
|
dec day+2
|
||||||
|
lb0b stz hour+2
|
||||||
|
lda hour
|
||||||
|
bpl lb0c
|
||||||
|
dec hour+2
|
||||||
|
lb0c stz minute+2
|
||||||
|
lda minute
|
||||||
|
bpl lb0e
|
||||||
|
dec minute+2
|
||||||
|
;
|
||||||
|
; adjust for out-of-range month values
|
||||||
|
;
|
||||||
|
lb0e lda month
|
||||||
|
bpl lb0f
|
||||||
|
clc
|
||||||
|
adc #12
|
||||||
|
sta month
|
||||||
|
dec4 year
|
||||||
|
bra lb0e
|
||||||
|
lb0f sec
|
||||||
|
sbc #12
|
||||||
|
bmi lb0x
|
||||||
|
sta month
|
||||||
|
inc4 year
|
||||||
|
bra lb0e
|
||||||
|
;
|
||||||
|
; compute the # of days since 13 Nov 1969
|
||||||
|
;
|
||||||
|
lb0x mul4 year,#365,count count := 365*year + day + 31*month
|
||||||
add4 count,day
|
add4 count,day
|
||||||
mul4 month,#31,t1
|
mul4 month,#31,t1
|
||||||
add4 count,t1
|
add4 count,t1
|
||||||
sub4 count,#31
|
add4 year,#32800,t2 t2 := year + 32800 (so it is positive)
|
||||||
move4 year,t2 t2 := year
|
|
||||||
lda month if January or February then
|
lda month if January or February then
|
||||||
cmp #3
|
cmp #2
|
||||||
bge lb1
|
bge lb1
|
||||||
dec t2 year := year-1
|
dec4 t2 year := year-1
|
||||||
bra lb2 else
|
bra lb2 else
|
||||||
lb1 mul4 month,#4,t1 count := count - (month*4+23) div 10
|
lb1 mul4 month,#4,t1 count := count - (month*4+27) div 10
|
||||||
add4 t1,#23
|
add4 t1,#27
|
||||||
div4 t1,#10
|
div4 t1,#10
|
||||||
sub4 count,t1
|
sub4 count,t1
|
||||||
lb2 lda t2 count := count + year div 4
|
lb2 div4 t2,#4,t1 count := count + (year+32800) div 4
|
||||||
lsr A
|
add4 count,t1
|
||||||
lsr A
|
add4 t2,#300 count := count -
|
||||||
clc
|
div4 t2,#100 ((300+year+32800) div 100+1)*3 div 4
|
||||||
adc count
|
|
||||||
sta count
|
|
||||||
bcc lb3
|
|
||||||
inc count+2
|
|
||||||
lb3 add4 t2,#300 count := count -
|
|
||||||
div4 t2,#100 ((300+year) div 100+1)*3 div 4
|
|
||||||
inc4 t2
|
inc4 t2
|
||||||
mul4 t2,#3
|
mul4 t2,#3
|
||||||
div4 t2,#4
|
div4 t2,#4
|
||||||
sub4 count,t2
|
sub4 count,t2
|
||||||
sub4 count,#25516 subtract off days between 1 Jan 00 and
|
sub4 count,#25518-2+7954 subtract off days between 1 Jan 1900
|
||||||
! 1 Jan 70
|
! and 13 Nov 1969, minus 2 to adjust for
|
||||||
|
! skipped leap days in 1700 and 1800,
|
||||||
|
! plus 7954 to adjust for leap days in
|
||||||
|
! an additional 32800 years
|
||||||
;
|
;
|
||||||
; Convert to seconds and add in time of day in seconds
|
; Convert to seconds and add in time of day in seconds
|
||||||
;
|
;
|
||||||
mul4 count,#24*60*60 convert to seconds
|
lda count+2 convert to 64-bit count of seconds
|
||||||
mul4 hour,#3600,t1 add in hours*3600
|
pha
|
||||||
add4 count,t1
|
bpl lb3 if count is negative, negate it
|
||||||
|
sub4 #0,count,count
|
||||||
|
lb3 tsc compute count*24*60*60
|
||||||
|
sec
|
||||||
|
sbc #8
|
||||||
|
tcs
|
||||||
|
ph4 count
|
||||||
|
ph4 #24*60*60
|
||||||
|
_LongMul
|
||||||
|
pla
|
||||||
|
sta count
|
||||||
|
pla
|
||||||
|
sta count+2
|
||||||
|
pla
|
||||||
|
sta count+4
|
||||||
|
pla
|
||||||
|
sta count+6
|
||||||
|
pla
|
||||||
|
bpl lb4 if count was negative, negate result
|
||||||
|
negate8 count
|
||||||
|
lb4 mul4 hour,#3600,t1 add in hours*3600
|
||||||
|
jsr add_t1_to_count
|
||||||
mul4 minute,#60,t1 add in minutes*60
|
mul4 minute,#60,t1 add in minutes*60
|
||||||
add4 count,t1
|
jsr add_t1_to_count
|
||||||
add4 count,second add in seconds
|
move4 second,t1 add in seconds
|
||||||
|
;
|
||||||
|
; Add t1 (4 bytes) to count (8 bytes).
|
||||||
|
; (This is called as a subroutine and also run at the end of factor.)
|
||||||
|
;
|
||||||
|
add_t1_to_count anop
|
||||||
|
clc
|
||||||
|
lda t1
|
||||||
|
adc count
|
||||||
|
sta count
|
||||||
|
lda t1+2
|
||||||
|
tax
|
||||||
|
adc count+2
|
||||||
|
sta count+2
|
||||||
|
lda #0
|
||||||
|
txy
|
||||||
|
bpl ad1
|
||||||
|
dec a
|
||||||
|
ad1 tay
|
||||||
|
adc count+4
|
||||||
|
sta count+4
|
||||||
|
tya
|
||||||
|
adc count+6
|
||||||
|
sta count+6
|
||||||
rts
|
rts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ~get_tz_offset - get current time zone offset from UTC
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* A-X - time zone offset from UTC
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
~get_tz_offset private
|
||||||
|
lda >__useTimeTool if not using time tool
|
||||||
|
beq no_tz assume we have no TZ offset
|
||||||
|
|
||||||
|
pha make space for TZ prefs
|
||||||
|
pha
|
||||||
|
pea 1 get one record element only (TZ offset)
|
||||||
|
|
||||||
|
tsc get time zone preference
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
_tiGetTimePrefs
|
||||||
|
pla
|
||||||
|
bcc have_tz
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
lda #0 assume 0 offset if TZ info not available
|
||||||
|
no_tz tax
|
||||||
|
rts
|
||||||
|
|
||||||
|
have_tz pha determine if it's daylight savings
|
||||||
|
ph2 #$5E
|
||||||
|
_ReadBParam
|
||||||
|
pla
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
|
bcs ret
|
||||||
|
|
||||||
|
; clc
|
||||||
|
lda #60*60 adjust for DST (+1 hour) if needed
|
||||||
|
adc 1,s
|
||||||
|
sta 1,s
|
||||||
|
lda #0
|
||||||
|
adc 3,s
|
||||||
|
sta 3,s
|
||||||
|
|
||||||
|
ret pla return offset value
|
||||||
|
plx
|
||||||
|
rts
|
||||||
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* gmlocaltime_tm - struct tm used by gmtime and localtime
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
gmlocaltime_tm private
|
||||||
|
ds 9*2
|
||||||
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* struct tm *gmtime(t)
|
||||||
|
* time_t *t;
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* t - pointer to # of seconds since 13 Nov 1969
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* returns a pointer to a time record for UTC time
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
gmtime start
|
||||||
|
t equ 6
|
||||||
|
|
||||||
|
phd
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
ldy #2 dereference the pointer to time_t
|
||||||
|
lda [t],Y
|
||||||
|
tax
|
||||||
|
lda [t]
|
||||||
|
tay
|
||||||
|
pld
|
||||||
|
|
||||||
|
phb
|
||||||
|
pla move return address
|
||||||
|
sta 3,s
|
||||||
|
pla
|
||||||
|
sta 3,s
|
||||||
|
plb
|
||||||
|
|
||||||
|
ph4 #gmlocaltime_tm push address of struct tm to use
|
||||||
|
pea 0 push tm_isdst value (no DST for UTC)
|
||||||
|
phx push time_t value to convert
|
||||||
|
phy
|
||||||
|
|
||||||
|
jsr ~get_tz_offset push time zone offset
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
|
||||||
|
doit jsl ~gmlocaltime use common gmtime/localtime code
|
||||||
|
rtl
|
||||||
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
|
@ -289,106 +497,172 @@ lb3 add4 t2,#300 count := count -
|
||||||
* time_t *t;
|
* time_t *t;
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* t - # seconds since 1 Jan 1970
|
* t - pointer to # of seconds since 13 Nov 1969
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* returns a pointer to a time record for local time
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
localtime start
|
||||||
|
using TimeCommon
|
||||||
|
t equ 6
|
||||||
|
|
||||||
|
phd
|
||||||
|
tsc
|
||||||
|
tcd
|
||||||
|
ldy #2 dereference the pointer to time_t
|
||||||
|
lda [t],Y
|
||||||
|
tax
|
||||||
|
lda [t]
|
||||||
|
tay
|
||||||
|
pld
|
||||||
|
|
||||||
|
phb
|
||||||
|
pla move return address
|
||||||
|
sta 3,s
|
||||||
|
pla
|
||||||
|
sta 3,s
|
||||||
|
|
||||||
|
lda #-1 default DST setting = -1 (unknown)
|
||||||
|
cpy lasttime determine DST setting, if we can
|
||||||
|
bne lb1
|
||||||
|
cpx lasttime+2
|
||||||
|
bne lb1
|
||||||
|
lda lastDST
|
||||||
|
lb1 plb
|
||||||
|
|
||||||
|
ph4 #gmlocaltime_tm push address of struct tm to use
|
||||||
|
pha push tm_isdst value
|
||||||
|
phx push time_t value to convert
|
||||||
|
phy
|
||||||
|
pea 0 no time zone offset
|
||||||
|
pea 0
|
||||||
|
jsl ~gmlocaltime use common gmtime/localtime code
|
||||||
|
rtl
|
||||||
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ~gmlocaltime - common code for gmtime and localtime
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* tz_offset - offset of local time from desired time zone
|
||||||
|
* t - time_t value (# of seconds since 13 Nov 1969)
|
||||||
|
* isdst - value for tm_isdst flag
|
||||||
|
* tm - pointer to struct tm for result
|
||||||
*
|
*
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* returns a pointer to a time record
|
* returns a pointer to a time record
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
localtime start
|
~gmlocaltime private
|
||||||
gmtime entry
|
|
||||||
using TimeCommon
|
using TimeCommon
|
||||||
|
|
||||||
csubroutine (4:t),0
|
csubroutine (4:tz_offset,4:t,2:isdst,4:tm),0
|
||||||
phb
|
phb
|
||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
|
|
||||||
ldy #2 dereference the pointer
|
|
||||||
lda [t],Y
|
|
||||||
tax
|
|
||||||
lda [t]
|
|
||||||
sta t
|
|
||||||
stx t+2
|
|
||||||
|
|
||||||
ldy #-1 default DST setting = -1 (unknown)
|
|
||||||
cmp lasttime determine DST setting, if we can
|
|
||||||
bne lb0
|
|
||||||
cpx lasttime+2
|
|
||||||
bne lb0
|
|
||||||
ldy lastDST
|
|
||||||
lb0 sty tm_isdst
|
|
||||||
|
|
||||||
lda #69 find the year
|
lda #69 find the year
|
||||||
sta year
|
sta year
|
||||||
lda #1
|
lda #1
|
||||||
sta month
|
|
||||||
sta day
|
sta day
|
||||||
|
stz month
|
||||||
stz hour
|
stz hour
|
||||||
stz minute
|
stz minute
|
||||||
stz second
|
lda tz_offset
|
||||||
|
sta second
|
||||||
|
lda tz_offset+2
|
||||||
|
sta second+2
|
||||||
lb1 inc year
|
lb1 inc year
|
||||||
jsr factor
|
jsr factor_second32
|
||||||
|
lda count+4
|
||||||
|
bne lb1b
|
||||||
lda count+2
|
lda count+2
|
||||||
cmp t+2
|
cmp t+2
|
||||||
bne lb1a
|
bne lb1a
|
||||||
lda count
|
lda count
|
||||||
cmp t
|
cmp t
|
||||||
lb1a ble lb1
|
lb1a ble lb1
|
||||||
dec year
|
lb1b dec year
|
||||||
lb2 inc month find the month
|
lb2 inc month find the month
|
||||||
jsr factor
|
jsr factor_second32
|
||||||
|
lda count+4
|
||||||
|
bmi lb2
|
||||||
|
bne lb2b
|
||||||
lda count+2
|
lda count+2
|
||||||
cmp t+2
|
cmp t+2
|
||||||
bne lb2a
|
bne lb2a
|
||||||
lda count
|
lda count
|
||||||
cmp t
|
cmp t
|
||||||
lb2a ble lb2
|
lb2a ble lb2
|
||||||
dec month
|
lb2b dec month
|
||||||
jsr factor recompute the factor
|
jsr factor_second32 recompute the factor
|
||||||
lda year set the year
|
lda year set the year
|
||||||
sta tm_year
|
ldy #tm_year
|
||||||
|
sta [tm],y
|
||||||
lda month set the month
|
lda month set the month
|
||||||
dec A
|
ldy #tm_mon
|
||||||
sta tm_mon
|
sta [tm],y
|
||||||
|
ph4 <t save original t value
|
||||||
sub4 t,count find the number of seconds
|
sub4 t,count find the number of seconds
|
||||||
move4 t,t1
|
move4 t,t1
|
||||||
div4 t,#60
|
div4 t,#60
|
||||||
mul4 t,#60,t2
|
mul4 t,#60,t2
|
||||||
sub4 t1,t2
|
sub4 t1,t2
|
||||||
lda t1
|
lda t1
|
||||||
sta tm_sec
|
ldy #tm_sec
|
||||||
|
sta [tm],y
|
||||||
move4 t,t1 find the number of minutes
|
move4 t,t1 find the number of minutes
|
||||||
div4 t,#60
|
div4 t,#60
|
||||||
mul4 t,#60,t2
|
mul4 t,#60,t2
|
||||||
sub4 t1,t2
|
sub4 t1,t2
|
||||||
lda t1
|
lda t1
|
||||||
sta tm_min
|
ldy #tm_min
|
||||||
|
sta [tm],y
|
||||||
move4 t,t1 find the number of hours
|
move4 t,t1 find the number of hours
|
||||||
div4 t,#24
|
div4 t,#24
|
||||||
mul4 t,#24,t2
|
mul4 t,#24,t2
|
||||||
sub4 t1,t2
|
sub4 t1,t2
|
||||||
lda t1
|
lda t1
|
||||||
sta tm_hour
|
ldy #tm_hour
|
||||||
|
sta [tm],y
|
||||||
lda t set the day
|
lda t set the day
|
||||||
inc A
|
inc A
|
||||||
sta tm_mday
|
ldy #tm_mday
|
||||||
ph4 #tm_sec set the day of week/year
|
sta [tm],y
|
||||||
jsl mktime
|
pl4 t restore original t value
|
||||||
lla t,tm_sec
|
stz month compute the days since the start of the
|
||||||
|
jsr factor_second32 year (in desired time zone)
|
||||||
|
sub4 t,count,count
|
||||||
|
div4 count,#60*60*24
|
||||||
|
ldy #tm_yday set the day of year
|
||||||
|
lda count
|
||||||
|
sta [tm],y
|
||||||
|
lb3 cmpl t,#7*3000*60*60*24 compute the day of week
|
||||||
|
blt lb3a
|
||||||
|
sub4 t,#7*3000*60*60*24
|
||||||
|
bra lb3
|
||||||
|
lb3a add4 t,#4*60*60*24
|
||||||
|
sec (adjust for time zone)
|
||||||
|
lda t
|
||||||
|
sbc tz_offset
|
||||||
|
sta t
|
||||||
|
lda t+2
|
||||||
|
sbc tz_offset+2
|
||||||
|
sta t+2
|
||||||
|
div4 t,#60*60*24
|
||||||
|
mod4 t,#7
|
||||||
|
lda t set the day of week
|
||||||
|
ldy #tm_wday
|
||||||
|
sta [tm],y
|
||||||
|
lda isdst set the DST flag
|
||||||
|
ldy #tm_isdst
|
||||||
|
sta [tm],y
|
||||||
plb
|
plb
|
||||||
creturn 4:t
|
creturn 4:tm
|
||||||
|
|
||||||
tm_sec ds 2 seconds 0..59
|
|
||||||
tm_min ds 2 minutes 0..59
|
|
||||||
tm_hour ds 2 hours 0..23
|
|
||||||
tm_mday ds 2 day 1..31
|
|
||||||
tm_mon ds 2 month 0..11
|
|
||||||
tm_year ds 2 year 70..200 (1900=0)
|
|
||||||
tm_wday ds 2 day of week 0..6 (Sun = 0)
|
|
||||||
tm_yday ds 2 day of year 0..365
|
|
||||||
tm_isdst ds 2 daylight savings? 1 = yes, 0 = no
|
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
@ -402,7 +676,7 @@ tm_isdst ds 2 daylight savings? 1 = yes, 0 = no
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* tmptr->wday - day of week
|
* tmptr->wday - day of week
|
||||||
* tmptr->yday - day of year
|
* tmptr->yday - day of year
|
||||||
* returns the ime in seconds since 1 Jan 1970
|
* returns the ime in seconds since 13 Nov 1969
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
|
@ -416,16 +690,12 @@ temp2 equ 5 temp variable
|
||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
|
|
||||||
lla temp,-1 assume we can't do it
|
ldy #tm_year set time parameters
|
||||||
ldy #10 error if year < 70
|
|
||||||
lda [tmptr],Y
|
lda [tmptr],Y
|
||||||
sta year
|
sta year
|
||||||
cmp #70
|
dey
|
||||||
jlt lb1
|
|
||||||
dey set the other time parameters
|
|
||||||
dey
|
dey
|
||||||
lda [tmptr],Y
|
lda [tmptr],Y
|
||||||
inc A
|
|
||||||
sta month
|
sta month
|
||||||
dey
|
dey
|
||||||
dey
|
dey
|
||||||
|
@ -441,24 +711,22 @@ temp2 equ 5 temp variable
|
||||||
sta minute
|
sta minute
|
||||||
lda [tmptr]
|
lda [tmptr]
|
||||||
sta second
|
sta second
|
||||||
jsr factor compute seconds since 1970
|
jsr factor compute seconds since 13 Nov 1969
|
||||||
move4 count,temp save the value for later return
|
lda count+4 if time is unrepresentable
|
||||||
lda #1 compute the days since the start of the
|
ora count+6
|
||||||
sta month year
|
beq lb0
|
||||||
sta day
|
lda #-1 return -1
|
||||||
jsr factor
|
sta temp
|
||||||
sub4 temp,count,count
|
sta temp+2
|
||||||
div4 count,#60*60*24
|
brl lb1
|
||||||
ldy #14 set the days
|
lb0 move4 count,temp save the value for later return
|
||||||
lda count
|
ph4 <tmptr recompute struct tm values
|
||||||
sta [tmptr],Y
|
ldy #tm_isdst
|
||||||
div4 temp,#60*60*24,temp2 compute the day of week
|
lda [tmptr],y
|
||||||
add4 temp2,#4
|
pha
|
||||||
mod4 temp2,#7
|
ph4 <temp
|
||||||
lda temp2 set the day of week
|
ph4 #0
|
||||||
ldy #12
|
jsl ~gmlocaltime
|
||||||
sta [tmptr],Y
|
|
||||||
|
|
||||||
lb1 plb
|
lb1 plb
|
||||||
creturn 4:temp
|
creturn 4:temp
|
||||||
end
|
end
|
||||||
|
@ -494,20 +762,16 @@ time start
|
||||||
and #$00FF
|
and #$00FF
|
||||||
inc A
|
inc A
|
||||||
sta day
|
sta day
|
||||||
lda 5,S set the month
|
lda 6,S set the month
|
||||||
and #$FF00
|
and #$00FF
|
||||||
xba
|
|
||||||
inc A
|
|
||||||
sta month
|
sta month
|
||||||
lda 3,S set the year
|
lda 4,S set the year
|
||||||
and #$FF00
|
and #$00FF
|
||||||
xba
|
|
||||||
sta year
|
sta year
|
||||||
lda 3,S set the hour
|
lda 3,S set the hour
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta hour
|
sta hour
|
||||||
lda 1,S set the minute
|
lda 2,S set the minute
|
||||||
xba
|
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta minute
|
sta minute
|
||||||
pla set the second
|
pla set the second
|
||||||
|
@ -517,7 +781,13 @@ time start
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
jsr factor convert the seconds
|
jsr factor convert the seconds
|
||||||
lda tptr if tptr <> nil then
|
lda count+4 if time is unrepresentable
|
||||||
|
ora count+6
|
||||||
|
beq lb0
|
||||||
|
lda #-1 set return value to -1
|
||||||
|
sta count
|
||||||
|
sta count+2
|
||||||
|
lb0 lda tptr if tptr <> nil then
|
||||||
ora tptr+2
|
ora tptr+2
|
||||||
beq lb1
|
beq lb1
|
||||||
ldy #2 place the result there
|
ldy #2 place the result there
|
||||||
|
@ -544,6 +814,70 @@ lb1 lda count
|
||||||
creturn 4:tptr
|
creturn 4:tptr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* int timespec_get(struct timespec *ts, int base);
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* ts - pointer to structure for result
|
||||||
|
* base - requested time base
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* *tptr - the requested time (if successful)
|
||||||
|
* returns base if successful, or 0 otherwise
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
timespec_get start
|
||||||
|
using TimeCommon
|
||||||
|
tz_offset equ 1 time zone offset from UTC
|
||||||
|
current_time equ 5 current time
|
||||||
|
|
||||||
|
TIME_UTC equ 1 UTC time base
|
||||||
|
|
||||||
|
tv_sec equ 0 struct timespec members
|
||||||
|
tv_nsec equ 4
|
||||||
|
|
||||||
|
csubroutine (4:ts,2:base),8
|
||||||
|
|
||||||
|
lda base
|
||||||
|
cmp #TIME_UTC
|
||||||
|
bne err
|
||||||
|
|
||||||
|
ph4 #0 get current time (in count)
|
||||||
|
jsl time
|
||||||
|
sta current_time
|
||||||
|
stx current_time+2
|
||||||
|
and current_time+2 if time is not available
|
||||||
|
inc a
|
||||||
|
beq err report error
|
||||||
|
|
||||||
|
jsr ~get_tz_offset get time zone offset
|
||||||
|
sta tz_offset
|
||||||
|
stx tz_offset+2
|
||||||
|
|
||||||
|
sec adjust for time zone & store result
|
||||||
|
lda current_time
|
||||||
|
sbc tz_offset
|
||||||
|
sta [ts]
|
||||||
|
lda current_time+2
|
||||||
|
sbc tz_offset+2
|
||||||
|
ldy #tv_sec+2
|
||||||
|
sta [ts],y
|
||||||
|
|
||||||
|
ldy #tv_nsec ts->tv_nsec = 0
|
||||||
|
lda #0
|
||||||
|
sta [ts],y
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
sta [ts],y
|
||||||
|
bra ret
|
||||||
|
|
||||||
|
err stz base unsupported base: return 0
|
||||||
|
|
||||||
|
ret creturn 2:base
|
||||||
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* size_t strftime(
|
* size_t strftime(
|
||||||
|
@ -978,12 +1312,53 @@ Y_skip inx
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;%z - offset from UTC, if available
|
;%z - offset from UTC, if available
|
||||||
;we print nothing, because time zone info is not available
|
|
||||||
fmt_z rts
|
|
||||||
|
|
||||||
;%Z - time zone name or abbreviation, if available
|
;%Z - time zone name or abbreviation, if available
|
||||||
;we print nothing, because time zone info is not available
|
;we print the numeric offset for both, or nothing if time zone is not available
|
||||||
fmt_Z rts
|
fmt_z anop
|
||||||
|
fmt_Z lda >__useTimeTool if not using Time Tool
|
||||||
|
beq z_ret write nothing
|
||||||
|
pea 0 push pointer to string buffer
|
||||||
|
tdc
|
||||||
|
clc
|
||||||
|
adc #numstr
|
||||||
|
pha
|
||||||
|
pha make space for TZ preferences record
|
||||||
|
pha
|
||||||
|
pea 1 get one record element only (TZ offset)
|
||||||
|
tsc get time zone preference
|
||||||
|
inc a
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
_tiGetTimePrefs
|
||||||
|
pla
|
||||||
|
bcc z_dst
|
||||||
|
z_bail pla bail out in case of error
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
z_ret rts
|
||||||
|
z_dst ldy #tm_isdst adjust for DST (+1 hour) if needed
|
||||||
|
lda [timeptr],y
|
||||||
|
bmi z_bail bail out if DST is unknown
|
||||||
|
beq z_fmtstr
|
||||||
|
; clc
|
||||||
|
pla
|
||||||
|
adc #60*60
|
||||||
|
tay
|
||||||
|
pla
|
||||||
|
adc #0
|
||||||
|
pha
|
||||||
|
phy
|
||||||
|
z_fmtstr pea 0 no DST mangling
|
||||||
|
_tiOffset2TimeZoneString get TZ offset string
|
||||||
|
bcs z_ret
|
||||||
|
ldx #1
|
||||||
|
z_loop lda numstr,x print the digits
|
||||||
|
jsr writech
|
||||||
|
inx
|
||||||
|
cpx #5+1
|
||||||
|
blt z_loop
|
||||||
|
rts
|
||||||
|
|
||||||
fmt_invalid rts
|
fmt_invalid rts
|
||||||
|
|
||||||
|
|
56
time.macros
56
time.macros
|
@ -477,11 +477,6 @@
|
||||||
~&SYSCNT ~RESTM
|
~&SYSCNT ~RESTM
|
||||||
MEND
|
MEND
|
||||||
MACRO
|
MACRO
|
||||||
&LAB JLT &BP
|
|
||||||
&LAB BGE *+5
|
|
||||||
BRL &BP
|
|
||||||
MEND
|
|
||||||
MACRO
|
|
||||||
&LAB LLA &AD1,&AD2
|
&LAB LLA &AD1,&AD2
|
||||||
&LAB ANOP
|
&LAB ANOP
|
||||||
LCLA &L
|
LCLA &L
|
||||||
|
@ -621,3 +616,54 @@
|
||||||
&LAB LDX #$260B
|
&LAB LDX #$260B
|
||||||
JSL $E10000
|
JSL $E10000
|
||||||
MEND
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab _tiStatus
|
||||||
|
&lab ldx #$0638
|
||||||
|
jsl $E10000
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab _tiGetTimePrefs
|
||||||
|
&lab ldx #$0938
|
||||||
|
jsl $E10000
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab _tiOffset2TimeZoneString
|
||||||
|
&lab ldx #$1138
|
||||||
|
jsl $E10000
|
||||||
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab _LongMul
|
||||||
|
&lab ldx #$0C0B
|
||||||
|
jsl $E10000
|
||||||
|
MEND
|
||||||
|
macro
|
||||||
|
&l negate8 &n1
|
||||||
|
&l ~setm
|
||||||
|
sec
|
||||||
|
ldy #0
|
||||||
|
tya
|
||||||
|
sbc &n1
|
||||||
|
sta &n1
|
||||||
|
tya
|
||||||
|
sbc &n1+2
|
||||||
|
sta &n1+2
|
||||||
|
tya
|
||||||
|
sbc &n1+4
|
||||||
|
sta &n1+4
|
||||||
|
tya
|
||||||
|
sbc &n1+6
|
||||||
|
sta &n1+6
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
macro
|
||||||
|
&l cmpl &n1,&n2
|
||||||
|
lclb &yistwo
|
||||||
|
&l ~setm
|
||||||
|
~lda.h &n1
|
||||||
|
~op.h cmp,&n2
|
||||||
|
bne ~a&SYSCNT
|
||||||
|
~lda &n1
|
||||||
|
~op cmp,&n2
|
||||||
|
~a&SYSCNT anop
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
|
38
toolglue.asm
38
toolglue.asm
|
@ -206,6 +206,44 @@ yPos ds 2
|
||||||
xPos ds 2
|
xPos ds 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* ReadMouse2 - return mouse statistics
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* Returns a pointer to a record with the following
|
||||||
|
* structure:
|
||||||
|
*
|
||||||
|
* typedef struct MouseRec {
|
||||||
|
* char mouseMode;
|
||||||
|
* char mouseStatus;
|
||||||
|
* int yPos;
|
||||||
|
* int xPos;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
ReadMouse2 start
|
||||||
|
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
pha
|
||||||
|
_ReadMouse2
|
||||||
|
sta >~TOOLERROR
|
||||||
|
pl2 >mouseMode
|
||||||
|
pl2 >yPos
|
||||||
|
pl2 >xPos
|
||||||
|
|
||||||
|
lda #mouseMode
|
||||||
|
ldx #^mouseMode
|
||||||
|
rtl
|
||||||
|
|
||||||
|
mouseMode ds 1
|
||||||
|
mouseStatus ds 1
|
||||||
|
yPos ds 2
|
||||||
|
xPos ds 2
|
||||||
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* ReadTimeHex - returns the time in hex format
|
* ReadTimeHex - returns the time in hex format
|
||||||
|
|
|
@ -384,3 +384,8 @@
|
||||||
&lab ldx #$1F23
|
&lab ldx #$1F23
|
||||||
jsl $E10000
|
jsl $E10000
|
||||||
MEND
|
MEND
|
||||||
|
MACRO
|
||||||
|
&lab _ReadMouse2
|
||||||
|
&lab ldx #$3303
|
||||||
|
jsl $E10000
|
||||||
|
MEND
|
||||||
|
|
4
vars.asm
4
vars.asm
|
@ -23,7 +23,7 @@ Dummy start (dummy root segment)
|
||||||
*
|
*
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
CVars start
|
~CVars start
|
||||||
|
|
||||||
errno entry library error number
|
errno entry library error number
|
||||||
ds 2
|
ds 2
|
||||||
|
@ -35,6 +35,8 @@ sys_nerr entry # of error messages
|
||||||
_toolErr entry last error in a tool call (C)
|
_toolErr entry last error in a tool call (C)
|
||||||
~TOOLERROR entry last error in a tool call (Pascal)
|
~TOOLERROR entry last error in a tool call (Pascal)
|
||||||
ds 2
|
ds 2
|
||||||
|
__useTimeTool entry use Time Tool in <time.h> functions?
|
||||||
|
ds 2
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
|
Loading…
Reference in New Issue
Block a user