Just want to unroll a loop, like this:
Code: Select all
!mov ecx, ebx
!horloop:
!lodsd
!mov [edi], eax
!add edi, 4
!dec ecx
!jnz horloop
of "chunk", then jump to the entry point, skipping some part of repeating "chunks"
Code: Select all
!xor edx, edx
!mov eax, offset endchunk
!sub eax, offset startchunk ; Get size of code "chunk" into EAX
!mul ecx ; EAX = code size * counter
!mov ecx, offset endofcode ; ECX points to the offset of unrolled code sequence
!sub ecx, eax ; ECX = entry point
!jmp ecx ; go to entry point
!startchunk:
!lodsd
!mov [edi], eax
!add edi, 4
!endchunk:
; repeat 1023 times
!lodsd
!mov [edi], eax
!add edi, 4
!lodsd
!mov [edi], eax
!add edi, 4
!lodsd
!mov [edi], eax
!add edi, 4
!lodsd
!mov [edi], eax
!add edi, 4
!lodsd
!mov [edi], eax
!add edi, 4
.....
!lodsd
!mov [edi], eax
!add edi, 4
!endofcode:
I use similar code many years ago in DOS era, but this doesn't work in PB.
Got error message on this
!mov eax, offset endchunk
Any ideas why ? What i'm doing wrong here ? Thanks a lot in advance