Altair emulator code & C pointers
> // copy binary image to the emulator memory
> for (i = 0; i <= iLength; i++)
> Mem[i+addr] = (uchar) *pstrBuffer+i;
> return 0;
>
> This is the important code. The Altair's memory is represented
> by an array
> of type uchar and pstrBuffer is the file buffer used int he fread command.
> My question is whether I'm doing the assignment right?
You could potentially get weird behavior that way. Some compilers do
strange
things converting signed to unsigned values. Try this instead:
Mem[i+addr] = *((uchar *)(pstrBuffer+i));
or even:
Mem[i+addr] = ((uchar *)pstrBuffer)[i];
for clarity. Note, I tend to go overboard with parens, I've seen a number
of compilers and other programs which didn't do operator precedence
correctly.
Received on Mon Jun 12 2000 - 10:18:58 BST
This archive was generated by hypermail 2.3.0
: Fri Oct 10 2014 - 23:33:01 BST