Page 1 of 1
C Stack
Posted: Thu Sep 11, 2003 11:00 pm
by pepito
How can I add a STACK to program writen in C, using GCC-LD to compile it?
Thank you
pepito
RE:C Stack
Posted: Fri Sep 12, 2003 11:00 pm
by beyondsociety
Do you have a stub that calls your c code? If so, you can add assembly code to setup the stack. Basically with the nasm assembler, you would do:
mov esp, stack
stack: resd 1024 ; allocate 1024 bytes for the stack
Then if you use bochs, you can use the bochs debugger to print the contents of the stack for you.
Hope this helps.
RE:C Stack
Posted: Sat Sep 13, 2003 11:00 pm
by pepito
Really, I need a stack for each application written for my OS because the 'task manager' need the ss/esp values to create a process. I need to know where C creates the application's stack.
By now, as you say, I add an ASM file with the line 'times 4096 db 0' at the end of the application, but maybe exist another stack into the C program compiled with GCC.
Thank you for your response,
pepito
P.D. How can I print the contents of the stack using bochs?
P.D...
Posted: Sat Sep 13, 2003 11:00 pm
by Robert Lee
...police department? Don't you mean "PS" (Postscript)?
RE:C Stack
Posted: Mon Sep 15, 2003 11:00 pm
by beyondsociety
[quote]P.S. How can I print the contents of the stack using bochs?[/quote]
type "print-stack"