X86 assembly: print value without saving

In x86 assembly, is it possible to delete a value from the stack without saving it? Something like strings pop word null? Obviously, I could use it add esp,4, but maybe there is a good and clean mnemonics that I miss?

+4
source share
1 answer

add esp,4/ add rsp,8is the normal / idiomatic / clean way. No special way is needed, because the stacks are not magical or special (at least not in this respect); it's just a pointer in a register with some instructions that use it implicitly. (And for stacks, interrupt kernels use it asynchronously, so the software cannot implement the red-zone kernel, even if it wants to ...)

, CISC leave= mov esp, ebx/pop ebp ( 16 64- ). enter, , , - 3 uop Intel. (http://agner.org/optimize/). leave , ebp/rbp. ( , , , push , , C99 VLA alloca. 16- , SP .)

CISC stack-args ret imm16 ( 1 uop), args, , . ret, mov push ( - - -, register-arg.)

, CISC , .


, pop reg add esp,4:

  • code-size: pop r32/r64 - , 3 add esp,4 4 add rsp,8.
  • : Intel esp/rsp (push/pop/call/ret). , call ( ret), uop pop add esp,4 ret .

    AMD , push-pop- -. Intel/AMD, push/pop , mov /, uop . .

. RAX ? .

, , , , x86 asm, .


, 1 , add, , pop. , +128 , sub esp, -128, -128 imm8, +128 .

, , lea esp, [esp+4], , gcc -mtune=atom. ( in-order, silvermont). , , x86 asm.


pop . E/RSP , , , .

, 7- (x86-32) 15 (x86-64) pop , , add. , pop; pop.

, pop Sreg ( ) - " " (32 64 , ), 16 16- . pop ds/es/ss . pop fs/gs - 2 . , , pop gs 1 add esp,4, . ( 2 add rsp,8).

+7

Source: https://habr.com/ru/post/1693413/


All Articles