home *** CD-ROM | disk | FTP | other *** search
- Title Turbo loader program
- ret_f_2 macro
- db 0cah,02,00
- endm
- ret_n macro
- db 0c3h
- endm
- code segment
- org 100h
- assume cs:code,ds:code,es:code
- turbak: jmp start
- message1 db 'Memory Allocation error. Not enough memory ??',0dh,0ah,'$'
- message2 db 'Program loading error. Run program with "/I" switch'
- db ' to install. (TLOAD /I)'
- CRLF db 0dh,0ah,'$'
- Noofchars db 64
- Name_len db ?
- progname db 'turbo.com',0 ; ASCIIZ filename of program
- db 55 dup (0) ; space for longer pathnames
- Oldint21 dd ? ; pointer to the real interrupt 16
- ext_addr dw ?
- pathname db 64 dup (?),0
- count db 3 ; Number of backups maintained (excluding .BAK)
- param dw 0
- cmdline dd ?
- fcb1 dd ?
- fcb2 dd ?
-
- newint21: cmp ah,41h
- jz del_file
- cmp ah,56h
- jz ren_file
- exit: jmp cs:[Oldint21]
- del_file: sti
- call bakfind
- jz exit
- push ax
- push bx
- push cx
- push dx
- push si
- push di
- push es
- mov bx,cs:ext_addr
- mov si,bx
- add bx,dx
- mov al,cs:count
- mov [bx],al
- add byte ptr [bx],30h
- mov ah,41h
- pushf
- call cs:[oldint21]
- push cs
- pop es
- mov di,offset pathname
- add si,di
- mov cl,cs:count
- xor ch,ch
- ren_baks: mov ah,56h
- mov cs:[si],cl
- add byte ptr cs:[si],30h
- mov [bx],cl
- add byte ptr [bx],2fh
- cmp cl,1
- jnz call_ren
- mov byte ptr [bx],4bh
- call_ren: push cx
- pushf
- call cs:[oldint21]
- pop cx
- loop ren_baks
- ren_ret: pop es
- pop di
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- clc
- ret_f_2
- ren_file: sti
- call bakfind
- jz exit
- pushf
- call cs:[oldint21]
- push ax
- push bx
- push cx
- push dx
- push si
- push di
- push es
- mov bx,cs:ext_addr
- mov si,bx
- add bx,dx
- push cs
- pop es
- mov di,offset pathname
- add si,di
- mov cl,cs:count
- xor ch,ch
- mov byte ptr cs:[si],4bh
- mov byte ptr [bx],31h
- ren_again: mov ah,56h
- push cx
- pushf
- call cs:[oldint21]
- pop cx
- inc byte ptr [bx]
- cmp cl,cs:count
- jz firstloop
- inc byte ptr cs:[si]
- jmp notfirst
- firstloop: mov al,31h
- mov cs:[si],al
- notfirst: loop ren_again
- jmp ren_ret
- bakfind: push ax
- push si
- push di
- push es
- mov si,dx
- cld
- mov ah,2eh
- mov di,offset pathname
- push cs
- pop es
- get_one: lodsb
- stosb
- cmp al,ah
- jz period
- or al,al
- jnz get_one
- ret_bak: pop es
- pop di
- pop si
- pop ax
- ret_n
- period: lodsb
- cmp al,42h
- jnz wrong
- stosb
- lodsb
- cmp al,41h
- jnz wrong
- stosb
- lodsb
- cmp al,4Bh
- jnz wrong
- stosb
- xor al,al
- stosb
- sub si,dx
- dec si
- mov cs:ext_addr,si
- inc al
- jmp short ret_bak
- wrong: xor al,al
- jmp short ret_bak
- start: mov cl,cs:[80h]
- xor ch,ch
- or cl,cl
- jz noslash
- jmp install
- noslash: mov di,offset cmdline
- mov ax,offset param
- mov bx,cs
- stosw
- xchg ax,bx
- stosw
- xchg ax,bx
- stosw
- xchg ax,bx
- stosw
- xchg ax,bx
- stosw
- xchg ax,bx
- stosw
- push cs
- pop ds
- mov ax,3521h
- int 21h
- mov si,offset Oldint21
- mov ds:[si],bx
- inc si
- inc si
- mov ds:[si],es
- mov dx,offset newint21
- mov ax,2521h
- int 21h
- push cs
- pop es
- mov bx,offset instmess1
- mov cl,4
- shr bx,cl
- inc bx
- mov ah,4ah
- int 21h
- jc error1
- mov ax,4b00h
- mov dx,offset progname
- mov bx,offset param
- int 21h
- jc error2
- normexit: mov si,offset Oldint21
- mov dx,cs:[si]
- inc si
- inc si
- mov ds,cs:[si]
- mov ax,2521h
- int 21h
- int 20h
- error1: mov dx,offset message1
- errexit: call write
- jmp normexit
- error2: mov dx,offset message2
- jmp errexit
- write: mov ah,9
- int 21h
- ret_n
- instmess1 db 'Enter full pathname for TURBO.COM (Including filename)'
- db 0dh,0ah,'> $'
- instmess2 db 0dh,0ah,'Enter number of backups required in addition '
- db 'to .BAK : (0 to 9) > $'
- instmess3 db 0dh,0ah,'Turbo loading program installed.',0dh,0ah
- author db 'Written by : Babu Kalakrishnan 14th January,1986',0dh,0ah,'$'
- helpmess db 'This program enables Turbo 3.0 editor to'
- db ' maintain more than 1 backup version ',0dh,0ah
- db 'of the file being edited. To change the'
- db ' number of backup versions and specify',0dh,0ah
- db 'a full pathname for TURBO.COM, run this'
- db ' program with a /I switch. (TLOAD /I).',0dh,0ah,'$'
- db ' ',0dh,0ah,'$'
- opmess db 'Error creating file TLOAD.COM. Directory full ?',0dh,0ah,'$'
- writmess db 0dh,0ah,'Error writing file TLOAD.COM. Disk full ?',0dh,0ah,'$'
- loadprog db 'TLOAD.COM',0
- handle dw ?
- install: mov al,2fh
- mov di,81h
- repne scasb
- jcxz help
- mov al,es:[di]
- cmp al,69h
- jz instprog
- cmp al,49h
- jz instprog
- help: mov dx,offset helpmess
- call write
- mov dx,offset author
- jmp writ_exit
- instprog: mov dx,offset instmess1
- call write
- mov dx,offset Noofchars
- mov ah,0ah
- int 21h
- mov al,Name_len
- xor ah,ah
- cmp al,64
- jz instsize
- mov di,offset progname
- add di,ax
- xor al,al
- stosb
- instsize: mov dx,offset instmess2
- call write
- readchar: mov ah,7
- int 21h
- cmp al,30h
- jb one_more
- cmp al,39h
- ja one_more
- mov dl,al
- mov ah,2
- int 21h
- sub al,30h
- mov cs:count,al
- mov dx,offset loadprog
- mov cx,20h
- mov ah,3ch
- int 21h
- jc fil_err
- mov handle,ax
- mov bx,ax
- mov dx,100h
- mov cx,offset lastcode
- sub cx,100h
- mov ah,40h
- int 21h
- jnc noerr
- call writ_err
- noerr: mov bx,handle
- mov ah,3eh
- int 21h
- mov dx,offset instmess3
- call write
- int 20h
- one_more: mov dl,7
- mov ah,2
- int 21h
- jmp readchar
- fil_err: mov dx,offset opmess
- writ_exit: call write
- int 20h
- writ_err: mov dx,offset writmess
- call write
- ret_n
- lastcode: nop
- code ends
- end turbak
- handle dw ?
- install: mov al,2fh
-