I have this code:
Code: Select all
Macro m_Get_cur_code()
!mov eax, 1
!mov cl, byte [p.v_codesize]
!shl eax, cl
!sub eax, 1
!mov ecx, [p.v_index]
!mov edx, [ecx]
!mov cl, byte [p.v_offset]
!shl eax, cl
!And edx, eax
!shr edx, cl
!mov [p.v_cur_code], edx
!mov eax, [p.v_offset]
!add eax, [p.v_codesize]
!mov [p.v_offset], eax
While offset>=8
index+1
offset-8
bytesleft-1
Wend
EndMacro
As you can see the last part of the logic is a small loop written in PB code. I tried writing that section in asm and it worked fine once but the problem is the only way I know how to test-and-branch is using labels. In a procedure this would be no issue but if I put a label in this macro, the second time it gets called it will error out on "duplicate label" and I'm dead. This is with PB labels or assembler labels, same thing. Surely there must be a way to do this loop in a macro without hitting this problem. Can anyone point out how? Also, any tips on optimizing this for speed would be appreciated as I'm not very strong in asm.