Data transfer instructions and stack operations

data transfer instruction

instruction Effect describe
MOV S,D D<—S send
movb transmit bytes
movw transfer word
movl send double word
movq send four characters
movabsq I,R R<—I send absolute quads

Simple data transfer instructions, note that both operands cannot be memory

instruction Effect describe
MOVZ S,R R<—zero extension (S) Delivered with zero extension
movzbw transfer zero-extended byte to word
movzbl transfer zero-extended byte to double word
movzwl transfer zero-extended word to double word
movzbq Transfer zero-extended bytes to quadwords
movzwq Transfer zero-extended word to quadword

Zero-extended data transfer instruction. These instructions take a register or memory address as source and register as destination

instruction Effect describe
MOVS S,R R<—sign extension (S) transfer sign-extended bytes
movsbw transfer sign-extended bytes to words
movsbl transfer sign-extended byte to double word
movswl transfer sign-extended word to double word
movsbq Transfer sign-extended bytes to quadwords
movswq transfer sign-extended word to quadword
movslq transfer sign-extended doubleword to quadword
cltq %rax<—sign extension (%eax) Extend %eax sign to %rax

Sign-extended data transfer instruction. The MOVS instruction takes a register or memory address as the source and the register as the destination. The cltq instruction only acts on registers %eax and %rax

stack operation

In x86-64, the stack grows downward. The
write picture description here
register %rsp is used to operate on the stack

instruction Effect describe
push S R[%rsp]<—R[%rsp]-8; push quadword onto stack
M[R[%rsp]]<—S
popq D D<—M[R[%rsp]]; pop the quadword off the stack
R[%rsp]<—R[%rsp]+8

Pushing to the stack is to first move the stack pointer down by 8 bits, and then assign a value

  • The behavior of pushq %rbp is equivalent to the following two instructions:
subq $8, %rsp          Decrement stack pointer
movq %rbp, (%rsp)       Store %rbp on stack
  • popq %rax is equivalent to the following two instructions
movq (%rsp), %rax       Read %rax from stack
addq $8, %rsp          Increment stack pointer

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325920592&siteId=291194637