home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tpfast.zip / FASTFILE.ASM < prev    next >
Assembly Source File  |  1990-09-26  |  23KB  |  461 lines

  1. ;   _______________________________________________________________
  2. ;  |                                                               |
  3. ;  |            Copyright (C) 1989,1990  Steven Lutrov             |
  4. ;  |_______________________________________________________________|____
  5. ;  |                                                               |    |
  6. ;  |  Program Title : Fastfile.Asm                                 |    | ___
  7. ;  |  Author        : Steven Lutrov                                |    |    |
  8. ;  |  Revision      : 2.01                                         |    |    |
  9. ;  |  Date          : 1990-03-16                                   |    |    |
  10. ;  |  Language      : Turbo Assembler                              |    |    |
  11. ;  |                                                               |    |    |
  12. ;  |                                                               |    |    |
  13. ;  |  Description   : Assembly functions For primitive file        |    |    |
  14. ;  |                : handeling.                                   |    |    |
  15. ;  |                : Tested on Turbo Pascal Turbo Pascal 5.5      |    |    |
  16. ;  |                                                               |    |    |
  17. ;  |_______________________________________________________________|    |    |
  18. ;      |                                                                |    |
  19. ;      |________________________________________________________________|    |
  20. ;          |                                                                 |
  21. ;          |_________________________________________________________________|
  22. ;
  23.  
  24.  
  25.  
  26. Code Segment Word Public
  27.  
  28. Assume Cs:Code,Ds:Data
  29.  
  30.  
  31. Public Closefile,Createfile,Erasefile,Fmovepointer,Openfile,Readfile,
  32. Public Writefile,Getverify,Getvolume,Readsector,Setverify,Setvolume
  33. Public Writesector
  34.  
  35.  
  36.  
  37. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. ;Function Getverify: Boolean;
  39. ;
  40. ;
  41. Getverify Proc Far
  42.         Mov  Ah,54H                     ;Dos Func To Get Verify
  43.         Int  21H                        ;Get Status
  44.         Ret
  45. Getverify Endp
  46.  
  47.  
  48. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. ;Function Getvolume(Disk: Integer; Workarea: Pointer): Stype;
  50. ;
  51. ;
  52. Getvolume Proc Far
  53.                 Push Bp                         ;Save Turbos Bp
  54.                 Mov  Bp,Sp                      ;
  55.                 Push Ds                         ;Save Turbo'S Ds
  56.                 Mov  Ah,2Fh                     ;Save Current Dta
  57.                 Int  21H                        ;
  58.                 Push Es                         ;
  59.                 Push Bx                         ;
  60.                 Cld                             ;Set Direction Flag
  61.                 Lds  Dx,Dword Ptr[Bp+6]         ;Ds:Dx Pts To Workarea
  62.                 Mov  Ah,1Ah                     ;Function To Set Dta
  63.                 Int  21H                        ;Set Dta
  64.                 Mov  Si,Dx                      ;Point Si To Dta
  65.                 Mov  Al,[Bp+10]                 ;Get Drive Specifier
  66.                 Or   Al,Al                      ;0 = Current Drive
  67.                 Jnz  Getv1                      ;Jump If Not Current
  68.                 Mov  Ah,19H                     ;Dos Func To Get Drv Num
  69.                 Int  21H                        ;Get Current Drive
  70.                 Inc  Al                         ;Count Drives From 1
  71. Getv1:          Add  Al,64                      ;Convert To A:, B: Etc.
  72.                 Mov  [Si],Al                    ;Write It
  73.                 Inc  Si                         ;Forward Ptr
  74.                 Mov  Al,':'                     ;Colour To Follow Drv Spec
  75.                 Mov  [Si],Al                    ;Write It
  76.                 Inc  Si                         ;Forward Ptr
  77.                 Mov  Al,'*'                     ;Global Character
  78.                 Mov  [Si],Al                    ;Write It
  79.                 Inc  Si                         ;Forward Ptr
  80.                 Mov  Al,'.'                     ;Global Character
  81.                 Mov  [Si],Al                    ;Write It
  82.                 Inc  Si                         ;Forward Ptr
  83.                 Mov  Al,'*'                     ;Global Character
  84.                 Mov  [Si],Al                    ;Write It
  85.                 Inc  Si                         ;Forward Ptr
  86.                 Mov  Al,0                       ;Terminate With 0
  87.                 Mov  [Si],Al                    ;Write It
  88.                 Mov  Cx,8                       ;Attribute For Vol Label
  89.                 Les  Di,Dword Ptr[Bp+12]        ;Point To Return String
  90.                 Mov  Ah,4Eh                     ;Function To Seek File
  91.                 Int  21H                        ;Seek Vol Label
  92.                 Jnc  Getv2                      ;Jump If Found
  93.                 Mov  Byte Ptr Es:[Di],0         ;Set Null String Descriptor
  94.                 Jmp  Getv5                      ;Go Quit
  95. Getv2:          Inc  Di                         ;Forward Pointer To First Char
  96.                 Mov  Si,Dx                      ;Si To Start Of Workarea
  97.                 Add  Si,30                      ;Offset To Vol Label
  98.                 Sub  Cl,Cl                      ;Count Strx Len In Cl
  99. Getv3:          Lodsb                           ;Get A Byte
  100.                 Or   Al,Al                      ;Test For Terminating 0
  101.                 Jz   Getv4                      ;Jump When Finished
  102.                 Cmp  Al,'.'                     ;Period?
  103.                 Je   Getv3                      ;Skip It If So
  104.                 Stosb                           ;Transfer Char
  105.                 Inc  Cl                         ;Inc Length Counter
  106.                 Jmp  Short Getv3                ;Go Get Next
  107. Getv4:          Les  Di,Dword Ptr[Bp+12]        ;Return String Address
  108.                 Mov  Es:[Di],Cl                 ;Set Descriptor
  109. Getv5:          Pop  Dx                         ;Restore Prior Dta
  110.                 Pop  Ds                         ;
  111.                 Mov  Ah,1Ah                     ;
  112.                 Int  21H                        ;
  113.                 Pop  Ds                         ;
  114.                 Pop  Bp
  115.                 Ret  6
  116. Getvolume  Endp
  117.  
  118.  
  119. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  120. ;Procedure Readsector(Segment,Offset,Drive,Sector,Number: Word);
  121. ;
  122. ;
  123. Data    Segment
  124.         Extrn  Errreturn:Byte
  125. Data    Ends
  126. ;
  127. ;
  128. Readsector Proc Far
  129.                 Push  Bp                        ;Save Bp
  130.                 Mov   Bp,Sp                     ;Set Up Stack Frame
  131.                 Push  Ds                        ;Save Ds
  132.                 Lds   Bx,Dword Ptr[Bp+12]       ;Get Buffer Address
  133.                 Mov   Al,[Bp+10]                ;Drive Code
  134.                 Dec   Al                        ;Adjust For Turbo
  135.                 Mov   Dx,[Bp+8]                 ;Logical Sector Number
  136.                 Mov   Cx,[Bp+6]                 ;Number Sectors To Read
  137.                 Int   25H                       ;Read The Sector(S)
  138.                 Mov   Bl,0                      ;0 = No Error
  139.                 Jnc   Rsec1                     ;Test For Error
  140.                 Mov   Bl,Ah                     ;Error Code To Bl
  141. Rsec1:          Pop   Cx                        ;Balance Stack
  142.                 Pop   Ds                        ;Restore Ds
  143.                 Pop   Bp                        ;Restore Bp
  144.                 Mov   Errreturn,Bl              ;Set Error Code
  145.                 Ret   10
  146. Readsector Endp
  147.  
  148.  
  149. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  150. ;Procedure Setverify(Setting: Boolean);
  151. ;
  152. ;
  153. Setverify Proc Far
  154.                 Mov  Bx,Sp                      ;
  155.                 Sub  Dl,Dl                      ;Dl Must = 0
  156.                 Mov  Al,Ss:[Bx+4]               ;1 = On, 0 = Off
  157.                 Mov  Ah,2Eh                     ;Dos Func To Set Verify
  158.                 Int  21H                        ;Set Verification
  159.                 Ret  2
  160. Setverify Endp
  161.  
  162.  
  163. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  164. ;Procedure Setvolume(Disk: Integer; Newlabel: Stype; Workarea: Pointer);
  165. ;
  166. ;
  167. Setvolume Proc Far
  168.                 Push Bp                         ;
  169.                 Mov  Bp,Sp                      ;
  170.                 Push Ds                         ;
  171.                 Mov  Ah,2Fh                     ;Save Current Dta
  172.                 Int  21H                        ;Dos Interrupt
  173.                 Push Es                         ;
  174.                 Push Bx                         ;
  175.                 Lds  Dx,Dword Ptr[Bp+6]         ;Ds:Dx Pts To Workarea
  176.                 Mov  Ah,1Ah                     ;Function To Set Dta
  177.                 Int  21H                        ;Set Dta
  178. Setv1:          Les  Di,Dword Ptr[Bp+6]         ;Es:Di Pts To Workarea
  179.                 Lds  Si,Dword Ptr[Bp+6]         ;Ds:Dx Pts To Workarea
  180.                 Mov  Ax,2020H                   ;Clear With Spaces
  181.                 Mov  Cx,22                      ;22 Words In Workarea
  182.                 Cld                             ;Direction Forward
  183.                 Rep  Stosw                      ;Clear The Workarea
  184.                 Mov  Byte Ptr[Si],0Ffh          ;Ff Marks Extended Fcb
  185.                 Add  Si,6                       ;Forward To Attri Byte
  186.                 Mov  Byte Ptr[Si],8             ;Volume Label Attribute
  187.                 Inc  Si                         ;Forward Ptr
  188.                 Mov  Al,[Bp+14]                 ;Drive Number
  189.                 Mov  [Si],Al                    ;Set It
  190.                 Mov  Bx,Si                      ;
  191.                 Inc  Bx                         ;
  192.                 Les  Di,Dword Ptr[Bp+10]        ;Es:Di Pts To New Label
  193.                 Sub  Cx,Cx                      ;Clear Cx
  194.                 Mov  Cl,Es:[Di]                 ;Length Of New Label
  195.                 Jcxz Sevol3                     ;Jump If Null
  196.                 Cmp  Cx,13                      ;In Range?
  197.                 Ja   Sevol4                     ;Quit If Not
  198. Sevol2:         Inc  Si                         ;Forward Target Ptr
  199.                 Inc  Di                         ;
  200.                 Mov  Al,Es:[Di]                 ;Get A Byte
  201.                 Mov  [Si],Al                    ;Transfer To Workarea
  202.                 Loop Sevol2                     ;Go Do Next
  203.                 Mov  Ah,16H                     ;"Create File"
  204.                 Int  21H                        ;Go Set Label
  205.                 Cmp  Al,0Ffh                    ;Test For Error
  206.                 Jne  Sevol4                     ;Quit If None
  207. Sevol3:         Mov  Ax,Ds                      ;Point Es:Di Back To Label Field
  208.                 Mov  Es,Ax                      ;
  209.                 Mov  Di,Bx                      ;
  210.                 Mov  Al,'?'                     ;Write Global Chars
  211.                 Mov  Cx,13                      ;13 Chars
  212.                 Rep  Stosb                      ;Write Them
  213.                 Mov  Ah,13H                     ;Func To Delete Label
  214.                 Int  21H                        ;Get Rid Of Old Label
  215.                 Cmp  Al,0Ffh                    ;Test For Error
  216.                 Je   Sevol4                     ;Get Out If Error
  217.                 Mov  Si,Bx                      ;Pt Back To Label Field
  218.                 Mov  Di,Bx                      ;Di Too
  219.                 Jmp  Short Setv1                ;Go Set Up Label Again
  220. Sevol4:         Pop  Dx                         ;Restore Prior Dta
  221.                 Pop  Ds                         ;
  222.                 Mov  Ah,1Ah                     ;
  223.                 Int  21H                        ;
  224.                 Pop  Ds                         ;
  225.                 Pop  Bp                         ;
  226.                 Ret  10
  227. Setvolume  Endp
  228.  
  229.  
  230. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  231. ;Procedure Writesector(Segment,Offset,Drive,Sector,Number: Word;);
  232. ;
  233. ;
  234. Data    Segment
  235.         Extrn  Errreturn:Byte
  236. Data    Ends
  237. ;
  238. ;
  239. Writesector Proc Far
  240.                 Push  Bp                        ;Save Bp
  241.                 Mov   Bp,Sp                     ;Set Up Stack Frame
  242.                 Push  Ds                        ;Save Ds
  243.                 Lds   Bx,Dword Ptr[Bp+12]       ;Get Buffer Address
  244.                 Mov   Al,[Bp+10]                ;Drive Code
  245.                 Dec   Al                        ;Adjust For Turbo
  246.                 Mov   Dx,[Bp+8]                 ;Logical Sector Number
  247.                 Mov   Cx,[Bp+6]                 ;Number Sectors To Write
  248.                 Int   26H                       ;Write The Sector(S)
  249.                 Mov   Bl,0                      ;0 = No Error
  250.                 Jnc   Wsec1                     ;Test For Error
  251.                 Mov   Bl,Ah                     ;Error Code To Bl
  252. Wsec1:          Pop   Cx                        ;Balance Stack
  253.                 Pop   Ds                        ;Restore Ds
  254.                 Pop   Bp                        ;Restore Bp
  255.                 Mov   Errreturn,Bl              ;Set Error Code
  256.                 Ret   10                        ;
  257. Writesector Endp
  258.  
  259. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  260. ;Function Createfile(Fname:String; Attribute:Integer):Integer;
  261.  
  262. Fcname     Equ        Dword Ptr [Bp+8]
  263. Fcattr     Equ        Word  Ptr [Bp+6]
  264. Fcsize     Equ        4 + 2
  265.  
  266. Createfile    Proc Far
  267.                 Push Bp                      ; Save Bp
  268.                 Mov  Bp,Sp                   ; Setup Stack Frame
  269.                 Push Ds                      ; Save Ds
  270.                 Lds  Si,Fcname               ; Get Fcname Address
  271.                 Mov  Bl,[Si]                 ; Get Length Of String In Dx
  272.                 Inc  Si                      ; Skip Pascal String[0] Length Byte
  273.                 Xor  Bh,Bh                   ; Bx=$00Xx, Where Xx Is Length
  274.                 Mov  [Si+Bx],Bh              ; End String With Asciz
  275.                 Mov  Dx,Si                   ; Fname Asciz Ptr In Ds:Dx
  276.                 Mov  Cx,Fcattr               ; Attribute To Set In Created File
  277.                 Mov  Ah,3Ch                  ; Create
  278.                 Int  21H                     ; Do It
  279.                 Jnc  Fc01                    ; Jump If No Error
  280.                 Neg  Ax                      ; Ax:=-Ax
  281. Fc01:           Pop  Ds                      ;
  282.                 Pop  Bp                      ;
  283.                 Ret  Fcsize
  284. Createfile    Endp
  285. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  286. ;Function Openfile(Name:String; Access:Integer):Integer;
  287.  
  288. Foname     Equ        Dword Ptr [Bp+8]
  289. Foacce     Equ        Word  Ptr [Bp+6]
  290. Fosize     Equ        4 + 2
  291.  
  292. Openfile      Proc Far
  293.                 Push Bp                      ; Save Bp
  294.                 Mov  Bp,Sp                   ; Set Up Stack Frame
  295.                 Push Ds                      ; Save Ds
  296.                 Lds  Si,Foname               ; Get Foname Address
  297.                 Mov  Bl,[Si]                 ; Get Length Of String In Dx
  298.                 Inc  Si                      ; Skip Pascal String[0] Length Byte
  299.                 Xor  Bh,Bh                   ; Bx=$00Xx, Where Xx Is Length
  300.                 Mov  [Si+Bx],Bh              ; End String With Asciz
  301.                 Mov  Dx,Si                   ; Fname Asciz Ptr In Ds:Dx
  302.                 Mov  Ax,Foacce               ; File Access Code
  303.                 Mov  Ah,3Dh                  ; Open File
  304.                 Int  21H                     ; Do It
  305.                 Mov  Bx,0                    ; Boolean False
  306.                 Jnc  Fo01                    ; Jump If No Error
  307.                 Neg  Ax                      ; Ax:=-Ax;
  308. Fo01:           Pop  Ds                      ; Restore Ds
  309.                 Pop  Bp                      ; Restore Bp
  310.                 Ret  Fosize
  311. Openfile      Endp
  312.  
  313.  
  314.  
  315. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  316. ;Function Closefile(Handle:Integer):Boolean;
  317.  
  318. Fclhandle  Equ  Word Ptr [Bp+6]
  319. Fclsize    Equ  2
  320.  
  321. Closefile     Proc Far
  322.                 Push Bp                      ; Save Bp Stack
  323.                 Mov  Bp,Sp                   ; Set Up Stack Frame
  324.                 Mov  Bx,Fclhandle            ; File Handler Identifier
  325.                 Mov  Ah,3Eh                  ; Close
  326.                 Int  21H                     ; Do It
  327.                 Mov  Ax,0                    ; Boolean False
  328.                 Jc   Fcl01                   ; Jump If Error
  329.                 Mov  Ax,1                    ; Boolean True
  330. Fcl01:          Pop  Bp
  331.                 Ret  Fclsize
  332. Closefile     Endp
  333.  
  334.  
  335.  
  336. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  337. ;Function Writefile(Handle:Integer; Nwrite:Word; Var Buff):Integer;
  338.  
  339. Fwhandle   Equ  Word Ptr [Bp+12]
  340. Fwwrite    Equ  Word Ptr [Bp+10]
  341. Fwbuff     Equ  Dword Ptr [Bp+6]
  342. Fwsize     Equ  2 + 2 + 4
  343.  
  344. Writefile     Proc Far
  345.                 Push Bp                      ; Save Bp Stack
  346.                 Mov  Bp,Sp                   ; Set Up Stack Frame
  347.                 Push Ds                      ; Save Ds
  348.                 Mov  Bx,Fwhandle             ; File Handler Identifier
  349.                 Lds  Dx,Fwbuff               ; Data Buffer
  350.                 Mov  Cx,Fwwrite              ; Number Of Bytes To Write
  351.                 Cmp  Cx,07Fffh               ; Above 7Fff
  352.                 Ja   Fw02                    ; To Many Bytes To Write
  353.                 Mov  Ah,40H                  ; Write
  354.                 Int  21H                     ; Do It
  355.                 Jnc  Fw01                    ; Jump If No Error
  356. Fw02:           Neg  Ax                      ; Ax:=-Ax;
  357. Fw01:           Pop  Ds                      ; Restore Bs
  358.                 Pop  Bp                      ; Restore Bp
  359.                 Ret  Fwsize
  360. Writefile     Endp
  361.  
  362.  
  363. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  364. ;Function Readfile(Handle:Word; Amount:Word; Var Buff):Integer;
  365.  
  366. Frhandle   Equ  Word Ptr [Bp+12]
  367. Framount   Equ  Word Ptr [Bp+10]
  368. Frbuff     Equ  Dword Ptr [Bp+6]
  369. Frsize     Equ  2 + 2 + 4
  370.  
  371. Readfile      Proc Far
  372.                 Push Bp                      ; Store Bp
  373.                 Mov  Bp,Sp                   ; Setup Stack Frame
  374.                 Push Ds                      ; Save Ds
  375.                 Mov  Bx,Frhandle             ; File Handler Identifier
  376.                 Lds  Dx,Frbuff               ; Data Buffer
  377.                 Mov  Cx,Framount               ; Number Of Bytes To Read
  378.                 Cmp  Cx,07Fffh               ; Above 7Fff
  379.                 Ja   Fr02                    ; Too Many Bytes To Read
  380.                 Mov  Ah,3Fh                  ; Read
  381.                 Int  21H                     ; Do It
  382.                 Jnc  Fr01                    ; Jump If No Error
  383. Fr02:           Neg  Ax                      ; Make Ax Negative
  384. Fr01:           Pop  Ds                      ; Restore Ds
  385.                 Pop  Bp                      ; Restore Bp
  386.                 Ret  Frsize
  387. Readfile      Endp
  388.  
  389.  
  390. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  391. ;Function Fmovepointer(Handle:Integer; Mode:Integer; Offset:Longint;
  392. ;                      Var Location:Longint):Boolean;
  393.  
  394. Fshandle   Equ  Word Ptr [Bp+16]
  395. Fsmode     Equ  Word Ptr [Bp+14]
  396. Fsofshi    Equ  Word Ptr [Bp+12]
  397. Fsofslo    Equ  Word Ptr [Bp+10]
  398. Fslocation Equ  Dword Ptr [Bp+6]
  399.  
  400. Fssize     Equ  2 + 2 + 4 + 4
  401.  
  402. Fmovepointer      Proc Far
  403.                 Push Bp                      ; Save Bp
  404.                 Mov  Bp,Sp                   ; Set Up Stack Frame
  405.                 Push Ds                      ; Save Ds
  406.                 Mov  Bx,Fshandle             ; File Handler Identifier
  407.                 Mov  Cx,Fsofshi              ; File Offset In Cx
  408.                 Mov  Dx,Fsofslo              ; File Offset In Cx:Dx
  409.                 Mov  Ax,Fsmode               ; Load Method Code
  410.                 Mov  Ah,42H                  ; Seek
  411.                 Int  21H                     ; Do It
  412.                 Mov  Bx,1                    ; Boolean True
  413.                 Jnc  Fs01                    ; Jump If Not Error
  414.                 Mov  Bx,0                    ; Boolean False
  415.                 Mov  Dx,0                    ; High Word In Location=$0000
  416. Fs01:           Les  Di,Fslocation           ; Point To Fslocation
  417.                 Cld                          ; Set Direction Flag
  418.                 Stosw                        ; Low Word To Location
  419.                 Mov  Ax,Dx                   ;
  420.                 Stosw                        ; High Word To Location
  421.                 Mov  Ax,Bx                   ; Return False Or True
  422.                 Pop  Ds                      ; Restore Ds
  423.                 Pop  Bp                      ; Restore Bp
  424.                 Ret  Fssize
  425. Fmovepointer      Endp
  426.  
  427.  
  428.  
  429. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  430. ;Function Erasefile(Name:String):Integer;
  431.  
  432. Fename     Equ  Dword Ptr [Bp+6]
  433. Fesize     Equ  4
  434.  
  435. Erasefile     Proc Far
  436.                 Push Bp                      ; Save Bp
  437.                 Mov  Bp,Sp                   ; Set Up Stack Frame
  438.                 Push Ds                      ; Save Ds
  439.                 Lds  Si,Fename               ; Get Address Of Fename
  440.                 Mov  Bl,[Si]                 ; Get Length Of String In Dx
  441.                 Inc  Si                      ; Skip Pascal String[0] Length Byte
  442.                 Xor  Bh,Bh                   ; Bx=$00Xx, Where Xx Is Length
  443.                 Mov  [Si+Bx],Bh              ; End String With Asciz
  444.                 Mov  Dx,Si                   ; Fname Asciz Ptr In Ds:Dx
  445.                 Mov  Ah,41H                  ; Erase File
  446.                 Int  21H                     ; Do It
  447.                 Mov  Bx,0                    ; Boolean False
  448.                 Jnc  Fe01                    ; Jump If No Error
  449.                 Neg  Ax                      ; Make Ax -Ax;
  450.                 Jmp  Fe02                    ; Restore And Exit
  451. Fe01:           Mov  Ax,0                    ;
  452. Fe02:           Pop  Ds                      ; Restore Ds
  453.                 Pop  Bp                      ; Restore Bp
  454.                 Ret  Fesize
  455. Erasefile     Endp
  456.  
  457.  
  458. Code    Ends
  459.         End
  460.  
  461.