home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1997 July / Sezamfile97_1.iso / msdos / utility / sdf105.arj / STRING.ASM < prev   
Assembly Source File  |  1993-08-27  |  3KB  |  169 lines

  1. ;; ╔════════════════════════╗
  2. ;; ║   25/08/1993 - mjova   ║
  3. ;; ╚════════════════════════╝
  4.  
  5.  
  6. locals
  7. .model large
  8.  
  9.  
  10.  
  11. .code
  12.  
  13. ; --------------------------------------------------------------------
  14. StrCat            proc c returns len: far ptr byte
  15.                     public c StrCat
  16.                     uses ds
  17.                     arg dest: far ptr byte
  18.                     arg src: far ptr byte
  19.  
  20.                     cld
  21.                     les di, dest
  22.                     mov dx, es
  23.                     mov ax, di
  24.                     push ax
  25.                     lds si, src
  26.                     mov cx, 0ffffh
  27.                     mov ax, 0
  28.             repne scasb
  29.                     dec di
  30. @@loop:            lodsb
  31.                     and al, al
  32.                     stosb
  33.                     jnz @@loop
  34.                     pop ax
  35.                     ret
  36.  
  37. StrCat            endp
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. ;;        byte PrintFileStdout(DirEntry *Entry, char far *Path);
  45.  
  46. DirEntry            struc
  47.                     FileName    db 8 dup (?)
  48.                     Ext        db 3 dup (?)
  49.                     Attr        db ?
  50.                     Reserved db 10 dup (?)
  51.                     Time        dw ?
  52.                     Date        dw ?
  53.                     Cluster    dw ?
  54.                     Len        dd ?
  55. DirEntry            ends
  56.  
  57. .data
  58. OneLineBuffer    db 132 dup (0)
  59.  
  60. extrn _Drive:byte
  61. .code
  62.  
  63. ; --------------------------------------------------------------------
  64. PrepareEntry    proc c
  65.  
  66.                     lea di, OneLineBuffer
  67.                     xor bx, bx
  68.                     mov cx, 8
  69. @@Loop:            mov al, es:[si+bx]
  70.                     mov ds:[di+bx], al
  71.                     inc bx
  72.                     loop @@Loop
  73.  
  74.                     mov ds:[di+bx], byte ptr '.'
  75.                     inc di
  76.  
  77.                     mov cx, 3
  78. @@Loop1:            mov al, es:[si+bx]
  79.                     mov ds:[di+bx], al
  80.                     inc bx
  81.                     loop @@Loop1
  82.  
  83.                     mov ds:[di+bx], byte ptr ' '
  84.                     inc bx
  85.                     mov al, _Drive
  86.                     add al, 'A'
  87.                     mov ds:[di+bx], al
  88.                     inc bx
  89.                     mov ds:[di+bx], byte ptr ':'
  90.                     inc bx
  91.                     mov ds:[di+bx], byte ptr '\'
  92.                     inc bx
  93.                     mov ds:[di+bx], byte ptr 0
  94.  
  95.                     ret
  96. PrepareEntry    endp
  97.                     
  98.  
  99. ; --------------------------------------------------------------------
  100. PrintFileStdout proc c returns len: far ptr byte
  101.                     public c PrintFileStdout
  102.                     arg Entry: far ptr DirEntry
  103.                     arg Path: far ptr byte
  104.                     
  105.                     les si, Entry
  106.                     call PrepareEntry
  107.                     
  108.                     les bx, Path
  109.                     push es
  110.                     push bx
  111.                     lea bx, OneLineBuffer
  112.                     push ds
  113.                     push bx
  114.                     call StrCat
  115.                     pop bx
  116.                     add sp, 6
  117.                     
  118.                     mov es:[di-1], byte ptr 0dh
  119.                     mov es:[di+0], byte ptr 0ah
  120.                     inc di
  121.  
  122.                     mov dx, bx
  123.                     sub di, bx
  124.                     mov cx, di
  125.                     mov bx, 1
  126.                     mov ax, 4000h
  127.                     int 21h
  128.  
  129.                     ret
  130.  
  131. PrintFileStdout endp
  132.  
  133.  
  134. ; --------------------------------------------------------------------
  135. PrintFileVideo    proc c returns len: far ptr byte
  136.                     public c PrintFileVideo
  137.                     arg Entry: far ptr DirEntry
  138.                     arg Path: far ptr byte
  139.                     
  140.                     les si, Entry
  141.                     call PrepareEntry
  142.                     
  143.                     les bx, Path
  144.                     push es
  145.                     push bx
  146.                     lea bx, OneLineBuffer
  147.                     push ds
  148.                     push bx
  149.                     call StrCat
  150.                     pop bx
  151.                     add sp, 6
  152.                     
  153.                     mov es:[di-1], byte ptr 0dh
  154.                     mov es:[di+0], byte ptr 0ah
  155.                     inc di
  156.  
  157.                     mov dx, bx
  158.                     sub di, bx
  159.                     mov cx, di
  160.                     mov bx, 1
  161.                     mov ax, 4000h
  162.                     int 21h
  163.  
  164.                     ret
  165.  
  166. PrintFileVideo endp
  167.  
  168.                     end
  169.