.386
.model flat,stdcall
option casemap:none
extrn printf:near
repargv MACRO arg
LOCAL nustr
quot SUBSTR <arg>,1,1
IFIDN quot,<"> ;; if 1st char = "
.data
nustr db arg,0 ;; write arg to .DATA section
.code
mov eax, OFFSET nustr
EXITM <eax> ;; return data section offset in eax
ELSE
mov eax, arg
EXITM <eax> ;; else return arg
ENDIF
ENDM
;;过滤空格键
conbreak macro $szStr:vararg
szBuf textequ <>
szTemp textequ <>
%echo ************************************
forc qout,<$szStr>
ifidn <qout>,< >
else
szTemp textequ <qout>
szBuf textequ @CatStr(<%szBuf>,<%szTemp>)
%echo szBuf
endif
endm
exitm <szBuf>
endm
;输出
cout macro $string:vararg
LOCAL fuck
LOCAL pStr
LOCAL szEndl
LOCAL pTemp
LOCAL szMakeTab
LOCAL szDec
nNumf = 1
nNuml = 0
nNum = 0
fuck textequ <#>
.data
szDec db '%d',0
szEndl db 13,10,0
szMakeTab db 09,0
forc qStr,<$string>
nNuml = nNuml + 1
ifidn <qStr>,fuck
%echo qStr
pStr textequ %nNumf
%echo pStr
nNum =nNuml - nNumf
pStr textequ @SubStr(<$string>,nNumf,nNum)
nNumf = nNuml + 1
%echo pStr
;***********************************
pTemp textequ pStr
pTemp textequ conbreak(%pTemp)
%echo pTemp
%echo pStr
ifidn <endl>,pTemp
;打印一个换行
.code
pushad
push offset szEndl
call printf
add esp,4
popad
elseifidn <table>,pTemp
.code
pushad
push offset szMakeTab
call printf
add esp,4
popad
else
pTemp SUBSTR pStr,1,1
ifidn pTemp,<">
pushad
push repargv(%pStr)
call printf
add esp,4
popad
else
.code
pushad
push pStr
push offset szDec
call printf
add esp,8
popad
endif
;pStr ;;输出汇编语句
endif
;***********************************
else
%echo qStr
endif
endm
nNum =nNuml - nNumf + 1
pStr textequ @SubStr(<$string>,nNumf,nNum)
nNumf = nNuml + 1
%echo pStr
;**********************************************
;pStr ;;输出汇编语句
;**********************************************
pTemp textequ pStr
pTemp textequ conbreak(%pTemp)
%echo pTemp
%echo pStr
ifidn <endl>,pTemp
;打印一个换行
.code
pushad
push offset szEndl
call printf
add esp,4
popad
elseifidn <table>,pTemp
.code
pushad
push offset szMakeTab
call printf
add esp,4
popad
else
pTemp SUBSTR pStr,1,1
ifidn pTemp,<">
pushad
push repargv(%pStr)
call printf
add esp,4
popad
else
.code
pushad
push pStr
push offset szDec
call printf
add esp,8
popad
endif
;pStr ;;输出汇编语句
endif
;***********************************
endm
.data
dNum dd 1220
.code
start:
mov eax,1
mov ebx,100
cout eax#endl
;cout ebx#endl
cout eax
cout endl
cout ebx
cout endl
cout "this is a test"#endl
cout endl
cout "eax 的值是:" #eax #"ebx 的值是:" #ebx #endl #eax #endl
;
cout "this is a macro for cout"#endl
cout endl
cout "you can cout something like that"#endl
cout endl
;ok
cout eax # endl #ebx # endl
;error
;cout #endl
;ok
cout ebx
;error
;cout eax ebx
;yes,it is ok
cout "dNum的数值是:"#dNum#endl
;also ok
cout "dNum的数值是:"# dNum # endl
ret
end start
Added code tags
Hi debugee,
Nice job but could you please enclose all the code between the [ code] tags to provide readability?
Hi Vortex
Thanks for you reply
I was so busy that i am late to see your reply
I sorry about that
you can have a look at the macro file
regards