To aid in my debugging, I defined M_PRINTF macro that I use throughout my code. To further enhance it, I was wondering to see if there is a way to determine the proc name through manipulation of any of the pre-defined macro or any other means, so that, as of now, I can call M_PRINTF macro with string:
Code:
M_PRINTF "\nBlah blah"
and it prints out following output
Code:
Blah blah
If I can automatically get proc name, so that when M_PRINTF macro called from any procedure, it is able to print something as follows:
Code:
<procName>: Blah blah
<procName1>: Helloworld
when it is called from following proc-s:
Code:
<procName> proc far
....
M_PRINTF "\nBlah blah"
....
<procName> endp
<procName1> proc far
....
M_PRINTF "\nHelloworld"
....
<procName1> endp
Sure, you can type manually in every M_PRINTF statement but that is huge maintenance nightmare, tedious and prone to errors and omissions.
I did this exactly in python using one of the python library, printing out calling function name in prefix automatiicaly with any print out is huge debugging clarity and assistance.
So far I looked through most comprehensive ASM X86 manual and looked through pre-defined macros so far, not finding anything.
Thanks.,
Here is my M_PRINTF macro which you can use to print any string on the fly without defining it on data segment and pass pointers to it:
it can currently process new line chars but i am planning to enhance further too:
Code:
M_PRINTF MACRO pStr
local skipStr, printfLoop, exitMacro, printfStr, m_printf_skip_esc_char
IF OPTION_ENABLE_M_PRINT
push ax
push dx
push bp
push cx
jmp skipStr
printfStr db pStr, '$'
skipStr:
lea bp, cs:printfStr
mov cx, 3h
printfLoop:
mov ah, 02h
mov dl, cs:[bp]
cmp dl, '$'
je ExitMacro
cmp dl, '\'
jne m_printf_skip_esc_char
cmp byte ptr cs:[bp+1], 'n'
jne m_printf_skip_esc_char
inc bp
mov dl, 0dh
mov ah, 02h
int 21h
mov dl, 0ah
mov ah, 02h
; int 21h
m_printf_skip_esc_char:
int 21h
inc bp
dec cx
; jz exitMacro
jmp printfLoop
exitMacro:
pop cx
pop bp
pop dx
pop ax
ENDM