In the "Programming from the ground up" book, I see the stack frame when calling function is somewhat like this
parameter 2 <- 12(%ebp)
parameter 1 <- 8(%ebp)
return address <- 4(%ebp)
ebp <- (%ebp)
local var 1 <-…
how functions are stored on memory i.e : the data segment as normal variables expressions or on the code segment
in either one What is pushed to the stack
a pointer? or the whole function and why do we need to push the local variables and…
I am trying to implement a merge sort algorithm in C. In the recursive array split function, my base case is occurring infinitely, despite the return statement, and the merge function is never called. Here is my code:
#include
const int…
I was wondering if there would be a convenient way to copy the current stack frame, move it somewhere else, and then 'return' from the function, from the new location?
I have been playing around with setjmp and longjmp while allocating large arrays…
void foo()
{
int i;
printf("%d",i++);
}
int main()
{
int j;
for(j=0;j<10;j++)
{
foo();
}
}
The output of the code is a series of 10 random but continuous numbers.
I wanted to know how is this possible if i is being…
Hi I write a Fibonacci recursive code in assembly with the amd64 abi calling convention, but I always get segmentation fault :/
I compile it with:
nasm -f elf64 -o fibo.o fibonacci.asm
ld -o fibo fibo.o
./fibo
I have no compiling errors but a…
Compiling a simple C code into assembly using GCC will have the following output:
...
13 xorl %eax, %eax
14 movl $0, -4(%rbp)
15 movl $5, -8(%rbp)
16 movl $6, -12(%rbp)
17 movl -8(%rbp),…
I am facing the issue that copy of an 2 dimensional array is not made in each stack frame of recursive call. I am doing indirect recursion.
I also tried sending my data in function call from main() function but the copy was not made. Same address…
Logically, I would assume that there has to be. If im correct, I'm also assuming that its separate from the global symbol table, and that its created by the compiler when a function call is reached and deleted when the compiler reaches the end of…
Im trying to implement custom threads in C by creating a simple context switch function plus a FCFS scheduler.
The first step that i want to perform is to copy the entire function stack frame to heap to a saved frame and replace it by the first in…
Here is my code
segment .data
; initialized data is put in the data segment here
;
segment .text
global main
main:
enter 0,0 ; setup stack frame
pusha
call func
;
;
;
;
popa
…
Porting some code from .NET Framework to UWP, and I'm not sure how to replicate this in a UWP project:
StackFrame frame = new StackFrame(1);
var method = frame.GetMethod();
var names = method.Name.Split('_');
var propertyName = names.Length == 2 ?…
I wrote a single c program that prints input to std output. Then I converted it to assembly language. By the way I am using AT&T Syntax.
This is the simple C code.
#include
int main()
{
int c;
while ((c = getchar ()) != EOF)
…
Why do we need these two functions at the start of every assembly program?
pushl %ebp
movl %esp,%ebp
I don't know what they do and they don't seem to contribute to the code functionality. I come from the Python world so this is pretty weird.