Category : Files from Magazines
Archive   : TINYLIB.ZIP
Filename : MAKEFNM.ASM

 
Output of file : MAKEFNM.ASM contained in archive : TINYLIB.ZIP
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

procdef makefnm, <, , >
locs <>
pushds
pushreg ; save index regs
mov ax, ':' ; look in SRC for drivespec
callit rindex, <, >
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, <, , >
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, <, >
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, <, >
svptr ax, temp, dx
or ax, ax
jz spath ; none there either, look for path
subptr ax, tmpl
inc ax
push ax
callit strncpy, <, , >
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, <, >
svptr ax, temp, dx
or ax, ax
jz tpath ; none there, try TMPL
subptr ax, src
inc ax
push ax
callit strncpy, <, , >
pop ax
addptr dst, ax
ldptr ax, temp, dx
inc ax
svptr ax, src, dx
mov ax, '\'
callit rindex, <, >
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, <, >
svptr ax, temp, dx
or ax, ax
jz sname ; none there either, look for name
subptr ax, tmpl
inc ax
push ax
callit strncpy, <, , >
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, <, >
svptr ax, temp, dx
or ax, ax
jnz snam1 ; no ext so try for EOS
callit rindex, <, >
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, <, , >
pop ax
addptr dst, ax
ldptr ax, temp, dx
svptr ax, src, dx
mov ax, '.'
callit rindex, <, >
svptr ax, temp, dx
or ax, ax
jnz snam2
callit rindex, <, >
snam2: svptr ax, tmpl, dx
jmp short endnam

tname: mov ax, '.' ; look for filename in TMPL
callit rindex, <, >
svptr ax, temp, dx
or ax, ax
jnz tnam1 ; no extension, try for EOS
callit rindex, <, >
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, <, , >
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, <, >
jmp short alldun

ext2: ldptr si, tmpl
mov al, [si]
cmp al, '.'
jnz alldun ; none in TMPL either
callit strcpy, <, >

alldun: pret ; restore regs and return
pend makefnm

finish


  3 Responses to “Category : Files from Magazines
Archive   : TINYLIB.ZIP
Filename : MAKEFNM.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/