home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / assemutl.zip / FREE.ASM < prev    next >
Assembly Source File  |  1985-05-11  |  5KB  |  282 lines

  1. cseg    segment
  2.     org 100h
  3.     assume cs:cseg,ds:cseg
  4. start    proc near
  5.     call lfeed
  6.     mov si,offset buff
  7.     call parse
  8.     cmp byte ptr [si],255
  9.     jnz here
  10.     mov ah,19h
  11.     int 21h
  12.     inc al
  13.     mov ah,al
  14.     mov al,0
  15.     mov [si],ax
  16.     mov byte ptr [si+2],255
  17. here:    cmp byte ptr [si],0
  18.     jnz leave
  19.     mov dl,[si+1]
  20.     inc si
  21.     inc si
  22.     call space
  23.     cmp ah,1
  24.     jz here
  25.     mov dx,offset bytes
  26.     mov ah,9
  27.     int 21h
  28.     jmp here
  29. leave:    int 20h
  30. space:    push si
  31.     push dx
  32.     add dl,64
  33.     mov [drive],dl
  34.     mov dx,offset message
  35.     mov ah,9
  36.     int 21h
  37.     pop dx
  38.     mov ah,36h
  39.     int 21h
  40.     cmp ax,0ffffh
  41.     jnz conts
  42.     mov dx,offset errmess
  43.     mov ah,9
  44.     int 21h
  45.     mov ah,1
  46.     jmp lvspa
  47. conts:    mul bx
  48.     mul cx
  49.     mov si,offset buffer
  50.     call condw
  51.     call ascdw
  52.     mov byte ptr [si+10],'$'
  53.     mov cx,9
  54.     call zapzer
  55.     mov dx,si
  56. here3:    mov ah,9
  57.     int 21h
  58.     mov ah,0
  59. lvspa:    pop si
  60.     ret
  61. lfeed:    mov dx,offset lfee
  62.     mov ah,9
  63.     int 21h
  64.     ret
  65. start    endp
  66.  
  67. ;CONVERT WORD TO DECIMAL
  68.  
  69. ;Takes a number in AX and places the ascii value at DS:SI
  70. ;AX, BX, CX, and flags are messed up
  71.  
  72. conw    proc near
  73.     mov cx,5
  74.     mov bx,10
  75.     add si,4
  76. conaaa: mov dx,0
  77.     div bx
  78.     mov [si],dl
  79.     dec si
  80.     loop conaaa
  81.     inc si
  82.     ret
  83. conw    endp
  84.  
  85. ;CONVERT DOUBLEWORD TO DECIMAL
  86.  
  87. ;Handles numbers 0-655,350,000 - pass it others and it INT 0s
  88. ;Takes a number in DX-AX and places the ascii value at DS:SI
  89. ;AX, BX, CX, DX, and flags are messed up
  90.  
  91. condw    proc near
  92.     mov bx,10000
  93.     div bx
  94.     push dx
  95.     call conw
  96.     add si,4
  97.     pop ax
  98.     mov dl,[si]
  99.     push dx
  100.     call conw
  101.     pop dx
  102.     mov [si],dl
  103.     sub si,4
  104.     ret
  105. condw    endp
  106.  
  107. ;CONVERT DECIMAL WORD TO ASCII
  108.  
  109. ;Takes number at DS:SI and leaves it in ASCII
  110. ;CX and flags messed up
  111.  
  112. ascw    proc near
  113.     mov cx,5
  114. ascaaa: add byte ptr [si],48
  115.     inc si
  116.     loop ascaaa
  117.     sub si,5
  118.     ret
  119. ascw    endp
  120.  
  121. ;CONVERT DECIMAL DOUBLEWORD TO ASCII
  122.  
  123. ;Takes number at DS:SI and leaves it in ASCII
  124. ;CX, DX, and flags messed up
  125.  
  126. ascdw    proc near
  127.     call ascw
  128.     add si,4
  129.     mov dl,[si]
  130.     call ascw
  131.     mov [si],dl
  132.     sub si,4
  133.     ret
  134. ascdw    endp
  135.  
  136. ;ZAP LEADING ZEROS IN A STRING
  137.  
  138. ;Zaps leading zeros in a string of length CX at address DS:SI
  139. ;Returns with SI pointing to first nonzero byte
  140. ;CX and flags messed up
  141.  
  142. zapzer    proc near
  143.     cmp byte ptr [si],48
  144.     jnz zapaaa
  145.     mov byte ptr [si],32
  146.     inc si
  147.     loop zapzer
  148. zapaaa: ret
  149. zapzer    endp
  150.  
  151. ;PARSE COMMAND LINE
  152.  
  153. ;Places parsed list at DS:SI - format
  154. ; 0/#             Drive number #
  155. ; 1/#/filespec.ext   Filename of length #
  156. ; 2/#/parameter      /parameter of length #
  157. ; 255             End of list
  158. ;everthing but SI, BP, segment registers, and stack messed up
  159.  
  160. parse    proc near
  161.     push si
  162.     mov di,80h
  163.     mov cl,[di]
  164.     inc di
  165.     cmp cl,0
  166.     jnz paraaa
  167.     jmp paraar
  168. paraaa: mov al,[di]            ;main loop - jump here to
  169.     cmp al,32            ;process new sections
  170.     jnz paraab
  171.     jmp paraal
  172. paraab: cmp al,'/'    ;47
  173.     jnz paraac
  174.     jmp paraam
  175. paraac: cmp al,64
  176.     jle paraal
  177.     mov bx,offset paraat        ;either filename or drivespec
  178.     mov [paraas],0
  179. paraad: mov [bx],al            ;main loop for moving characters
  180.     inc bx                ;to the temporary buffer with
  181.     inc di                ;either filename or drivespec
  182.     dec cl
  183.     jz paraaf
  184. paraae: mov al,[di]
  185.     inc di
  186.     dec cl
  187.     cmp al,32
  188.     jnz paraah
  189. paraaf: cmp byte ptr [paraas],1     ;end of current string by end of
  190.     jz paraak            ;buffer or delimeter
  191.     mov byte ptr [si],1
  192.     mov dx,bx
  193.     sub dx,offset paraat
  194.     inc si
  195.     mov [si],dl
  196.     inc si
  197.     mov bx,offset paraat
  198. paraag: mov al,[bx]            ;loop for moving filespec to return
  199.     mov [si],al            ;buffer
  200.     inc si
  201.     inc bx
  202.     dec dl
  203.     jnz paraag
  204.     cmp cl,0
  205.     jz paraar
  206.     jmp paraaa
  207. paraah: cmp al,':'                      ;check to see if char is a colon
  208.     jnz paraai
  209.     mov [paraas],1            ;set colon=last character
  210.     jmp paraaj
  211. paraai: mov [paraas],0            ;set colon<>last character
  212. paraaj: mov [bx],al            ;put in buffer
  213.     inc bx
  214.     cmp cl,0
  215.     jz paraaf
  216.     jmp paraae
  217. paraak: mov byte ptr [si],0        ;end of buffer, drivespec found
  218.     inc si
  219.     dec bx
  220.     dec bx
  221.     mov al,[bx]
  222.     and al,95
  223.     sub al,64
  224.     mov byte ptr [si],al
  225.     inc si
  226.     cmp cl,0
  227.     jz paraar
  228.     jmp paraaa
  229. paraal: inc di                ;ignore character
  230.     dec cl
  231.     jz paraar
  232.     jmp paraaa
  233. paraam: inc di                ;/parameter found
  234.     dec cl
  235.     jz paraao
  236.     mov bx,offset paraat
  237. paraan: mov al,[di]            ;loop for placing characters
  238.     cmp al,32            ;into the temporary buffer
  239.     jz paraao
  240.     mov [bx],al
  241.     inc di
  242.     inc bx
  243.     dec cl
  244.     jnz paraan
  245. paraao: mov byte ptr [si],2        ;end of parameter
  246.     inc si
  247.     mov dx,bx
  248.     sub dx,offset paraat
  249.     mov [si],dl
  250.     inc si
  251.     cmp dl,0
  252.     jz paraaq
  253.     mov bx,offset paraat
  254. paraap: mov al,[bx]            ;move characters from temporary
  255.     mov [si],al            ;buffer
  256.     inc si
  257.     inc bx
  258.     dec dl
  259.     jnz paraap
  260. paraaq: cmp cl,0            ;jump back to normal routine
  261.     jz paraar
  262.     jmp paraaa
  263. paraar: mov byte ptr [si],255        ;end of buffer code
  264.     pop si
  265.     ret                ;leave
  266. paraas    db ?                ;colon=last character?
  267. paraat    db 128 dup(?)            ;temporary storage area
  268. parse    endp
  269.  
  270. buffer    db 10 dup(?)
  271. buff    db 170 dup(?)
  272. message db 'Drive '
  273. drive    db ?,': $'
  274. errmess db 'invalid',13,10,'$'
  275. bytes    db 'bytes free',13,10,'$'
  276. lfee    db 13,10,'$'
  277. cseg    ends
  278.     end start
  279.  
  280. ;program by Alan Bishop - CIS 72405,647 Version 1.2
  281.  
  282.