Uncertainty of point and pop operands on processors

Why do we have commands like push and pop?

From what I understand popand pushbasically the same as for ( movthen add) and ( subthen mov) respectively esp.


For example, there would be:

pushl %eax

is equivalent to:

subl $4, %esp
movl %eax, (%esp-4)

please correct me, if access to the stack is not (%esp-4), I'm still studying the assembly


The only true advantage that I see is that if both operations simultaneously give some advantage; however, I do not understand how this is possible.

+5
source share
3 answers

CALL. , :

sub esp,4
mov [esp-4], offset return_address
jmp myproc

RET, :

mov eax,[esp]
add esp,4
jmp [eax]

, , , . ?

x86 , . , , .

70- 64 , . , , . , fetch , . , , .

- , - . , , , , , - . .

:

- , CALL . , dword:

push eax
push ebx
call proc    ; pushes the return address and jumps to proc
...

proc:
  ; at this point, [esp] contains the return address

RET .

-, , . , . , ret 8, .

. http://www.delorie.com/djgpp/doc/ug/asm/calling.html.

+8

. , , , . cpu . . . cpu , , ... , , . risc, .

+2

1 opcode> 2 opcode, at least when you are trying to reduce CPU usage.

+1
source

All Articles