Merge branch 'master' into gno-version

This commit is contained in:
Stephen Heumann 2022-07-16 20:45:02 -05:00
commit 1fd1de0be8
21 changed files with 7943 additions and 7716 deletions

57
cc.asm
View File

@ -372,6 +372,63 @@ start ds 2 start of the command line string
targv ds 4
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

169
cc.macros
View File

@ -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
@ -300,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

1652
ctype.asm

File diff suppressed because it is too large Load Diff

View File

@ -63,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
! ----------------
@ -73,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

View File

@ -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

View File

@ -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

View File

@ -26,8 +26,8 @@ fpextra private dummy segment
~SinglePrecision start
tsc
clc
adc #4
ldy #0
adc #4
ldy #0
phy
pha
phy
@ -53,8 +53,8 @@ fpextra private dummy segment
~DoublePrecision start
tsc
clc
adc #4
ldy #0
adc #4
ldy #0
phy
pha
phy
@ -83,19 +83,19 @@ fpextra private dummy segment
~CompPrecision start
tsc round to integer
clc
adc #4
pea 0
adc #4
pea 0
pha
FRINTX
lda 4+8,s
lda 4+8,s
pha save original sign
asl a force sign to positive
lsr a
sta 6+8,s
asl a force sign to positive
lsr a
sta 6+8,s
tsc limit precision
clc
adc #6
ldy #0
adc #6
ldy #0
phy
pha
phy
@ -107,10 +107,10 @@ fpextra private dummy segment
FX2C
FC2X
pla restore original sign
bpl ret
lda 4+8,s
ora #$8000
sta 4+8,s
bpl ret
lda 4+8,s
ora #$8000
sta 4+8,s
ret rtl
end

View File

@ -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 csubroutine &parms,&work
&lab anop
@ -91,52 +144,6 @@
.j
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
&l cmp4 &n1,&n2
lclb &yistwo

View File

@ -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

View File

@ -112,7 +112,7 @@ lb2 asl A get the signal handler address
long M
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

View File

@ -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

9777
stdio.asm

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,95 @@
macro
&l ph2 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
lda (&n1)
pha
ago .e
.b
aif "&c"="<",.c
lda &n1
pha
ago .e
.c
&n1 amid &n1,2,l:&n1-1
pei &n1
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l ph4 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l negate8 &n1
&l ~setm
sec
@ -569,84 +660,6 @@
.I
MEND
MACRO
&LAB PH2 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDA (&N1)
PHA
AGO .E
.B
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PH4 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDY #2
LDA (&N1),Y
PHA
LDA (&N1)
PHA
AGO .E
.B
AIF "&C"<>"[",.C
LDY #2
LDA &N1,Y
PHA
LDA &N1
PHA
AGO .E
.C
LDA &N1+2
PHA
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA +(&N1)|-16
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PL4 &N1
LCLC &C
&LAB ANOP

View File

@ -351,8 +351,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
@ -588,8 +588,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
@ -717,8 +717,8 @@ qsort start
lda compar+1
sta jsl1+2
sta jsl2+2
ph4 count do the sort
ph4 base
ph4 <count do the sort
ph4 <base
jsl rsort
done plb
@ -781,8 +781,8 @@ sr1a 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 ph4 <last
ph4 <left
jsl1 entry
jsl jsl1
tax
@ -794,14 +794,14 @@ 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
ph4 <last
ph4 <right
jsl2 entry
jsl jsl2
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
@ -809,15 +809,15 @@ 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
ph4 <right
ph4 <first
jsl rsort
add4 left,lsize,first sort right part of array
brl sr0
@ -1007,10 +1007,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
@ -1194,9 +1194,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
@ -1329,10 +1329,10 @@ cn1 cmp #'+' else if the char is '+' then
bne cn3
cn2 inc4 str ++str
cn3 ph4 str save the starting string
ph2 base convert the unsigned number
ph4 ptr
ph4 str
cn3 ph4 <str save the starting string
ph2 <base convert the unsigned number
ph4 <ptr
ph4 <str
tdc
clc
adc #val
@ -1539,7 +1539,7 @@ cn3 cmp base branch if the digit is too big
pea 0
pea 0
pea 0
ph2 base
ph2 <base
jsl ~UMUL8
pl8 val
pla get the saved digit

View File

@ -1,4 +1,95 @@
macro
&l ph2 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
lda (&n1)
pha
ago .e
.b
aif "&c"="<",.c
lda &n1
pha
ago .e
.c
&n1 amid &n1,2,l:&n1-1
pei &n1
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l ph4 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l negate8 &n1
&l ~setm
sec
@ -459,84 +550,6 @@
.C
MEND
MACRO
&LAB PH2 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDA (&N1)
PHA
AGO .E
.B
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PH4 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDY #2
LDA (&N1),Y
PHA
LDA (&N1)
PHA
AGO .E
.B
AIF "&C"<>"[",.C
LDY #2
LDA &N1,Y
PHA
LDA &N1
PHA
AGO .E
.C
LDA &N1+2
PHA
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA +(&N1)|-16
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PL4 &N1
LCLC &C
&LAB ANOP

2598
string.asm

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -138,7 +138,7 @@ tm_wday equ 12
phk
plb
ph4 timeptr convert to a time record
ph4 <timeptr convert to a time record
jsl localtime
sta timeptr
stx timeptr+2

View File

@ -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
@ -418,52 +509,6 @@
.D
MEND
MACRO
&LAB PH4 &N1
LCLC &C
&LAB ANOP
&C AMID &N1,1,1
AIF "&C"="#",.D
AIF S:LONGA=1,.A
REP #%00100000
.A
AIF "&C"<>"{",.B
&C AMID &N1,L:&N1,1
AIF "&C"<>"}",.G
&N1 AMID &N1,2,L:&N1-2
LDY #2
LDA (&N1),Y
PHA
LDA (&N1)
PHA
AGO .E
.B
AIF "&C"<>"[",.C
LDY #2
LDA &N1,Y
PHA
LDA &N1
PHA
AGO .E
.C
LDA &N1+2
PHA
LDA &N1
PHA
AGO .E
.D
&N1 AMID &N1,2,L:&N1-1
PEA +(&N1)|-16
PEA &N1
AGO .F
.E
AIF S:LONGA=1,.F
SEP #%00100000
.F
MEXIT
.G
MNOTE "Missing closing '}'",16
MEND
MACRO
&LAB PL4 &N1
LCLC &C
&LAB ANOP
@ -517,44 +562,6 @@
&l blt &bp
beq &bp
mend
macro
&l ph2 &n1
aif "&n1"="*",.f
lclc &c
&l anop
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
lda (&n1)
pha
ago .e
.b
aif "&c"="<",.c
lda &n1
pha
ago .e
.c
&n1 amid &n1,2,l:&n1-1
pei &n1
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
MACRO
&lab _ReadBParam
&lab ldx #$0C03

View File

@ -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
@ -278,8 +278,8 @@ addr equ 1
sec
sbc #8
tcs
ph4 dividend
ph4 divisor
ph4 <dividend
ph4 <divisor
_LongDivide
sta >~TOOLERROR
pl4 >quotient
@ -313,8 +313,8 @@ addr equ 1
sec
sbc #8
tcs
ph4 multiplicand
ph4 multiplier
ph4 <multiplicand
ph4 <multiplier
_LongMul
sta >~TOOLERROR
pl4 >lsResult
@ -346,8 +346,8 @@ addr equ 1
pha
pha
ph2 dividend
ph2 divisor
ph2 <dividend
ph2 <divisor
_SDivide
sta >~TOOLERROR
pl2 >quotient
@ -379,8 +379,8 @@ addr equ 1
pha
pha
ph2 dividend
ph2 divisor
ph2 <dividend
ph2 <divisor
_UDivide
sta >~TOOLERROR
pl2 >quotient
@ -421,9 +421,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 +464,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 +508,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 +551,7 @@ addr equ 1
sec
sbc #10
tcs
ph2 uID
ph2 <uID
_Restart
sta >~TOOLERROR
pl2 >userID
@ -590,7 +590,7 @@ addr equ 1
pha
pha
pha
ph4 segaddr
ph4 <segaddr
_UnloadSeg
sta >~TOOLERROR
pl2 >userID

View File

@ -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