Apropos of @MichaelPetch's question: how are you preparing the C executable, in what form or format is it stored in the disk image, and how are you loading it? Are you converting it to a raw binary image, or is it loading it from an executable in a standard
Executable Format such as
ELF or
PE?
I am not particularly familiar with the tutorial you mention,
but a quick review of the PDF tells me that it is converting the executable to raw binary, so am assuming that this is the procedure you are following.
I should point out that while this does look like a pretty solid tutorial, you should keep in mind that
no tutorial is flawless, and most tutorials have long-standing, known bugs which don't always get fixed. Also, while most of the things they apply remain stable for years, things do grow out of date with time. You need to apply any tutorial thoughtfully, and while you do seem to be doing so, it is always worth reminding people of this -
especially when the tutorial is, for the most part, a good one, as it is all too easy to get used to assuming that the tutorial will remain correct.
Trust me, I am speaking from personal experience on this, having made that mistake all too many times myself.
On a somewhat related note, have you prepared a separate
GCC Cross-Compiler and cross-development
OS-Specific Toolchain, separate from any tools targeting your development host (which you state is 32-bit Windows XP)? Again, not being familiar with the tutorial, I can't be sure, but it looks it isn't something it discusses. While it is possible to work without doing that - as the part that does seem to work shows - using a cross-compiler solves a lot of the problems with doing that, as does using a build tool such as
Make rather than running the compiler on the command line directly.
You probably should keep following the process as given, to avoid confusion for now, but be aware that in later development you probably should set up a cross-compiler.
One other thing, though this is just a stylistic question: why are you using
while() loops for definite loops instead of
for()? For example, rather than:
Code: Select all
while(j < 80 * 25 * 2) {
vidmem[j] = ' ';
vidmem[j+1] = 0x07;
j = j + 2;
}
you could use
Code: Select all
const unsigned int rows = 25, columns = 80;
const unsigned int vidbuf_size = rows * columns * 2;
unsigned int j = 0;
for (j = 0; j < vidbuf_size; j += 2) {
vidmem[j] = ' ';
vidmem[j+1] = 0x07;
}
This makes it clearer that the intent is to walk through a fixed number of iterations - what is called a 'definite iteration' - which is the main purpose of
for(). The
while() loop, conversely, is usually used for
indefinite loops, where the number of passes is determined by something in the loop body rather than the loop conditionals.
I am not saying the code was wrong - it does clearly work - but it isn't really idiomatic in C to use
while() for that. I was just wondering if there was a specific reason why you were doing it that way.