Hi all.
I was wondering if it is at all possible to use the NASM macro language to find the "nearest" RET instructions to a particular address? For example, I frequently use simple conditional return macros but in some cases, where there might be multiple conditional return macros within a 128 byte window of a ret instruction, I'd rather not have each conditional return macro define it's own ret instruction, but instead have them share the same return instruction.
As part of my conditional return macros, I have a "return" macro which wraps the ret instruction and adds a label which points to the instruction. This label is called %%_ret.
My idea is to search the 128 byte window for a regular expression which ends with a _ret label, from $ inside the conditional return macro, but I am not sure if the NASM preprocessor accept's regexes. Nevertheless, I thought I'd ask here. Perhaps I am approaching it the wrong way.
Either way, any help would be appreciated.
Many thanks,
zcap
PS. Here is an example of the situation:
myProc:
call proc1
retc ;Return if carry
push rax
movzx eax, word [var1]
cmp ax, word [rdi + myStruc.localLabel1]
pop rax
rete
mov al, 6
stc
return
Here are my macro definitions for the retc, rete and return macros:
%macro return 0
%%_ret:
ret
%endmacro
%macro cret 1
j%-1 short %%a
return
%%a:
%endmacro
%macro retc 0
cret c
%endmacro
%macro rete 0
cret e
%endmacro