flat assembler
Message board for the users of flat assembler.
Index
> Main > Optimize code size |
Author |
|
revolution 27 Jun 2012, 05:16
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.
|
|||
27 Jun 2012, 05:16 |
|
Madis731 29 Jun 2012, 07:59
I checked that its also true in 64-bit land:
Code: use32 push ebp mov ebp,esp cmp dword[ebp+16],0 align 16 use64 push rbp mov ebp,esp cmp dword[rbp+16],0 These both result in exactly the same 7-byte sequence. esp/rsp adds 1 byte to both. |
|||
29 Jun 2012, 07:59 |
|
rugxulo 05 Jul 2012, 21:59
Quote:
Hopefully this is obvious, but just in case ... you didn't actually use EBP here at all! So why push/pop it?? (Hmmm, perhaps because you sometimes jump further on, but it seems mostly silly and useless. Please keep this in mind as a lot of compilers don't omit such stack frame setups even when not needed.) |
|||
05 Jul 2012, 21:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.