C question

From: Cini, Richard <RCini_at_congressfinancial.com>
Date: Thu Aug 1 08:15:02 2002

Hello, all:

        I have another C issue that I can't seem to see the answer for, so I
thought I'd throw it out to the masses.

        I'm deep into the Altair 680b emulation project (base code done,
working on telnet access) and I'm experiencing problems reading a file
stream into the memory array. Here's snippets of the code:

byte *ppmem ; // pointer into memory array
byte ucMem[3*65536] ; // actual memory-see defines below for usage
// roms[] is an array of structures defining start-time loaded ROMs. Only
one ROM now
//(the monitor PROM), but flexible enough to allow bank-switched ROMs (not
//in the 680b but a leftover from the 6800 processor emulation code that was
//for the project)
//MEM_xxx are defines for the offset into the ucMem array to various areas
#define MEM_RAM 0
#define MEM_ROM 0x10000
#define MEM_FLAGS 0x20000

// open file, etc.

//create while loop to walk through roms[] array

// Read ROM directly to memory. This works.
ppmem = &ucMem[roms[i].iROMStart + MEM_ROM] ;
fread(ppmem, sizeof(byte), roms[i].iROMLen, pFH) ;

//this doesn't work...
//fread(&ucMem[roms[i].iROMStart + MEM_ROM], sizeof(byte), roms[i].iROMLen,
pFH) ;

//...nor does this
//fread((char *)ucMem[roms[i].iROMStart + MEM_ROM], sizeof(byte),
roms[i].iROMLen, pFH) ;

// Set flags for ROM
memset(&ucMem[roms[i].iROMStart + MEM_FLAGS], 1, roms[i].iROMLen) ;

        So here's where I'm missing it. Under all three fread scenarios, the
compiler doesn't throw a warning...they all compile cleanly. But only the
first works.

        This sounds like one of those "What's the Bug" ads from DDJ. What am
I missing?

Received on Thu Aug 01 2002 - 08:15:02 BST

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