[comp.sys.ibm.pc] > 64 K data

rahardj@ccu.umanitoba.ca (Budi Rahardjo) (11/19/89)

I am trying to write a program (in MSC) which loads a 100K data into memory,
and save the starting address and ending address with a pointer or index.
The problem is after reaching the end of 64 K the pointer wrap around
the beginning of the same data blocks, so it writes over the first 36K.
To make it simple, here is the problem I have :
* How do I increment the pointer so that it can point beyond the 64 barier ?


Here is part of my code :

/******************
	READ FILES
*******************/
int read_file()
{
    extern int far *basech1;
    extern long int endch1;
    extern char *data_file;
    int far *_fmalloc();
    int *calloc();
    int numread = BUFFER_SIZE;
    int *buffer;
	int i;
    char ch1file[FILE_NAME_LENGTH];
    FILE *stream;
	long int counter = 0;

    buffer = calloc(BUFFER_SIZE, sizeof(int));
    if (buffer == NULL) {
        printw("Not enough Memory\n");
        return(1);}

    basech1 = _fmalloc(CH1_SIZE , sizeof(int));
	if (basech1 == NULL) {
		printw("Not enough Memory\n");
		return(1); }


	stream = fopen(ch1file,"rb");
	if (stream == NULL) {
		printw("File error\n");
		refresh();
		return(1);}

	while (numread == BUFFER_SIZE) {
		numread = fread((int *)buffer,1,BLK_TOREAD,stream);
		for (i=0 ; i < (numread/(sizeof(int))) ; i++)
			{
            *(basech1+counter) = buffer[i];
            counter = counter + 1;
			}
		} /* end of while */
	endch1 = counter;
    fclose(stream);
	printw("End of file 1 (%u)\n", endch1);
	refresh();
	}


Thanks, Budi

-- 
-----------------------------------------------
Budi - VLSI Lab.     | rahardj@ccu.UManitoba.CA
Electrical Eng.      | rahardj@ccm.UManitoba.CA
U. of Manitoba       | rahard@ee.UManitoba.CA

ccsdra@gdt.bath.ac.uk (Dave Allum) (11/23/89)

In article <1989Nov18.222704.16822@ccu.umanitoba.ca> rahardj@ccu.UManitoba.CA (Budi Rahardjo) writes:
>I am trying to write a program (in MSC) which loads a 100K data into memory,
>and save the starting address and ending address with a pointer or index.
>The problem is after reaching the end of 64 K the pointer wrap around
>the beginning of the same data blocks, so it writes over the first 36K.
>To make it simple, here is the problem I have :
>* How do I increment the pointer so that it can point beyond the 64 barier ?

Declare your pointers as char huge * and use the halloc/hfree routines.