mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-09-28 11:54:48 +00:00
Compare commits
No commits in common. "0e519e1e58a3268d1192ee5748e3f2b6be421e8f" and "ce87c0e008d844d8f7ffcf1c446bc30bc013bad8" have entirely different histories.
0e519e1e58
...
ce87c0e008
100
stdio.asm
100
stdio.asm
@ -83,13 +83,16 @@ stdfile equ 7 is this a standard file?
|
|||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
|
|
||||||
|
lda #EOF assume we will get an error
|
||||||
|
sta err
|
||||||
ph4 <stream verify that stream exists
|
ph4 <stream verify that stream exists
|
||||||
jsl ~VerifyStream
|
jsl ~VerifyStream
|
||||||
jcs rts_err
|
jcs rts
|
||||||
|
|
||||||
ph4 <stream do any pending I/O
|
ph4 <stream do any pending I/O
|
||||||
jsl fflush
|
jsl fflush
|
||||||
sta err initialize err to fflush result
|
tax
|
||||||
|
jne rts
|
||||||
|
|
||||||
stz stdfile not a standard file
|
stz stdfile not a standard file
|
||||||
lda stream+2 bypass file disposal if the file is
|
lda stream+2 bypass file disposal if the file is
|
||||||
@ -107,10 +110,11 @@ lb1 inc stdfile
|
|||||||
|
|
||||||
cl0 lla p,stderr+4 find the file record that points to this
|
cl0 lla p,stderr+4 find the file record that points to this
|
||||||
ldy #2 one
|
ldy #2 one
|
||||||
cl1 lda [p],Y
|
cl1 lda [p]
|
||||||
|
ora [p],Y
|
||||||
|
jeq rts
|
||||||
|
lda [p],Y
|
||||||
tax
|
tax
|
||||||
ora [p]
|
|
||||||
jeq rts_err
|
|
||||||
lda [p]
|
lda [p]
|
||||||
cmp stream
|
cmp stream
|
||||||
bne cl2
|
bne cl2
|
||||||
@ -124,10 +128,46 @@ cl3 lda [stream] remove stream from the file list
|
|||||||
sta [p]
|
sta [p]
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
sta [p],Y
|
sta [p],Y
|
||||||
cl3a ldy #FILE_flag if the buffer was allocated by fopen then
|
cl3a ldy #FILE_flag if the file was opened by tmpfile then
|
||||||
|
lda [stream],Y
|
||||||
|
and #_IOTEMPFILE
|
||||||
|
beq cl3d
|
||||||
|
ph4 #nameBuffSize p = malloc(nameBuffSize)
|
||||||
|
jsl malloc grPathname = p
|
||||||
|
sta p dsPathname = p+2
|
||||||
|
stx p+2
|
||||||
|
sta grPathname
|
||||||
|
stx grPathname+2
|
||||||
|
clc
|
||||||
|
adc #2
|
||||||
|
bcc cl3b
|
||||||
|
inx
|
||||||
|
cl3b sta dsPathname
|
||||||
|
stx dsPathname+2
|
||||||
|
lda #nameBuffSize p->size = nameBuffSize
|
||||||
|
sta [p]
|
||||||
|
ldy #FILE_file clRefnum = grRefnum = stream->_file
|
||||||
|
lda [stream],Y
|
||||||
|
beq cl3e
|
||||||
|
sta grRefnum
|
||||||
|
GetRefInfoGS gr GetRefInfoGS(gr)
|
||||||
|
bcs cl3c
|
||||||
|
lda grRefnum OSClose(cl)
|
||||||
|
sta clRefNum
|
||||||
|
OSClose cl
|
||||||
|
DestroyGS ds DestroyGS(ds)
|
||||||
|
cl3c ph4 <p free(p)
|
||||||
|
jsl free
|
||||||
|
bra cl3e else
|
||||||
|
cl3d ldy #FILE_file close the file
|
||||||
|
lda [stream],Y
|
||||||
|
beq cl3e
|
||||||
|
sta clRefNum
|
||||||
|
OSClose cl
|
||||||
|
cl3e ldy #FILE_flag if the buffer was allocated by fopen then
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
and #_IOMYBUF
|
and #_IOMYBUF
|
||||||
beq cl3b
|
beq cl4
|
||||||
ldy #FILE_base+2 dispose of the file buffer
|
ldy #FILE_base+2 dispose of the file buffer
|
||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
pha
|
pha
|
||||||
@ -136,47 +176,6 @@ cl3a ldy #FILE_flag if the buffer was allocated by fopen the
|
|||||||
lda [stream],Y
|
lda [stream],Y
|
||||||
pha
|
pha
|
||||||
jsl free
|
jsl free
|
||||||
cl3b ldy #FILE_flag if the file was opened by tmpfile then
|
|
||||||
lda [stream],Y
|
|
||||||
and #_IOTEMPFILE
|
|
||||||
beq cl3f
|
|
||||||
ph4 #nameBuffSize p = malloc(nameBuffSize)
|
|
||||||
jsl malloc
|
|
||||||
sta p
|
|
||||||
stx p+2
|
|
||||||
ora p+2 if p == NULL then
|
|
||||||
bne cl3c
|
|
||||||
lda #EOF flag error
|
|
||||||
sta err
|
|
||||||
bra cl3f just close the file
|
|
||||||
cl3c lda p
|
|
||||||
sta grPathname grPathname = p
|
|
||||||
stx grPathname+2
|
|
||||||
clc dsPathname = p+2
|
|
||||||
adc #2
|
|
||||||
bcc cl3d
|
|
||||||
inx
|
|
||||||
cl3d sta dsPathname
|
|
||||||
stx dsPathname+2
|
|
||||||
lda #nameBuffSize p->size = nameBuffSize
|
|
||||||
sta [p]
|
|
||||||
ldy #FILE_file clRefnum = grRefnum = stream->_file
|
|
||||||
lda [stream],Y
|
|
||||||
beq cl4
|
|
||||||
sta grRefnum
|
|
||||||
sta clRefNum
|
|
||||||
GetRefInfoGS gr GetRefInfoGS(gr)
|
|
||||||
bcs cl3e
|
|
||||||
OSClose cl OSClose(cl)
|
|
||||||
DestroyGS ds DestroyGS(ds)
|
|
||||||
cl3e ph4 <p free(p)
|
|
||||||
jsl free
|
|
||||||
bra cl4 else
|
|
||||||
cl3f ldy #FILE_file close the file
|
|
||||||
lda [stream],Y
|
|
||||||
beq cl4
|
|
||||||
sta clRefNum
|
|
||||||
OSClose cl
|
|
||||||
cl4 lda stdfile if this is not a standard file then
|
cl4 lda stdfile if this is not a standard file then
|
||||||
bne cl5
|
bne cl5
|
||||||
ph4 <stream dispose of the file buffer
|
ph4 <stream dispose of the file buffer
|
||||||
@ -190,10 +189,7 @@ cl6 lda [p],Y
|
|||||||
dey
|
dey
|
||||||
cpy #2
|
cpy #2
|
||||||
bne cl6
|
bne cl6
|
||||||
cl7 bra rts no error found
|
cl7 stz err no error found
|
||||||
|
|
||||||
rts_err lda #EOF
|
|
||||||
sta err
|
|
||||||
rts plb
|
rts plb
|
||||||
creturn 2:err
|
creturn 2:err
|
||||||
|
|
||||||
|
15
stdlib.asm
15
stdlib.asm
@ -1584,13 +1584,16 @@ cn3 cmp base branch if the digit is too big
|
|||||||
cn3a clc add in the new digit
|
cn3a clc add in the new digit
|
||||||
adc val
|
adc val
|
||||||
sta val
|
sta val
|
||||||
|
lda val+2
|
||||||
|
adc #0
|
||||||
|
sta val+2
|
||||||
|
lda val+4
|
||||||
|
adc #0
|
||||||
|
sta val+4
|
||||||
|
lda val+6
|
||||||
|
adc #0
|
||||||
|
sta val+6
|
||||||
bcc cn4
|
bcc cn4
|
||||||
inc val+2
|
|
||||||
bne cn4
|
|
||||||
inc val+4
|
|
||||||
bne cn4
|
|
||||||
inc val+6
|
|
||||||
bne cn4
|
|
||||||
stz rangeOK
|
stz rangeOK
|
||||||
cn4 inc4 str next char
|
cn4 inc4 str next char
|
||||||
bra cn1
|
bra cn1
|
||||||
|
70
string.asm
70
string.asm
@ -244,8 +244,8 @@ lb3 lda [p1],Y scan until the end of memory is reached
|
|||||||
dex
|
dex
|
||||||
bne lb3
|
bne lb3
|
||||||
|
|
||||||
; ldx #0
|
ldx #0 memory matches
|
||||||
bra lb5 memory matches
|
bra lb5
|
||||||
|
|
||||||
lb4 blt less memory differs - set the result
|
lb4 blt less memory differs - set the result
|
||||||
ldx #1
|
ldx #1
|
||||||
@ -303,8 +303,8 @@ rtl equ 1 return address
|
|||||||
short M move 1 byte now
|
short M move 1 byte now
|
||||||
lda [p2]
|
lda [p2]
|
||||||
sta [p1]
|
sta [p1]
|
||||||
dec len
|
|
||||||
long M
|
long M
|
||||||
|
dec len
|
||||||
inc4 p1
|
inc4 p1
|
||||||
inc4 p2
|
inc4 p2
|
||||||
lb1 anop endif
|
lb1 anop endif
|
||||||
@ -482,19 +482,19 @@ rtl equ 1 return address
|
|||||||
|
|
||||||
ph4 <p save the pointer
|
ph4 <p save the pointer
|
||||||
|
|
||||||
short I,M
|
short M
|
||||||
ldx val form a 2 byte value
|
lda val form a 2 byte value
|
||||||
stx val+1
|
sta val+1
|
||||||
|
|
||||||
lda len if there are an odd # of bytes then
|
lda len if there are an odd # of bytes then
|
||||||
lsr A
|
lsr A
|
||||||
bcc lb1
|
bcc lb1
|
||||||
txa set 1 byte now
|
lda val set 1 byte now
|
||||||
sta [p]
|
sta [p]
|
||||||
|
long M
|
||||||
dec len
|
dec len
|
||||||
long I,M
|
|
||||||
inc4 p
|
inc4 p
|
||||||
lb1 long I,M endif
|
lb1 long M endif
|
||||||
|
|
||||||
lda val set len bytes
|
lda val set len bytes
|
||||||
ldx len+2 set full banks
|
ldx len+2 set full banks
|
||||||
@ -616,9 +616,7 @@ lb2 long M
|
|||||||
clc
|
clc
|
||||||
adc s1
|
adc s1
|
||||||
sta s1
|
sta s1
|
||||||
bcc lb2a
|
short M copy characters 'til the null is found
|
||||||
inc s1+2
|
|
||||||
lb2a short M copy characters 'til the null is found
|
|
||||||
ldy #0
|
ldy #0
|
||||||
lb3 lda [s2],Y
|
lb3 lda [s2],Y
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
@ -958,12 +956,9 @@ str equ 4 pointer to the string
|
|||||||
tcd
|
tcd
|
||||||
|
|
||||||
ldy #0 advance s1 to point to the terminating
|
ldy #0 advance s1 to point to the terminating
|
||||||
tyx null
|
ldx #0 null
|
||||||
short M
|
short M
|
||||||
lb1 lda [str],Y
|
lb1 lda [str],Y
|
||||||
beq lb2
|
|
||||||
iny
|
|
||||||
lda [str],Y
|
|
||||||
beq lb2
|
beq lb2
|
||||||
iny
|
iny
|
||||||
bne lb1
|
bne lb1
|
||||||
@ -1018,35 +1013,27 @@ lb2 long M
|
|||||||
clc
|
clc
|
||||||
adc s1
|
adc s1
|
||||||
sta s1
|
sta s1
|
||||||
bcc lb2a
|
short M copy characters 'til the null is found
|
||||||
inc s1+2
|
|
||||||
lb2a ldx n copy characters 'til the null is found
|
|
||||||
bne lb2b
|
|
||||||
lda n+2
|
|
||||||
beq lb6
|
|
||||||
lb2b short M
|
|
||||||
ldy #0
|
ldy #0
|
||||||
|
ldx n
|
||||||
|
beq lb4
|
||||||
|
bmi lb4
|
||||||
lb3 lda [s2],Y
|
lb3 lda [s2],Y
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
beq lb5
|
|
||||||
iny
|
|
||||||
bne lb3a
|
|
||||||
inc s1+2
|
|
||||||
inc s2+2
|
|
||||||
lb3a dex
|
|
||||||
bne lb3
|
|
||||||
ldx n+2
|
|
||||||
beq lb4
|
beq lb4
|
||||||
|
iny
|
||||||
dex
|
dex
|
||||||
stx n+2
|
bne lb3
|
||||||
ldx #0
|
lda n+2
|
||||||
|
beq lb4
|
||||||
|
dec n+2
|
||||||
bra lb3
|
bra lb3
|
||||||
|
|
||||||
lb4 lda #0 write the terminating null
|
lb4 lda #0 write the terminating null
|
||||||
sta [s1],Y
|
sta [s1],Y
|
||||||
lb5 long M return to the caller
|
long M return to the caller
|
||||||
|
|
||||||
lb6 creturn 4:rval
|
creturn 4:rval
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
@ -1073,6 +1060,7 @@ flag equ 1 return flag
|
|||||||
|
|
||||||
ldy #0 scan until the end of string is reached
|
ldy #0 scan until the end of string is reached
|
||||||
ldx n+2 or a difference is found
|
ldx n+2 or a difference is found
|
||||||
|
bmi equal
|
||||||
bne lb0
|
bne lb0
|
||||||
ldx n
|
ldx n
|
||||||
beq equal
|
beq equal
|
||||||
@ -1084,11 +1072,9 @@ lb1 lda [s1],Y
|
|||||||
bne lb3
|
bne lb3
|
||||||
dex
|
dex
|
||||||
bne lb1a
|
bne lb1a
|
||||||
ldx n+2
|
lda n+2
|
||||||
beq equal
|
beq equal
|
||||||
dex
|
dec n+2
|
||||||
stx n+2
|
|
||||||
ldx #0
|
|
||||||
lb1a iny
|
lb1a iny
|
||||||
bne lb1
|
bne lb1
|
||||||
inc s1+2
|
inc s1+2
|
||||||
@ -1214,9 +1200,9 @@ lb3 long I,M increment s by Y and load the value
|
|||||||
clc
|
clc
|
||||||
adc s
|
adc s
|
||||||
tay
|
tay
|
||||||
ldx s+2
|
lda s+2
|
||||||
bcc lb4
|
adc #0
|
||||||
inx
|
tax
|
||||||
|
|
||||||
lb4 lda rtl+1 remove the parameters
|
lb4 lda rtl+1 remove the parameters
|
||||||
sta set+2
|
sta set+2
|
||||||
|
Loading…
Reference in New Issue
Block a user