Strange Behaviour in C

Programming, for all ages and all languages.
PlayOS

Re:Strange Behaviour in C

Post 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
Andrew_Baker

Re:Strange Behaviour in C

Post 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.
grey wolf

Re:Strange Behaviour in C

Post by grey wolf »

try:

Code: Select all

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

Re:Strange Behaviour in C

Post by sonneveld »

Perhaps the compiled code is assuming something about the stack and hasn't be initialised properly?

- Nick
PlayOS

Re:Strange Behaviour in C

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

Re:Strange Behaviour in C

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