mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-06-14 03:29:41 +00:00
Compare commits
155 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 | ||
|
ee395c371b | ||
|
9937ef7003 | ||
|
869f8726a6 | ||
|
690ee7137f | ||
|
79201198a1 | ||
|
9e727697d3 | ||
|
98cfd4e831 | ||
|
07959d32eb | ||
|
0685ce71ca | ||
|
7e95f8b182 | ||
|
9af245933c | ||
|
52c011ab48 | ||
|
f9d7017687 | ||
|
81e152f863 | ||
|
6bf27c6743 | ||
|
91f0dcbdb9 | ||
|
7ad54827a3 | ||
|
a5d0172d82 | ||
|
c185face85 | ||
|
4f9b41938a | ||
|
cfc3fd3468 | ||
|
6626aad7f0 | ||
|
bc21593507 | ||
|
375d664ae1 | ||
|
2f68708b47 | ||
|
66e1835175 | ||
|
61bfc70b9b | ||
|
de9f830c0c | ||
|
23a27bd434 | ||
|
539707344a | ||
|
3ef9687b7e | ||
|
aa1351f84d | ||
|
506f9fa965 | ||
|
6635346ae8 | ||
|
b072f5d042 | ||
|
d1d0358e4b | ||
|
2bb5361c24 | ||
|
80dbf0c34c | ||
|
bd1e822a43 | ||
|
7c4141f03d | ||
|
71a25f0fef | ||
|
37c38a7077 |
35
assert.asm
35
assert.asm
|
@ -22,11 +22,12 @@ Assert start dummy routine
|
|||
|
||||
****************************************************************
|
||||
*
|
||||
* void __assert (char *f, int l)
|
||||
* void __assert (char *f, unsigned l, char *s)
|
||||
*
|
||||
* Inputs:
|
||||
* f - pointer to the file name
|
||||
* l - line number
|
||||
* s - assertion string
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
|
@ -44,5 +45,35 @@ __assert start
|
|||
|
||||
creturn
|
||||
|
||||
msg dc c'Assertion failed: file %s, line %d; assertion: %s',i1'10,0'
|
||||
msg dc c'Assertion failed: file %s, line %u; assertion: %s',i1'10,0'
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* void __assert2 (char *f, unsigned l, char *fn, char *s)
|
||||
*
|
||||
* Inputs:
|
||||
* f - pointer to the file name
|
||||
* l - line number
|
||||
* fn - function name
|
||||
* s - assertion string
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
__assert2 start
|
||||
|
||||
csubroutine (4:f,2:l,4:fn,4:s),0
|
||||
|
||||
ph4 <s
|
||||
ph4 <fn
|
||||
ph2 <l
|
||||
ph4 <f
|
||||
ph4 #msg
|
||||
ph4 >stderr
|
||||
jsl fprintf
|
||||
jsl abort
|
||||
|
||||
creturn
|
||||
|
||||
msg dc c'Assertion failed: file %s, line %u, function %s; assertion: %s',i1'10,0'
|
||||
end
|
||||
|
|
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
|
||||
|
|
517
int64.asm
Normal file
517
int64.asm
Normal file
|
@ -0,0 +1,517 @@
|
|||
keep obj/int64
|
||||
mcopy int64.macros
|
||||
case off
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* Int64 - 64-bit integer math routines.
|
||||
*
|
||||
* This code implements routines called by ORCA/C generated
|
||||
* code for operations on 64-bit integers.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
Int64 private dummy segment
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~UMUL8 - Eight Byte Unsigned Integer Multiply
|
||||
*
|
||||
* Inputs:
|
||||
* NUM1,NUM2 - operands
|
||||
*
|
||||
* Outputs:
|
||||
* NUM2 - result
|
||||
* X - next 16 bits of true result (bits 64-79)
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~UMUL8 START
|
||||
|
||||
ANS EQU 3
|
||||
RETURN EQU ANS+16
|
||||
NUM1 EQU RETURN+3
|
||||
NUM2 EQU NUM1+8
|
||||
|
||||
LDA #0 set up initial working value
|
||||
PHA
|
||||
PHA
|
||||
PHA
|
||||
PHA
|
||||
LDA 18,s initially, ANS = NUM1
|
||||
PHA
|
||||
LDA 18,s
|
||||
PHA
|
||||
LDA 18,s
|
||||
PHA
|
||||
LDA 18,s
|
||||
PHA
|
||||
PHD
|
||||
TSC
|
||||
TCD
|
||||
;
|
||||
; Do a 64 bit by 64 bit multiply.
|
||||
;
|
||||
LDY #64 64 bit multiply
|
||||
ML1 LDA ANS
|
||||
LSR A
|
||||
BCC ML2
|
||||
CLC add multiplicand to the partial product
|
||||
LDA ANS+8
|
||||
ADC NUM2
|
||||
STA ANS+8
|
||||
LDA ANS+10
|
||||
ADC NUM2+2
|
||||
STA ANS+10
|
||||
LDA ANS+12
|
||||
ADC NUM2+4
|
||||
STA ANS+12
|
||||
LDA ANS+14
|
||||
ADC NUM2+6
|
||||
STA ANS+14
|
||||
ML2 ROR ANS+14 shift the interim result
|
||||
ROR ANS+12
|
||||
ROR ANS+10
|
||||
ROR ANS+8
|
||||
ROR ANS+6
|
||||
ROR ANS+4
|
||||
ROR ANS+2
|
||||
ROR ANS
|
||||
DEY loop until done
|
||||
BNE ML1
|
||||
|
||||
move4 ANS,NUM2 move return value and address
|
||||
move4 ANS+4,NUM2+4
|
||||
move4 RETURN-1,NUM1+4
|
||||
LDX ANS+8 set X to next 16 bits of result
|
||||
PLD fix stack, DP
|
||||
TSC
|
||||
CLC
|
||||
ADC #24
|
||||
TCS
|
||||
RTL
|
||||
END
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~CDIV8 - Eight Byte Signed Integer Divide,
|
||||
* with C-style remainder computation
|
||||
*
|
||||
* Inputs:
|
||||
* NUM1 - numerator
|
||||
* NUM2 - denominator
|
||||
*
|
||||
* Outputs:
|
||||
* ANS - result
|
||||
* REM - remainder
|
||||
* V - set for division by zero
|
||||
*
|
||||
* Notes
|
||||
* 1) Uses ~SIG8.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~CDIV8 START
|
||||
SIGN EQU 1 sign of answer
|
||||
NUM1 EQU 36
|
||||
NUM2 EQU 28
|
||||
ANS EQU 9 answer
|
||||
REM EQU 17 remainder
|
||||
RETURN EQU 25
|
||||
;
|
||||
; Initialize
|
||||
;
|
||||
TSC set up DP
|
||||
SEC
|
||||
SBC #24
|
||||
TCS
|
||||
PHD
|
||||
TCD
|
||||
LDA NUM2 check for division by zero
|
||||
ORA NUM2+2
|
||||
ORA NUM2+4
|
||||
ORA NUM2+6
|
||||
BNE DV1
|
||||
|
||||
PLD division by zero
|
||||
TSC
|
||||
CLC
|
||||
ADC #24
|
||||
TCS
|
||||
SEP #%01000000
|
||||
RTL
|
||||
|
||||
DV1 JSL ~SIG8 convert to positive numbers
|
||||
;
|
||||
; 64 BIT DIVIDE
|
||||
;
|
||||
LDY #64 64 bits to go
|
||||
DV3 ASL ANS roll up the next number
|
||||
ROL ANS+2
|
||||
ROL ANS+4
|
||||
ROL ANS+6
|
||||
ROL ANS+8
|
||||
ROL ANS+10
|
||||
ROL ANS+12
|
||||
ROL ANS+14
|
||||
SEC subtract for this digit
|
||||
LDA ANS+8
|
||||
SBC NUM2
|
||||
TAX
|
||||
LDA ANS+10
|
||||
SBC NUM2+2
|
||||
STA SIGN+2
|
||||
LDA ANS+12
|
||||
SBC NUM2+4
|
||||
STA SIGN+4
|
||||
LDA ANS+14
|
||||
SBC NUM2+6
|
||||
BCC DV4 branch if minus
|
||||
STX ANS+8 save partial numerator
|
||||
STA ANS+14
|
||||
LDA SIGN+2
|
||||
STA ANS+10
|
||||
LDA SIGN+4
|
||||
STA ANS+12
|
||||
INC ANS turn the bit on
|
||||
DV4 DEY next bit
|
||||
BNE DV3
|
||||
;
|
||||
; SET SIGN
|
||||
;
|
||||
LDA SIGN branch if positive
|
||||
BEQ DV10
|
||||
SEC negate the result
|
||||
LDA #0
|
||||
SBC ANS
|
||||
STA ANS
|
||||
LDA #0
|
||||
SBC ANS+2
|
||||
STA ANS+2
|
||||
LDA #0
|
||||
SBC ANS+4
|
||||
STA ANS+4
|
||||
LDA #0
|
||||
SBC ANS+6
|
||||
STA ANS+6
|
||||
DV10 LDA NUM1+6 if numerator is negative
|
||||
BPL DV11
|
||||
SEC negate the remainder
|
||||
LDA #0
|
||||
SBC REM
|
||||
STA REM
|
||||
LDA #0
|
||||
SBC REM+2
|
||||
STA REM+2
|
||||
LDA #0
|
||||
SBC REM+4
|
||||
STA REM+4
|
||||
LDA #0
|
||||
SBC REM+6
|
||||
STA REM+6
|
||||
DV11 LDX #14 move answer, remainder to stack
|
||||
DV12 LDA ANS,X
|
||||
STA NUM2,X
|
||||
DEX
|
||||
DEX
|
||||
BPL DV12
|
||||
CLV
|
||||
PLD fix stack, DP
|
||||
TSC
|
||||
CLC
|
||||
ADC #24
|
||||
TCS
|
||||
RTL
|
||||
END
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~UDIV8 - Eight Byte Unsigned Integer Divide
|
||||
*
|
||||
* Inputs:
|
||||
* NUM1 - numerator
|
||||
* NUM2 - denominator
|
||||
*
|
||||
* Outputs:
|
||||
* ANS - result
|
||||
* REM - remainder
|
||||
* V - set for division by zero
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~UDIV8 START
|
||||
TEMP EQU 1
|
||||
NUM1 EQU 32
|
||||
NUM2 EQU 24
|
||||
ANS EQU 5 answer
|
||||
REM EQU 13 remainder
|
||||
RETURN EQU 21
|
||||
;
|
||||
; Initialize
|
||||
;
|
||||
TSC set up DP
|
||||
SEC
|
||||
SBC #20
|
||||
TCS
|
||||
PHD
|
||||
TCD
|
||||
LDA NUM2 check for division by zero
|
||||
ORA NUM2+2
|
||||
ORA NUM2+4
|
||||
ORA NUM2+6
|
||||
BNE DV1
|
||||
|
||||
PLD division by zero
|
||||
TSC
|
||||
CLC
|
||||
ADC #20
|
||||
TCS
|
||||
SEP #%01000000
|
||||
RTL
|
||||
|
||||
DV1 STZ REM initialize REM to 0
|
||||
STZ REM+2
|
||||
STZ REM+4
|
||||
STZ REM+6
|
||||
move4 NUM1,ANS initialize ANS to NUM1
|
||||
move4 NUM1+4,ANS+4
|
||||
;
|
||||
; 64 BIT DIVIDE
|
||||
;
|
||||
LDY #64 64 bits to go
|
||||
DV3 ASL ANS roll up the next number
|
||||
ROL ANS+2
|
||||
ROL ANS+4
|
||||
ROL ANS+6
|
||||
ROL ANS+8
|
||||
ROL ANS+10
|
||||
ROL ANS+12
|
||||
ROL ANS+14
|
||||
SEC subtract for this digit
|
||||
LDA ANS+8
|
||||
SBC NUM2
|
||||
TAX
|
||||
LDA ANS+10
|
||||
SBC NUM2+2
|
||||
STA TEMP
|
||||
LDA ANS+12
|
||||
SBC NUM2+4
|
||||
STA TEMP+2
|
||||
LDA ANS+14
|
||||
SBC NUM2+6
|
||||
BCC DV4 branch if minus
|
||||
STX ANS+8 save partial numerator
|
||||
STA ANS+14
|
||||
LDA TEMP
|
||||
STA ANS+10
|
||||
LDA TEMP+2
|
||||
STA ANS+12
|
||||
INC ANS turn the bit on
|
||||
DV4 DEY next bit
|
||||
BNE DV3
|
||||
|
||||
DV10 LDX #14 move answer, remainder to stack
|
||||
DV11 LDA ANS,X
|
||||
STA NUM2,X
|
||||
DEX
|
||||
DEX
|
||||
BPL DV11
|
||||
CLV
|
||||
PLD fix stack, DP
|
||||
TSC
|
||||
CLC
|
||||
ADC #20
|
||||
TCS
|
||||
RTL
|
||||
END
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~SCMP8 - Eight Byte Signed Integer Compare
|
||||
*
|
||||
* Inputs:
|
||||
* NUM1 - first argument
|
||||
* NUM2 - second argument
|
||||
*
|
||||
* Outputs:
|
||||
* C - set if NUM1 >= NUM2, else clear
|
||||
* Z - set if NUM1 = NUM2, else clear
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~SCMP8 START
|
||||
NUM1 EQU 12 first argument
|
||||
NUM2 EQU 4 second argument
|
||||
RETURN EQU 0 P reg and return addr
|
||||
|
||||
TDC set up DP
|
||||
TAX
|
||||
TSC
|
||||
TCD
|
||||
LDA NUM1+6 if numbers are of opposite sign then
|
||||
EOR NUM2+6
|
||||
BPL LB1
|
||||
LDA NUM2+6 reverse sense of compare
|
||||
CMP NUM1+6
|
||||
BRA LB2 else
|
||||
LB1 LDA NUM1+6 compare numbers
|
||||
CMP NUM2+6
|
||||
BNE LB2
|
||||
LDA NUM1+4
|
||||
CMP NUM2+4
|
||||
BNE LB2
|
||||
LDA NUM1+2
|
||||
CMP NUM2+2
|
||||
BNE LB2
|
||||
LDA NUM1
|
||||
CMP NUM2
|
||||
LB2 ANOP endif
|
||||
PHP save result
|
||||
LDA RETURN move P and return addr
|
||||
STA NUM1+4
|
||||
LDA RETURN+2
|
||||
STA NUM1+6
|
||||
CLC remove 16 bytes from stack
|
||||
TSC
|
||||
ADC #16
|
||||
TCS
|
||||
TXA restore DP
|
||||
TCD
|
||||
PLP restore P
|
||||
RTL return
|
||||
END
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~LShr8 - Shift an unsigned long long value right
|
||||
*
|
||||
* Inputs:
|
||||
* num1 - value to shift
|
||||
* A - # of bits to shift by
|
||||
*
|
||||
* Outputs:
|
||||
* num1 - result
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~LShr8 start
|
||||
num1 equ 4
|
||||
|
||||
tax save shift count
|
||||
beq rtl return if it is 0
|
||||
|
||||
tsc
|
||||
phd
|
||||
tcd
|
||||
|
||||
txa
|
||||
loop0 cmp #16 shift by 16s first
|
||||
blt loop1
|
||||
ldy num1+2
|
||||
sty num1
|
||||
ldy num1+4
|
||||
sty num1+2
|
||||
ldy num1+6
|
||||
sty num1+4
|
||||
stz num1+6
|
||||
; sec
|
||||
sbc #16
|
||||
bne loop0
|
||||
bra rt0
|
||||
|
||||
loop1 lsr num1+6 do the remaining shift
|
||||
ror num1+4
|
||||
ror num1+2
|
||||
ror num1
|
||||
dec a
|
||||
bne loop1
|
||||
|
||||
rt0 pld
|
||||
rtl rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~AShr8 - Shift a signed long long value right
|
||||
*
|
||||
* Inputs:
|
||||
* num1 - value to shift
|
||||
* A - # of bits to shift by
|
||||
*
|
||||
* Outputs:
|
||||
* num1 - result
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~AShr8 start
|
||||
num1 equ 4
|
||||
|
||||
tax save shift count
|
||||
beq rtl return if it is 0
|
||||
|
||||
tsc
|
||||
phd
|
||||
tcd
|
||||
|
||||
loop1 lda num1+6 do the shift
|
||||
asl a
|
||||
ror num1+6
|
||||
ror num1+4
|
||||
ror num1+2
|
||||
ror num1
|
||||
dex
|
||||
bne loop1
|
||||
|
||||
pld
|
||||
rtl rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ~Shl8 - Shift a signed long long value left
|
||||
*
|
||||
* Inputs:
|
||||
* num1 - value to shift
|
||||
* A - # of bits to shift by
|
||||
*
|
||||
* Outputs:
|
||||
* num1 - result
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
~Shl8 start
|
||||
num1 equ 4
|
||||
|
||||
tax save shift count
|
||||
beq rtl return if it is 0
|
||||
|
||||
tsc
|
||||
phd
|
||||
tcd
|
||||
|
||||
txa
|
||||
loop0 cmp #16 shift by 16s first
|
||||
blt loop1
|
||||
ldy num1+4
|
||||
sty num1+6
|
||||
ldy num1+2
|
||||
sty num1+4
|
||||
ldy num1
|
||||
sty num1+2
|
||||
stz num1
|
||||
; sec
|
||||
sbc #16
|
||||
bne loop0
|
||||
bra rt0
|
||||
|
||||
loop1 asl num1 do the remaining shift
|
||||
rol num1+2
|
||||
rol num1+4
|
||||
rol num1+6
|
||||
dec a
|
||||
bne loop1
|
||||
|
||||
rt0 pld
|
||||
rtl rtl
|
||||
end
|
123
int64.macros
Normal file
123
int64.macros
Normal file
|
@ -0,0 +1,123 @@
|
|||
macro
|
||||
&l move4 &m1,&m2
|
||||
lclb &yistwo
|
||||
&l ~setm
|
||||
~lda &m1
|
||||
~sta &m2
|
||||
~lda.h &m1
|
||||
~sta.h &m2
|
||||
~restm
|
||||
mend
|
||||
macro
|
||||
&l ~lda &op
|
||||
lclc &c
|
||||
&c amid "&op",1,1
|
||||
aif "&c"<>"{",.b
|
||||
&c amid "&op",l:&op,1
|
||||
aif "&c"="}",.a
|
||||
mnote "Missing closing '}'",2
|
||||
&op setc &op}
|
||||
.a
|
||||
&op amid "&op",2,l:&op-2
|
||||
&op setc (&op)
|
||||
.b
|
||||
&l lda &op
|
||||
mend
|
||||
macro
|
||||
&l ~lda.h &op
|
||||
&l anop
|
||||
lclc &c
|
||||
&c amid "&op",1,1
|
||||
aif "&c"="[",.b
|
||||
aif "&c"<>"{",.d
|
||||
&c amid "&op",l:&op,1
|
||||
aif "&c"="}",.a
|
||||
mnote "Missing closing '}'",2
|
||||
&op setc &op}
|
||||
.a
|
||||
&op amid "&op",2,l:&op-2
|
||||
&op setc (&op)
|
||||
.b
|
||||
aif &yistwo,.c
|
||||
&yistwo setb 1
|
||||
ldy #2
|
||||
.c
|
||||
&op setc "&op,y"
|
||||
lda &op
|
||||
mexit
|
||||
.d
|
||||
aif "&c"<>"#",.e
|
||||
&op amid "&op",2,l:&op-1
|
||||
&op setc "#^&op"
|
||||
lda &op
|
||||
mexit
|
||||
.e
|
||||
lda 2+&op
|
||||
mend
|
||||
macro
|
||||
&l ~restm
|
||||
&l anop
|
||||
aif (&~la+&~li)=2,.i
|
||||
sep #32*(.not.&~la)+16*(.not.&~li)
|
||||
aif &~la,.h
|
||||
longa off
|
||||
.h
|
||||
aif &~li,.i
|
||||
longi off
|
||||
.i
|
||||
mend
|
||||
macro
|
||||
&l ~setm
|
||||
&l anop
|
||||
aif c:&~la,.b
|
||||
gblb &~la
|
||||
gblb &~li
|
||||
.b
|
||||
&~la setb s:longa
|
||||
&~li setb s:longi
|
||||
aif s:longa.and.s:longi,.a
|
||||
rep #32*(.not.&~la)+16*(.not.&~li)
|
||||
longa on
|
||||
longi on
|
||||
.a
|
||||
mend
|
||||
macro
|
||||
&l ~sta &op
|
||||
lclc &c
|
||||
&c amid "&op",1,1
|
||||
aif "&c"<>"{",.b
|
||||
&c amid "&op",l:&op,1
|
||||
aif "&c"="}",.a
|
||||
mnote "Missing closing '}'",2
|
||||
&op setc &op}
|
||||
.a
|
||||
&op amid "&op",2,l:&op-2
|
||||
&op setc (&op)
|
||||
.b
|
||||
&l sta &op
|
||||
mend
|
||||
macro
|
||||
&l ~sta.h &op
|
||||
&l anop
|
||||
lclc &c
|
||||
&c amid "&op",1,1
|
||||
aif "&c"="[",.b
|
||||
aif "&c"<>"{",.d
|
||||
&c amid "&op",l:&op,1
|
||||
aif "&c"="}",.a
|
||||
mnote "Missing closing '}'",2
|
||||
&op setc &op}
|
||||
.a
|
||||
&op amid "&op",2,l:&op-2
|
||||
&op setc (&op)
|
||||
.b
|
||||
aif &yistwo,.c
|
||||
&yistwo setb 1
|
||||
ldy #2
|
||||
.c
|
||||
&op setc "&op,y"
|
||||
sta &op
|
||||
mexit
|
||||
.d
|
||||
sta 2+&op
|
||||
mend
|
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
|
93
locale.macros
Normal file
93
locale.macros
Normal file
|
@ -0,0 +1,93 @@
|
|||
MACRO
|
||||
&lab csubroutine &parms,&work
|
||||
&lab anop
|
||||
aif c:&work,.a
|
||||
lclc &work
|
||||
&work setc 0
|
||||
.a
|
||||
gbla &totallen
|
||||
gbla &worklen
|
||||
&worklen seta &work
|
||||
&totallen seta 0
|
||||
aif c:&parms=0,.e
|
||||
lclc &len
|
||||
lclc &p
|
||||
lcla &i
|
||||
&i seta 1
|
||||
.b
|
||||
&p setc &parms(&i)
|
||||
&len amid &p,2,1
|
||||
aif "&len"=":",.c
|
||||
&len amid &p,1,2
|
||||
&p amid &p,4,l:&p-3
|
||||
ago .d
|
||||
.c
|
||||
&len amid &p,1,1
|
||||
&p amid &p,3,l:&p-2
|
||||
.d
|
||||
&p equ &totallen+4+&work
|
||||
&totallen seta &totallen+&len
|
||||
&i seta &i+1
|
||||
aif &i<=c:&parms,^b
|
||||
.e
|
||||
tsc
|
||||
aif &work=0,.f
|
||||
sec
|
||||
sbc #&work
|
||||
tcs
|
||||
.f
|
||||
phd
|
||||
tcd
|
||||
mend
|
||||
MACRO
|
||||
&lab creturn &r
|
||||
&lab anop
|
||||
lclc &len
|
||||
aif c:&r,.a
|
||||
lclc &r
|
||||
&r setc 0
|
||||
&len setc 0
|
||||
ago .h
|
||||
.a
|
||||
&len amid &r,2,1
|
||||
aif "&len"=":",.b
|
||||
&len amid &r,1,2
|
||||
&r amid &r,4,l:&r-3
|
||||
ago .c
|
||||
.b
|
||||
&len amid &r,1,1
|
||||
&r amid &r,3,l:&r-2
|
||||
.c
|
||||
aif &len<>2,.d
|
||||
ldy &r
|
||||
ago .h
|
||||
.d
|
||||
aif &len<>4,.e
|
||||
ldx &r+2
|
||||
ldy &r
|
||||
ago .h
|
||||
.e
|
||||
aif &len<>10,.g
|
||||
ldy #&r
|
||||
ldx #^&r
|
||||
ago .h
|
||||
.g
|
||||
mnote 'Not a valid return length',16
|
||||
mexit
|
||||
.h
|
||||
aif &totallen=0,.i
|
||||
lda &worklen+2
|
||||
sta &worklen+&totallen+2
|
||||
lda &worklen+1
|
||||
sta &worklen+&totallen+1
|
||||
.i
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #&worklen+&totallen
|
||||
tcs
|
||||
aif &len=0,.j
|
||||
tya
|
||||
.j
|
||||
rtl
|
||||
mend
|
81
m16.int64
Normal file
81
m16.int64
Normal file
|
@ -0,0 +1,81 @@
|
|||
;
|
||||
; New and improved macros for operations on 64-bit integers
|
||||
;
|
||||
|
||||
; Negate a 64-bit value (DP, absolute, or absolute long)
|
||||
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
|
||||
|
||||
|
||||
; Improved ph8 macro:
|
||||
; - Generates more effecient code for constants
|
||||
; - Supports "ph8 <dp" to get better code using pei
|
||||
macro
|
||||
&l ph8 &n1
|
||||
lclc &c
|
||||
&l anop
|
||||
&c amid &n1,1,1
|
||||
aif s:longa=1,.a
|
||||
rep #%00100000
|
||||
.a
|
||||
aif "&c"="#",.d
|
||||
aif "&c"="[",.b
|
||||
aif "&c"<>"{",.c
|
||||
&c amid &n1,l:&n1,1
|
||||
aif "&c"<>"}",.g
|
||||
&n1 amid &n1,2,l:&n1-2
|
||||
&n1 setc (&n1)
|
||||
.b
|
||||
ldy #6
|
||||
~&SYSCNT lda &n1,y
|
||||
pha
|
||||
dey
|
||||
dey
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.c
|
||||
aif "&c"<>"<",.c1
|
||||
pei &n1+6
|
||||
pei &n1+4
|
||||
pei &n1+2
|
||||
pei &n1
|
||||
ago .e
|
||||
.c1
|
||||
ldx #6
|
||||
~&SYSCNT lda &n1,x
|
||||
pha
|
||||
dex
|
||||
dex
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea +(&n1)|-48
|
||||
pea +(&n1)|-32
|
||||
pea +(&n1)|-16
|
||||
pea &n1
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
5
make
5
make
|
@ -19,7 +19,7 @@ if {#} == 0
|
|||
unset exit
|
||||
end
|
||||
|
||||
for i in cc ctype string stdlib time setjmp orca fcntl vars toolglue signal
|
||||
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
|
||||
|
@ -39,7 +39,8 @@ echo delete orcalib
|
|||
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
|
||||
set list {list} time.a signal.a toolglue.a orca.a fcntl.a stdio.a int64.a
|
||||
set list {list} locale.a uchar.a
|
||||
for i in {list}
|
||||
echo makelib orcalib +obj/{i}
|
||||
makelib orcalib +obj/{i}
|
||||
|
|
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
|
||||
|
|
427
stdio.macros
427
stdio.macros
|
@ -1,3 +1,165 @@
|
|||
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
|
||||
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 ph8 &n1
|
||||
lclc &c
|
||||
&l anop
|
||||
&c amid &n1,1,1
|
||||
aif s:longa=1,.a
|
||||
rep #%00100000
|
||||
.a
|
||||
aif "&c"="#",.d
|
||||
aif "&c"="[",.b
|
||||
aif "&c"<>"{",.c
|
||||
&c amid &n1,l:&n1,1
|
||||
aif "&c"<>"}",.g
|
||||
&n1 amid &n1,2,l:&n1-2
|
||||
&n1 setc (&n1)
|
||||
.b
|
||||
ldy #6
|
||||
~&SYSCNT lda &n1,y
|
||||
pha
|
||||
dey
|
||||
dey
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.c
|
||||
aif "&c"<>"<",.c1
|
||||
pei &n1+6
|
||||
pei &n1+4
|
||||
pei &n1+2
|
||||
pei &n1
|
||||
ago .e
|
||||
.c1
|
||||
ldx #6
|
||||
~&SYSCNT lda &n1,x
|
||||
pha
|
||||
dex
|
||||
dex
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea +(&n1)|-48
|
||||
pea +(&n1)|-32
|
||||
pea +(&n1)|-16
|
||||
pea &n1
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
MACRO
|
||||
&lab cstr &s
|
||||
&lab dc c"&s",i1'0'
|
||||
|
@ -256,42 +418,6 @@
|
|||
~RESTM
|
||||
MEND
|
||||
MACRO
|
||||
&LAB SUB4 &M1,&M2,&M3
|
||||
LCLB &YISTWO
|
||||
LCLC &C
|
||||
&LAB ~SETM
|
||||
AIF C:&M3,.A
|
||||
&C AMID "&M2",1,1
|
||||
AIF "&C"<>"#",.A
|
||||
&C AMID "&M1",1,1
|
||||
AIF "&C"="{",.A
|
||||
AIF "&C"="[",.A
|
||||
&C AMID "&M2",2,L:&M2-1
|
||||
AIF &C>=65536,.A
|
||||
SEC
|
||||
~LDA &M1
|
||||
~OP SBC,&M2
|
||||
~STA &M1
|
||||
BCS ~&SYSCNT
|
||||
~OP.H DEC,&M1
|
||||
~&SYSCNT ANOP
|
||||
AGO .C
|
||||
.A
|
||||
AIF C:&M3,.B
|
||||
LCLC &M3
|
||||
&M3 SETC &M1
|
||||
.B
|
||||
SEC
|
||||
~LDA &M1
|
||||
~OP SBC,&M2
|
||||
~STA &M3
|
||||
~LDA.H &M1
|
||||
~OP.H SBC,&M2
|
||||
~STA.H &M3
|
||||
.C
|
||||
~RESTM
|
||||
MEND
|
||||
MACRO
|
||||
&LAB ~OP.H &OPC,&OP
|
||||
&LAB ANOP
|
||||
LCLC &C
|
||||
|
@ -534,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
|
||||
|
@ -775,3 +823,154 @@
|
|||
dc i2'$2002'
|
||||
dc i4'&p'
|
||||
mend
|
||||
macro
|
||||
&l pl8 &n1
|
||||
lclc &c
|
||||
&l anop
|
||||
aif s:longa=1,.a
|
||||
rep #%00100000
|
||||
.a
|
||||
&c amid &n1,1,1
|
||||
aif "&c"<>"{",.b
|
||||
&c amid &n1,l:&n1,1
|
||||
aif "&c"<>"}",.f
|
||||
&n1 amid &n1,2,l:&n1-2
|
||||
pla
|
||||
sta (&n1)
|
||||
ldy #2
|
||||
pla
|
||||
sta (&n1),y
|
||||
ldy #4
|
||||
pla
|
||||
sta (&n1),y
|
||||
ldy #6
|
||||
pla
|
||||
sta (&n1),y
|
||||
ago .d
|
||||
.b
|
||||
aif "&c"<>"[",.c
|
||||
pla
|
||||
sta &n1
|
||||
ldy #2
|
||||
pla
|
||||
sta &n1,y
|
||||
ldy #4
|
||||
pla
|
||||
sta &n1,y
|
||||
ldy #6
|
||||
pla
|
||||
sta &n1,y
|
||||
ago .d
|
||||
.c
|
||||
pla
|
||||
sta &n1
|
||||
pla
|
||||
sta &n1+2
|
||||
pla
|
||||
sta &n1+4
|
||||
pla
|
||||
sta &n1+6
|
||||
.d
|
||||
aif s:longa=1,.e
|
||||
sep #%00100000
|
||||
.e
|
||||
mexit
|
||||
.f
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
macro
|
||||
&l jpl &bp
|
||||
&l bmi *+5
|
||||
brl &bp
|
||||
mend
|
||||
macro
|
||||
&l lret &r
|
||||
&l anop
|
||||
lclc &len
|
||||
aif c:&r,.a
|
||||
lclc &r
|
||||
&r setc 0
|
||||
&len setc 0
|
||||
ago .h
|
||||
.a
|
||||
&len amid &r,2,1
|
||||
aif "&len"=":",.b
|
||||
&len amid &r,1,2
|
||||
&r amid &r,4,l:&r-3
|
||||
ago .c
|
||||
.b
|
||||
&len amid &r,1,1
|
||||
&r amid &r,3,l:&r-2
|
||||
.c
|
||||
aif &len<>2,.d
|
||||
ldy &r
|
||||
ago .h
|
||||
.d
|
||||
aif &len<>4,.e
|
||||
ldx &r+2
|
||||
ldy &r
|
||||
ago .h
|
||||
.e
|
||||
aif &len<>10,.g
|
||||
ldy #&r
|
||||
ldx #^&r
|
||||
ago .h
|
||||
.g
|
||||
mnote 'Not a valid return length',16
|
||||
mexit
|
||||
.h
|
||||
aif &totallen=0,.i
|
||||
lda &worklen+1
|
||||
sta &worklen+&totallen+1
|
||||
.i
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #&worklen+&totallen
|
||||
tcs
|
||||
aif &len=0,.j
|
||||
tya
|
||||
.j
|
||||
rts
|
||||
mend
|
||||
macro
|
||||
&l lsub &parms,&work
|
||||
&l anop
|
||||
aif c:&work,.a
|
||||
lclc &work
|
||||
&work setc 0
|
||||
.a
|
||||
gbla &totallen
|
||||
gbla &worklen
|
||||
&worklen seta &work
|
||||
&totallen seta 0
|
||||
aif c:&parms=0,.e
|
||||
lclc &len
|
||||
lclc &p
|
||||
lcla &i
|
||||
&i seta c:&parms
|
||||
.b
|
||||
&p setc &parms(&i)
|
||||
&len amid &p,2,1
|
||||
aif "&len"=":",.c
|
||||
&len amid &p,1,2
|
||||
&p amid &p,4,l:&p-3
|
||||
ago .d
|
||||
.c
|
||||
&len amid &p,1,1
|
||||
&p amid &p,3,l:&p-2
|
||||
.d
|
||||
&p equ &totallen+3+&work
|
||||
&totallen seta &totallen+&len
|
||||
&i seta &i-1
|
||||
aif &i,^b
|
||||
.e
|
||||
tsc
|
||||
aif &work=0,.f
|
||||
sec
|
||||
sbc #&work
|
||||
tcs
|
||||
.f
|
||||
phd
|
||||
tcd
|
||||
mend
|
||||
|
|
705
stdlib.asm
705
stdlib.asm
|
@ -4,10 +4,10 @@
|
|||
|
||||
****************************************************************
|
||||
*
|
||||
* StdDef - Standard Definitions
|
||||
* StdLib - Standard Library Utility Functions
|
||||
*
|
||||
* This code implements the tables and subroutines needed to
|
||||
* support the standard C library STDDEF.
|
||||
* support the standard C library STDLIB.
|
||||
*
|
||||
* December 1988
|
||||
* Mike Westerfield
|
||||
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
****************************************************************
|
||||
*
|
||||
StdDef start dummy segment
|
||||
StdLib start dummy segment
|
||||
copy equates.asm
|
||||
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ abort start
|
|||
ph2 #SIGABRT
|
||||
jsl raise
|
||||
lda #-1
|
||||
jmp ~C_QUIT
|
||||
brl ~C_QUIT
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -276,6 +276,35 @@ atol entry
|
|||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* atoll - convert a string to a long long
|
||||
*
|
||||
* Inputs:
|
||||
* str - pointer to the string
|
||||
*
|
||||
* Outputs:
|
||||
* converted number
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
atoll start
|
||||
|
||||
ph2 #10 base 10
|
||||
ph4 #0 no pointer returned
|
||||
lda 12,S pass the string addr on
|
||||
pha
|
||||
lda 12,S
|
||||
pha note: x reg is unchanged
|
||||
jsl strtoll convert the string
|
||||
lda 2,S fix the stack
|
||||
sta 6,S
|
||||
pla
|
||||
sta 3,S
|
||||
pla
|
||||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* char *bsearch(key, base, count, size, compar)
|
||||
|
@ -304,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
|
||||
|
@ -322,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
|
||||
|
@ -407,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
|
||||
|
||||
****************************************************************
|
||||
|
@ -496,6 +529,47 @@ labs start
|
|||
lb1 creturn 4:i
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* long long llabs(long long i)
|
||||
*
|
||||
* Return the absolute value of i.
|
||||
*
|
||||
* Inputs:
|
||||
* i - argument
|
||||
*
|
||||
* Outputs:
|
||||
* Returns abs(i).
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
llabs start
|
||||
imaxabs entry
|
||||
retptr equ 1
|
||||
|
||||
csubroutine (8:i),4
|
||||
stx retptr
|
||||
stz retptr+2
|
||||
|
||||
ph8 <i
|
||||
jsl ~ABS8
|
||||
pla
|
||||
sta [retptr]
|
||||
ldy #2
|
||||
pla
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
pla
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
pla
|
||||
sta [retptr],y
|
||||
|
||||
creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* ldiv_t ldiv(n,d)
|
||||
|
@ -518,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
|
||||
|
@ -534,6 +608,81 @@ lb1 lla addr,div_t return the result
|
|||
div_t ds 8
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* lldiv_t lldiv(long long n, long long d)
|
||||
*
|
||||
* Inputs:
|
||||
* n - numerator
|
||||
* d - denominator
|
||||
*
|
||||
* Outputs:
|
||||
* lldiv_t - contains result & remainder
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
lldiv start
|
||||
imaxdiv entry
|
||||
addr equ 1
|
||||
|
||||
csubroutine (8:n,8:d),4
|
||||
phb use local addressing
|
||||
phk
|
||||
plb
|
||||
ph8 <n do the divide
|
||||
ph8 <d
|
||||
jsl ~CDIV8
|
||||
pl8 lldiv_t
|
||||
pl8 lldiv_t+8
|
||||
lla addr,lldiv_t return the result
|
||||
plb
|
||||
|
||||
creturn 4:addr
|
||||
|
||||
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)
|
||||
|
@ -555,10 +704,14 @@ div_t ds 8
|
|||
qsort start
|
||||
|
||||
csubroutine (4:base,4:count,4:size,4:compar),0
|
||||
|
||||
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
|
||||
|
@ -569,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
|
||||
|
||||
plb
|
||||
creturn
|
||||
done creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
@ -617,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
|
||||
|
@ -646,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
|
||||
|
@ -661,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
|
||||
|
@ -682,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
|
||||
|
@ -696,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
|
||||
|
@ -745,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
|
||||
|
||||
****************************************************************
|
||||
|
@ -770,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
|
||||
|
@ -795,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
|
||||
|
@ -834,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
|
||||
|
@ -922,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
|
||||
|
@ -1021,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
|
||||
|
@ -1086,6 +1292,370 @@ rt3 lda rtl fix the stack
|
|||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* strtoll - convert a string to a long long
|
||||
*
|
||||
* 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
|
||||
* base - base of the number
|
||||
*
|
||||
* Outputs:
|
||||
* converted number
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
strtoll start
|
||||
strtoimax entry
|
||||
base equ 26 base
|
||||
ptr equ 22 *return pointer
|
||||
str equ 18 string pointer
|
||||
rtl equ 15 return address
|
||||
|
||||
retptr equ 11 pointer to location for return value
|
||||
val equ 3 value
|
||||
negative equ 1 is the number negative?
|
||||
|
||||
lda #0
|
||||
pha make room for & initialize retptr
|
||||
phx
|
||||
pha make room for & initialize val
|
||||
pha
|
||||
pha
|
||||
pha
|
||||
pha make room for & initialize negative
|
||||
tsc set up direct page addressing
|
||||
phd
|
||||
tcd
|
||||
;
|
||||
; Skip any leading whitespace
|
||||
;
|
||||
lda ptr if ptr in non-null then
|
||||
ora ptr+2
|
||||
beq sw1
|
||||
lda str initialize it to str
|
||||
sta [ptr]
|
||||
ldy #2
|
||||
lda str+2
|
||||
sta [ptr],Y
|
||||
|
||||
sw1 lda [str] skip the white space
|
||||
and #$00FF
|
||||
tax
|
||||
lda >__ctype+1,X
|
||||
and #_space
|
||||
beq cn0
|
||||
inc4 str
|
||||
bra sw1
|
||||
;
|
||||
; Convert the number
|
||||
;
|
||||
cn0 lda [str] if the next char is '-' then
|
||||
and #$00FF
|
||||
cmp #'-'
|
||||
bne cn1
|
||||
inc negative negative := true
|
||||
bra cn2 ++str
|
||||
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
|
||||
tdc
|
||||
clc
|
||||
adc #val
|
||||
tax
|
||||
jsl ~strtoull
|
||||
lda val+6
|
||||
bpl rt1 see if we have an overflow
|
||||
ldy negative allow LLONG_MIN as legal value
|
||||
beq ov0
|
||||
cmp #$8000
|
||||
bne ov0
|
||||
lda val
|
||||
ora val+2
|
||||
ora val+4
|
||||
beq rt1
|
||||
;
|
||||
; Overflow - flag the error
|
||||
;
|
||||
ov0 lda #ERANGE errno = ERANGE
|
||||
sta >errno
|
||||
ldx #$7FFF return value = LLONG_MAX
|
||||
ldy #$FFFF
|
||||
lda negative if negative then
|
||||
beq ov1
|
||||
inx return value = LLONG_MIN
|
||||
iny
|
||||
ov1 sty val
|
||||
sty val+2
|
||||
sty val+4
|
||||
stx val+6
|
||||
;
|
||||
; return the results
|
||||
;
|
||||
rt1 pla remove the original value of str from
|
||||
pla the stack
|
||||
lda negative if negative then
|
||||
beq rt2
|
||||
negate8 val val = -val
|
||||
|
||||
rt2 lda val get the value
|
||||
sta [retptr]
|
||||
ldy #2
|
||||
lda val+2
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
lda val+4
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
lda val+6
|
||||
sta [retptr],y
|
||||
lda rtl fix the stack
|
||||
sta base-1
|
||||
lda rtl+1
|
||||
sta base
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #24
|
||||
tcs
|
||||
tya return
|
||||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* strtoull - convert a string to an unsigned long long
|
||||
* ~strtoull - alt entry point that does not parse leading
|
||||
* white space and sign
|
||||
*
|
||||
* 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
|
||||
* base - base of the number
|
||||
*
|
||||
* Outputs:
|
||||
* converted number
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
strtoull start
|
||||
strtoumax entry
|
||||
base equ 30 base
|
||||
ptr equ 26 *return pointer
|
||||
str equ 22 string pointer
|
||||
rtl equ 19 return address
|
||||
|
||||
retptr equ 15 pointer to location for return value
|
||||
rangeOK equ 13 was the number within range?
|
||||
negative equ 11 was there a minus sign?
|
||||
val equ 3 value
|
||||
foundOne equ 1 have we found a number?
|
||||
|
||||
ldy #0
|
||||
bra init
|
||||
|
||||
~strtoull entry alt entry point called from strtoll
|
||||
ldy #1
|
||||
|
||||
init lda #0
|
||||
pha make room for & initialize retptr
|
||||
phx
|
||||
pea 1 make room for & initialize rangeOK
|
||||
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
|
||||
;
|
||||
; Skip any leading whitespace
|
||||
;
|
||||
tya just process number if called from strtol
|
||||
bne db1c
|
||||
|
||||
lda ptr if ptr in non-null then
|
||||
ora ptr+2
|
||||
beq sw1
|
||||
lda str initialize it to str
|
||||
sta [ptr]
|
||||
ldy #2
|
||||
lda str+2
|
||||
sta [ptr],Y
|
||||
|
||||
sw1 lda [str] skip the white space
|
||||
and #$00FF
|
||||
tax
|
||||
lda >__ctype+1,X
|
||||
and #_space
|
||||
beq db1
|
||||
inc4 str
|
||||
bra sw1
|
||||
;
|
||||
; Deduce the base
|
||||
;
|
||||
db1 lda [str] if the next char is '-' then
|
||||
and #$00FF
|
||||
cmp #'-'
|
||||
bne db1a
|
||||
inc negative negative := true
|
||||
bra db1b
|
||||
db1a cmp #'+' skip any leading '+'
|
||||
bne db1c
|
||||
db1b inc4 str
|
||||
db1c lda base if the base is zero then
|
||||
bne db2
|
||||
lda #10 assume base 10
|
||||
sta base
|
||||
lda [str] if the first char is 0 then
|
||||
and #$00FF
|
||||
cmp #'0'
|
||||
bne cn1
|
||||
lda #8 assume base 8
|
||||
sta base
|
||||
ldy #1 if the second char is 'X' or 'x' then
|
||||
lda [str],Y
|
||||
and #$00DF
|
||||
cmp #'X'
|
||||
bne cn1
|
||||
asl base base 16
|
||||
bra db3
|
||||
db2 cmp #16 if the base is 16 then
|
||||
bne db4
|
||||
lda [str] if the first two chars are 0x or 0X then
|
||||
and #$DFFF
|
||||
cmp #'X0'
|
||||
bne cn1
|
||||
db3 add4 str,#2 skip them
|
||||
bra cn1
|
||||
db4 cmp #37 check for invalid base value
|
||||
jge cn6
|
||||
dec a
|
||||
jeq cn6
|
||||
;
|
||||
; Convert the number
|
||||
;
|
||||
cn1 lda [str] get a (possible) digit
|
||||
and #$00FF
|
||||
cmp #'0' branch if it is not a digit
|
||||
blt cn5
|
||||
cmp #'9'+1 branch if it is a numeric digit
|
||||
blt cn2
|
||||
and #$00DF convert lowercase to uppercase
|
||||
cmp #'A' branch if it is not a digit
|
||||
blt cn5
|
||||
cmp #'Z'+1 branch if it is not a digit
|
||||
bge cn5
|
||||
sbc #'A'-11 convert "alpha" digit to value
|
||||
bra cn3 go test the digit
|
||||
|
||||
cn2 and #$000F convert digit to value
|
||||
cn3 cmp base branch if the digit is too big
|
||||
bge cn5
|
||||
|
||||
ldx #1 note that we have found a number
|
||||
stx foundOne
|
||||
pha save the digit
|
||||
ph8 <val val = val*base
|
||||
pea 0
|
||||
pea 0
|
||||
pea 0
|
||||
ph2 <base
|
||||
jsl ~UMUL8
|
||||
pl8 val
|
||||
pla get the saved digit
|
||||
txy branch if there was an error
|
||||
beq cn3a
|
||||
stz rangeOK
|
||||
cn3a clc add in the new digit
|
||||
adc val
|
||||
sta val
|
||||
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
|
||||
|
||||
cn5 lda foundOne if no digits were found, flag the error
|
||||
bne rt1
|
||||
cn6 lda #EINVAL
|
||||
sta >errno
|
||||
bra rt2a
|
||||
;
|
||||
; return the results
|
||||
;
|
||||
rt1 lda ptr if ptr is non-null then
|
||||
ora ptr+2
|
||||
beq rt1a
|
||||
lda str set it to str
|
||||
sta [ptr]
|
||||
ldy #2
|
||||
lda str+2
|
||||
sta [ptr],Y
|
||||
|
||||
rt1a lda rangeOK check if number was out of range
|
||||
bne rt2
|
||||
lda #ERANGE errno = ERANGE
|
||||
sta >errno
|
||||
lda #$FFFF return value = ULLONG_MAX
|
||||
sta [retptr]
|
||||
ldy #2
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
sta [retptr],y
|
||||
bra rt3
|
||||
rt2 lda negative if negative then
|
||||
beq rt2a
|
||||
negate8 val val = -val
|
||||
rt2a lda val get the value
|
||||
sta [retptr]
|
||||
ldy #2
|
||||
lda val+2
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
lda val+4
|
||||
sta [retptr],y
|
||||
iny
|
||||
iny
|
||||
lda val+6
|
||||
sta [retptr],y
|
||||
rt3 lda rtl fix the stack
|
||||
sta base-1
|
||||
lda rtl+1
|
||||
sta base
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #28
|
||||
tcs
|
||||
tya return
|
||||
rtl
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int system(command)
|
||||
|
@ -1121,14 +1691,14 @@ system start
|
|||
sta exComm+2
|
||||
lb1 phy execute the command
|
||||
phx
|
||||
plb
|
||||
Execute ex
|
||||
ldy empty
|
||||
bne ret if doing system(NULL)
|
||||
tya
|
||||
bcs ret error => no command processor
|
||||
inc a (& vice versa)
|
||||
ret rtl
|
||||
ret plb
|
||||
rtl
|
||||
|
||||
ex dc i'$8000'
|
||||
exComm ds 4
|
||||
|
@ -1138,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.
|
||||
*
|
||||
|
|
317
stdlib.macros
317
stdlib.macros
|
@ -1,3 +1,165 @@
|
|||
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
|
||||
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 ph8 &n1
|
||||
lclc &c
|
||||
&l anop
|
||||
&c amid &n1,1,1
|
||||
aif s:longa=1,.a
|
||||
rep #%00100000
|
||||
.a
|
||||
aif "&c"="#",.d
|
||||
aif "&c"="[",.b
|
||||
aif "&c"<>"{",.c
|
||||
&c amid &n1,l:&n1,1
|
||||
aif "&c"<>"}",.g
|
||||
&n1 amid &n1,2,l:&n1-2
|
||||
&n1 setc (&n1)
|
||||
.b
|
||||
ldy #6
|
||||
~&SYSCNT lda &n1,y
|
||||
pha
|
||||
dey
|
||||
dey
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.c
|
||||
aif "&c"<>"<",.c1
|
||||
pei &n1+6
|
||||
pei &n1+4
|
||||
pei &n1+2
|
||||
pei &n1
|
||||
ago .e
|
||||
.c1
|
||||
ldx #6
|
||||
~&SYSCNT lda &n1,x
|
||||
pha
|
||||
dex
|
||||
dex
|
||||
bpl ~&SYSCNT
|
||||
ago .e
|
||||
.d
|
||||
&n1 amid &n1,2,l:&n1-1
|
||||
pea +(&n1)|-48
|
||||
pea +(&n1)|-32
|
||||
pea +(&n1)|-16
|
||||
pea &n1
|
||||
.e
|
||||
aif s:longa=1,.f
|
||||
sep #%00100000
|
||||
.f
|
||||
mexit
|
||||
.g
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
MACRO
|
||||
&LAB MOVE4 &F,&T
|
||||
&LAB ~SETM
|
||||
|
@ -388,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
|
||||
|
@ -585,3 +669,80 @@
|
|||
DC I4'&DCB'
|
||||
~RESTM
|
||||
MEND
|
||||
macro
|
||||
&l pl8 &n1
|
||||
lclc &c
|
||||
&l anop
|
||||
aif s:longa=1,.a
|
||||
rep #%00100000
|
||||
.a
|
||||
&c amid &n1,1,1
|
||||
aif "&c"<>"{",.b
|
||||
&c amid &n1,l:&n1,1
|
||||
aif "&c"<>"}",.f
|
||||
&n1 amid &n1,2,l:&n1-2
|
||||
pla
|
||||
sta (&n1)
|
||||
ldy #2
|
||||
pla
|
||||
sta (&n1),y
|
||||
ldy #4
|
||||
pla
|
||||
sta (&n1),y
|
||||
ldy #6
|
||||
pla
|
||||
sta (&n1),y
|
||||
ago .d
|
||||
.b
|
||||
aif "&c"<>"[",.c
|
||||
pla
|
||||
sta &n1
|
||||
ldy #2
|
||||
pla
|
||||
sta &n1,y
|
||||
ldy #4
|
||||
pla
|
||||
sta &n1,y
|
||||
ldy #6
|
||||
pla
|
||||
sta &n1,y
|
||||
ago .d
|
||||
.c
|
||||
pla
|
||||
sta &n1
|
||||
pla
|
||||
sta &n1+2
|
||||
pla
|
||||
sta &n1+4
|
||||
pla
|
||||
sta &n1+6
|
||||
.d
|
||||
aif s:longa=1,.e
|
||||
sep #%00100000
|
||||
.e
|
||||
mexit
|
||||
.f
|
||||
mnote "Missing closing '}'",16
|
||||
mend
|
||||
macro
|
||||
&l jge &bp
|
||||
&l blt *+5
|
||||
brl &bp
|
||||
mend
|
||||
macro
|
||||
&l jeq &bp
|
||||
&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
|
||||
|
|
2661
string.asm
2661
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
|
||||
|
|
285
time.macros
285
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,46 +557,113 @@
|
|||
&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
|
||||
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
|
||||
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
|
133
uchar.macros
Normal file
133
uchar.macros
Normal file
|
@ -0,0 +1,133 @@
|
|||
MACRO
|
||||
&lab csubroutine &parms,&work
|
||||
&lab anop
|
||||
aif c:&work,.a
|
||||
lclc &work
|
||||
&work setc 0
|
||||
.a
|
||||
gbla &totallen
|
||||
gbla &worklen
|
||||
&worklen seta &work
|
||||
&totallen seta 0
|
||||
aif c:&parms=0,.e
|
||||
lclc &len
|
||||
lclc &p
|
||||
lcla &i
|
||||
&i seta 1
|
||||
.b
|
||||
&p setc &parms(&i)
|
||||
&len amid &p,2,1
|
||||
aif "&len"=":",.c
|
||||
&len amid &p,1,2
|
||||
&p amid &p,4,l:&p-3
|
||||
ago .d
|
||||
.c
|
||||
&len amid &p,1,1
|
||||
&p amid &p,3,l:&p-2
|
||||
.d
|
||||
&p equ &totallen+4+&work
|
||||
&totallen seta &totallen+&len
|
||||
&i seta &i+1
|
||||
aif &i<=c:&parms,^b
|
||||
.e
|
||||
tsc
|
||||
aif &work=0,.f
|
||||
sec
|
||||
sbc #&work
|
||||
tcs
|
||||
.f
|
||||
phd
|
||||
tcd
|
||||
mend
|
||||
MACRO
|
||||
&lab creturn &r
|
||||
&lab anop
|
||||
lclc &len
|
||||
aif c:&r,.a
|
||||
lclc &r
|
||||
&r setc 0
|
||||
&len setc 0
|
||||
ago .h
|
||||
.a
|
||||
&len amid &r,2,1
|
||||
aif "&len"=":",.b
|
||||
&len amid &r,1,2
|
||||
&r amid &r,4,l:&r-3
|
||||
ago .c
|
||||
.b
|
||||
&len amid &r,1,1
|
||||
&r amid &r,3,l:&r-2
|
||||
.c
|
||||
aif &len<>2,.d
|
||||
ldy &r
|
||||
ago .h
|
||||
.d
|
||||
aif &len<>4,.e
|
||||
ldx &r+2
|
||||
ldy &r
|
||||
ago .h
|
||||
.e
|
||||
aif &len<>10,.g
|
||||
ldy #&r
|
||||
ldx #^&r
|
||||
ago .h
|
||||
.g
|
||||
mnote 'Not a valid return length',16
|
||||
mexit
|
||||
.h
|
||||
aif &totallen=0,.i
|
||||
lda &worklen+2
|
||||
sta &worklen+&totallen+2
|
||||
lda &worklen+1
|
||||
sta &worklen+&totallen+1
|
||||
.i
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #&worklen+&totallen
|
||||
tcs
|
||||
aif &len=0,.j
|
||||
tya
|
||||
.j
|
||||
rtl
|
||||
mend
|
||||
macro
|
||||
&l 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