Function Call halts execution - Screwed up code? O_o

Programming, for all ages and all languages.
Post Reply
vargadanis
Posts: 7
Joined: Fri Sep 24, 2010 7:45 am

Function Call halts execution - Screwed up code? O_o

Post by vargadanis »

Hello everyone!

I am facing an interesting problem. In short: I have function A and B. When Calling B from inside A my code stops the execution and nothing happens from that point on. A is called from kmain() function (yes I am saving the world and writing yet another OS :) ) I have no idea why that happens.

The line that 'breaks' my code is at line 44 here
https://github.com/fenistil/ToyToyOS/bl ... nel/scrn.c

If I comment it out like it is now on the git website, bochs has no trouble running it. Seems to be working the way I want it to work. I compile the c file with these options:
-c -g3 -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs -I./include
Any help would be appreciated
Developing for fun...
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Function Call halts execution - Screwed up code? O_o

Post by Tosi »

Try setting up a GDT with a flat address space, the multiboot specification recommends that the kernel set up its own GDT as soon as possible.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Function Call halts execution - Screwed up code? O_o

Post by Combuster »

Assuming you tried rebuilding everything, the obvious thing to check is the stack: can you tell exactly what part of memory it is supposed to use, and then what the actual value of ESP and EBP is?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
vargadanis
Posts: 7
Joined: Fri Sep 24, 2010 7:45 am

Re: Function Call halts execution - Screwed up code? O_o

Post by vargadanis »

A solution is to move the function definitions above the line of the calling function. Even tho I have included a header file that contains the declarations the function call halts. I suppose it could be cause of faulty stack or not set up GDT. I'll get back to this problem once I have facilities to check the stack's value and as well the contents of the registers.
Developing for fun...
Post Reply