C question

From: Sellam Ismail <foo_at_siconic.com>
Date: Thu Aug 1 16:04:25 2002

On Thu, 1 Aug 2002, Cini, Richard wrote:

> No errors or warnings are emitted by the compiler, so the way I'm
> determining that the various functions work or not work is by looking at a
> "core dump" of the emulator memory (performed by another routine). In all
> but the first example, the memory is empty (they remain the initialized
> value of 0). The first way, the emulator memory indeed shows the contents of
> the loaded ROM.
> I've "watched" the contents of the roms array and have also
> outputted the values to the debug screen. The values are as expected.

And you've done this in both instances? As others do, I find it odd that
this form doesn't work:

fread(&ucMem[roms[i].iROMStart + MEM_ROM], sizeof(byte),roms[i].iROMLen, pFH);

I don't have my C references with me but fread expects a void pointer
(void *) for the memory address, right? Have you tried casting it as a
byte pointer (byte *) to be more explicit? I can't see how this would
change things but maybe you have a weird compiler. Aren't you using
Visual C++?

Let's look at it another way:

fread(&(ucMem[roms[i].iROMStart + MEM_ROM]), sizeof(byte),roms[i].iROMLen,

By putting the array cell in parentheses, the value of that cell will be
used as the address, right? Maybe this is how the compiler is parsing
this, which would then read the data into an unintended location.

At this point I usually just go with what works and chalk it up to a lame
compiler :)

Sellam Ismail Vintage Computer Festival
International Man of Intrigue and Danger http://www.vintage.org

 * Old computing resources for business and academia at www.VintageTech.com *
Received on Thu Aug 01 2002 - 16:04:25 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:35 BST