使用MASM软件编写汇编的时候,不得不面临在命令行下敲各种命令。这对于我们现在这些对windows命令不太熟悉的人来说有点繁琐和难懂。为了方便,我把在windows下使用MASM软件编译调试汇编程序的全过程用批处理写了出来。
@echo off
:k
cls
@echo .
@echo .
echo *************************************************************************
echo * please enter the source file name (Not to bring the extension) *
echo *************************************************************************
set /p name= the source filename is:
if not exist %name%.asm goto st
:s
cls
echo .
echo .
echo ********************* start menu ***********************
echo 1----------masm link and debug %name%...
echo 2----------debug %name%.exe
echo 3----------run %name%.exe
echo 4----------edit %name%.asm
echo 5----------open %name%.asm with note.exe
echo 6----------masm other source file
echo 7----------delete %name%.obj %name%.exe
echo 8----------exit
echo ********************************************************
echo .
set /p ID=please choose you op:
cls
if "%id%"=="1" goto m
if "%id%"=="2" goto d
IF "%id%"=="8" exit
if "%id%"=="3" goto r
if "%id%"=="4" QE %name%.asm
if "%id%"=="6" goto k
if "%id%"=="5" start %name%.asm
if "%id%"=="7" goto delete
goto s
:m
echo -----------masm %name%.asm------------
masm %name%
echo -----------link %name%.obj------------
link %name%
:d
echo -----------debug %name%.exe-----------
debug %name%.exe
goto s
:r
echo -----------now %name%.exe is running-------------
%name%.exe
echo -------------%name%.exe run over-----------------
pause
goto s
:st
cls
echo .
echo **********************************************************************
echo Not Exit %name%.asm, Do you want continue?
echo **********************************************************************
set m=Y
set /p m=N for exit and others for continue:
if %m%==N exit
goto k
CLS
echo --------please enter the source file name (Not to bring the extension)----------
set /p name=
if not exist %name%.asm goto st
goto s
:delete
del %name%.obj
del %name%.exe
echo -------%name%.obj %name%.exe have been deleted-----
pause
goto s
只要把这个批处理文件和masm link 汇编源文件放到一起,双击.bat文件运行即可
下面是批处理文件运行过程
1 提示输入源文件名 这里输入exp2(即本次试验用到的简单程序的代码文件名)
2进入主菜单
3 选择第一项,进行汇编连接和调试,由程序自动完成命令的输入。
反汇编后可以看出数据段段基地址为0b49h;
对于初学者来说,汇编代码的调试是一个艰苦的过程。今天偶然见到一篇文章,总结的不错,特意做个笔记于此:
————————————————————————————————————————————————————————————
代码 错误含义
00 Block nesting error嵌套出错。嵌套的过程、段、结构、宏指令或重复块等非正常结束。例如:在嵌套语句中有外层的结束语句,而无内层的结束语句
01 Extra characters on line一语句行有多余字符,可能是语句中给出的参数太多
02 Internal error-Register already defined