home *** CD-ROM | disk | FTP | other *** search
- include compiler.inc
-
- ttl MAKFNM, 1.05, 11-04-86, jwk
-
- ; makes filename by merging default values from TMPL into SRC and
- ; putting result at DST. handles drive, path, name, and extension.
-
- dseg
- cseg
-
- incptr macro bump
- ifdef bump&_v
- inc word ptr bump&_v
- else
- inc word ptr bump
- endif
- endm
-
- subptr macro cnt,bump
- ifdef bump&_v
- sub cnt,word ptr bump&_v
- else
- sub cnt,word ptr bump
- endif
- endm
-
- addptr macro bump,cnt
- ifdef bump&_v
- add word ptr bump&_v,cnt
- else
- add word ptr bump,cnt
- endif
- endm
-
- xtfs <rindex, strncpy, strcpy>
-
- procdef makefnm, <<src, ptr>, <tmpl, ptr>, <dst, ptr>>
- locs <<temp, ptr>>
- pushds
- pushreg ; save index regs
- mov ax, ':' ; look in SRC for drivespec
- callit rindex, <<ax, reg>, <src, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz tdrv ; none there, try TMPL
- subptr ax, src ; got one, calc length
- inc ax
- push ax ; save the length
- callit strncpy, <<ax, reg>, <src, ptr>, <dst,ptr>>
- pop ax ; get length back
- addptr dst, ax ; and adjust DST
- ldptr ax, temp, dx ; now adjust SRC also
- inc ax
- svptr ax, src, dx
- mov ax, ':' ; and step over any in TMPL
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz spath ; none there, look for path
- inc ax
- svptr ax, tmpl, dx ; else adjust TMPL too
- jmp short spath
-
- tdrv: mov ax, ':' ; look for drivespec in TMPL
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz spath ; none there either, look for path
- subptr ax, tmpl
- inc ax
- push ax
- callit strncpy, <<ax, reg>, <tmpl, ptr>, <dst, ptr>>
- pop ax
- addptr dst, ax
- ldptr ax, temp, dx ; adjust TMPL after copy
- inc ax
- svptr ax, tmpl, dx
-
- spath: mov ax, '\' ; look for pathspec in SRC
- callit rindex, <<ax, reg>, <src, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz tpath ; none there, try TMPL
- subptr ax, src
- inc ax
- push ax
- callit strncpy, <<ax, reg>, <src, ptr>, <dst, ptr>>
- pop ax
- addptr dst, ax
- ldptr ax, temp, dx
- inc ax
- svptr ax, src, dx
- mov ax, '\'
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz sname
- inc ax
- svptr ax, tmpl, dx
- jmp short sname
-
- tpath: mov ax, '\' ; look for pathspec in TMPL
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jz sname ; none there either, look for name
- subptr ax, tmpl
- inc ax
- push ax
- callit strncpy, <<ax, reg>, <tmpl, ptr>, <dst, ptr>>
- pop ax
- addptr dst, ax
- ldptr ax, temp, dx
- inc ax
- svptr ax, tmpl, dx
-
- sname: mov ax, '.' ; look for filename in SRC
- callit rindex, <<ax, reg>, <src, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jnz snam1 ; no ext so try for EOS
- callit rindex, <<ax, reg>, <src, ptr>>
- svptr ax, temp, dx
- snam1:
- ldptr si,src
- cmp ax, si ; find anything?
- jz tname ; no, try TMPL
- subptr ax, src
- push ax
- callit strncpy, <<ax, reg>, <src, ptr>, <dst, ptr>>
- pop ax
- addptr dst, ax
- ldptr ax, temp, dx
- svptr ax, src, dx
- mov ax, '.'
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jnz snam2
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- snam2: svptr ax, tmpl, dx
- jmp short endnam
-
- tname: mov ax, '.' ; look for filename in TMPL
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- or ax, ax
- jnz tnam1 ; no extension, try for EOS
- callit rindex, <<ax, reg>, <tmpl, ptr>>
- svptr ax, temp, dx
- tnam1:
- ldptr si,tmpl
- cmp ax, si ; find anything?
- jz endnam ; no, all done
- subptr ax, tmpl
- push ax
- callit strncpy, <<ax, reg>, <tmpl, ptr>, <dst, ptr>>
- pop ax
- addptr dst, ax
- ldptr ax, temp, dx
- svptr ax, tmpl, dx
-
- endnam: ldptr si, dst ; set EOS into DST
- xor ax, ax
- mov [si], al
-
- ldptr si, src ; now check for extension
- mov al, [si]
- cmp al, '.'
- jnz ext2 ; none in SRC, try TMPL
- callit strcpy, <<src, ptr>, <dst, ptr>>
- jmp short alldun
-
- ext2: ldptr si, tmpl
- mov al, [si]
- cmp al, '.'
- jnz alldun ; none in TMPL either
- callit strcpy, <<tmpl, ptr>, <dst, ptr>>
-
- alldun: pret ; restore regs and return
- pend makefnm
-
- finish
-