Mercurial > hg > Members > kono > nitros9-code
changeset 2148:aaff55744d7d
comments updated
author | boisy |
---|---|
date | Fri, 22 Feb 2008 23:32:36 +0000 |
parents | aa3228536418 |
children | fff5c57bbc77 |
files | level1/cmds/backup.asm |
diffstat | 1 files changed, 152 insertions(+), 122 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/cmds/backup.asm Fri Feb 22 15:15:35 2008 +0000 +++ b/level1/cmds/backup.asm Fri Feb 22 23:32:36 2008 +0000 @@ -9,7 +9,7 @@ * 8 ????/??/?? * From Tandy OS-9 Level Two VR 02.00.01. * -* 9 2005/5/3 Robert Gault +* 9 2005/05/03 Robert Gault * Folded in a new option F to permit a .dsk image file to be used * instead of dev1. Full path or local file can be used. There is * still a comparison of LSN0 to make sure that a disk actually has @@ -42,26 +42,28 @@ pmptsng rmb 1 single disk copy prompt flag (1 = prompt for single, 0 = don't) dontvfy rmb 1 don't verify backup (1 = Don't!, 0 = do) fileflg rmb 1 0 = disk, 1 = file (.dsk) to disk; RG -u000D rmb 1 -u000E rmb 1 -u000F rmb 1 -u0010 rmb 1 -u0011 rmb 2 -u0013 rmb 1 -u0014 rmb 1 -u0015 rmb 32 -u0035 rmb 32 +noprompt rmb 1 0 = prompt user, 1 = do not prompt user +srcerr rmb 1 source disk error code on I$Read +curlsn rmb 3 current 24-bit LSN counter used while backing up +sctbuf rmb 2 sector buffer pointer +numpages rmb 1 number of 256 byte pages we can use for backup buffer +pagcntr rmb 1 256 byte page counter (for backup buffer) +dstdev rmb 32 +optbuf rmb 32 SS/GS OPT buffer bufptr rmb 2 buffer pointer strbuf rmb 424 buffer -u01FF rmb 81 -u0250 rmb 256 -u0350 rmb 3840 +stack rmb 80 +* Important, the next two lines MUST STAY TOGETHER because of assumptions +* about their location in the code. +dstlsn0 rmb 256 +srclsn0 rmb 256 +backbuff rmb 14*256 reserve pages for backup buffer size equ . name fcs /Backup/ fcb edition -L0014 fcc "/d0 /d1" +defparms fcc "/d0 /d1" fcb C$CR IFNE DOHELP * Added F option; RG @@ -74,6 +76,8 @@ fcb C$LF fcc " f - replace dev1 with .dsk image file" fcb C$LF + fcc " p - do not prompt user" + fcb C$LF fcc " s - single drive prompts" fcb C$LF fcc " -v - inhibit verify pass" @@ -81,41 +85,58 @@ L00A0 fcb $80+C$CR L00A1 fcc "Ready to backup from" L00B5 fcb $80+C$SPAC -L00B6 fcs " to " -L00BA fcc "Ok" -L00BC fcs " ?: " -L00C0 fcs "Ready Source, hit a key: " -L00D9 fcs "Ready Destination, hit a key: " +to fcs " to " +ok fcc "Ok" +ask fcs " ?: " +rdysrc fcs "Ready Source, hit a key: " +rdydst fcs "Ready Destination, hit a key: " L00F7 fcs "Sector $" -L00FF fcs "Sectors copied: $" -L0112 fcb C$LF +sctscpd fcs "Sectors copied: $" +vfypass fcb C$LF fcc "Verify pass" fcb $80+C$CR -L011F fcs "Sectors verified: $" -L0132 fcb C$LF +sctvfd fcs "Sectors verified: $" +scratch fcb C$LF fcc " is being scratched" fcb $80+C$CR -NotSame fcc "Disks not formatted identically" +notsame fcc "Disks not formatted identically" fcb C$LF -L0167 fcc "Backup Aborted" +bkabort fcc "Backup Aborted" fcb $80+C$CR -start leas >u01FF,u - pshs b,a - pshs u - tfr y,d - subd ,s++ - subd #$0250 - sta <u0013 +* Here's how registers are set when this process is forked: +* +* +-----------------+ <-- Y (highest address) +* ! Parameter ! +* ! Area ! +* +-----------------+ <-- X, SP +* ! Data Area ! +* +-----------------+ +* ! Direct Page ! +* +-----------------+ <-- U, DP (lowest address) +* +* D = parameter area size +* PC = module entry point abs. address +* CC = F=0, I=0, others undefined + +* The start of the program is here. +start leas >stack,u move stack pointer to here + pshs b,a save parameter area size + pshs u save lowest addr + tfr y,d move top of parameter area to Y + subd ,s++ D=Y-U + subd #backbuff-stack +* A = number of 256 byte pages that are available for backup buffer + sta <numpages clr <pmptsng clr <fileflg clr <errabrt clr <dontvfy - clr <u000D + clr <srcerr leay <strbuf,u get address of our buffer sty <bufptr and save its pointer here - ldd ,s++ - beq L01E3 + ldd ,s++ get parameter length + beq L01E3 if parameter length is 0, use defaults L0199 ldd ,x+ get two bytes of command line prompt cmpa #C$SPAC space? beq L0199 continue if so @@ -123,11 +144,17 @@ beq L0199 continue if so eora #'E check for "abort if read error" flag anda #$DF mask it - bne Chk4S branch if not option + bne Chk4P branch if not option cmpb #'0 - bcc Chk4S branch if char after option is > $30 + bcc Chk4P branch if char after option is > $30 inc <errabrt else set flag bra L0199 and continue parsing +Chk4P lda -$01,x load A with prev char and backup X one byte + eora #'P check for "do not prompt user" flag + anda #$DF mask it + bne Chk4S branch if not option + inc <noprompt + bra L0199 Chk4S lda -$01,x load A with prev char and backup X one byte eora #'S check for "single drive prompts" flag anda #$DF mask it @@ -143,8 +170,8 @@ bne L01C1 cmpb #'0 bcc L01C1 - inc <fileflg update flag - bra L0199 keep reading + inc <fileflg update flag + bra L0199 keep reading * End of new routine L01C1 ldd -$01,x load A with prev char and backup X one byte cmpa #'- dash? @@ -158,13 +185,13 @@ inc <dontvfy bra L0199 L01D7 lda ,-x - tst <fileflg Don't look for / if image file, take anything; RG + tst <fileflg don't look for / if image file, take anything; RG bne L01E7 cmpa #PDELIM path delimiter? beq L01E7 branch if so cmpa #C$CR carriage return? lbne ShowHelp if not, show some help -L01E3 leax >L0014,pcr +L01E3 leax >defparms,pcr L01E7 leay >L00A1,pcr ready to backup lbsr L044B ready message ldy <bufptr @@ -187,17 +214,17 @@ L020B cmpa #PDELIM path delimiter? lbne ShowHelp if not, show some help leax -$01,x - leay >L00B6,pcr "to" + leay >to,pcr "to" lbsr L044B print ldy <bufptr sty <u0004 lbsr L043A parse path - leay >L00BC,pcr - lbsr L0421 + leay >ask,pcr + lbsr getkey comb eora #'Y anda #$DF - lbne L03BA + lbne exit tst <fileflg bne L0238b if file instead of device don't add @ ldx <u0002 @@ -209,9 +236,9 @@ lda #READ. os9 I$Open open source device (the one we're backing up) bcs L027C branch if error - leax >u0350,u + leax >srclsn0,u ldy #256 - os9 I$Read read LSN 0 + os9 I$Read read LSN 0 of source bcs L027C os9 I$Close ldx <u0002 @@ -220,105 +247,108 @@ bcs L027C sta <srcpath save path to source ldx <u0004 - leay <u0015,u + leay <dstdev,u L0267 ldb ,x+ stb ,y+ cmpb #C$SPAC bne L0267 ldd #'@*256+C$SPAC std -$01,y - leax <u0015,u + leax <dstdev,u lda #READ.+WRITE. os9 I$Open open destination device (the one we're writing to) L027C lbcs L03AF sta <dstpath save destination path - clr <u000E - clr <u000F - clr <u0010 + clr <curlsn + clr <curlsn+1 + clr <curlsn+2 lbsr L0419 lda <dstpath get destination path - leax >u0250,u + leax >dstlsn0,u ldy #256 - os9 I$Read read LSN0 + os9 I$Read read LSN0 of destination pshs u,x ldx #$0000 leau ,x os9 I$Seek reseek to start of disk puls u,x bcs L027C branch if error - ldd >256,x check for source/dest disk having same format + ldd >256,x check for source/dest disk having same number of sectors cmpd ,x bne DsksNOk branch if different ldb >$0102,x cmpb $02,x beq DsksOk -DsksNOk leay >NotSame,pcr +DsksNOk leay >notsame,pcr lbra L03B6 -DsksOk leax >u0250,u +DsksOk leax >dstlsn0,u X now points to source LSN0 lda #$BF - sta <$3F,x - leay <$1F,x + sta <DD.OPT,x + leay <DD.NAM,x lbsr L044B - leay >L0132,pcr + leay >scratch,pcr lbsr L0456 - leay >L00BA,pcr - lbsr L0421 + leay >ok,pcr + lbsr getkey get a key from the stdin comb eora #'Y anda #$DF - lbne L03BA + lbne exit exit if not ok to scratch lda <dstpath get destination path - leax >u0350,u + leax >srclsn0,u get src LSN0 read earlier ldy #256 - os9 I$Write - lbcs L03AF + os9 I$Write write it to destination + lbcs L03AF pshs u ldx #$0000 leau ,x os9 I$Seek seek to LSN0 puls u - leax >u0350,u + lbcs L03AF added Feb 8, 2008 BGP + leax >srclsn0,u os9 I$Read lbcs L03AF os9 I$Close close path - leax <u0015,u + leax <dstdev,u lda #WRITE. os9 I$Open open destination in write only mode lbcs L03AF sta <dstpath save new destination path - leax <u0035,u + leax <optbuf,u ldb #SS.OPT os9 I$GetStt ldb #$01 - stb $08,x + stb PD.VFY,x turn off verify ldb #SS.OPT os9 I$SetStt lbcs L03AF -L0332 leay >L00C0,pcr - lbsr L041D - lda <u0013 - sta <u0014 - leax >u0250,u + +copyloop leay >rdysrc,pcr + lbsr doprompt possibly show "ready source" message + lda <numpages + sta <pagcntr + leax >dstlsn0,u lbsr L0403 lbsr L0419 - ldd <u0011 - leax >u0250,u - stx <u0011 - subd <u0011 + ldd <sctbuf + leax >dstlsn0,u + stx <sctbuf + subd <sctbuf beq L035C tfr d,y lda <dstpath +* DriveWire Note: backup /x1 /d1 returns error 247 at this I$Write! os9 I$Write bcs L03AF -L035C lda <u000D +L035C lda <srcerr cmpa #E$EOF - bne L0332 - leay >L00FF,pcr + bne copyloop + leay >sctscpd,pcr lbsr L0470 tst <dontvfy - bne L03BA + bne exit * Verification code - leay >L0112,pcr + leay >vfypass,pcr lbsr L0456 lda <srcpath os9 I$Close close source path @@ -326,65 +356,65 @@ lda <dstpath os9 I$Close close destination path bcs L03AF - leax <u0015,u + leax <dstdev,u lda #READ. os9 I$Open open source path in READ mode bcs L03AF sta <srcpath save newly acquired path number - clr <u000E - clr <u000F - clr <u0010 - clr <u000D -L0396 lda <u0013 - sta <u0014 - leax >u0250,u + clr <curlsn + clr <curlsn+1 + clr <curlsn+2 + clr <srcerr +L0396 lda <numpages + sta <pagcntr + leax >dstlsn0,u bsr L0403 - lda <u000D + lda <srcerr cmpa #E$EOF bne L0396 - leay >L011F,pcr + leay >sctvfd,pcr lbsr L0470 - bra L03BA + bra exit L03AF os9 F$PErr - leay >L0167,pcr + leay >bkabort,pcr L03B6 lbsr L0456 comb -L03BA ldb #$00 +exit ldb #$00 os9 F$Exit L03BF ldy #256 lda <srcpath os9 I$Read bcc L03DC - stb <u000D + stb <srcerr cmpb #E$EOF beq L040D lbsr L046C - ldb <u000D + ldb <srcerr tst <errabrt bne L03AF os9 F$PErr -L03DC ldd <u000F - addd #$0001 - std <u000F - bcc L03E7 - inc <u000E -L03E7 tst <u000D +L03DC ldd <curlsn+1 get lower 16 bits of current LSN + addd #$0001 increment + std <curlsn+1 and save back + bcc L03E7 branch if no carry + inc <curlsn else increment bits 23-16 of LSN +L03E7 tst <srcerr beq L03FD pshs u - ldx <u000E - tfr b,a - clrb - tfr d,u + ldx <curlsn get curlsn in X + tfr b,a put bits 7-0 of LSN into bits 15-8 + clrb and clear B + tfr d,u transfer to U lda <srcpath os9 I$Seek puls u - clr <u000D -L03FD ldx <u0011 + clr <srcerr +L03FD ldx <sctbuf leax >256,x -L0403 stx <u0011 - lda <u0014 +L0403 stx <sctbuf + lda <pagcntr suba #$01 - sta <u0014 + sta <pagcntr bcc L03BF L040D rts @@ -395,12 +425,12 @@ leay >HelpMsg,pcr point to help message data bra L03B6 ELSE - bra L03BA + bra exit ENDC -L0419 leay >L00D9,pcr -L041D tst <pmptsng - beq L0439 -L0421 bsr L0456 +L0419 leay >rdydst,pcr +doprompt tst <pmptsng single disk backup prompt? + beq L0439 if not, just return +getkey bsr L0456 pshs y,x,b,a leax ,s ldy #$0001 @@ -451,12 +481,12 @@ puls pc,y,x,a L046C leay >L00F7,pcr L0470 bsr L044B - lda <u000E + lda <curlsn bsr L0486 inc <u0009 - lda <u000F + lda <curlsn+1 bsr L0488 - lda <u0010 + lda <curlsn+2 bsr L0488 leay >L00B5,pcr bra L0456