if not exist %1.asm goto END
del %1.txt
rem RENAME prior conversion result using TXT extension.
ren %1.s %1.txt
rem Source must be in lower-case with TABS controlling columns.
rem sr <%1.s “/!/i/dcs/!/i/\/*” “/d0%%e/d1” >%1.tmp these might still be close.
rem sr <%1.tmp “/!/i/dCS/!/i/\/*” “/d0%%E/d1” >%1.s
rem sr <%1.s “/!/i/dds/!/i/\/*” “/d0%%e/d1” >%1.tmp
rem sr <%1.tmp “/!/i/dDS/!/i/\/*” “/d0%%E/d1” >%1.s
rem sr <%1.s “/!/i/des/!/i/\/*” “/d0%%e/d1” >%1.tmp
rem sr <%1.tmp “/!/i/dES/!/i/\/*” “/d0%%E/d1” >%1.s
rem sr <%1.s “/!/i/dss/!/i/\/*” “/d0%%e/d1” >%1.tmp
rem sr <%1.tmp “/!/i/dSS/!/i/\/*” “/d0%%E/d1” >%1.s
sr <%1.asm “/!/i/dax/!/i/\/*” “/d0%%e/d1” >%1.s
sr <%1.s “/!/i/dbx/!/i/\/*” “/d0%%e/d1” >%1.tmp
sr <%1.tmp “/!/i/dcx/!/i/\/*” “/d0%%e/d1” >%1.s
sr <%1.s “/!/i/ddx/!/i/\/*” “/d0%%e/d1” >%1.tmp
sr <%1.tmp “/!/i/ddi/!/i/\/*” “/d0%%e/d1” >%1.s
sr <%1.s “/!/i/dbp/!/i/\/*” “/d0%%e/d1” >%1.tmp
sr <%1.tmp “/!/i/dfl/!/i/\/*” “/d0%%e/d1” >%1.s
sr <%1.s “/!/i/dsp/!/i/\/*” “/d0%%e/d1” >%1.tmp
sr <%1.tmp “/!/i/dsi/!/i/\/*” “/d0%%e/d1” >%1.s
sr <%1.s “/!/ij/dcxz/!/i/\/*” “/d0e/d1” >%1.tmp
rem Protect ‘;,? punctuations
sr <%1.tmp “/i/d’/d/i” “/d0|APOSTROPHE|/d2” |sr “‘/d/+0/!”” “‘1/d10” >%1.s
:SEMICOLON
rem fc %1.tmp %1.s |more
copy %1.s %1.tmp
sr <%1.tmp “‘1/+0/!’/\/+0/!;/\;/d;” “/d0|SEMICOLON|” >%1.s
if not errorlevel 1 goto SEMICOLON
:COMMA1
rem fc %1.tmp %1.s |more
copy %1.s %1.tmp
sr <%1.tmp “‘1/+0/!’/\/+0/!,/\,/d,” “/d0|COMMA|” >%1.s
if not errorlevel 1 goto COMMA1
:COMMA2
rem fc %1.tmp %1.s |more
copy %1.s %1.tmp
sr <%1.tmp “;/+0/!/n/\/+0/!,/\,/d,” “/d0|COMMA|” >%1.s
if not errorlevel 1 goto COMMA2
:QUESTION
rem fc %1.tmp %1.s |more
copy %1.s %1.tmp
sr <%1.tmp “;/+0/!/n/\/+0/!?/\?/d?” “/d0|QUESTION|” >%1.s
if not errorlevel 1 goto QUESTION
sr <%1.s “;” “#” >%1.tmp
sr <%1.tmp “/n” “/t/n” |sr “comment/s///d/+9/!//” “/d1*” >%1.s
sr <%1.s “/sName/s/d/+1/!/n/d/n” “/t.file/t/q/d1/q/n//*” >%1.tmp
sr <%1.tmp “#” “/t#” |sr “/t/t#” “/t#” >%1.s
rem CHANGES BEFORE SWAPPING OPERANDS
sr <%1.s “/!/i/doffset ” “/d0$” |sr “/t’1” “/t$’1” >%1.tmp
sr <%1.tmp “/t/d/#” “/t$/d1” >%1.s
sr <%1.s “[” “(” |sr “]” “)” >%1.tmp
sr <%1.tmp “byte ptr ” “#bPTR” |sr “near ptr ” “#nPTR” >%1.s
sr <%1.s “dword ptr ” “#dPTR” |sr “word ptr ” “#wPTR” >%1.tmp
sr <%1.tmp “far ptr ” “#fPTR” |sr “short ” “#sPTR” >%1.s
sr <%1.s “/tal,” “b/tal,” |sr “/tah,” “b/tah,” >%1.tmp
sr <%1.tmp “/tbl,” “b/tbl,” |sr “/tbh,” “b/tbh,” >%1.s
sr <%1.s “/tcl,” “b/tcl,” |sr “/tch,” “b/tch,” >%1.tmp
sr <%1.tmp “/tdl,” “b/tdl,” |sr “/tdh,” “b/tdh,” >%1.s
sr <%1.s “/t#/d/l/dPTR” “/d1/t” |sr “/!l/d/t%%e” “/d0l/t%%e” >%1.tmp
sr <%1.tmp “/n/+1/!,/\/+1/!/t/d/+1/!,/d,/d/+1/!/t” “/d0/d3,/d1” >%1.s
rem CHANGES AFTER SWAPPING OPERANDS
sr <%1.s “/!/i/doffset ” “/d0$” |sr “/t’1” “/t$’1” >%1.tmp
sr <%1.tmp “/t/d/#” “/t$/d1” >%1.s
sr <%1.s “/tal,” “b/tal,” |sr “/tah,” “b/tah,” >%1.tmp
sr <%1.tmp “/tbl,” “b/tbl,” |sr “/tbh,” “b/tbh,” >%1.s
sr <%1.s “/tcl,” “b/tcl,” |sr “/tch,” “b/tch,” >%1.tmp
sr <%1.tmp “/tdl,” “b/tdl,” |sr “/tdh,” “b/tdh,” >%1.s
sr <%1.s “/t#/d/l/dPTR” “/d1/t” |sr “/!l/d/t%%e” “/d0l/t%%e” >%1.tmp
rem DIRECTIVES
sr <%1.tmp ” rept ” ” .rept ” |sr ” macro ” ” .macro ” >%1.s
sr <%1.s ” endm ” ” .endr ” |sr ” irp ” ” .irp ” >%1.tmp
sr <%1.tmp ” else ” ” .else ” |sr ” end ” ” .end ” >%1.s
sr <%1.s ” endif ” ” .endif ” |sr ” if ” ” .if ” >%1.tmp
sr <%1.tmp ” dw ” ” .word ” |sr ” db ” ” .byte ” >%1.s
sr <%1.s “/tinclude/t” “/t.include/t” |sr ” assume ” “# .assume ” >%1.tmp
sr <%1.tmp “/h/+0/tcode ” “#/t.code ” |sr ” org ” ” .org ” >%1.s
sr <%1.s “/h/+1/!/t/d/+1/t/dequ/t” “/t./d2/d0,/d1” >%1.tmp
sr <%1.tmp “/#/+0/-16/x/dh” “0x/d0” |sr “0x0/d/x” “0x/d1” >%1.s
sr <%1.s “/t.byte/d/t/+1/!/n/\/!/+0’/\’/\/*/\/!'” “/t.ascii/d1” >%1.tmp
sr <%1.tmp “/t.ascii/t/d/+1/!’/d’1” “/d0’1/d1” >%1.s
sr <%1.s “/t.ascii/t/+1/!/n/\/+1/!’/\’/d’0/d/+1/!/n” “/d0/d2’0” >%1.tmp
sr <%1.tmp “+/d/+1/?/d)” “)+/d1” |sr “-/d/+1/?/d)” “)-/d1” >%1.s
sr <%1.s “(%/-3/i/d+/d%/-3/i)” “/d0,/d2” |sr “/h/i/+0/!/s/\/!:/*” “/d9:” >%1.tmp
sr <%1.tmp “/trep/+0/-1n/+0/-1z/d/t” “/d0/n/t” |sr “?” “99” >%1.s
sr <%1.s “/trep/+0/-1n/+0/-1e/d/t” “/d0/n/t” |sr “/tjmps/t” “/tjmp/t” >%1.tmp
rem CLEANUP
echo /* Translated from %1.asm by %0 to %1.s on %date% at %time% */ > %1.s
sr <%1.tmp “/$/r” “/r” |sr “/t*//” ” *//” >>%1.s
rem Restore ‘;,? punctuations
sr <%1.s “|SEMICOLON|” “;” |sr “|COMMA|” “,” >%1.tmp
sr <%1.tmp “‘/#” “/q” |sr “/q/d/-1/!/q/d/q” “‘/d1′” >%1.s
sr <%1.s “|APOSTROPHE|” “‘” |SR “|QUESTION|” “?” >%1.tmp
@if errorlevel 1 echo The last SR failed!
del %1.s
ren %1.tmp %1.s
rem Display differences between prior result & new conversion result.
fc %1.txt %1.s |more
:END