rahardj@ccu.umanitoba.ca (Budi Rahardjo) (11/12/89)
I have another problem. I'd like to load a binary file (about 150 K) into the memory and use it as my data (using pointer or array). I'm trying to write the program with MSC 5.1 using Large or Huge model. and so far no luck. It was easy to do this on Sun workstation. Thanks, Budi -- ----------------------------------------------- VLSI Lab. | rahardj@ccu.UManitoba.CA Electrical Eng. | rahardj@ccm.UManitoba.CA U. of Manitoba | rahard@ee.UManitoba.CA
LC.YRS@forsythe.stanford.edu (Richard Stanton) (11/14/89)
In article <1989Nov11.184105.29291@ccu.umanitoba.ca>, rahardj@ccu.umanitoba.ca (Budi Rahardjo) writes: >I have another problem. I'd like to load a binary file (about 150 K) >into the memory and use it as my data (using pointer or array). >I'm trying to write the program with MSC 5.1 using Large or Huge model. >and so far no luck. >It was easy to do this on Sun workstation. In MS C (at least in Quick C, which I use), you can use arrays larger in size than 64k in huge models, but you cannot just set aside space for them by using a line like char bigarray[150000]; You have to use one of the memory allocation functions (e.g. malloc, calloc) to explicitly request storage for your array before you use it. These functions return a pointer to the allocated space if successful, or else NULL if the allocation failed. For very large arrays, there are also some restrictions about the size of each element being a power of 2, I seem to remember, but if you are just using char or int, this should not be a problem. Richard Stanton PSTANTON@gsb-what.stanford.edu
LC.YRS@forsythe.stanford.edu (Richard Stanton) (11/14/89)
I made a mistake in my last message. The standard allocation functions are OK for arrays < 64k, but for larger arrays you need the specific function "halloc" which allows arrays > 64 The inverse function is hfree, which frees the memory you allocated with halloc. Richard Stanton PSTANTON@gsb-what.stanford.edu
mcdonald@uxe.cso.uiuc.edu (11/15/89)
>In MS C [...] you can use arrays >larger in size than 64k in huge models, but you cannot just set >aside space for them by using a line like >char bigarray[150000]; This is incorrect. In MSC 5.1 you can indeed say: char huge bigarray[150000]; >For very large arrays, there are also some restrictions about >the size of each element being a power of 2, I seem to remember, >but if you are just using char or int, this should not be a problem. long or float or double is OK also. But you must remember that you have to be careful about passing huge addresses to routines expecting "far" ones. Doug McDonald
plim@hpsgpa.HP.COM (Peter Lim) (11/15/89)
> I made a mistake in my last message. The standard allocation > functions are OK for arrays < 64k, but for larger arrays you need > the specific function "halloc" which allows arrays > 64 The inverse > function is hfree, which frees the memory you allocated with > halloc. > Are you sure about that ? I thought "halloc" and "hfree" will allow you to work with arrays > 64k using any memory model. And that for HUGE memory model, "malloc" and "free" will do the job. Regards, Peter Lim. HP Singapore IC Design Center. E-mail address: plim@hpsgwg Snail Mail address: Peter Lim Hewlett Packard Singapore, (ICDS, ICS) 1150, Depot Road, Singapore 0410. Telephone: (065)-279-2289