home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
ZCAT
/
TPSAVFIL.LBR
/
TURBOSAV.ASM
next >
Wrap
Assembly Source File
|
2000-06-30
|
6KB
|
141 lines
*****************************************************************
* *
* TURBO-SAVE is an assembly language program written to *
* salvage files in the event of a crash during compilation. *
* It's great for those times when you forgot to save the *
* program before compiling, and end up in a continuous loop. *
* *
* Credit Where Due: TURBO-SAVE was written entirely from *
* Savestar.asm, a program written to do the same thing for *
* lost WordStar files, by D. Weinberger, 1985. *
* *
* TURBO-SAVE was prepared by Alan Therrien for the members of *
* the Bergen/Rockland KUG. It may be distributed free, but *
* not for profit. *
* *
*****************************************************************
; ---- EQUATES------
boot equ 0000h ;sys reboot
bdos equ 0005h ;BDOS jmp spot
deletef equ 19 ;delete file function
makef equ 22 ;make file function
writef equ 21 ;sequential write
closef equ 16 ;close file function
ctrlZ equ 1AH ;EOF character
endfill equ 0000H ;Another filler character
FFfill equ 00FFH ;Yet another filler character
prnt equ 9 ;print to console function
cr equ 13 ;carriage return
lf equ 10 ;line feed
memax equ 00ECh ;hi-bite of where BDOS begins
; -------Where text is stored in the program ------
BEGTEXT equ 8118h ;7848H for WS v 3.0, 846Dh for WS v 3.3, 802Ch for
; Turbo v 2 w/error msg, 7A74h for Turbo v 2 w/o error msg
; 7BF3h for Turbo v 3 w/o error msg, 8118h for Turbo v3 w
; error messages
; ======Program Start==============================
;
;SET UP PROGRAM AND ASSIGN THE STACK
org 100h
lxi sp,stack
;
;PRINT SIGN ON MSG
lxi d,sinon
mvi c,prnt
call bdos
;
;DELETE ANY OLD COPY OF FILE "SALVAGED", precludes two files w/same name
lxi d,tfcb
mvi c,deletef
call bdos
;
;MAKE A NEW FILE CALLED "SALVAGED"
lxi d,tfcb
mvi c,makef
call bdos
;Enough room in the dir
cpi 0FFh
jz fuldir
;
;=======MAIN LOOP WRITE MEMORY TO DISK =========
lxi h,begtext ;Load HL w/loc of lost text beginning
mspot: push h ;Save this pointer into text
;
;SET DMA to read next 128 of memory
xchg ;DE now points into text
mvi c,1Ah ;C calls set-dma function
call bdos
;write a record (128 bytes)
lxi d,tfcb ;DE=fcb of file to write into SALVAGED
mvi c,writef ;C calls write-file function
call bdos
;Was write successful
cpi 0 ;A=0 if write ok
jnz filled ;if disk full, jump to sub-routine
;Have we written from memory past where text is
pop h ;Restore H as pointer into text
mvi a,memax ;Load A with hi-bite of max mem
cmp h ;compare it to where we are
jz finis ;if the same, jump to end
;Check for EOF
lxi d,127 ;Load DE with 127
dad d ;Add whats in DE to address in HL
mov a,m ;Load A w/address in HL-last byte of recd
cpi ctrlz ;Is it EOF marker
jz finis ;If so, jump to end
cpi endfill ;Is it 00
jz finis ;If so, jump to end
cpi FFfill ;Is it 00FFh
jz finis ;If so, jump to end
;We're not done
inx h ;HL=HL+1, so it points to new record
jmp mspot ;Loop back and do it again
;
;FINISHED READING AND WRITING SUCCESSFULLY
FINIS: lxi d,donemsg ;DE=address of sign-off msg
mvi c,prnt ;C calls print string function
call bdos
;Continue to CLSF to close file "salvaged"
;
;CLOSE THE NEW FILE
clsf: lxi d,tfcb ;DE=address of fcb
mvi c,closef ;C calls close file function
call bdos
mvi c,boot ;re-boot to system
call bdos
;
;---ERROR ROUTINES----
;
;WRITE FAILED DUE TO DISK FULL
filled: lxi d,fulldsk ;DE=address of full disk msg
mvi c,prnt ;C calls print string function
call bdos
;
jmp clsf ;jump to close file function
;
;MAKE-FILE FAILED DUE TO DIR FULL
fuldir: lxi d,fuldr ;DE=address of full dir msg
mvi c,prnt
call bdos
;
mvi c,boot ;re-boot to system
call bdos
;
;----MESSAGES-----
;
;
sinon db 'TURBOSAVE By Alan R. Therrien - for Bergen/Rockland KUG',cr,lf
db 'from SaveStar by D. Weinberger 1985',cr,lf,'$'
donemsg db ctrlZ,cr,lf,'==> Saved your butt again. Look at file B:Salvaged'
db cr,lf,'$'
fulldsk db 7,'++ Disk Full. Erase a file or use new disk.'
db ' Try again ++',cr,lf,'$'
fuldr db 7,'++ Directory full. Erase a file or use new disk.'
db ' Try again ++',cr,lf,'$'
tfcb db 2,'SALVAGED ',0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0
ds 64
stack db 0
;
end 2,'SA