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 >
Assembly Source File  |  2000-06-30  |  6KB  |  141 lines

  1. *****************************************************************
  2. *                                                               *
  3. *  TURBO-SAVE is an assembly language program written to        *
  4. *  salvage files in the event of a crash during compilation.    *
  5. *  It's great for those times when you forgot to save the       *
  6. *  program before compiling, and end up in a continuous loop.   *
  7. *                                                               *
  8. *  Credit Where Due:  TURBO-SAVE was written entirely from      *
  9. *  Savestar.asm, a program written to do the same thing for     *
  10. *  lost WordStar files, by D. Weinberger, 1985.                 *
  11. *                                                               *
  12. *  TURBO-SAVE was prepared by Alan Therrien for the members of  *
  13. *  the Bergen/Rockland KUG.  It may be distributed free, but    *
  14. *  not for profit.                                              *
  15. *                                                               *
  16. *****************************************************************
  17.  
  18. ; ---- EQUATES------
  19. boot   equ  0000h    ;sys reboot
  20. bdos   equ  0005h    ;BDOS jmp spot
  21. deletef equ  19      ;delete file function
  22. makef  equ  22       ;make file function
  23. writef equ  21       ;sequential write
  24. closef equ  16       ;close file function
  25. ctrlZ  equ  1AH      ;EOF character
  26. endfill equ 0000H    ;Another filler character
  27. FFfill equ  00FFH    ;Yet another filler character
  28. prnt   equ  9        ;print to console function
  29. cr     equ  13       ;carriage return
  30. lf     equ  10       ;line feed
  31. memax  equ  00ECh    ;hi-bite of where BDOS begins
  32. ; -------Where text is stored in the program ------
  33. BEGTEXT equ 8118h   ;7848H for WS v 3.0, 846Dh for WS v 3.3, 802Ch for 
  34.                     ; Turbo v 2 w/error msg, 7A74h for Turbo v 2 w/o error msg
  35.                     ; 7BF3h for Turbo v 3 w/o error msg, 8118h for Turbo v3 w
  36.                     ; error messages
  37. ; ======Program Start==============================
  38. ;
  39. ;SET UP PROGRAM AND ASSIGN THE STACK
  40.        org  100h
  41.        lxi  sp,stack
  42. ;
  43. ;PRINT SIGN ON MSG
  44.        lxi  d,sinon
  45.        mvi  c,prnt
  46.        call bdos
  47. ;
  48. ;DELETE ANY OLD COPY OF FILE "SALVAGED", precludes two files w/same name
  49.        lxi  d,tfcb
  50.        mvi  c,deletef
  51.        call bdos
  52. ;
  53. ;MAKE A NEW FILE CALLED "SALVAGED"
  54.        lxi  d,tfcb
  55.        mvi  c,makef
  56.        call bdos
  57. ;Enough room in the dir
  58.        cpi  0FFh
  59.        jz   fuldir
  60. ;
  61. ;=======MAIN LOOP WRITE MEMORY TO DISK =========
  62.        lxi  h,begtext                 ;Load HL w/loc of lost text beginning
  63. mspot: push h                         ;Save this pointer into text
  64. ;
  65. ;SET DMA to read next 128 of memory
  66.        xchg                           ;DE now points into text
  67.        mvi  c,1Ah                     ;C calls set-dma function
  68.        call bdos
  69. ;write a record (128 bytes)
  70.        lxi  d,tfcb                    ;DE=fcb of file to write into SALVAGED
  71.        mvi  c,writef                  ;C calls write-file function
  72.        call bdos
  73. ;Was write successful
  74.        cpi  0                         ;A=0 if write ok
  75.        jnz  filled                    ;if disk full, jump to sub-routine
  76. ;Have we written from memory past where text is
  77.        pop  h                         ;Restore H as pointer into text
  78.        mvi  a,memax                   ;Load A with hi-bite of max mem
  79.        cmp  h                         ;compare it to where we are
  80.        jz   finis                     ;if the same, jump to end
  81. ;Check for EOF
  82.        lxi  d,127                     ;Load DE with 127
  83.        dad  d                         ;Add whats in DE to address in HL
  84.        mov  a,m                       ;Load A w/address in HL-last byte of recd
  85.        cpi  ctrlz                     ;Is it EOF marker
  86.        jz   finis                     ;If so, jump to end
  87.        cpi  endfill                   ;Is it 00
  88.        jz   finis                     ;If so, jump to end
  89.        cpi  FFfill                    ;Is it 00FFh
  90.        jz   finis                     ;If so, jump to end
  91. ;We're not done
  92.        inx  h                         ;HL=HL+1, so it points to new record
  93.        jmp  mspot                     ;Loop back and do it again
  94. ;
  95. ;FINISHED READING AND WRITING SUCCESSFULLY
  96. FINIS: lxi  d,donemsg                 ;DE=address of sign-off msg
  97.        mvi  c,prnt                    ;C calls print string function
  98.        call bdos
  99. ;Continue to CLSF to close file "salvaged"
  100. ;
  101. ;CLOSE THE NEW FILE
  102. clsf:  lxi  d,tfcb                    ;DE=address of fcb
  103.        mvi  c,closef                  ;C calls close file function
  104.        call bdos       
  105.        mvi  c,boot                    ;re-boot to system
  106.        call bdos
  107. ;
  108. ;---ERROR ROUTINES----
  109. ;
  110. ;WRITE FAILED DUE TO DISK FULL
  111. filled: lxi d,fulldsk                 ;DE=address of full disk msg
  112.        mvi  c,prnt                    ;C calls print string function
  113.        call bdos
  114. ;
  115.        jmp  clsf                      ;jump to close file function
  116. ;
  117. ;MAKE-FILE FAILED DUE TO DIR FULL
  118. fuldir: lxi d,fuldr                   ;DE=address of full dir msg
  119.        mvi  c,prnt
  120.        call bdos
  121. ;
  122.        mvi  c,boot                    ;re-boot to system
  123.        call bdos
  124. ;
  125. ;----MESSAGES-----
  126. ;
  127. ;
  128. sinon  db   'TURBOSAVE By Alan R. Therrien  - for Bergen/Rockland KUG',cr,lf
  129.        db   'from SaveStar by D. Weinberger 1985',cr,lf,'$'
  130. donemsg db  ctrlZ,cr,lf,'==> Saved your butt again. Look at file B:Salvaged'
  131.         db  cr,lf,'$'
  132. fulldsk db  7,'++ Disk Full.  Erase a file or use new disk.'
  133.         db  ' Try again ++',cr,lf,'$'
  134. fuldr  db   7,'++ Directory full.  Erase a file or use new disk.'
  135.        db   ' Try again ++',cr,lf,'$'
  136. tfcb   db   2,'SALVAGED   ',0,0,0,0,0,0,0,0,0,0,0,0,0,0
  137.        db   0,0,0,0,0,0,0,0,0,0,0,0
  138.        ds   64
  139. stack  db   0
  140. ;
  141.        end 2,'SA