『第
2 楼』:
厉害了,我的锅!
下载内容的批处理内容:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-4 delims= " %%a in (%~fs1)do (set keyword=%%a
set par1=%%b
set par2=%%c
set par3=%%d
call :count
)
goto :eof
:count
if "!keyword!"=="comp" (
call :recomp
)else if "!keyword!"=="lmov" (
call :relmov
)else if "!keyword!"=="dlay" (
call :redlay
)else if "!keyword!"=="sort" (
call :resort
)else (
:other
echo !keyword! !par1!>>%~dps0\tmp.asm
goto :eof
)
goto :eof
:recomp
echo COMP: MOV R0,!par1!;比较大小 >>%~dps0\tmp.asm
echo MOV A,!par2! >>%~dps0\tmp.asm
echo DJNE A,R0,LOOP1 >>%~dps0\tmp.asm
echo SJMP LOOP4 >>%~dps0\tmp.asm
echo LOOP1: JC LOOP2 >>%~dps0\tmp.asm
echo SJMP LOOP3 >>%~dps0\tmp.asm
echo LOOP2: ;这里加入小于处理 >>%~dps0\tmp.asm
echo. >>%~dps0\tmp.asm
echo LOOP3: ;这里加入大于处理 >>%~dps0\tmp.asm
echo. >>%~dps0\tmp.asm
echo LOOP4: ;这里加入等于处理 >>%~dps0\tmp.asm
echo. >>%~dps0\tmp.asm
goto :eof
:relmov
echo LMOV: MOV R0,!par1! ;转移一段数据>>%~dps0\tmp.asm
echo MOV R7,!par3! >>%~dps0\tmp.asm
echo MOV DPTR,!par2! >>%~dps0\tmp.asm
echo LOOP4: MOV A,@R0 >>%~dps0\tmp.asm
echo MOV @DPTR,A >>%~dps0\tmp.asm
echo INC R0 >>%~dps0\tmp.asm
echo INC DPTR >>%~dps0\tmp.asm
echo DJNZ R7,LOOP >>%~dps0\tmp.asm
echo RET >>%~dps0\tmp.asm
goto :eof
:redlay
echo DELAY: MOV R7,!par1! ;延时>>%~dps0\tmp.asm
echo DEL: MOV R6,!par2! >>%~dps0\tmp.asm
echo DEL1: DJNZ R6,DEL1 >>%~dps0\tmp.asm
echo DJNZ R7,DEL >>%~dps0\tmp.asm
echo RET >>%~dps0\tmp.asm
goto :eof
:resort
echo SORT: MOV R2,!par2! ;排序数目>>%~dps0\tmp.asm
echo MOV R3,!par2!>>%~dps0\tmp.asm
echo BUBBLE: CLR 7FH>>%~dps0\tmp.asm
echo MOV A,R3>>%~dps0\tmp.asm
echo MOV R2,A>>%~dps0\tmp.asm
echo MOV R0,!par1!>>%~dps0\tmp.asm
echo BULOOP: MOV 20H,@R0>>%~dps0\tmp.asm
echo MOV A,@R0>>%~dps0\tmp.asm
echo INC R0>>%~dps0\tmp.asm
echo MOV 21H,@R0>>%~dps0\tmp.asm
echo CJNE A,21H,LOOP>>%~dps0\tmp.asm
echo SETB C>>%~dps0\tmp.asm
echo LOOP: JC BUNEXT>>%~dps0\tmp.asm
echo MOV @R0,20H>>%~dps0\tmp.asm
echo DEC R0>>%~dps0\tmp.asm
echo MOV @R0,21H>>%~dps0\tmp.asm
echo INC R0>>%~dps0\tmp.asm
echo SETB 7FH>>%~dps0\tmp.asm
echo BUNEXT: DJNZ R2,BULOOP>>%~dps0\tmp.asm
echo JNB 7FH,BUOK>>%~dps0\tmp.asm
echo DJNZ R3,BUBBLE>>%~dps0\tmp.asm
echo BUOK: SJMP $>>%~dps0\tmp.asm
echo RET>>%~dps0\tmp.asm
goto :eof [ Last edited by zzz19760225 on 2017-11-21 at 17:37 ]
|