Question

This question is in regards to Assembly. What x86-64 register is changed to allocate local variables?...

This question is in regards to Assembly.
What x86-64 register is changed to allocate local variables? Explain briefly with an example.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

What x86-64 bit register is changed or used to allocate the local variables:

Answer: rbp register

Description:

• The base pointer register %rbp is used to keep track of the base value of the current stack frame. The start of the frame can be defined by moving the current stack pointer register to frame pointer.

• Example:

• Consider the following C code which is having variable a and b.

int main()

{

int a = 10, b = 20;

return 0;

}

Stack frame for main function will look like as follows:

• Assembly code to implement above function using %rbp register.

main:

pushq %rbp ; push or save the rbp on stack.

movq %rsp, %rbp ; Move the current stack frame of main function

movl $10, -8(%rbp) ; Assign value 10 to variable a

movl $20, -4(%rbp) ; Assign value 20 to variable b

movl $0, %eax ; return 0 function value

leave ; cleans allocated variables and restore the rbp register.

ret

In x86-32 architecture, register ebp is used to allocate local variables.

Add a comment
Know the answer?
Add Answer to:
This question is in regards to Assembly. What x86-64 register is changed to allocate local variables?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the correct way to address local stack variables in a loop (programmatically) using x86 a...

    What is the correct way to address local stack variables in a loop (programmatically) using x86 assembly? Why can't i use this code: mov [ebp - 4 * ecx], eax Where ecx is a counter?

  • What is the RISC-V assembly code to load hexadecimal number 3D0500hexas a 64-bit constant into register...

    What is the RISC-V assembly code to load hexadecimal number 3D0500hexas a 64-bit constant into register x19?

  • Question 2 Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)...

    Question 2 Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a) Explain the meaning of the following instruction: movq %rbx, (%rcx)         State your assumptions of the content in registers and memory, before executing this instruction.         What will happen after executing this instruction? (b)Convert the following code fragment (in the C language) to assembly code. Explain your steps. [25 marks] long test ( long a, long b, long c ) { long t; if...

  • This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the...

    This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the solution is not there. Programming exercise 12.7 #2. The code must be in assembly language for Intel using Kip Irvine library. An example of the source code would be: INCLUDE Irvine32.inc .code main PROC mov ax,4000h mov bx,1000h mov cx,1500h sub ax,bx sub ax,cx call DumpRegs exit main ENDP END main Question: Write a procedure that receives a single-precision floating-point binary value and displays...

  • Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)  Explain the meaning...

    Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)  Explain the meaning of the following instruction:                movq %rbx, (%rcx)         State your assumptions of the content in registers and memory, before executing this instruction.         What will happen after executing this instruction? Answer: [ Write answer here ] 2(b)        Convert the following code fragment (in the C language) to assembly code. Explain steps.                                                                     [25 marks]    long test ( long a, long b, long c ) {        long t; if (a>b)...

  • I need some help on this assembly question, it has to be done strictly in Intel...

    I need some help on this assembly question, it has to be done strictly in Intel x86 64 bit assembly language and the other part in C language The faction findRange find the range of the numbers in a given amay and retums the range The range is defined as the difference between the maximum number and the minimum number in the given amay write the function findRange both in C and in Assembly. The function stub for findRange is...

  • NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors...

    NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors - Irvine) that has two procedures, a main procedure and a procedure called Fib. The fib procedure is to uses a loop to calculate and printout the first N Fibonacci numbers. Fibonacci sequence is described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). The value of N is to be communicated to this...

  • Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the...

    Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...

  • QUESTION 5 What result will be in AVR registers r16, r18 and the status register (Z, C, N, V bits...

    QUESTION 5 What result will be in AVR registers r16, r18 and the status register (Z, C, N, V bits) after the execution of all of the following AVR assembly language instructions: Idi r16, 77 Idi r17, OxAB ldi r18, 34 and r16, r17 add r18, r17 Your answers should consist of binary digits only (0's and 1's)- your r16 and r18 values should show 8 binary digits; your status register values should be shown with a single bit. r16:...

  • Question 3: ARM Processor a) What is the number of bits in a general-purpose register (e.g., R1) of the ARM Cortex-M4 processor (CPU)? b) What is the number of bits in a memory address for the ARM pr...

    Question 3: ARM Processor a) What is the number of bits in a general-purpose register (e.g., R1) of the ARM Cortex-M4 processor (CPU)? b) What is the number of bits in a memory address for the ARM processor architecture? c) What is the number of bits in an assembly instruction for the ARM Thumb-2 instruction set? d) Consider the memory map used with the TM4C123 microcontroller shown below. If the stack is in data memory, what is the initial address...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT