Skip to main content
Tweeted twitter.com/StackProgrammer/status/673647785124749312

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

int i = 6;
int j = 4;
int k = 5;
int a = i + j + k;

Since ii,j j, and kk are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k"int a = i + j + k into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push the result to the stack." Am I correct?

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push the result to the stack." Am I correct?

Suppose I have a very simple C program that just does this:

int i = 6;
int j = 4;
int k = 5;
int a = i + j + k;

Since i, j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates int a = i + j + k into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push the result to the stack." Am I correct?

deleted 320 characters in body
Source Link
moonman239
  • 2.1k
  • 4
  • 19
  • 26

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push thatthe result to the stack." Am I correct?

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push that to the stack."

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push the result to the stack." Am I correct?

deleted 320 characters in body
Source Link
moonman239
  • 2.1k
  • 4
  • 19
  • 26

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler basically writes assembly code that says something to the effect of "Move the stack pointer to the next available spot in memory, then store the number 6. Then move the stack pointer down another x bytes and store the number 4. Then, move the stack pointer down another x bytes and store the number 5. Then, move the stack pointer down another x bytes. In this new spot, addtranslates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push that to the stack." Am I correct?

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler basically writes assembly code that says something to the effect of "Move the stack pointer to the next available spot in memory, then store the number 6. Then move the stack pointer down another x bytes and store the number 4. Then, move the stack pointer down another x bytes and store the number 5. Then, move the stack pointer down another x bytes. In this new spot, add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x)" Am I correct?

Suppose I have a very simple C program that just does this:

int i = 6; int j = 4; int k = 5; int a = i + j + k;

Since i,j, and k are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates "int a = i + j + k" into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push that to the stack."

Source Link
moonman239
  • 2.1k
  • 4
  • 19
  • 26
Loading