mov rbp, rsp in function prologue

mov rbp, rsp in function prologue

Questions : mov rbp, rsp in function prologue

push rbp mov rbp, rsp mov DWORD PTR [rbp-0x4],edi 

In assembly function prologue, isn’t push in4codes_assembly rbp already moves its value to rsp ? Why did in4codes_assembly mov rbp, rsp instruction move the same rsp in4codes_assembly values to rbp again? Is it necessary or in4codes_assembly redundant?

Total Answers 2

Answers 1 : of mov rbp, rsp in function prologue

isn’t push rbp already moves its value in4codes_x86 to rsp?

No. push rbp is equivalent to:

sub rsp, 8 ; but without setting FLAGS mov [rsp], rbp 

No more, no less, just like pushing any in4codes_x86 other register in4codes_x86 ( in4codes_x86 This stores rbp to memory pointed-to by in4codes_x86 rsp, but doesn’t modify registers other in4codes_x86 than rsp-=8. It’s not an enter in4codes_x86 instruction.

You may already know this, but rbp is in4codes_x86 used as a frame pointer. mov rbp, rsp in4codes_x86 saves the previous top of the stack to in4codes_x86 rbp, and this top now serves as the in4codes_x86 bottom of the current stack frame.

But this creates an issue: if rbp has in4codes_x86 been modified, what about the previous in4codes_x86 stack frame? Since the stack frame has in4codes_x86 been modified, after this function in4codes_x86 returns, rbp would be in the wrong in4codes_x86 position and things would go very wrong.

This is where push rbp comes in. It in4codes_x86 saves the value of rbp before being in4codes_x86 modified so that right before the in4codes_x86 function returns, rbp’s original value in4codes_x86 can be popped right back to rbp so the in4codes_x86 previous stack frame remains okay.

(Or in other words, rbp is in4codes_x86 call-preserved, so we need to in4codes_x86 save/restore it as part of setting it up in4codes_x86 as a frame pointer for our stack frame.)



Answers 2 : of mov rbp, rsp in function prologue

mov rbp, rsp takes the current value in in4codes_x86 rsp and moves it into rbp.

Think as: You want to save the last in4codes_x86 stackframe and build another one.

There is also a difference between intel in4codes_x86 (the code above) and at&t syntax.

Intel: mov dest, source


Answer Link
  • Unable to run NoraUI mvn verify goal
  • Unable to run my app on emulator in VS Code
  • Unable to run multiple instances of libVLC(MobileVLCKit) in IOS via flutter framework
  • Unable to run make on griddb source on ubuntu 20.04 (building from source)
  • Unable to run latexindent macOS Monterey 12.0.1
  • Unable to run kotlinc-native command
  • Unable to run JUnit Test… Java.lang.ExceptionInInitializerError (Android Studio)
  • Unable to run java with -Xmx > 966m
  • Unable to run ionic cap run android from wsl2 inorder to start android emulator
  • Unable to run Intel HAXM installer: Cannot start process, the working directory does not exist
  • fs
  • Unable to run Google Analytics sample code
  • unable to run flutter run after upgarding to flutter 2.8.0 from 2.5.3
  • Unable to run Django with PostgreSQL in Docker
  • Unable to Run Container Using testcontainers
  • Unable to run ClojureScript Hello World program, Error building classpath. Error reading edn.
  • unable to run client command for apache karaf 4.3.3 through remote server
  • Unable to run c program 2nd time using eclipse
  • unable to run c++ in visual studio code on m1 chipset
  • Unable to run Android Instrumented Tests
  • Unable to run adb, check your Android SDK installation and ANDROID_SDK_ROOT environment variable: …AndroidSdkplatform-toolsadb.exe
  • Unable to run a singlespecific .spec.ts file through angular cli using ng test –include option
  • Unable to run a Mango query
  • Unable to return response back to view in laravel from package
  • Unable to return object reference in std::optional
  • Unable to return NULL in a function that expects an integer return type
  • Unable to return correct change in JavaScript Cash Register
  • Unable to retrieve version information from Elasticsearch nodes. Request timed out
  • Unable to retrieve values from Axios Response data
  • Unable to retrieve dotenv JWT secret Error: secretOrPrivateKey must have a value
  • Unable to resolve your shell environment
  • Unable to resolve token for FCM while implementing Push notification for Xamarin
  • Unable to resolve the request yii
  • Unable to resolve service for type Swashbuckle.AspNetCore.Swagger.ISwaggerProvider
  • Unable to resolve service for type Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger