C Stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pepito

C Stack

Post by pepito »

How can I add a STACK to program writen in C, using GCC-LD to compile it?

Thank you

pepito
beyondsociety

RE:C Stack

Post 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.
pepito

RE:C Stack

Post 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?
Robert Lee

P.D...

Post by Robert Lee »

...police department? Don't you mean "PS" (Postscript)?
beyondsociety

RE:C Stack

Post by beyondsociety »

[quote]P.S. How can I print the contents of the stack using bochs?[/quote]
type "print-stack"
Post Reply