home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / MISC.ZIP / TLOAD.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-01-28  |  9.0 KB  |  313 lines

  1. Title       Turbo loader program
  2. ret_f_2     macro
  3.             db     0cah,02,00
  4.             endm
  5. ret_n       macro
  6.             db     0c3h
  7.             endm
  8. code        segment
  9.             org    100h
  10.             assume cs:code,ds:code,es:code
  11. turbak:     jmp    start
  12. message1    db     'Memory Allocation error. Not enough memory ??',0dh,0ah,'$'
  13. message2    db     'Program loading error. Run program with "/I" switch'
  14.             db     ' to install. (TLOAD /I)'
  15. CRLF        db     0dh,0ah,'$'
  16. Noofchars   db     64
  17. Name_len    db     ?
  18. progname    db     'turbo.com',0 ; ASCIIZ filename of program
  19.             db     55 dup (0)    ; space for longer pathnames
  20. Oldint21    dd     ?           ; pointer to the real interrupt 16
  21. ext_addr    dw     ?
  22. pathname    db     64 dup (?),0
  23. count       db     3           ; Number of backups maintained (excluding .BAK)
  24. param       dw     0
  25. cmdline     dd     ?
  26. fcb1        dd     ?
  27. fcb2        dd     ?
  28.  
  29. newint21:   cmp    ah,41h
  30.             jz     del_file
  31.             cmp    ah,56h
  32.             jz     ren_file
  33. exit:       jmp    cs:[Oldint21]
  34. del_file:   sti
  35.             call   bakfind
  36.             jz     exit
  37.             push   ax
  38.             push   bx
  39.             push   cx
  40.             push   dx
  41.             push   si
  42.             push   di
  43.             push   es
  44.             mov    bx,cs:ext_addr
  45.             mov    si,bx
  46.             add    bx,dx
  47.             mov    al,cs:count
  48.             mov    [bx],al
  49.             add    byte ptr [bx],30h
  50.             mov    ah,41h
  51.             pushf
  52.             call   cs:[oldint21]
  53.             push   cs
  54.             pop    es
  55.             mov    di,offset pathname
  56.             add    si,di
  57.             mov    cl,cs:count
  58.             xor    ch,ch
  59. ren_baks:   mov    ah,56h
  60.             mov    cs:[si],cl
  61.             add    byte ptr cs:[si],30h
  62.             mov    [bx],cl
  63.             add    byte ptr [bx],2fh
  64.             cmp    cl,1
  65.             jnz    call_ren
  66.             mov    byte ptr [bx],4bh
  67. call_ren:   push   cx
  68.             pushf
  69.             call   cs:[oldint21]
  70.             pop    cx
  71.             loop   ren_baks
  72. ren_ret:    pop    es
  73.             pop    di
  74.             pop    si
  75.             pop    dx
  76.             pop    cx
  77.             pop    bx
  78.             pop    ax
  79.             clc
  80.             ret_f_2
  81. ren_file:   sti
  82.             call   bakfind
  83.             jz     exit
  84.             pushf
  85.             call   cs:[oldint21]
  86.             push   ax
  87.             push   bx
  88.             push   cx
  89.             push   dx
  90.             push   si
  91.             push   di
  92.             push   es
  93.             mov    bx,cs:ext_addr
  94.             mov    si,bx
  95.             add    bx,dx
  96.             push   cs
  97.             pop    es
  98.             mov    di,offset pathname
  99.             add    si,di
  100.             mov    cl,cs:count
  101.             xor    ch,ch
  102.             mov    byte ptr cs:[si],4bh
  103.             mov    byte ptr [bx],31h
  104. ren_again:  mov    ah,56h
  105.             push   cx
  106.             pushf
  107.             call   cs:[oldint21]
  108.             pop    cx
  109.             inc    byte ptr [bx]
  110.             cmp    cl,cs:count
  111.             jz     firstloop
  112.             inc    byte ptr cs:[si]
  113.             jmp    notfirst
  114. firstloop:  mov    al,31h
  115.             mov    cs:[si],al
  116. notfirst:   loop   ren_again
  117.             jmp    ren_ret
  118. bakfind:    push   ax
  119.             push   si
  120.             push   di
  121.             push   es
  122.             mov    si,dx
  123.             cld
  124.             mov    ah,2eh
  125.             mov    di,offset pathname
  126.             push   cs
  127.             pop    es
  128. get_one:    lodsb
  129.             stosb
  130.             cmp    al,ah
  131.             jz     period
  132.             or     al,al
  133.             jnz    get_one
  134. ret_bak:    pop    es
  135.             pop    di
  136.             pop    si
  137.             pop    ax
  138.             ret_n
  139. period:     lodsb
  140.             cmp    al,42h
  141.             jnz    wrong
  142.             stosb
  143.             lodsb
  144.             cmp    al,41h
  145.             jnz    wrong
  146.             stosb
  147.             lodsb
  148.             cmp    al,4Bh
  149.             jnz    wrong
  150.             stosb
  151.             xor    al,al
  152.             stosb
  153.             sub    si,dx
  154.             dec    si
  155.             mov    cs:ext_addr,si
  156.             inc    al
  157.             jmp    short  ret_bak
  158. wrong:      xor    al,al
  159.             jmp    short  ret_bak
  160. start:      mov    cl,cs:[80h]
  161.             xor    ch,ch
  162.             or     cl,cl
  163.             jz     noslash
  164.             jmp    install
  165. noslash:    mov    di,offset cmdline
  166.             mov    ax,offset param
  167.             mov    bx,cs
  168.             stosw
  169.             xchg   ax,bx
  170.             stosw
  171.             xchg   ax,bx
  172.             stosw
  173.             xchg   ax,bx
  174.             stosw
  175.             xchg   ax,bx
  176.             stosw
  177.             xchg   ax,bx
  178.             stosw
  179.             push   cs
  180.             pop    ds
  181.             mov    ax,3521h
  182.             int    21h
  183.             mov    si,offset Oldint21
  184.             mov    ds:[si],bx
  185.             inc    si
  186.             inc    si
  187.             mov    ds:[si],es
  188.             mov    dx,offset newint21
  189.             mov    ax,2521h
  190.             int    21h
  191.             push   cs
  192.             pop    es
  193.             mov    bx,offset instmess1
  194.             mov    cl,4
  195.             shr    bx,cl
  196.             inc    bx
  197.             mov    ah,4ah
  198.             int    21h
  199.             jc     error1
  200.             mov    ax,4b00h
  201.             mov    dx,offset progname
  202.             mov    bx,offset param
  203.             int    21h
  204.             jc     error2
  205. normexit:   mov    si,offset Oldint21
  206.             mov    dx,cs:[si]
  207.             inc    si
  208.             inc    si
  209.             mov    ds,cs:[si]
  210.             mov    ax,2521h
  211.             int    21h
  212.             int    20h
  213. error1:     mov    dx,offset message1
  214. errexit:    call   write
  215.             jmp    normexit
  216. error2:     mov    dx,offset message2
  217.             jmp    errexit
  218. write:      mov    ah,9
  219.             int    21h
  220.             ret_n
  221. instmess1   db     'Enter full pathname for TURBO.COM (Including filename)'
  222.             db     0dh,0ah,'> $'
  223. instmess2   db     0dh,0ah,'Enter number of backups required in addition '
  224.             db     'to .BAK : (0 to 9) > $'
  225. instmess3   db     0dh,0ah,'Turbo loading program installed.',0dh,0ah
  226. author      db     'Written by : Babu Kalakrishnan    14th January,1986',0dh,0ah,'$'
  227. helpmess    db     'This program enables Turbo 3.0 editor to'
  228.             db     ' maintain more than 1 backup version  ',0dh,0ah
  229.             db     'of the file being edited. To change the'
  230.             db     ' number of backup versions and specify',0dh,0ah
  231.             db     'a full pathname for TURBO.COM, run this'
  232.             db     ' program with a /I switch. (TLOAD /I).',0dh,0ah,'$'
  233.             db     ' ',0dh,0ah,'$'
  234. opmess      db     'Error creating file TLOAD.COM. Directory full ?',0dh,0ah,'$'
  235. writmess    db     0dh,0ah,'Error writing file TLOAD.COM. Disk full ?',0dh,0ah,'$'
  236. loadprog    db     'TLOAD.COM',0
  237. handle      dw     ?
  238. install:    mov    al,2fh
  239.             mov    di,81h
  240.             repne  scasb
  241.             jcxz   help
  242.             mov    al,es:[di]
  243.             cmp    al,69h
  244.             jz     instprog
  245.             cmp    al,49h
  246.             jz     instprog
  247. help:       mov    dx,offset helpmess
  248.             call   write
  249.             mov    dx,offset author
  250.             jmp    writ_exit
  251. instprog:   mov    dx,offset instmess1
  252.             call   write
  253.             mov    dx,offset Noofchars
  254.             mov    ah,0ah
  255.             int    21h
  256.             mov    al,Name_len
  257.             xor    ah,ah
  258.             cmp    al,64
  259.             jz     instsize
  260.             mov    di,offset progname
  261.             add    di,ax
  262.             xor    al,al
  263.             stosb
  264. instsize:   mov    dx,offset instmess2
  265.             call   write
  266. readchar:   mov    ah,7
  267.             int    21h
  268.             cmp    al,30h
  269.             jb     one_more
  270.             cmp    al,39h
  271.             ja     one_more
  272.             mov    dl,al
  273.             mov    ah,2
  274.             int    21h
  275.             sub    al,30h
  276.             mov    cs:count,al
  277.             mov    dx,offset loadprog
  278.             mov    cx,20h
  279.             mov    ah,3ch
  280.             int    21h
  281.             jc     fil_err
  282.             mov    handle,ax
  283.             mov    bx,ax
  284.             mov    dx,100h
  285.             mov    cx,offset lastcode
  286.             sub    cx,100h
  287.             mov    ah,40h
  288.             int    21h
  289.             jnc    noerr
  290.             call   writ_err
  291. noerr:      mov    bx,handle
  292.             mov    ah,3eh
  293.             int    21h
  294.             mov    dx,offset instmess3
  295.             call   write
  296.             int    20h
  297. one_more:   mov    dl,7
  298.             mov    ah,2
  299.             int    21h
  300.             jmp    readchar
  301. fil_err:    mov    dx,offset opmess
  302. writ_exit:  call   write
  303.             int    20h
  304. writ_err:   mov    dx,offset writmess
  305.             call   write
  306.             ret_n
  307. lastcode:   nop
  308. code        ends
  309. end         turbak
  310. 
  311. handle      dw     ?
  312. install:    mov    al,2fh
  313.