@echo off
::::::::Colorful Characters::::::::
::::::::{ s11ss 2007-10-27 }::::::::
::Release all variables once the programme has ended:
setlocal
::Receive the string to be showed:
set "str=%1"
goto :CalLen
:GetStr
echo Please input a string,like CN-DOS:
set/p str=
:CalLen
if "%str%" equ "" goto :GetStr
::Calculate the length of the string:
set/a len=0
:AddLen
call set word=%%str:~%len%,1%%
if not "%word%" equ "" (
set/a len=%len%+1
goto :AddLen
)
::Calculate the size of the file t.com:
set/a comsize=48+%len%
::Switch 10 to 16,for making t.t:
call :10to16 %len%
call :10to16 %comsize%
call set len=%%r%len%%%
call set comsize=%%r%comsize%%%
::Make t.t:
cd.>t.t
set w=^>^>t.t echo
%w% a
%w% xor di,di
%w% sub si,si
%w% mov dx,ds
%w% mov cx,%len%
< "%~f0" more +88 >>t.t
%w%.
%w% e130 "%str%"
%w% rcx
%w% %comsize%
%w% n t.com
%w% w
%w% q
::Make t.com:
more t.t|debug>nul
::Run t.com:
t.com
::Delete temporary files:
del t.t
del t.com
::End the programme:
goto :eof
::::::::Function definition and other codes for making files::::::::
::This function returns the value in hex,named r%1:
:10to16
set/a q=%1
:c
set/a r=%q%%%16
set/a q=%q%/16
call set r=%%r:10=a%%
call set r=%%r:11=b%%
call set r=%%r:12=c%%
call set r=%%r:13=d%%
call set r=%%r:14=e%%
call set r=%%r:15=f%%
call set r%1=%r%%%r%1%%
if not %q% equ 0 goto :c
goto :eof
::This is one part of the file t.t,which is the source of t.com:
mov ds,dx
mov bl,
mov ax,b8f0
mov ds,ax
mov ,bl
mov ax,cx
mov bl,7
div bl
inc ah
mov ,ah
inc si
add di,2
loop 109
xor ah,ah
int 16
mov ax,4c00
int 21