mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-06-14 03:29:41 +00:00
Compare commits
113 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 | ||
|
505f1c2804 | ||
|
a2bca0df04 | ||
|
ad273126dd | ||
|
7b6cb049b7 | ||
|
12f8d74c99 | ||
|
463d24a028 | ||
|
219e4352a0 | ||
|
89b501f259 | ||
|
ef63f26c4f | ||
|
c877c74b92 | ||
|
2d6ca8a7b2 | ||
|
3eb8a9cb55 | ||
|
36808404ca | ||
|
84f471474a | ||
|
c95bfc19fb | ||
|
a2b3d4541a | ||
|
1f88a38e2e | ||
|
38666ee111 | ||
|
7c2fb70c4a | ||
|
8cfb73a474 | ||
|
0047b755c9 | ||
|
3581d20a7c | ||
|
ab2f17c249 | ||
|
997e430562 | ||
|
b62940404f | ||
|
818707ed8c | ||
|
a45f531fe6 | ||
|
b01800ff77 | ||
|
b6690c4826 | ||
|
eddf778f09 | ||
|
66cfa0d406 | ||
|
e00c21dd70 | ||
|
503182e435 | ||
|
88a7bbebcc | ||
|
d08773af0d | ||
|
6364d0f48f | ||
|
ce05615a63 | ||
|
14908ebcd6 | ||
|
c025bba177 | ||
|
2334443437 | ||
|
268892b671 | ||
|
3ec8a8797f | ||
|
fb5683a14d | ||
|
b8605de33f | ||
|
e3c9bc96bc | ||
|
ae504c6e4f | ||
|
09942026a8 | ||
|
3a847d245e | ||
|
512fadeff0 | ||
|
5ad86f4a0b | ||
|
379f2f93ad |
174
cc.asm
174
cc.asm
|
@ -187,6 +187,7 @@ TAB equ 9 TAB key code
|
|||
stz ~QuickExitList
|
||||
stz ~QuickExitList+2
|
||||
case on
|
||||
stz __useTimeTool do not use Time Tool
|
||||
jsl ~InitIO reset standard I/O
|
||||
case off
|
||||
|
||||
|
@ -243,8 +244,6 @@ lb6 long M
|
|||
phy
|
||||
sec
|
||||
adc 1,S
|
||||
ply
|
||||
pha
|
||||
pha
|
||||
pea 0
|
||||
pha
|
||||
|
@ -264,20 +263,19 @@ lb7 pl4 argv get the pointer to the area
|
|||
lda [argv]
|
||||
sta targv
|
||||
stx targv+2
|
||||
clc get a pointer to the command line string
|
||||
adc start
|
||||
; clc (already clear)
|
||||
adc start get a pointer to the command line string
|
||||
bcc lb8
|
||||
inx
|
||||
lb8 sta argv
|
||||
stx argv+2
|
||||
short M move the command line string
|
||||
ldy #0
|
||||
lb9 lda [cLine],Y
|
||||
ldy #-1
|
||||
lb9 iny
|
||||
lda [cLine],Y
|
||||
sta [argv],Y
|
||||
beq lb10
|
||||
iny
|
||||
bra lb9
|
||||
lb10 long M
|
||||
bne lb9
|
||||
long M
|
||||
move4 argv,cLine save the pointer
|
||||
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 ~QuickExitList
|
||||
stz ~QuickExitList+2
|
||||
case on
|
||||
stz __useTimeTool do not use Time Tool
|
||||
case off
|
||||
lda #~RTL set up so exit(), etc. call ~RTL
|
||||
sta ~C_Quit+1
|
||||
|
||||
|
@ -375,6 +376,135 @@ start ds 2 start of the command line string
|
|||
targv ds 4
|
||||
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
|
||||
*
|
||||
* Inputs:
|
||||
* X,A - operands
|
||||
*
|
||||
* Outputs:
|
||||
* A - result
|
||||
*
|
||||
* Notes:
|
||||
* This routine is used for array index calculations and
|
||||
* for unsigned multiplies. It returns the low-order
|
||||
* 16 bits of the true result in case of overflow.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~CUMul2 start
|
||||
n1 equ 3
|
||||
n2 equ 5
|
||||
;
|
||||
; Initialization
|
||||
;
|
||||
phx save the operands
|
||||
pha
|
||||
phd set up our DP
|
||||
tsc
|
||||
tcd
|
||||
cpx n1 make sure n1 is the smaller argument
|
||||
bge in1
|
||||
lda n1
|
||||
stx n1
|
||||
sta n2
|
||||
in1 anop
|
||||
;
|
||||
; Do the multiply
|
||||
;
|
||||
lda #0
|
||||
|
||||
lsr n1
|
||||
lb0 bcc lb1
|
||||
clc
|
||||
adc n2
|
||||
lb1 asl n2
|
||||
|
||||
lsr n1
|
||||
bne lb0
|
||||
bcc aa1
|
||||
clc
|
||||
adc n2
|
||||
|
||||
aa1 pld return the result
|
||||
plx
|
||||
plx
|
||||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~Exit - call exit routines and clean up open files
|
||||
|
@ -389,10 +519,7 @@ ptr equ 3 pointer to exit routines
|
|||
;
|
||||
; Set up our stack frame
|
||||
;
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
ph4 ~ExitList set up our stack frame
|
||||
ph4 >~ExitList set up our stack frame
|
||||
phd
|
||||
tsc
|
||||
tcd
|
||||
|
@ -441,7 +568,6 @@ lb3 lda >stderr+6 while there is a next file
|
|||
lb4 pld return
|
||||
pla
|
||||
pla
|
||||
plb
|
||||
rts
|
||||
end
|
||||
|
||||
|
@ -459,10 +585,7 @@ ptr equ 3 pointer to exit routines
|
|||
;
|
||||
; Set up our stack frame
|
||||
;
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
ph4 ~QuickExitList set up our stack frame
|
||||
ph4 >~QuickExitList set up our stack frame
|
||||
phd
|
||||
tsc
|
||||
tcd
|
||||
|
@ -499,7 +622,6 @@ lb2 ldy #2 dereference the pointer
|
|||
lb3 pld return
|
||||
pla
|
||||
pla
|
||||
plb
|
||||
rts
|
||||
end
|
||||
|
||||
|
@ -727,6 +849,8 @@ lb3 sec
|
|||
csubroutine (4:len,4:source),0
|
||||
dest equ source+4
|
||||
|
||||
pei dest+2 save original dest value
|
||||
pei dest
|
||||
ldx len+2 move whole banks
|
||||
beq lm2
|
||||
ldy #0
|
||||
|
@ -761,7 +885,11 @@ lb2 lda [source],Y
|
|||
bne lb2
|
||||
lb3 lda [source]
|
||||
sta [dest]
|
||||
lb4 creturn
|
||||
lb4 pla restore original dest value
|
||||
sta dest
|
||||
pla
|
||||
sta dest+2
|
||||
creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -862,7 +990,9 @@ lb2 lda [source],Y
|
|||
bne lb2
|
||||
lb3 lda [source]
|
||||
sta [dest]
|
||||
lb4 creturn
|
||||
lb4 bcc lb5 if the move length was odd
|
||||
dec4 dest restore original dest value
|
||||
lb5 creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
|
183
cc.macros
183
cc.macros
|
@ -1,3 +1,94 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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 error &e
|
||||
&lab ph2 &e
|
||||
|
@ -280,11 +371,6 @@
|
|||
~&SYSCNT ~RESTM
|
||||
MEND
|
||||
MACRO
|
||||
&LAB JEQ &BP
|
||||
&LAB BNE *+5
|
||||
BRL &BP
|
||||
MEND
|
||||
MACRO
|
||||
&LAB LONG &A,&B
|
||||
LCLB &I
|
||||
LCLB &M
|
||||
|
@ -305,84 +391,6 @@
|
|||
.C
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 PL4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
@ -539,3 +547,12 @@
|
|||
.j
|
||||
rtl
|
||||
mend
|
||||
macro
|
||||
&l dec4 &a
|
||||
&l ~setm
|
||||
lda &a
|
||||
bne ~&SYSCNT
|
||||
dec 2+&a
|
||||
~&SYSCNT dec &a
|
||||
~restm
|
||||
mend
|
||||
|
|
|
@ -19,6 +19,7 @@ EMFILE gequ 8 too many files are open
|
|||
EACCES gequ 9 access bits prevent the operation
|
||||
EEXIST gequ 10 the file exists
|
||||
ENOSPC gequ 11 the file is too large
|
||||
EILSEQ gequ 12 encoding error
|
||||
;
|
||||
; masks for the __ctype array
|
||||
;
|
||||
|
@ -62,6 +63,7 @@ _IOEOF gequ $0080 has an EOF been found?
|
|||
_IOERR gequ $0100 has an error occurred?
|
||||
_IOTEXT gequ $0200 is this file a text file?
|
||||
_IOTEMPFILE gequ $0400 was this file created by tmpfile()?
|
||||
_IOAPPEND gequ $0800 is this file open in append mode?
|
||||
|
||||
! record structure
|
||||
! ----------------
|
||||
|
@ -72,7 +74,7 @@ FILE_end gequ FILE_base+4 end of the file buffer
|
|||
FILE_size gequ FILE_end+4 size of the file buffer
|
||||
FILE_cnt gequ FILE_size+4 # chars that can be read/written to buffer
|
||||
FILE_pbk gequ FILE_cnt+4 put back character
|
||||
FILE_flag gequ FILE_pbk+2 buffer flags
|
||||
FILE_flag gequ FILE_pbk+4 buffer flags
|
||||
FILE_file gequ FILE_flag+2 GS/OS file ID
|
||||
|
||||
sizeofFILE gequ FILE_file+2 size of the record
|
||||
|
|
96
fcntl.asm
96
fcntl.asm
|
@ -99,7 +99,7 @@ err equ 1 error return code
|
|||
lda mode convert mode to ProDOS format
|
||||
jsr unixtoprodos
|
||||
sta siAccess
|
||||
ph4 path set the path name
|
||||
ph4 <path set the path name
|
||||
jsl ctoosstr
|
||||
sta siPathname
|
||||
stx siPathname+2
|
||||
|
@ -148,7 +148,6 @@ err equ 1 error return code
|
|||
|
||||
stz err err = 0 {no error}
|
||||
lda filds error if there are too many open files
|
||||
bmi lb2
|
||||
cmp #OPEN_MAX
|
||||
bge lb2
|
||||
asl A get the file reference number
|
||||
|
@ -209,8 +208,8 @@ err equ 1 error return code
|
|||
csubroutine (4:path,2:mode),2
|
||||
|
||||
ph2 #O_WRONLY+O_TRUNC+O_CREAT
|
||||
ph2 mode
|
||||
ph4 path
|
||||
ph2 <mode
|
||||
ph4 <path
|
||||
jsl openfile
|
||||
sta err
|
||||
|
||||
|
@ -239,7 +238,7 @@ err equ 1 error return code
|
|||
|
||||
ph2 #0
|
||||
ph2 #F_DUPFD
|
||||
ph2 old
|
||||
ph2 <old
|
||||
jsl fcntl
|
||||
sta err
|
||||
|
||||
|
@ -280,7 +279,6 @@ flags equ 5 file flags
|
|||
bra lb7
|
||||
|
||||
lb1 lda filds error if there are too many open files
|
||||
bmi lb2
|
||||
cmp #OPEN_MAX
|
||||
bge lb2
|
||||
asl A get the file reference number
|
||||
|
@ -297,7 +295,6 @@ lb3 sta refnum
|
|||
sta flags
|
||||
|
||||
lda arg find a new filds
|
||||
bmi lb5
|
||||
cmp #OPEN_MAX
|
||||
bge lb5
|
||||
asl A
|
||||
|
@ -376,7 +373,6 @@ mark equ 1 new file mark
|
|||
sta mark
|
||||
sta mark+2
|
||||
lda filds get the file refnum
|
||||
bmi lb1
|
||||
cmp #OPEN_MAX
|
||||
bge lb1
|
||||
asl A
|
||||
|
@ -384,43 +380,56 @@ mark equ 1 new file mark
|
|||
tax
|
||||
lda >files,X
|
||||
bne lb2
|
||||
lb1 lda #EBADF bad refnum error
|
||||
sta >errno
|
||||
bra lb4
|
||||
lb1 bra lb4a bad refnum error
|
||||
|
||||
lb2 sta >smRefnum set the file refnum
|
||||
sta >gmRefnum
|
||||
lda whence convert from UNIX whence to GS/OS base
|
||||
beq lb3
|
||||
eor #$0003
|
||||
cmp #4
|
||||
bge lb2a
|
||||
cmp #2
|
||||
bne lb3
|
||||
sta >smBase
|
||||
lda offset+2
|
||||
bpl lb3a
|
||||
sub4 #0,offset,offset
|
||||
lda #3
|
||||
cmp #SEEK_SET if whence == 0 (SEEK_SET)
|
||||
bne lb2a
|
||||
lda offset+2 if offset is negative
|
||||
bmi lb4 fail with EINVAL
|
||||
lda #0 set mark to offset
|
||||
bra lb3
|
||||
lb2a lda #EINVAL invalid whence flag
|
||||
sta >errno
|
||||
bra lb4
|
||||
lb2a cmp #SEEK_END else if whence == 2 (SEEK_END)
|
||||
bne lb2c
|
||||
lda offset+2 if offset > 0
|
||||
bmi lb2b
|
||||
ora offset
|
||||
bne lb4 fail with EINVAL
|
||||
lb2b sub4 #0,offset,offset negate offset
|
||||
lda #1 set mark to EOF - offset
|
||||
bra lb3
|
||||
lb2c cmp #SEEK_CUR else if whence == 1 (SEEK_CUR)
|
||||
bne lb4
|
||||
lda offset if offset is positive or 0
|
||||
bmi lb2d
|
||||
lda #2 set mark to old mark + offset
|
||||
bra lb3 else
|
||||
lb2d sub4 #0,offset,offset negate offset
|
||||
lda #3 set mark to old mark - offset
|
||||
lb3 sta >smBase save the base parameter
|
||||
lb3a lda offset set the displacement
|
||||
sta >smDisplacement
|
||||
lda offset+2
|
||||
sta >smDisplacement+2
|
||||
OSSet_Mark smRec set the file mark
|
||||
bcs lb1
|
||||
OSGet_Mark gmRec get the new mark
|
||||
bcs lb1
|
||||
bcc lb5
|
||||
cmp #$4D out of range error => fail with EINVAL
|
||||
bne lb4a
|
||||
lb4 lda #EINVAL
|
||||
bra lb4b
|
||||
lb4a lda #EBADF bad refnum error
|
||||
lb4b sta >errno
|
||||
bra lb6
|
||||
lb5 OSGet_Mark gmRec get the new mark
|
||||
bcs lb4a
|
||||
lda >gmDisplacement
|
||||
sta mark
|
||||
lda >gmDisplacement+2
|
||||
sta mark+2
|
||||
|
||||
lb4 creturn 4:mark
|
||||
lb6 creturn 4:mark
|
||||
|
||||
smRec dc i'3' SetMark record
|
||||
smRefnum ds 2
|
||||
|
@ -453,9 +462,9 @@ err equ 1 error return code
|
|||
|
||||
csubroutine (4:path,2:oflag),2
|
||||
|
||||
ph2 oflag
|
||||
ph2 <oflag
|
||||
ph2 #$7180
|
||||
ph4 path
|
||||
ph4 <path
|
||||
jsl openfile
|
||||
sta err
|
||||
|
||||
|
@ -515,7 +524,7 @@ lb1 lda files,X
|
|||
brl lb11
|
||||
lb2 stx index save the index to the file
|
||||
|
||||
ph4 path convert the path to an OS string
|
||||
ph4 <path convert the path to an OS string
|
||||
jsl ctoosstr
|
||||
sta opPathname
|
||||
stx opPathname+2
|
||||
|
@ -546,8 +555,8 @@ lb4 sta crFileType
|
|||
lda #ENOENT
|
||||
sta >errno
|
||||
bra lb11
|
||||
lb4a ph2 mode set the access bits
|
||||
ph4 path
|
||||
lb4a ph2 <mode set the access bits
|
||||
ph4 <path
|
||||
jsl chmod
|
||||
bra lb8 else
|
||||
lb5 lda oflag if O_CREAT is not set then
|
||||
|
@ -634,7 +643,6 @@ err equ 1 error return code
|
|||
phk
|
||||
plb
|
||||
lda filds error if the file has not been opened
|
||||
bmi lb0
|
||||
cmp #OPEN_MAX
|
||||
bge lb0
|
||||
asl A get the file reference number
|
||||
|
@ -797,7 +805,6 @@ nbuff equ 3 new buffer pointer
|
|||
phk
|
||||
plb
|
||||
lda filds error if the file has not been opened
|
||||
bmi lb0
|
||||
cmp #OPEN_MAX
|
||||
bge lb0
|
||||
asl A get the file reference number
|
||||
|
@ -806,6 +813,7 @@ nbuff equ 3 new buffer pointer
|
|||
lda files,X
|
||||
beq lb0
|
||||
sta wrRefnum
|
||||
sta smRefnum
|
||||
stx filds
|
||||
lda files+2,X make sure the file is open for writing
|
||||
and #O_WRONLY+O_RDWR
|
||||
|
@ -827,7 +835,7 @@ lb0a move4 buf,wrDataBuffer set the location to write from
|
|||
and #O_BINARY
|
||||
bne lb0g
|
||||
pea 0 reserve a file buffer
|
||||
ph2 n
|
||||
ph2 <n
|
||||
jsl malloc
|
||||
sta nbuff
|
||||
stx nbuff+2
|
||||
|
@ -857,7 +865,12 @@ lb0e sta [nbuff]
|
|||
long M
|
||||
lb0f move4 nbuff,wrDataBuffer set the data buffer start
|
||||
|
||||
lb0g OSWrite wrRec write the bytes
|
||||
lb0g ldx filds if the file is in O_APPEND mode then
|
||||
lda files+2,X
|
||||
and #O_APPEND
|
||||
beq lb0h
|
||||
OSSet_Mark smRec set mark to EOF
|
||||
lb0h OSWrite wrRec write the bytes
|
||||
bcc lb1 if an error occurred then
|
||||
lda #EIO errno = EIO
|
||||
sta >errno
|
||||
|
@ -869,7 +882,7 @@ lb1 ldy wrTransferCount return the bytes read
|
|||
lda nbuff if nbuff <> NULL then
|
||||
ora nbuff+2
|
||||
beq lb2
|
||||
ph4 nbuff dispose of the buffer
|
||||
ph4 <nbuff dispose of the buffer
|
||||
jsl free
|
||||
lb2 anop
|
||||
|
||||
|
@ -881,4 +894,9 @@ wrRefnum ds 2
|
|||
wrDataBuffer ds 4
|
||||
wrRequestCount ds 4
|
||||
wrTransferCount ds 4
|
||||
|
||||
smRec dc i'3' SetMark record
|
||||
smRefnum ds 2
|
||||
smBase dc i'1' EOF-displacement mode
|
||||
smDisplacement dc i4'0' displacement = 0
|
||||
end
|
||||
|
|
169
fcntl.macros
169
fcntl.macros
|
@ -1,3 +1,94 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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 MOVE4 &F,&T
|
||||
&LAB ~SETM
|
||||
|
@ -148,84 +239,6 @@
|
|||
.C
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 SHORT &A,&B
|
||||
LCLB &I
|
||||
LCLB &M
|
||||
|
|
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
|
97
fpextra.asm
97
fpextra.asm
|
@ -1,97 +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
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~CompPrecision start
|
||||
tsc
|
||||
clc
|
||||
adc #4
|
||||
ldy #0
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
FX2C
|
||||
FC2X
|
||||
rtl
|
||||
end
|
||||
|
|
@ -1,36 +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
|
246
int64.asm
246
int64.asm
|
@ -515,249 +515,3 @@ loop1 asl num1 do the remaining shift
|
|||
rt0 pld
|
||||
rtl rtl
|
||||
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
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~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
|
||||
|
||||
convert tsc if it is not LONG_MIN, call fx2c:
|
||||
clc
|
||||
adc #4
|
||||
pea 0 push src address for fx2c
|
||||
pha
|
||||
pea 0 push dst address for fx2c
|
||||
inc a
|
||||
inc a
|
||||
pha
|
||||
fx2c convert
|
||||
|
||||
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
|
||||
&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
|
||||
lclb &yistwo
|
||||
&l ~setm
|
||||
|
@ -140,27 +121,3 @@
|
|||
.d
|
||||
sta 2+&op
|
||||
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
|
||||
|
|
107
locale.asm
Normal file
107
locale.asm
Normal file
|
@ -0,0 +1,107 @@
|
|||
keep obj/locale
|
||||
mcopy locale.macros
|
||||
case on
|
||||
****************************************************************
|
||||
*
|
||||
* Locale - locale support
|
||||
*
|
||||
* This currently implements a minimalistic version of the
|
||||
* <locale.h> functions, supporting only the "C" locale.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
Locale private dummy routine
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* char *setlocale(int category, const char *locale);
|
||||
*
|
||||
* Set or query current locale
|
||||
*
|
||||
* Inputs:
|
||||
* category - locale category to set or query
|
||||
* locale - locale name (or NULL for query)
|
||||
*
|
||||
* Outputs:
|
||||
* returns locale string (for relevant category),
|
||||
* or NULL if locale cannot be set as requested
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
setlocale start
|
||||
LC_MAX equ 5 maximum valid LC_* value
|
||||
|
||||
csubroutine (2:category,4:locale),0
|
||||
|
||||
lda category if category is invalid
|
||||
cmp #LC_MAX+1
|
||||
bge err return NULL
|
||||
lda locale if querying the current locale
|
||||
ora locale+2
|
||||
beq good return "C"
|
||||
lda [locale]
|
||||
cmp #'C' if locale is "C" or "", we are good
|
||||
beq good
|
||||
and #$00FF
|
||||
bne err
|
||||
good lda #C_str if successful, return "C"
|
||||
sta locale
|
||||
lda #^C_str
|
||||
sta locale+2
|
||||
bra ret
|
||||
err stz locale otherwise, return NULL for error
|
||||
stz locale+2
|
||||
ret creturn 4:locale
|
||||
|
||||
C_str dc c'C',i1'0'
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* struct lconv *localeconv(void);
|
||||
*
|
||||
* Get numeric formatting conventions
|
||||
*
|
||||
* Outputs:
|
||||
* returns pointer to a struct lconv containing
|
||||
* appropriate values for the current locale
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
localeconv start
|
||||
CHAR_MAX equ 255
|
||||
|
||||
ldx #^C_locale_lconv
|
||||
lda #C_locale_lconv
|
||||
rtl
|
||||
|
||||
C_locale_lconv anop
|
||||
decimal_point dc a4'period'
|
||||
thousands_sep dc a4'emptystr'
|
||||
grouping dc a4'emptystr'
|
||||
mon_decimal_point dc a4'emptystr'
|
||||
mon_thousands_sep dc a4'emptystr'
|
||||
mon_grouping dc a4'emptystr'
|
||||
positive_sign dc a4'emptystr'
|
||||
negative_sign dc a4'emptystr'
|
||||
currency_symbol dc a4'emptystr'
|
||||
frac_digits dc i1'CHAR_MAX'
|
||||
p_cs_precedes dc i1'CHAR_MAX'
|
||||
n_cs_precedes dc i1'CHAR_MAX'
|
||||
p_sep_by_space dc i1'CHAR_MAX'
|
||||
n_sep_by_space dc i1'CHAR_MAX'
|
||||
p_sign_posn dc i1'CHAR_MAX'
|
||||
n_sign_posn dc i1'CHAR_MAX'
|
||||
int_curr_symbol dc a4'emptystr'
|
||||
int_frac_digits dc i1'CHAR_MAX'
|
||||
int_p_cs_precedes dc i1'CHAR_MAX'
|
||||
int_n_cs_precedes dc i1'CHAR_MAX'
|
||||
int_p_sep_by_space dc i1'CHAR_MAX'
|
||||
int_n_sep_by_space dc i1'CHAR_MAX'
|
||||
int_p_sign_posn dc i1'CHAR_MAX'
|
||||
int_n_sign_posn dc i1'CHAR_MAX'
|
||||
|
||||
period dc c'.',i1'0'
|
||||
emptystr dc i1'0'
|
||||
end
|
|
@ -91,27 +91,3 @@
|
|||
.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
|
4
make
4
make
|
@ -19,7 +19,7 @@ if {#} == 0
|
|||
unset exit
|
||||
end
|
||||
|
||||
for i in cc ctype string stdlib time setjmp orca fcntl vars toolglue signal int64 fenv fpextra math2
|
||||
for i in cc ctype string stdlib time setjmp orca fcntl vars toolglue signal int64 locale uchar
|
||||
Newer obj/{i}.a {i}.asm
|
||||
if {Status} != 0
|
||||
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 {list} time.a signal.a toolglue.a orca.a fcntl.a stdio.a int64.a
|
||||
set list {list} fenv.a fpextra.a math2.a
|
||||
set list {list} locale.a uchar.a
|
||||
for i in {list}
|
||||
echo makelib orcalib +obj/{i}
|
||||
makelib orcalib +obj/{i}
|
||||
|
|
155
math2.asm
155
math2.asm
|
@ -1,155 +0,0 @@
|
|||
keep obj/math2
|
||||
mcopy math2.macros
|
||||
case on
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* Math2 - additional math routines
|
||||
*
|
||||
* This code provides additional functions from <math.h>
|
||||
* (including internal helper functions used by macros),
|
||||
* supplementing the ones in SysFloat.
|
||||
*
|
||||
****************************************************************
|
||||
|
||||
math2 private dummy segment
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int __fpclassifyf(float x);
|
||||
*
|
||||
* Classify a float value
|
||||
*
|
||||
* Inputs:
|
||||
* val - the number to classify
|
||||
*
|
||||
* Outputs:
|
||||
* one of the FP_* classification values
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__fpclassifyf start
|
||||
|
||||
csubroutine (10:val),0
|
||||
|
||||
tdc
|
||||
clc
|
||||
adc #val
|
||||
ldy #0
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
FX2S
|
||||
FCLASSS
|
||||
txa
|
||||
and #$00FF
|
||||
cmp #$00FC
|
||||
bne lb1
|
||||
inc a
|
||||
lb1 sta val
|
||||
|
||||
creturn 2:val
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int __fpclassifyd(double x);
|
||||
*
|
||||
* Classify a double value
|
||||
*
|
||||
* Inputs:
|
||||
* val - the number to classify
|
||||
*
|
||||
* Outputs:
|
||||
* one of the FP_* classification values
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__fpclassifyd start
|
||||
|
||||
csubroutine (10:val),0
|
||||
|
||||
tdc
|
||||
clc
|
||||
adc #val
|
||||
ldy #0
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
phy
|
||||
pha
|
||||
FX2D
|
||||
FCLASSD
|
||||
txa
|
||||
and #$00FF
|
||||
cmp #$00FC
|
||||
bne lb1
|
||||
inc a
|
||||
lb1 sta val
|
||||
|
||||
creturn 2:val
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int __fpclassifyl(long double x);
|
||||
*
|
||||
* Classify a long double value
|
||||
*
|
||||
* Inputs:
|
||||
* val - the number to classify
|
||||
*
|
||||
* Outputs:
|
||||
* one of the FP_* classification values
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__fpclassifyl start
|
||||
|
||||
csubroutine (10:val),0
|
||||
|
||||
tdc
|
||||
clc
|
||||
adc #val
|
||||
pea 0
|
||||
pha
|
||||
FCLASSX
|
||||
txa
|
||||
and #$00FF
|
||||
cmp #$00FC
|
||||
bne lb1
|
||||
inc a
|
||||
lb1 sta val
|
||||
|
||||
creturn 2:val
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int __signbit(long double x);
|
||||
*
|
||||
* Get the sign bit of a floating-point value
|
||||
*
|
||||
* Inputs:
|
||||
* val - the number
|
||||
*
|
||||
* Outputs:
|
||||
* 0 if positive, non-zero if negative
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__signbit start
|
||||
|
||||
csubroutine (10:val),0
|
||||
|
||||
lda val+8
|
||||
and #$8000
|
||||
sta val
|
||||
|
||||
creturn 2:val
|
||||
end
|
8
orca.asm
8
orca.asm
|
@ -53,7 +53,7 @@ lb1 rtl
|
|||
*
|
||||
enddesk start
|
||||
|
||||
jmp ~ENDDESK
|
||||
brl ~ENDDESK
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -64,7 +64,7 @@ enddesk start
|
|||
*
|
||||
endgraph start
|
||||
|
||||
jmp ~ENDGRAPH
|
||||
brl ~ENDGRAPH
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -119,7 +119,7 @@ id dc 8c' ',i1'0'
|
|||
*
|
||||
startdesk start
|
||||
|
||||
jmp ~STARTDESK
|
||||
brl ~STARTDESK
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -130,7 +130,7 @@ startdesk start
|
|||
*
|
||||
startgraph start
|
||||
|
||||
jmp ~STARTGRAPH
|
||||
brl ~STARTGRAPH
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
|
46
orca.macros
46
orca.macros
|
@ -1,46 +0,0 @@
|
|||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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
|
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,12 +107,11 @@ lb2 asl A get the signal handler address
|
|||
tay
|
||||
lda >subABRT-2,X
|
||||
bmi lb3 skip if it is SIG_DFL or SIG_IGN
|
||||
short M set up the call address
|
||||
sta >jsl+3
|
||||
long M
|
||||
xba set up the call address
|
||||
sta >jsl+2
|
||||
tya
|
||||
sta >jsl+1
|
||||
ph2 sig call the user signal handler
|
||||
ph2 <sig call the user signal handler
|
||||
jsl jsl jsl
|
||||
|
||||
lb3 creturn 2:val
|
||||
|
|
|
@ -1,3 +1,41 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
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
|
||||
|
@ -139,38 +177,6 @@
|
|||
.C
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB SHORT &A,&B
|
||||
LCLB &I
|
||||
LCLB &M
|
||||
|
|
169
stdio.macros
169
stdio.macros
|
@ -1,4 +1,95 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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
|
||||
&l negate8 &n1
|
||||
&l ~setm
|
||||
sec
|
||||
|
@ -569,84 +660,6 @@
|
|||
.I
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 PL4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
|
281
stdlib.asm
281
stdlib.asm
|
@ -37,7 +37,7 @@ abort start
|
|||
ph2 #SIGABRT
|
||||
jsl raise
|
||||
lda #-1
|
||||
jmp ~C_QUIT
|
||||
brl ~C_QUIT
|
||||
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
|
||||
|
||||
lda count if count is 0 then
|
||||
ora count+2
|
||||
jeq lb5 just return a null pointer
|
||||
|
||||
lda compar patch the call address
|
||||
sta >jsl+1
|
||||
lda compar+1
|
||||
|
@ -351,8 +355,8 @@ lb1 clc test = (left+right)/2
|
|||
ror test
|
||||
mul4 test,size,addr addr = test*size + base
|
||||
add4 addr,base
|
||||
ph4 addr compare the array elements
|
||||
ph4 key
|
||||
ph4 <addr compare the array elements
|
||||
ph4 <key
|
||||
jsl jsl jsl
|
||||
tax quit if *addr = *key
|
||||
beq lb6
|
||||
|
@ -436,14 +440,14 @@ exit start
|
|||
_exit entry
|
||||
_Exit entry
|
||||
lda 4,S
|
||||
jmp ~C_QUIT
|
||||
brl ~C_QUIT
|
||||
end
|
||||
|
||||
quick_exit start
|
||||
|
||||
jsr ~QUICKEXIT
|
||||
lda 4,S
|
||||
jmp ~C_QUIT
|
||||
brl ~C_QUIT
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -588,8 +592,8 @@ addr equ 1
|
|||
phb use local addressing
|
||||
phk
|
||||
plb
|
||||
ph4 n do the divide
|
||||
ph4 d
|
||||
ph4 <n do the divide
|
||||
ph4 <d
|
||||
jsl ~DIV4
|
||||
pl4 div_t
|
||||
pl4 div_t+4
|
||||
|
@ -638,6 +642,47 @@ addr equ 1
|
|||
lldiv_t ds 16
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int mblen(const char *s, size_t n)
|
||||
*
|
||||
* Inputs:
|
||||
* s - NULL or pointer to character
|
||||
* n - maximum number of bytes to inspect
|
||||
*
|
||||
* Outputs:
|
||||
* If s is NULL, returns 0, indicating encodings are not
|
||||
* state-dependent. Otherwise, returns 0 if s points to a
|
||||
* null character, -1 if the next n or fewer bytes do not
|
||||
* form a valid character, or the number of bytes forming
|
||||
* a valid character.
|
||||
*
|
||||
* Note: This implementation assumes we do not support actual
|
||||
* multi-byte or state-dependent character encodings.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
mblen start
|
||||
|
||||
csubroutine (4:s,4:n)
|
||||
ldx #0
|
||||
lda s if s == NULL
|
||||
ora s+2
|
||||
beq ret return 0
|
||||
lda n if n == 0
|
||||
ora n+2
|
||||
bne readchar
|
||||
dex return -1
|
||||
bra ret
|
||||
readchar lda [s] if *s == '\0'
|
||||
and #$00FF
|
||||
beq ret return 0
|
||||
inx else return 1
|
||||
|
||||
ret stx n
|
||||
creturn 2:n
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* void qsort(base, count, size, compar)
|
||||
|
@ -659,13 +704,14 @@ lldiv_t ds 16
|
|||
qsort start
|
||||
|
||||
csubroutine (4:base,4:count,4:size,4:compar),0
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
|
||||
lda count nothing to do if count is 0
|
||||
ora count+2
|
||||
beq done
|
||||
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
dec4 count set count to the addr of the last entry
|
||||
mul4 count,size
|
||||
add4 count,base
|
||||
|
@ -676,12 +722,13 @@ qsort start
|
|||
lda compar+1
|
||||
sta jsl1+2
|
||||
sta jsl2+2
|
||||
ph4 count do the sort
|
||||
ph4 base
|
||||
plb
|
||||
|
||||
ph4 <count do the sort
|
||||
ph4 <base
|
||||
jsl rsort
|
||||
|
||||
done plb
|
||||
creturn
|
||||
done creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -724,26 +771,31 @@ right equ 5 right address
|
|||
|
||||
csubroutine (4:first,4:last),8
|
||||
|
||||
phb
|
||||
sr0 phb
|
||||
phk
|
||||
plb
|
||||
sr0 lda last+2 if last <= first then quit
|
||||
lda last+2 if last <= first then quit
|
||||
bmi sr1a
|
||||
cmp first+2
|
||||
bne sr1
|
||||
lda last
|
||||
cmp first
|
||||
sr1 bgt sr1a
|
||||
plb
|
||||
sr1 bgt sr1b
|
||||
sr1a plb
|
||||
creturn
|
||||
|
||||
sr1a move4 last,right right = last
|
||||
sr1b move4 last,right right = last
|
||||
move4 first,left left = first
|
||||
bra sr3
|
||||
sr2 add4 left,lsize inc left until *left >= *last
|
||||
sr3 ph4 last
|
||||
ph4 left
|
||||
sr3 plb
|
||||
ph4 <last
|
||||
ph4 <left
|
||||
jsl1 entry
|
||||
jsl jsl1
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
tax
|
||||
bmi sr2
|
||||
sr4 lda right quit if right = first
|
||||
|
@ -753,14 +805,18 @@ sr4 lda right quit if right = first
|
|||
cmp first+2
|
||||
beq sr4b
|
||||
sr4a sub4 right,lsize dec right until *right <= *last
|
||||
ph4 last
|
||||
ph4 right
|
||||
plb
|
||||
ph4 <last
|
||||
ph4 <right
|
||||
jsl2 entry
|
||||
jsl jsl2
|
||||
phb
|
||||
phk
|
||||
plb
|
||||
dec A
|
||||
bpl sr4
|
||||
sr4b ph4 left swap left/right entries
|
||||
ph4 right
|
||||
sr4b ph4 <left swap left/right entries
|
||||
ph4 <right
|
||||
jsr swap
|
||||
lda left+2 loop if left < right
|
||||
cmp right+2
|
||||
|
@ -768,17 +824,30 @@ sr4b ph4 left swap left/right entries
|
|||
lda left
|
||||
cmp right
|
||||
sr5 blt sr2
|
||||
ph4 right swap left/right entries
|
||||
ph4 left
|
||||
ph4 <right swap left/right entries
|
||||
ph4 <left
|
||||
jsr swap
|
||||
ph4 left swap left/last entries
|
||||
ph4 last
|
||||
ph4 <left swap left/last entries
|
||||
ph4 <last
|
||||
jsr swap
|
||||
sub4 left,lsize,right sort left part of array
|
||||
ph4 right
|
||||
ph4 first
|
||||
sub4 left,lsize,right calculate bounds of subarrays
|
||||
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
|
||||
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
|
||||
;
|
||||
; swap - swap two entries
|
||||
|
@ -789,8 +858,9 @@ r equ 7 right entry
|
|||
swap tsc set up addressing
|
||||
phd
|
||||
tcd
|
||||
ldx lsize+2 move 64K chunks
|
||||
lda lsize+2 move 64K chunks
|
||||
beq sw2
|
||||
sta banks
|
||||
ldy #0
|
||||
sw1 lda [l],Y
|
||||
tax
|
||||
|
@ -803,7 +873,7 @@ sw1 lda [l],Y
|
|||
bne sw1
|
||||
inc l+2
|
||||
inc r+2
|
||||
dex
|
||||
dec banks
|
||||
bne sw1
|
||||
sw2 lda lsize if there are an odd number of bytes then
|
||||
lsr A
|
||||
|
@ -852,6 +922,8 @@ sw6 pld
|
|||
;
|
||||
lsize entry
|
||||
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
|
||||
|
||||
****************************************************************
|
||||
|
@ -877,6 +949,31 @@ srand start
|
|||
brl ~RANX2
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* strtof - convert a string to a float
|
||||
* strtold - convert a string to a long double
|
||||
*
|
||||
* Inputs:
|
||||
* str - pointer to the string
|
||||
* ptr - pointer to a pointer; a pointer to the first
|
||||
* char past the number is placed here. If ptr is
|
||||
* nil, no pointer is returned
|
||||
*
|
||||
* Outputs:
|
||||
* X-A - pointer to result
|
||||
*
|
||||
* Note: These are currently implemented by just calling strtod
|
||||
* (in SysFloat). As such, all of these function really
|
||||
* return values in the SANE extended format.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
strtold start
|
||||
strtof entry
|
||||
jml strtod
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* strtol - convert a string to a long
|
||||
|
@ -902,9 +999,10 @@ rtl equ 7 return address
|
|||
val equ 3 value
|
||||
negative equ 1 is the number negative?
|
||||
|
||||
pea 0 make room for & initialize val
|
||||
pea 0
|
||||
pea 0 make room for & initialize negative
|
||||
lda #0
|
||||
pha make room for & initialize val
|
||||
pha
|
||||
pha make room for & initialize negative
|
||||
tsc set up direct page addressing
|
||||
phd
|
||||
tcd
|
||||
|
@ -941,10 +1039,10 @@ cn1 cmp #'+' else if the char is '+' then
|
|||
bne cn3
|
||||
cn2 inc4 str ++str
|
||||
|
||||
cn3 ph4 str save the starting string
|
||||
ph2 base convert the unsigned number
|
||||
ph4 ptr
|
||||
ph4 str
|
||||
cn3 ph4 <str save the starting string
|
||||
ph2 <base convert the unsigned number
|
||||
ph4 <ptr
|
||||
ph4 <str
|
||||
jsl ~strtoul
|
||||
stx val+2
|
||||
sta val
|
||||
|
@ -1029,10 +1127,11 @@ foundOne equ 1 have we found a number?
|
|||
ldx #1
|
||||
|
||||
init pea 1 make room for & initialize rangeOK
|
||||
pea 0 make room for & initialize negative
|
||||
pea 0 make room for & initialize val
|
||||
pea 0
|
||||
pea 0 make room for & initialize foundOne
|
||||
lda #0
|
||||
pha make room for & initialize negative
|
||||
pha make room for & initialize val
|
||||
pha
|
||||
pha make room for & initialize foundOne
|
||||
tsc set up direct page addressing
|
||||
phd
|
||||
tcd
|
||||
|
@ -1128,9 +1227,9 @@ cn3 cmp base branch if the digit is too big
|
|||
pha
|
||||
pha
|
||||
pha
|
||||
ph4 val
|
||||
ph4 <val
|
||||
pea 0
|
||||
ph2 base
|
||||
ph2 <base
|
||||
_LongMul
|
||||
pl4 val
|
||||
pla branch if there was an error
|
||||
|
@ -1220,13 +1319,14 @@ retptr equ 11 pointer to location for return value
|
|||
val equ 3 value
|
||||
negative equ 1 is the number negative?
|
||||
|
||||
pea 0 make room for & initialize retptr
|
||||
lda #0
|
||||
pha make room for & initialize retptr
|
||||
phx
|
||||
pea 0 make room for & initialize val
|
||||
pea 0
|
||||
pea 0
|
||||
pea 0
|
||||
pea 0 make room for & initialize negative
|
||||
pha make room for & initialize val
|
||||
pha
|
||||
pha
|
||||
pha
|
||||
pha make room for & initialize negative
|
||||
tsc set up direct page addressing
|
||||
phd
|
||||
tcd
|
||||
|
@ -1263,10 +1363,10 @@ cn1 cmp #'+' else if the char is '+' then
|
|||
bne cn3
|
||||
cn2 inc4 str ++str
|
||||
|
||||
cn3 ph4 str save the starting string
|
||||
ph2 base convert the unsigned number
|
||||
ph4 ptr
|
||||
ph4 str
|
||||
cn3 ph4 <str save the starting string
|
||||
ph2 <base convert the unsigned number
|
||||
ph4 <ptr
|
||||
ph4 <str
|
||||
tdc
|
||||
clc
|
||||
adc #val
|
||||
|
@ -1369,15 +1469,16 @@ foundOne equ 1 have we found a number?
|
|||
~strtoull entry alt entry point called from strtoll
|
||||
ldy #1
|
||||
|
||||
init pea 0 make room for & initialize retptr
|
||||
init lda #0
|
||||
pha make room for & initialize retptr
|
||||
phx
|
||||
pea 1 make room for & initialize rangeOK
|
||||
pea 0 make room for & initialize negative
|
||||
pea 0 make room for & initialize val
|
||||
pea 0
|
||||
pea 0
|
||||
pea 0
|
||||
pea 0 make room for & initialize foundOne
|
||||
pha make room for & initialize negative
|
||||
pha make room for & initialize val
|
||||
pha
|
||||
pha
|
||||
pha
|
||||
pha make room for & initialize foundOne
|
||||
tsc set up direct page addressing
|
||||
phd
|
||||
tcd
|
||||
|
@ -1473,7 +1574,7 @@ cn3 cmp base branch if the digit is too big
|
|||
pea 0
|
||||
pea 0
|
||||
pea 0
|
||||
ph2 base
|
||||
ph2 <base
|
||||
jsl ~UMUL8
|
||||
pl8 val
|
||||
pla get the saved digit
|
||||
|
@ -1483,16 +1584,13 @@ cn3 cmp base branch if the digit is too big
|
|||
cn3a clc add in the new digit
|
||||
adc 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
|
||||
inc val+2
|
||||
bne cn4
|
||||
inc val+4
|
||||
bne cn4
|
||||
inc val+6
|
||||
bne cn4
|
||||
stz rangeOK
|
||||
cn4 inc4 str next char
|
||||
bra cn1
|
||||
|
@ -1610,8 +1708,37 @@ empty ds 2
|
|||
|
||||
****************************************************************
|
||||
*
|
||||
* void __va_end(list)
|
||||
* va_list list;
|
||||
* void __record_va_info(va_list ap);
|
||||
*
|
||||
* Record that a traversal of variable arguments has finished.
|
||||
* Data is recorded in the internal va info that will be used
|
||||
* to remove variable arguments at the end of the function.
|
||||
*
|
||||
* Inputs:
|
||||
* ap - the va_list
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__record_va_info start
|
||||
va_info_ptr equ 1 pointer to the internal va info
|
||||
|
||||
csubroutine (4:ap),4
|
||||
ldy #4 get pointer to internal va info
|
||||
lda [ap],y
|
||||
sta va_info_ptr
|
||||
stz va_info_ptr+2
|
||||
|
||||
lda [ap] update end of variable arguments
|
||||
cmp [va_info_ptr]
|
||||
blt ret
|
||||
sta [va_info_ptr]
|
||||
|
||||
ret creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* void __va_end(internal_va_info *list);
|
||||
*
|
||||
* Remove variable length arguments from the stack.
|
||||
*
|
||||
|
|
181
stdlib.macros
181
stdlib.macros
|
@ -1,4 +1,95 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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
|
||||
&l negate8 &n1
|
||||
&l ~setm
|
||||
sec
|
||||
|
@ -459,84 +550,6 @@
|
|||
.C
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 PL4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
@ -721,3 +734,15 @@
|
|||
&l bne *+5
|
||||
brl &bp
|
||||
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
|
||||
|
|
2659
string.asm
2659
string.asm
File diff suppressed because it is too large
Load Diff
111
string.macros
111
string.macros
|
@ -1,3 +1,56 @@
|
|||
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 MOVE4 &F,&T
|
||||
&LAB ~SETM
|
||||
|
@ -458,52 +511,6 @@
|
|||
.I
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 SHORT &A,&B
|
||||
LCLB &I
|
||||
LCLB &M
|
||||
|
@ -555,3 +562,15 @@
|
|||
&l bne *+5
|
||||
brl &bp
|
||||
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
|
||||
|
|
245
time.macros
245
time.macros
|
@ -1,3 +1,94 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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 MOVE4 &F,&T
|
||||
&LAB ~SETM
|
||||
|
@ -386,11 +477,6 @@
|
|||
~&SYSCNT ~RESTM
|
||||
MEND
|
||||
MACRO
|
||||
&LAB JLT &BP
|
||||
&LAB BGE *+5
|
||||
BRL &BP
|
||||
MEND
|
||||
MACRO
|
||||
&LAB LLA &AD1,&AD2
|
||||
&LAB ANOP
|
||||
LCLA &L
|
||||
|
@ -418,52 +504,6 @@
|
|||
.D
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 PL4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
@ -517,44 +557,6 @@
|
|||
&l blt &bp
|
||||
beq &bp
|
||||
mend
|
||||
macro
|
||||
&l ph2 &n1
|
||||
aif "&n1"="*",.f
|
||||
lclc &c
|
||||
&l anop
|
||||
&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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
MACRO
|
||||
&lab _ReadBParam
|
||||
&lab ldx #$0C03
|
||||
|
@ -600,3 +602,68 @@
|
|||
longi off
|
||||
.c
|
||||
mend
|
||||
macro
|
||||
&l dec4 &a
|
||||
&l ~setm
|
||||
lda &a
|
||||
bne ~&SYSCNT
|
||||
dec 2+&a
|
||||
~&SYSCNT dec &a
|
||||
~restm
|
||||
mend
|
||||
MACRO
|
||||
&LAB _INT2DEC
|
||||
&LAB LDX #$260B
|
||||
JSL $E10000
|
||||
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
|
||||
|
|
86
toolglue.asm
86
toolglue.asm
|
@ -68,10 +68,10 @@ addr equ 1 work pointer
|
|||
pha
|
||||
pha
|
||||
pha
|
||||
ph2 aRegValue
|
||||
ph2 xRegValue
|
||||
ph2 yRegValue
|
||||
ph2 eModeEntryPt
|
||||
ph2 <aRegValue
|
||||
ph2 <xRegValue
|
||||
ph2 <yRegValue
|
||||
ph2 <eModeEntryPt
|
||||
_FWEntry
|
||||
sta >~TOOLERROR
|
||||
pl2 >yRegExit
|
||||
|
@ -206,6 +206,44 @@ yPos ds 2
|
|||
xPos ds 2
|
||||
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
|
||||
|
@ -278,8 +316,8 @@ addr equ 1
|
|||
sec
|
||||
sbc #8
|
||||
tcs
|
||||
ph4 dividend
|
||||
ph4 divisor
|
||||
ph4 <dividend
|
||||
ph4 <divisor
|
||||
_LongDivide
|
||||
sta >~TOOLERROR
|
||||
pl4 >quotient
|
||||
|
@ -313,8 +351,8 @@ addr equ 1
|
|||
sec
|
||||
sbc #8
|
||||
tcs
|
||||
ph4 multiplicand
|
||||
ph4 multiplier
|
||||
ph4 <multiplicand
|
||||
ph4 <multiplier
|
||||
_LongMul
|
||||
sta >~TOOLERROR
|
||||
pl4 >lsResult
|
||||
|
@ -346,8 +384,8 @@ addr equ 1
|
|||
|
||||
pha
|
||||
pha
|
||||
ph2 dividend
|
||||
ph2 divisor
|
||||
ph2 <dividend
|
||||
ph2 <divisor
|
||||
_SDivide
|
||||
sta >~TOOLERROR
|
||||
pl2 >quotient
|
||||
|
@ -379,8 +417,8 @@ addr equ 1
|
|||
|
||||
pha
|
||||
pha
|
||||
ph2 dividend
|
||||
ph2 divisor
|
||||
ph2 <dividend
|
||||
ph2 <divisor
|
||||
_UDivide
|
||||
sta >~TOOLERROR
|
||||
pl2 >quotient
|
||||
|
@ -421,9 +459,9 @@ addr equ 1
|
|||
sec
|
||||
sbc #10
|
||||
tcs
|
||||
ph2 uID
|
||||
ph4 stAddr
|
||||
ph2 dpAddr
|
||||
ph2 <uID
|
||||
ph4 <stAddr
|
||||
ph2 <dpAddr
|
||||
_InitialLoad
|
||||
sta >~TOOLERROR
|
||||
pl2 >userID
|
||||
|
@ -464,10 +502,10 @@ addr equ 1
|
|||
sec
|
||||
sbc #10
|
||||
tcs
|
||||
ph2 uID
|
||||
ph4 buffAddr
|
||||
ph2 flagWord
|
||||
ph2 inputType
|
||||
ph2 <uID
|
||||
ph4 <buffAddr
|
||||
ph2 <flagWord
|
||||
ph2 <inputType
|
||||
_InitialLoad2
|
||||
sta >~TOOLERROR
|
||||
pl2 >userID
|
||||
|
@ -508,9 +546,9 @@ addr equ 1
|
|||
sec
|
||||
sbc #10
|
||||
tcs
|
||||
ph2 uID
|
||||
ph4 fName
|
||||
ph4 sName
|
||||
ph2 <uID
|
||||
ph4 <fName
|
||||
ph4 <sName
|
||||
_LoadSegName
|
||||
sta >~TOOLERROR
|
||||
pl4 >segAddr
|
||||
|
@ -551,7 +589,7 @@ addr equ 1
|
|||
sec
|
||||
sbc #10
|
||||
tcs
|
||||
ph2 uID
|
||||
ph2 <uID
|
||||
_Restart
|
||||
sta >~TOOLERROR
|
||||
pl2 >userID
|
||||
|
@ -590,7 +628,7 @@ addr equ 1
|
|||
pha
|
||||
pha
|
||||
pha
|
||||
ph4 segaddr
|
||||
ph4 <segaddr
|
||||
_UnloadSeg
|
||||
sta >~TOOLERROR
|
||||
pl2 >userID
|
||||
|
|
174
toolglue.macros
174
toolglue.macros
|
@ -1,3 +1,94 @@
|
|||
macro
|
||||
&l ph2 &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
|
||||
lda (&n1)
|
||||
pha
|
||||
ago .e
|
||||
.b
|
||||
aif "&c"="<",.c
|
||||
lda &n1
|
||||
pha
|
||||
ago .e
|
||||
.c
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pei &n1
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea &n1
|
||||
ago .f
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
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 LLA &AD1,&AD2
|
||||
&LAB ANOP
|
||||
|
@ -26,38 +117,6 @@
|
|||
.D
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PH2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
LDA (&N1)
|
||||
PHA
|
||||
AGO .E
|
||||
.B
|
||||
LDA &N1
|
||||
PHA
|
||||
AGO .E
|
||||
.D
|
||||
&N1 AMID &N1,2,L:&N1-1
|
||||
PEA &N1
|
||||
AGO .F
|
||||
.E
|
||||
AIF S:LONGA=1,.F
|
||||
SEP #%00100000
|
||||
.F
|
||||
MEXIT
|
||||
.G
|
||||
MNOTE "Missing closing '}'",16
|
||||
MEND
|
||||
MACRO
|
||||
&LAB PL2 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
@ -202,52 +261,6 @@
|
|||
rtl
|
||||
mend
|
||||
MACRO
|
||||
&LAB PH4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
&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
|
||||
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 PL4 &N1
|
||||
LCLC &C
|
||||
&LAB ANOP
|
||||
|
@ -371,3 +384,8 @@
|
|||
&lab ldx #$1F23
|
||||
jsl $E10000
|
||||
MEND
|
||||
MACRO
|
||||
&lab _ReadMouse2
|
||||
&lab ldx #$3303
|
||||
jsl $E10000
|
||||
MEND
|
||||
|
|
203
uchar.asm
Normal file
203
uchar.asm
Normal file
|
@ -0,0 +1,203 @@
|
|||
keep obj/uchar
|
||||
mcopy uchar.macros
|
||||
case on
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* UChar - Unicode utilities
|
||||
*
|
||||
* This code implements conversions to and from Unicode.
|
||||
* It assumes the multibyte character set is Mac OS Roman.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
uchar private
|
||||
copy equates.asm
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* size_t mbrtoc16(char16_t * pc16, const char * s, size_t n,
|
||||
* mbstate_t * ps);
|
||||
*
|
||||
* size_t mbrtoc32(char32_t * pc32, const char * s, size_t n,
|
||||
* mbstate_t * ps);
|
||||
*
|
||||
* Convert a multibyte character to UTF-16 or UTF-32.
|
||||
*
|
||||
* Inputs:
|
||||
* pc16 or pc32 - pointer to output location
|
||||
* s - pointer to multibyte character
|
||||
* n - maximum number of bytes to examine
|
||||
* ps - conversion state
|
||||
*
|
||||
* Outputs:
|
||||
* *pc16 or *pc32 - UTF-16 or UTF-32 code unit
|
||||
* Returns number of bytes in multibyte character or
|
||||
* 0 for null character.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
mbrtoc16 start
|
||||
clv v flag clear => doing mbrtoc16
|
||||
bra csub
|
||||
|
||||
mbrtoc32 entry
|
||||
sep #$40 v flag set => doing mbrtoc32
|
||||
|
||||
csub csubroutine (4:pc16,4:s,4:n,4:ps),0
|
||||
|
||||
lda s if s == NULL
|
||||
ora s+2
|
||||
bne check_n
|
||||
stz n call is equivalent to
|
||||
stz n+2 mbrtoc16(NULL, "", 1, ps),
|
||||
bra ret so return 0
|
||||
check_n lda n if n = 0
|
||||
ora n+2
|
||||
bne getchar
|
||||
dec a return (size_t)(-2)
|
||||
sta n+2
|
||||
dec a
|
||||
sta n
|
||||
bra ret
|
||||
getchar ldy #1 assume return value is 1
|
||||
lda [s] load character *s
|
||||
and #$00ff
|
||||
bne set_rv if *s == '\0'
|
||||
dey return value is 0
|
||||
set_rv sty n set return value
|
||||
stz n+2
|
||||
cmp #$0080 if *s is an ASCII character
|
||||
blt output store it as-is
|
||||
asl a else
|
||||
and #$00FF
|
||||
tax
|
||||
lda >macRomanToUCS,x convert it to Unicode
|
||||
output ldx pc16 if pc16 != NULL
|
||||
bne storeit
|
||||
ldx pc16+2
|
||||
beq ret
|
||||
storeit sta [pc16] store result to *pc16
|
||||
bvc ret if doing mbrtoc32
|
||||
lda #0
|
||||
ldy #2
|
||||
sta [pc16],y store 0 as high word of result
|
||||
|
||||
ret creturn 4:n
|
||||
end
|
||||
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* size_t c16rtomb(char * s, char16_t c16, mbstate_t * ps);
|
||||
*
|
||||
* Convert a UTF-16 code unit to a multibyte character.
|
||||
*
|
||||
* Inputs:
|
||||
* s - pointer to output location
|
||||
* c16 - UTF-16 code unit
|
||||
* ps - conversion state
|
||||
*
|
||||
* Outputs:
|
||||
* *s - converted character
|
||||
* Returns number of bytes stored, or -1 for error.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
c16rtomb start
|
||||
|
||||
csubroutine (4:s,2:c16,4:ps),0
|
||||
|
||||
lda s if s == NULL, call is equivalent to
|
||||
ora s+2 c16rtomb(internal_buf, 0, ps),
|
||||
beq return_1 so return 1
|
||||
lda c16 if c16 is an ASCII character
|
||||
cmp #$0080
|
||||
blt storeit store it as-is
|
||||
short I
|
||||
ldx #0
|
||||
cvt_loop lda >macRomanToUCS,x for each entry in macRomanToUCS
|
||||
cmp c16 if it matches c16
|
||||
beq gotit break and handle the mapping
|
||||
inx
|
||||
inx
|
||||
bne cvt_loop
|
||||
lda #EILSEQ if no mapping was found
|
||||
sta >errno errno = EILSEQ
|
||||
lda #-1 return -1
|
||||
sta s
|
||||
sta s+2
|
||||
long I
|
||||
bra ret
|
||||
gotit longi off
|
||||
txa if we found a mapping
|
||||
lsr a compute the MacRoman character
|
||||
ora #$0080
|
||||
storeit short M store the character
|
||||
sta [s]
|
||||
long M,I
|
||||
return_1 lda #1 return 1
|
||||
sta s
|
||||
stz s+2
|
||||
|
||||
ret creturn 4:s
|
||||
end
|
||||
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* size_t c32rtomb(char * s, char16_t c16, mbstate_t * ps);
|
||||
*
|
||||
* Convert a UTF-32 code unit to a multibyte character.
|
||||
*
|
||||
* Inputs:
|
||||
* s - pointer to output location
|
||||
* c16 - UTF-32 code unit
|
||||
* ps - conversion state
|
||||
*
|
||||
* Outputs:
|
||||
* *s - converted character
|
||||
* Returns number of bytes stored, or -1 for error.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
c32rtomb start
|
||||
|
||||
lda 10,s if char is outside the BMP
|
||||
beq fixstack
|
||||
lda #$FFFD substitute REPLACEMENT CHARACTER
|
||||
bra fs2
|
||||
|
||||
fixstack lda 8,s adjust stack for call to c16rtomb
|
||||
fs2 sta 10,s
|
||||
lda 6,s
|
||||
sta 8,s
|
||||
lda 4,s
|
||||
sta 6,s
|
||||
lda 2,s
|
||||
sta 4,s
|
||||
pla
|
||||
sta 1,s
|
||||
jml c16rtomb do the equivalent c16rtomb call
|
||||
end
|
||||
|
||||
|
||||
macRomanToUCS private
|
||||
dc i2'$00C4, $00C5, $00C7, $00C9, $00D1, $00D6, $00DC, $00E1'
|
||||
dc i2'$00E0, $00E2, $00E4, $00E3, $00E5, $00E7, $00E9, $00E8'
|
||||
dc i2'$00EA, $00EB, $00ED, $00EC, $00EE, $00EF, $00F1, $00F3'
|
||||
dc i2'$00F2, $00F4, $00F6, $00F5, $00FA, $00F9, $00FB, $00FC'
|
||||
dc i2'$2020, $00B0, $00A2, $00A3, $00A7, $2022, $00B6, $00DF'
|
||||
dc i2'$00AE, $00A9, $2122, $00B4, $00A8, $2260, $00C6, $00D8'
|
||||
dc i2'$221E, $00B1, $2264, $2265, $00A5, $00B5, $2202, $2211'
|
||||
dc i2'$220F, $03C0, $222B, $00AA, $00BA, $03A9, $00E6, $00F8'
|
||||
dc i2'$00BF, $00A1, $00AC, $221A, $0192, $2248, $2206, $00AB'
|
||||
dc i2'$00BB, $2026, $00A0, $00C0, $00C3, $00D5, $0152, $0153'
|
||||
dc i2'$2013, $2014, $201C, $201D, $2018, $2019, $00F7, $25CA'
|
||||
dc i2'$00FF, $0178, $2044, $00A4, $2039, $203A, $FB01, $FB02'
|
||||
dc i2'$2021, $00B7, $201A, $201E, $2030, $00C2, $00CA, $00C1'
|
||||
dc i2'$00CB, $00C8, $00CD, $00CE, $00CF, $00CC, $00D3, $00D4'
|
||||
dc i2'$F8FF, $00D2, $00DA, $00DB, $00D9, $0131, $02C6, $02DC'
|
||||
dc i2'$00AF, $02D8, $02D9, $02DA, $00B8, $02DD, $02DB, $02C7'
|
||||
end
|
|
@ -91,33 +91,43 @@
|
|||
.j
|
||||
rtl
|
||||
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
|
||||
&l long &a,&b
|
||||
lclb &i
|
||||
lclb &m
|
||||
&a amid &a,1,1
|
||||
&m setb ("&a"="M").or.("&a"="m")
|
||||
&i setb ("&a"="I").or.("&a"="i")
|
||||
aif c:&b=0,.a
|
||||
&b amid &b,1,1
|
||||
&m setb ("&b"="M").or.("&b"="m").or.&m
|
||||
&i setb ("&b"="I").or.("&b"="i").or.&i
|
||||
.a
|
||||
&l rep #&m*32+&i*16
|
||||
aif .not.&m,.b
|
||||
longa on
|
||||
.b
|
||||
aif .not.&i,.c
|
||||
longi on
|
||||
.c
|
||||
mend
|
||||
macro
|
||||
&l short &a,&b
|
||||
lclb &i
|
||||
lclb &m
|
||||
&a amid &a,1,1
|
||||
&m setb ("&a"="M").or.("&a"="m")
|
||||
&i setb ("&a"="I").or.("&a"="i")
|
||||
aif c:&b=0,.a
|
||||
&b amid &b,1,1
|
||||
&m setb ("&b"="M").or.("&b"="m").or.&m
|
||||
&i setb ("&b"="I").or.("&b"="i").or.&i
|
||||
.a
|
||||
&l sep #&m*32+&i*16
|
||||
aif .not.&m,.b
|
||||
longa off
|
||||
.b
|
||||
aif .not.&i,.c
|
||||
longi off
|
||||
.c
|
||||
mend
|
26
vars.asm
26
vars.asm
|
@ -23,7 +23,7 @@ Dummy start (dummy root segment)
|
|||
*
|
||||
****************************************************************
|
||||
*
|
||||
CVars start
|
||||
~CVars start
|
||||
|
||||
errno entry library error number
|
||||
ds 2
|
||||
|
@ -31,10 +31,12 @@ _ownerid entry user ID (C)
|
|||
~USER_ID entry user ID (Pascal, libraries)
|
||||
ds 2
|
||||
sys_nerr entry # of error messages
|
||||
dc i'12'
|
||||
dc i'13'
|
||||
_toolErr entry last error in a tool call (C)
|
||||
~TOOLERROR entry last error in a tool call (Pascal)
|
||||
ds 2
|
||||
__useTimeTool entry use Time Tool in <time.h> functions?
|
||||
ds 2
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -45,12 +47,12 @@ _toolErr entry last error in a tool call (C)
|
|||
*
|
||||
~InitIO start
|
||||
|
||||
ldx #24 set up the file records
|
||||
lb1 lda stderr+34,X
|
||||
ldx #sizeofFILE-4-2 set up the file records
|
||||
lb1 lda stderr+4+sizeofFILE,X
|
||||
sta stderr+8,X
|
||||
lda stdin+34,X
|
||||
lda stdin+4+sizeofFILE,X
|
||||
sta stdin+8,X
|
||||
lda stdout+34,X
|
||||
lda stdout+4+sizeofFILE,X
|
||||
sta stdout+8,X
|
||||
dex
|
||||
dex
|
||||
|
@ -77,7 +79,7 @@ lb1 dc a4'0' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file
|
||||
dc i'stderrID' error out
|
||||
|
||||
|
@ -86,7 +88,7 @@ lb1 dc a4'0' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file
|
||||
dc i'stderrID' error out
|
||||
end
|
||||
|
@ -107,7 +109,7 @@ lb1 dc a4'stdout+4' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOREAD+_IOTEXT' no buffering; allow reads; text file
|
||||
dc i'stdinID' standard in
|
||||
|
||||
|
@ -116,7 +118,7 @@ lb1 dc a4'stdout+4' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOREAD+_IOTEXT' no buffering; allow reads; text file
|
||||
dc i'stdinID' standard in
|
||||
end
|
||||
|
@ -137,7 +139,7 @@ lb1 dc a4'stderr+4' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file
|
||||
dc i'stdoutID' standard out
|
||||
|
||||
|
@ -146,7 +148,7 @@ lb1 dc a4'stderr+4' next file
|
|||
dc a4'0' end of the file buffer
|
||||
dc i4'0' size of the file buffer
|
||||
dc i4'0' count
|
||||
dc i'EOF' putback buffer
|
||||
dc i'EOF,EOF' putback buffer
|
||||
dc i'_IONBF+_IOWRT+_IOTEXT' no buffering; allow writes; text file
|
||||
dc i'stdoutID' standard out
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user