Page 2 of 2

Re:Strange Behaviour in C

Posted: Mon Nov 18, 2002 9:30 am
by PlayOS
Well, I worked out the problem, but I dont know why it is a problem, I have two boot loaders, one is a two stage loader (this causes an error), the other one is a single stage loader (this one works), when I boot with the 2 stage loader I do not get exceptions or anything like that, the variables will just not increment (GDTs are identical in both), but when I use the single stage loader everything runs perfect.

This is very weird!! :o

Re:Strange Behaviour in C

Posted: Mon Nov 18, 2002 8:53 pm
by Andrew_Baker
From what I learned in class, and on my own, if you icrement a pointer *foo++; you are actually changing the memory address it is pointing to by the bit value of the primitive on which the pointer is based. So, a char pointer should increment 8-bits.

Re:Strange Behaviour in C

Posted: Tue Nov 19, 2002 2:47 am
by grey wolf
try:

Code: Select all

*(++video)
it's just an idea, but may work.

Re:Strange Behaviour in C

Posted: Tue Nov 19, 2002 2:53 am
by sonneveld
Perhaps the compiled code is assuming something about the stack and hasn't be initialised properly?

- Nick

Re:Strange Behaviour in C

Posted: Tue Nov 19, 2002 5:00 am
by PlayOS
Perhaps you are right Nick, in the two stage loader I define a segment specifcally for the stack, and the base is not zero.

But in the signle stage loader, my data segment is used for the stack, and it is zero based.

I will try this and let you know.

Thanks.

Re:Strange Behaviour in C

Posted: Tue Nov 19, 2002 5:04 am
by PlayOS
Well that didn't take long, and guess what, Nick is now a genius in my book, because he was spot on the money.

Good stuff, that saved me alot of bug searching.

:) :D ;D :D :) :D ;D :D :)

Thanks Nick, and everyone else who tried to help me.