Oh and I forgot to explain that to implement the copy command I Had to add the ability to open files and have a file handle returned from the open operation to the kernel. an application can open 8 files currently and the a 1 byte file handle is returned in A.
CP is the first part of Symbiosys that is an external binary which resides in a common searched user area not entirely unlike a /bin/ directory.
I'll post the code here for the complete cp command but it is not commented, I have to push ahead with ideas in my mind and comments slow me down. I know this doesnt help anyone else looking at the cde but I will go back and comment it later I promise.
Never the less I believe anyone interested will be able to get an idea of what it's doing.
P.S. There are quite a few unused macros there, it;s a bit of a standard header, don't let them panic you.
Code:
# rae
rae
2000-5FFC 1000-1FFC 0F00
3B1C 1717
>pr
0020 ;
0030 ; cp command binary
0040 ;
0050 ; For Symbiosys with B.D.O.S. Ver. V
0060 ;
0070 ; House Harris
0080 ; July MMXI
0090 ;
0100 ;
0110 .os
0120 osflags .de $39f ;DOS control flags
0130 cwd .de $39d ;2 bytes for future expansion
0140 filenum .de $39c
0150 sectnum .de $39b
0160 bytenum .de $39a
0170 xfer.bytes .de $398 ; 16 bits bytes to transfer
0180 xfer.addr .de $396 ; 16 bits start addr for transfer
0190 dta.ptr .de $394 ; disk transfer buffer pointer
0200 ilba24 .de $393
0210 ilba16 .de $392
0220 ilba8 .de $391
0230 ilba0 .de $390
0240 compacptr .de $3fc
0250 path.user .de $3f8
0260 ;
0270 argc .de $37f ;$a60f
0280 argv[0] .de $380 ;$a610
0290 argv[1] .de $382 ;$a612
0300 argv[2] .de $384 ;$a614
0310 argv[3] .de $386 ;$a616
0320 argv[4] .de $388 ;$a618
0330 argv[5] .de $38a ;$a61a
0340 ;
0350 zargc .de $4f
0360 zargv[0] .de $50
0370 zargv[1] .de $52
0380 zargv[2] .de $54
0390 zargv[3] .de $56
0400 zargv[4] .de $58
0410 zargv[5] .de $5a
0420 zargv[6] .de $5c
0430 zargv[7] .de $5e
0440 ;
0450 ;
0460 call.bdos .de $9006 ; Call BDOS function held in reg x
0470 disk.init .de $00
0480 load.sect .de $02
0490 dump.sect .de $04
0500 writebytes .de $06
0510 readbytes .de $08
0520 writefile .de $0a
0530 readfile .de $0c
0540 wrt.dirent .de $0e
0550 rd.dirent .de $10
0560 findfile .de $12
0570 findnext .de $14
0580 execfile .de $16
0590 delfile .de $18 ;delete file from directory &
0600 openfile .de $1a
0610 rwsectfh .de $1c
0620 rwdirfh .de $1e
0630 ;
0640 hex.dump .de $9f03
0650 symbiosys .de $9003
0660 ;
0670 errorhndlr .de $9010
0680 lib.puts .de $9013
0690 date.prnt .de $901c
0700 rtc.read .de $901f
0710 rtc.write .de $9022
0720 dir.prnt .de $9025
0730 istr.prnt .de $9028
0740 lib.atoi .de $902b
0750 ptrn.match .de $902e
0760 proc.flist .de $9031
0770 verify .de $9034
0780 ver.prompt .de $9037
0790 lba.prnt .de $903a
0800 lib.parsfn .de $903d
0810 ;
0820 buffer.ptr .de $a0
0830 word.rtrn .de $a2
0840 genbuf.pt2 .de $a4
0850 fsave.x .de $a6
0860 ztemp .de $eb
0870 ;
0880 warment .de $8003
0890 usrent .de $8035
0900 outbyte .de $82fa
0910 ascnib .de $8275
0920 getchar .de $8a58
0930 outchar .de $8a47
0940 crlf .de $834d
0950 space .de $8342
0960 pshove .de $8208
0970 parnr .de $a649
0980 par3 .de $a64a
0990 par2 .de $a64c
1000 par1 .de $a64e
1010 techo .de $a653
1020 ;
1030 sectr.buff .de $0200
1040 osctrlblk .de $0300
1050 cli.buffer .de osctrlblk ;size 80
1060 pattern .de cli.buffer+80 ;size 32
1070 date.buff .de pattern+32 ;size 10
1080 byte.count .de date.buff+10 ;size 2
1090 ;
1100 ivmp.addr .de $37c
1110 ;
1120 of.bvffer .de $3a0
1170 ;
1180 of.rae .de $3ef ;temporary open file for RAE
1190 ;
1200 F.Aloc.Lst .de $0400
1210 dirnt.buff .de $0500
1220 ;
1230 RAE.warm .de $b003
1240 RAE.txtst .de $100
1250 RAE.tpres .de $d3
1260 ;
1380 ;
1390 ; Files Header
1400 ;
1470 file.color .de $00 ;size 1
1480 file.name .de file.color+1 ;size 30
1490 file.ver .de file.name+30 ;size 1
1500 file.size .de file.ver+1 ;size 8
1510 file.ctime .de file.size+8 ;size 8
1520 file.mtime .de file.ctime+8 ;size 8
1530 file.atrib .de file.mtime+8 ;size 4
1540 file.load .de file.atrib+4 ;size 4
1550 file.loc .de file.load+4 ;size 4
1560 file.comnt .de file.loc+4
1570 ;
1580 of.lba .de $00 ;size 3
1590 of.size .de of.lba+3 ;size 2
1600 of.flptr .de of.size+2 ;size 2
1610 of.flags .de of.flptr+2 ;size 1
1620 ;
1630 of.close .de %11111110
1640 of.open .de %00000001
1650 ;
1660 w .de $00
1670 r .de $01
1680 a .de $02
1690 ;
1700 !!!fopen .md (mode indic.zarg)
1710 ldy #$ff
1720 ...loop iny
1730 lda (indic.zarg),y
1740 sta pattern,y
1750 bne ...loop
1760 ldx #openfile
1770 lda #mode
1780 jsr call.bdos
1790 .me
1800 ;
1810 !!!parsefn .md (zarg)
1820 lda *zarg
1830 sta *buffer.ptr
1840 lda *zarg+1
1850 sta *buffer.ptr+1
1860 jsr lib.parsfn
1870 bcs ...exit
1880 adc *zarg
1890 sta *zarg
1900 clc
1910 ...exit .me
1920 ;
1930 !!!fclose .md
1940 tax
1950 lda of.bvffer+of.flags,x
1960 and #of.close
1970 sta of.bvffer+of.flags,x
1980 .me
1990 ;
2000 ;
2010 ; osflag values
2020 ;
2030 showprgrs .de %10000000
2040 readfrwrd .de %00000001
2050 verifymode .de %00000010
2060 fullpath .de %00000100
2070 ;
2080 !!!rstosfl .md (mask)
2090 lda #mask
2100 eor #$ff
2110 and osflags
2120 sta osflags
2130 .me
2140 !!!setosfl .md (mask)
2150 lda #mask
2160 ora osflags
2170 sta osflags
2180 .me
2190 ;
2200 !!!cmpdbl .md (first second)
2210 sec
2220 lda first
2230 sbc second
2240 sta *ztemp
2250 lda first+1
2260 sbc second+1
2270 ora *ztemp
2280 .me
2290 ;
2300 !!!puts .md (strng)
2310 lda #l,strng
2320 ldy #h,strng
2330 jsr lib.puts
2340 .me
2350 ;
2360 !!!stdbl .md (src dst)
2370 pha
2380 lda #l,src
2390 sta dst
2400 lda #h,src
2410 sta dst+1
2420 pla
2430 .me
2440 ;
2450 !!!dprintf .md (src)
2460 pha
2470 lda #l,src
2480 sta *buffer.ptr
2490 lda #h,src
2500 sta *buffer.ptr+1
2510 jsr date.prnt
2520 pla
2530 .me
2540 ;
2550 !!!getdate .md (dest)
2560 pha
2570 lda #l,dest
2580 sta *buffer.ptr
2590 lda #h,dest
2600 sta *buffer.ptr+1
2610 jsr rtc.read
2620 pla
2630 .me
2640 ;
2650 !!!datecpy .md (source dest)
2660 ldx #8
2670 ...loop lda source-1,x
2680 sta dest-1,x
2690 dex
2700 bne ...loop
2710 .me
2720 ;
2730 !!!bdos .md (funct)
2740 ldx #funct
2750 jsr call.bdos
2760 .me
2770 ;
2780 !!!zrgatoi .md (zargv dest)
2790 ldx #zargv-zargv[0]
2800 lda #l,dest
2810 ldy #h,dest
2820 jsr lib.atoi
2830 .me
2840 ;
2850 !!!zrgputs .md (indic.zarg)
2860 ldy #$ff
2870 ...loop iny
2880 lda (indic.zarg),y
2890 jsr outchar
2900 bne ...loop
2910 .me
2920 ;
2930 !!!zargcpy .md (indic.zarg locvs.dest)
2940 ldy #$ff
2950 ...loop iny
2960 lda (indic.zarg),y
2970 sta locvs.dest,y
2980 bne ...loop
2990 .me
3000 ;
3120 !!!xfrdbl .md (src dst)
3130 pha
3140 lda src
3150 sta dst
3160 lda src+1
3170 sta dst+1
3180 pla
3190 .me
3200 ;
3210 !!!decdbl .md (loc)
3220 lda loc
3230 bne ...skip
3240 dec loc+1
3250 ...skip dec loc
3260 .me
3270 ;
3280 !!!cmpzdbl .md (loc)
3290 lda loc
3300 ora loc+1
3310 .me
3320 ;
3330 ;
3340 !!!phdbl .md (locvs)
3350 lda #h,locvs
3360 pha
3370 lda #l,locvs
3380 pha
3390 .me
3400 ;
3410 ;
3420 ; .ba $9600
3430 ; .ba $6600
3440 .ba $6000
3450 .es
3460 ;
4050 ;
4060 cmnd.cp lda *zargc
4070 cmp #3
4080 beq cp.begin
4090 cp.err jsr istr.prnt
4100 .by '[usernum:]sourcefn [usernum:]destfn' $00
4110 rts
4120 cp.begin parsefn (zargv[1])
4130 bcs cp.err
4140 fopen (r zargv[1])
4150 bcc cp.cont ; bcs cp.err
4160 jsr istr.prnt
4170 .by 'source file does not exist' $00
4180 rts
4190 cp.cont sta src.flhdl
4200 rstosfl (fullpath)
4210 parsefn (zargv[2])
4220 bcs cp.fnerr
4230 lda #fullpath
4240 bit osflags
4250 beq cp.skip
4260 ldy #0
4270 lda (zargv[2]),y
4280 bne cp.skip
4290 fopen (w zargv[1])
4300 bcc cp.skip2
4310 cp.fnerr jsr istr.prnt
4320 .by 'dest filename error' $00
4330 rts
4340 cp.skip fopen (w zargv[2])
4350 cp.skip2 bcs cp.fnerr
4360 sta dst.flhdl
4370 stdbl (sectr.buff dta.ptr)
4380 setosfl (showprgrs)
4390 lda #0
4400 sta ilba0
4410 cp.loop ldy src.flhdl
4420 sec
4430 bdos (rwsectfh)
4440 ldy dst.flhdl
4450 clc
4460 bdos (rwsectfh)
4470 lda ilba0
4480 ldx src.flhdl
4490 cmp of.bvffer+of.size+1,x
4500 bcs cp.finish
4510 inc ilba0
4520 bne cp.loop
4530 cp.finish ldy src.flhdl
4540 sec
4550 bdos (rwdirfh)
4560 stdbl (dirnt.buff dta.ptr)
4570 ldy dst.flhdl
4580 sec
4590 bdos (rwdirfh)
4600 lda sectr.buff+file.color
4610 sta dirnt.buff+file.color
4620 xfrdbl (sectr.buff+file.size dirnt.buff+file.size)
4630 xfrdbl (sectr.buff+file.load dirnt.buff+file.load)
4640 stdbl (dirnt.buff+file.mtime buffer.ptr)
4650 jsr rtc.read
4660 ldy dst.flhdl
4670 clc
4680 bdos (rwdirfh)
4690 cp.exit lda src.flhdl
4691 fclose
4692 lda dst.flhdl
4693 fclose
4694 lda #1
4695 rts
4700 ;
4710 src.flhdl .by $00
4720 dst.flhdl .by $00
4730 .en
4740 ;
4750 ;
4760 ; end of cp binary
4770 ;
//
>