I got started on assembly language, I'm studying some codes, for a test I've copy a code to compare memory bytes and I saw size difference of compiled code, so I'll show the source and compiled one:


How we can see there is a bigger instruction size on memory manipulations. I think 60-80% of any application use memory R/W, this makes the output code 10-30% bigger.
I asked on flat assembler forum and revolution returned me this:
So how the PB code is translated to ASM and is compiled by flat assembler I decided post my doubt here.revolution wrote:When you access memory using the ESP register you have to use the SIB format for addressing. This is limitation of the x86 instruction design. Using EBP instead of ESP will make the code smaller.
This is the code
Code: Select all
Procedure MemCmp(*Source, *Pattern, Length)
!push ebp
!mov ebp, esp
cmp Length, 0h
mov ecx, *Pattern
mov eax, *Source
!jnz loc_count
!XOr eax, eax ;ProcedureReturn 1
!inc eax
!pop ebp
!retn 0ch
!loc_compare:
!mov dl, [eax]
!cmp dl, [ecx]
!jnz loc_return
!inc eax
!inc ecx
!loc_count:
dec Length
!jnz loc_compare
!loc_return:
!mov al, [eax]
!xor edx, edx
!cmp al, [ecx]
!setz dl
!mov eax, edx
!pop ebp
!retn 0ch
EndProcedure