home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / directry / direx / direx.asm next >
Encoding:
Assembly Source File  |  1987-02-15  |  10.2 KB  |  630 lines

  1.     target    equ    0d8h
  2.     source    equ    0b0h
  3. code_seg    segment
  4.         assume    cs:code_seg,ds:code_seg,es:code_seg
  5.     org    100h
  6. start:    jmp    direx
  7. prompt    db    'D=Delete P=Protect U=Unprotect C=Copy <Space>=Mark'
  8.     db    ' N=New Dir Q=Quits$'
  9. copy_prompt     db    'Pathname to copy marked files to : $'
  10. new_dir_prompt  db    'New Pathname : $'
  11. full_msg    db    '***      TARGET DISK FULL!         ***$'  
  12. del_msg        db    'Delete marked files (Y/N) ? $'
  13. copy_flag    db    0    ; set when doing copies.
  14. dl_flag        db    0    ; in DISPLAY, not DSPLAY@
  15. disp_flag    db    0    ; set when initial display done.
  16. full_flag    db    0    ; disk full flag
  17. nofile_flag    db    0     ; l-->No filename given.
  18. source_handle    dw    0    ; source file handle
  19. target_handle    dw    0    ; target file handle
  20. source_path_end    dw    0b0h    ; end of path -- put filenames here
  21. target_path_end    dw    0dbh    ; same for target
  22. test_path_end    dw    0    ; same for target
  23. bytes_read    dw    ?    ; bytes read -- for copy
  24. bytes_asked    dw    ?    ; bytes requested to be read.
  25. marked        db    ?    ; file marked ?
  26. attrib        db    ?    ; screen attribute
  27. wildcards    db    '*.*',0
  28. cursor_x    db    ?    ; reverse vid.cursor position x
  29. cursor_y    db    ?    ; same for y
  30. tempx        db    ?    ; temporary storage for x,y positions
  31. tempy        db    ?
  32. filename    db    10 dup(0) ; Store given filename here
  33.         db    'Copyright 1986 Ziff-Davis Publishing Co.',1ah
  34.         db    'Programmed by Steven Holzner',1ah
  35.  
  36.  
  37.  
  38. direx    proc    near
  39.     call    display            ;Setup -- put dir on screen.
  40.     mov    si,source_path_end    ; Light up first filename
  41.     call    get_file_name
  42. topper:    mov    attrib,70h
  43.     call    color    
  44. top:    mov    ah,0            ; read a character w/o echo
  45.     int    16h
  46. space:    cmp    al,20h            ; space ? mark a file ?
  47.     jne    right    
  48.     mov    ah,8
  49.     mov    bx,0
  50.     add    cursor_x,12
  51.     call    set_cursor
  52.     int    10h
  53.     cmp    al,0ffh
  54.     je    opp
  55.     mov    al,0ffh
  56.     jmp    ppo
  57. opp:    mov    al,0
  58. ppo:    mov    ah,10
  59.     mov    cx,1
  60.     int    10h
  61.     sub    cursor_x,12
  62.     call    set_cursor
  63.     jmp    top
  64. right:    cmp    ah,4dh
  65.     jne    left
  66.     mov    attrib,7
  67.     call    color
  68.     call    inc_cursor
  69.     mov    attrib,70h
  70.     call    color
  71.     jmp    top
  72. left:    cmp    ah,4bh
  73.     jne    up
  74.     mov    dl,cursor_x    
  75.     mov    dh,cursor_y
  76.     mov    attrib,7
  77.     call    color
  78.     sub    dl,13
  79.     jnc    ok
  80.     mov    dl,5*13
  81.     sub    dh,1
  82.     jnc    ok
  83.     mov    dl,cursor_x
  84.     mov    dh,cursor_y
  85. ok:    mov    cursor_x,dl
  86.     mov    cursor_y,dh
  87.     call    set_cursor
  88.     mov    attrib,70h
  89.     call    color
  90.     jmp    top
  91. up:    cmp    ah,48h
  92.     jne    down
  93.     mov    dl,cursor_x
  94.     mov    dh,cursor_y
  95.     mov    attrib,7 
  96.     call    color
  97.     sub    dh,1
  98.     jnc    nottop
  99.     add    dh,1
  100. nottop:    mov    cursor_x,dl
  101.     mov    cursor_y,dh
  102.     call    set_cursor
  103.     mov    attrib,70h
  104.     call    color
  105.     jmp    top
  106. down:    cmp    ah,50h
  107.     jne    letters
  108.     mov    attrib,7
  109.     call    color
  110.     inc    cursor_y
  111.     call    set_cursor
  112.     mov    si,source_path_end
  113.     call    get_file_name
  114.     cmp    byte ptr ds:[si],' '
  115.     ja    go
  116. nogo:    dec    cursor_y
  117.     call    set_cursor
  118. go:    mov    attrib,70h
  119.     call    color
  120.     jmp    top
  121. letters:cmp    al,'Z'
  122.     jl    gol
  123.     sub    al,'a'-'A'
  124. gol:    cmp    al,'Q'
  125.     jne    del
  126.     mov    cx,25
  127.     mov    cursor_x,0
  128.     mov    cursor_y,0
  129.     call    set_cursor
  130. wipe2:    push    cx
  131.     call    set_cursor
  132.     mov    cx,80
  133.     mov    ah,9
  134.     mov    bx,7
  135.     mov    al,0
  136.     int    10h
  137.     pop    cx
  138.     inc    cursor_y
  139.     loop    wipe2
  140.     mov    cursor_x,0
  141.     mov    cursor_y,0
  142.     call    set_cursor
  143.     jmp    out
  144. del:    cmp    al,'D'
  145.     je    okd
  146.     jmp    pro
  147. okd:    mov    attrib,7
  148.     call    color
  149.     mov    cursor_x,0
  150.     mov    cursor_y,24
  151.     call    set_cursor
  152.     mov    ah,9
  153.     mov    cx,80
  154.     mov    al,' '
  155.     mov    bx,7
  156.     int    10h
  157.     mov    cursor_x,0
  158.     mov    cursor_y,24
  159.     call    set_cursor
  160.     mov    ah,9
  161.     mov    dx,offset del_msg
  162.     int    21h
  163.     mov    ah,1
  164.     int    21h
  165.     cmp    al,'Z'
  166.     jl    checky
  167.     sub    al,'a'-'A'
  168. checky:    cmp    al,'Y'
  169.     je    godel
  170.     call    dsplay2
  171.     mov    attrib,70h
  172.     call    color
  173.     jmp    top
  174. godel:    mov    cursor_x,0
  175.     mov    cursor_y,0
  176.     call    set_cursor
  177. loopd:    call    get_marked_file
  178.     mov    dx,source
  179.     mov    ah,41h
  180.     int    21h
  181.     call    inc_cursor
  182.     cmp    dx,0ffh
  183.     je    find
  184.     cmp    cx,0ffh
  185.     jne    loopd
  186. find:    call    dsplay2
  187.     mov    attrib,70h
  188.     call    color
  189.     jmp    top
  190. pro:    cmp    al,'P'
  191.     jne    unpro
  192.     mov    attrib,7
  193.     call    color
  194.     mov    cursor_x,0
  195.     mov    cursor_y,0
  196.     call    set_cursor
  197. loopp:    call    get_marked_file
  198.     mov    dx,source
  199.     mov    ah,43h
  200.     mov    al,01
  201.     mov    cx,1
  202.     int    21h
  203.     call    inc_cursor
  204.     cmp    dx,0ffh    
  205.     je    finp
  206.     cmp    cx,0ffh
  207.     jne    loopp
  208. finp:    call    dsplay2
  209.     mov    attrib,70h
  210.     call    color
  211.     jmp    top
  212. unpro:    cmp    al,'U'
  213.     jne    copy
  214.     mov    attrib,7
  215.     call    color
  216.     mov    cursor_x,0
  217.     mov    cursor_y,0
  218.     call    set_cursor
  219. loopu:    call    get_marked_file
  220.     mov    dx,source
  221.     mov    ah,43h
  222.     mov    al,01
  223.     mov    cx,0
  224.     int    21h
  225.     call    inc_cursor
  226.     cmp    dx,0ffh    
  227.     je    finu
  228.     cmp    cx,0ffh
  229.     jne    loopu
  230. finu:    call    dsplay2
  231.     mov    attrib,70h
  232.     call    color
  233.     jmp    top
  234. copy:    cmp    al,'C'
  235.     je    goc
  236.     jmp    new_dir
  237. goc:    mov    attrib,7
  238.     mov    full_flag,0
  239.     call    color
  240.     mov    cursor_x,0
  241.     mov    cursor_y,24
  242.     call    set_cursor
  243.     mov    ah,9
  244.     mov    cx,80
  245.     mov    al,' '
  246.     mov    bx,7
  247.     int    10h
  248.     mov    cursor_x,0
  249.     mov    cursor_y,24
  250.     call    set_cursor
  251.     mov    ah,9
  252.     mov    dx,offset copy_prompt
  253.     int    21h
  254.     mov    ah,0ah
  255.     mov    bx,target-2
  256.     mov    dx,target-2
  257.     mov    byte ptr [bx],32
  258.     int    21h
  259.     mov    si,target
  260. trans:    cmp    byte ptr [si],13
  261.     je    slash2
  262.     inc    si
  263.     jmp    trans
  264. slash2:    cmp    byte ptr [si-1],'\'
  265.     je    filer2
  266.     mov    byte ptr [si],'\'
  267.     inc    si
  268. filer2:    mov    target_path_end,si
  269.     mov    attrib,7
  270.     call    color
  271.     mov    cursor_x,0
  272.     mov    cursor_y,0
  273.     call    set_cursor
  274. loopc:    mov    copy_flag,1
  275.     call    get_marked_file
  276.     mov    copy_flag,0
  277.     cmp    cx,0ffh
  278.     jne    open
  279.     jmp    finc
  280. open:    mov    dx,source
  281.     mov    ax,3d00h
  282.     int    21h
  283.     jc    botc
  284.     mov    source_handle,ax
  285.     mov    dx,target
  286.     mov    ah,3ch
  287.     mov    cx,0    
  288.     int    21h
  289.     jc    botc
  290.     mov    target_handle,ax
  291. stuff:    mov    dx,offset data
  292.     mov    cx,62*1024
  293.     mov    ah,3fh
  294.     mov    bx,source_handle
  295.     int    21h
  296.     mov    bytes_read,ax
  297.     mov    cx,ax
  298.     mov    bytes_asked,cx
  299.     mov    ah,40h
  300.     mov    bx,target_handle
  301.     mov    dx,offset data
  302.     int    21h
  303.     cmp    ax,bytes_read
  304.     jne    full
  305.     cmp    bytes_read,62*1024
  306.     je    stuff
  307.     jmp    botc
  308. full:    mov    cursor_x,0
  309.     mov    cursor_y,24
  310.     call    set_cursor
  311.     lea    dx,full_msg
  312.     mov    ah,9
  313.     int    21h
  314.     mov    full_flag,1
  315.     mov    cursor_x,0
  316.     mov    cursor_y,0
  317.     call    set_cursor
  318. botc:    mov    ah,3eh
  319.     mov    bx,source_handle
  320.     int    21h
  321.     mov    ah,3eh
  322.     mov    bx,target_handle
  323.     int    21h
  324.     cmp    full_flag,1
  325.     jne    notfull
  326.     mov    dx,target
  327.     mov    ah,41h
  328.     int    21h
  329.     jmp    topper
  330. notfull:call    inc_cursor
  331.     cmp    dx,0ffh
  332.     je    finc
  333.     jmp    loopc
  334. finc:    call    dsplay2
  335.     mov    attrib,70h
  336.     call    color
  337.     jmp    top
  338. new_dir:cmp    al,'N'
  339.     je    gon
  340.     jmp    top
  341. gon:    mov    attrib,7
  342.     call    color
  343.     mov    cursor_x,0
  344.     mov    cursor_y,24
  345.     call    set_cursor
  346.     mov    ah,9
  347.     mov    cx,80
  348.     mov    al,' '
  349.     mov    bx,7
  350.     int    10h
  351.     mov    cursor_x,0
  352.     mov    cursor_y,24
  353.     call    set_cursor
  354.     mov    ah,9
  355.     mov    dx,offset new_dir_prompt
  356.     int    21h
  357.     mov    ah,0ah
  358.     mov    bx,80h
  359.     mov    dx,80h
  360.     mov    byte ptr [bx],32
  361.     int    21h
  362.     jmp    direx
  363. out:    int    20h
  364. direx    endp
  365.  
  366. get_marked_file    proc    near
  367. begi:    mov    ah,8
  368.     add    cursor_x,12
  369.     call    set_cursor
  370.     mov    bx,0
  371.     int    10h
  372.     sub    cursor_x,12
  373.     call    set_cursor
  374.     cmp    al,0ffh
  375.     je    fini
  376.     call    inc_cursor
  377.     cmp    dx,0ffh
  378.     jne    begi
  379.     mov    cx,0ffh
  380.     jmp    outer
  381. fini:    mov    cx,0
  382.     mov    si,source_path_end
  383.     call    get_file_name
  384.     cmp    copy_flag,1
  385.     jne    outer
  386.     mov    si,target_path_end
  387.     call    get_file_name
  388. outer:    ret
  389. get_marked_file    endp
  390.  
  391. get_file_name    proc    near
  392.     push    cx
  393.     push    si
  394.     push    word ptr cursor_x
  395.     mov    ah,8
  396.     mov    bx,0
  397.     mov    cx,12
  398. loopb:    mov    ah,8
  399.     int    10h
  400.     inc    cursor_x
  401.     call    set_cursor
  402.     mov    ds:[si],al
  403.     inc    si
  404.     loop    loopb
  405.     mov    byte ptr ds:[si],0
  406.     pop    word ptr cursor_x
  407.     pop    si
  408.     call    set_cursor
  409.     pop    cx
  410.     ret
  411. get_file_name    endp
  412.  
  413. color     proc    near
  414.     push    cx
  415.     push    word ptr cursor_x
  416.     mov    cx,12
  417.     cmp    attrib,7
  418.     jne    here
  419.     mov    ah,8
  420.     add    cursor_x,12
  421.     call    set_cursor
  422.     mov    bx,0
  423.     int    10h
  424.     sub    cursor_x,12
  425.     call    set_cursor
  426.     cmp    al,0ffh
  427.     je    fine
  428. here:    mov    bx,0
  429.     mov    ah,8
  430.     int    10h
  431.     push    cx
  432.     mov    cx,1
  433.     mov    bl,attrib
  434.     mov    ah,9
  435.     int    10h
  436.     pop    cx
  437.     inc    cursor_x
  438.     call    set_cursor
  439.     loop    here
  440. fine:    pop    word ptr cursor_x
  441.     call    set_cursor
  442.     pop    cx
  443.     ret
  444. color    endp
  445.  
  446. display    proc    near
  447.     mov    di,source
  448.     mov    dl_flag,1
  449.     mov    si,82h
  450.     mov    source_path_end,source
  451.     mov    bx,80h
  452.     cmp    byte ptr [bx],0
  453.     je    dsplay2
  454. trans2:    cmp    byte ptr [si],13
  455.     je    put0
  456.     movsb
  457.     cmp    byte ptr [si-1],'\'
  458.     je    stor
  459.     cmp    byte ptr [si-1],':'
  460.     jne     trans2
  461. stor:    mov    source_path_end,di
  462.     push    si
  463.     push    di
  464.     lea    di,filename
  465.     mov    cx,10
  466.     mov    al,0
  467. rep    stosb
  468.     lea    di,filename
  469.     mov    cx,9
  470. oneby:    cmp    byte ptr [si],13
  471.     jne    move
  472.     mov     byte ptr [di],0
  473.     jmp    short fin0
  474. move:    movsb
  475.     loop    oneby
  476. fin0:    pop    di
  477.     pop    si
  478.     jmp    trans2
  479. put0:    mov    byte ptr [di],0
  480.     mov    test_path_end,di
  481.     mov    nofile_flag,0
  482.     jmp    chkfil
  483. dsplay2:mov    dl_flag,0
  484.     cmp    filename,0
  485.     jne    chkfil
  486.     mov    nofile_flag,1
  487. chkfil:    mov    cx,25
  488.     mov    cursor_x,0
  489.     mov    cursor_y,0
  490.     call    set_cursor
  491. wipe:    push    cx
  492.     call    set_cursor
  493.     mov    cx,80
  494.     mov    ah,9
  495.     mov    bx,7
  496.     mov    al,0
  497.     int    10h
  498.     pop    cx
  499.     inc     cursor_y
  500.     loop    wipe
  501.     mov    cursor_x,6
  502.     mov    cursor_y,24
  503.     call    set_cursor
  504.     mov    ah,9
  505.     mov     dx,offset prompt
  506.     int    21h
  507.     mov    cursor_x,0
  508.     mov    cursor_y,0
  509.     call    set_cursor
  510.     mov    di,test_path_end
  511.     cmp    nofile_flag,1
  512.     je    tslash
  513.     cmp    byte ptr [di-1],'\'
  514.     je    nofile
  515.     cmp    dl_flag,1
  516.     je    puta
  517.     cmp    filename,0
  518.     je    puta    
  519.     mov    cx,10
  520.     mov    si,offset filename
  521.     mov    di,source_path_end
  522. rep    movsb
  523. puta:    mov    ah,4eh
  524.     mov    dx,source
  525.     int    21h
  526. nofile:    mov    filename,0
  527. tslash:    cmp    test_path_end,0
  528.     jne    slash
  529.     mov    source_path_end,source
  530.     mov    di,source_path_end
  531.     jmp    putw
  532. slash:    mov    di,test_path_end
  533.     mov    source_path_end,di
  534.     cmp    byte ptr [di-1],'\'
  535.     je    putw
  536.     mov    byte ptr [di],'\'
  537.     inc    di
  538.     inc    source_path_end
  539. putw:    mov    cx,4
  540.     mov    si,offset wildcards
  541. rep    movsb
  542. src:    mov    ah,4eh
  543.     mov    dx,source
  544.     int    21h
  545.     jc    ender
  546. match1:    mov    dx,0
  547.     mov    ah,2
  548.     int    10h
  549.     call    print
  550.     mov    cx,120
  551. looper:    mov    ah,4fh
  552.     int    21h
  553.     jc    ender
  554.     mov    disp_flag,0ffh
  555.     call    inc_cursor
  556.     mov    disp_flag,0
  557.     call    print
  558.     mov    dx,offset source
  559.     loop    looper
  560. ender:    mov    cursor_x,0
  561.     mov    cursor_y,0
  562.     call    set_cursor
  563.     ret
  564. display    endp
  565.  
  566. inc_cursor    proc    near
  567.     push    cx
  568.     mov    dl,cursor_x
  569.     mov    dh,cursor_y
  570.     mov    tempx,dl
  571.     mov    tempy,dh
  572.     add    dl,13
  573.     cmp    dl,75
  574.     jl    fin
  575.     mov    dl,0
  576.     inc    dh
  577. fin:    mov    cursor_x,dl
  578.     mov    cursor_y,dh
  579.     mov    dx,0
  580.     call    set_cursor
  581.     cmp    disp_flag,0
  582.     jne    set
  583.     mov    si,source_path_end
  584.     call    get_file_name
  585.     cmp    byte ptr ds:[si],' '
  586.     ja    set
  587.     sub    cursor_x,13
  588.     cmp    cursor_x,0
  589.     jg    leav
  590.     mov    dl,tempx
  591.     mov    cursor_x,dl
  592.     mov    dh,tempy
  593.     mov    cursor_y,dh
  594. leav:    call    set_cursor
  595.     mov    dx,0ffh
  596. set:    pop    cx
  597.     ret
  598. inc_cursor    endp
  599.  
  600. set_cursor    proc    near
  601.     push    ax
  602.     mov    dl,cursor_x
  603.     mov    dh,cursor_y
  604.     mov    ah,2
  605.     int    10h
  606.     pop    ax
  607.     ret
  608. set_cursor    endp
  609.  
  610. print    proc    near
  611.     push    cx
  612.     mov    dx,80h+30
  613.     mov    bx,dx
  614.     mov    cx,13
  615. loopa:    cmp    byte ptr [bx],0
  616.     je    found
  617.     inc    bx
  618.     loop    loopa
  619. found:    mov    byte ptr ds:[bx+1],'$'
  620.     mov    ah,9
  621.     int    21h
  622.     pop    cx
  623.     ret
  624. print    endp
  625.  
  626. data:
  627. code_seg    ends
  628.     end    start
  629.  
  630.