|
From: Abhijit S. <mu...@gm...> - 2003-01-22 05:13:43
|
Greets, Oroszi and everyone. > Hello! > > I would like to ask a question, not really related to "modern" programming. > > In Borland C++ 3.11 (DOS version) can I allocate memory dynamically. I mean, do > I need page flipping and stuff like that, or is memory linear? > What if I run Borland C++ written programs under Windows? Shall my programs get > the memory. How much can I get (in DOS and Windows). > > I need help quickly (today) so I would be very happy if you could answer. > Thank you. > > -- > Greetings, > Balázs In DOS (real-mode), memory is banked. So you need two thingies to address it: the segment and offset. To make a pointer, given segment and offset, use MK_FP(seg, off) and to find the segment and offset of a pointer, use FP_OFF() and FP_SEG(). The segment is like a bank (they overlap, however), and the offset is the memory location within the segment. Search on Google for more info. Or see the X2 FTP, it's got a treasure-trove of info about MS-DOS programming: http://sunsite.lanet.lv/ftp/mirror/x2ftp/msdos/programming/ However, in most general applications, you won't need to bother with them. You simply call new or malloc(), and they return an appropriate far pointer (depending on the memory modely you're using - small, tiny models don't use far pointers). Only if you're doing some hardware-level stuff, you'll need to bother with segments and offsets. In small, tiny and medium models, I think you get 64k memory (a 16-bit pointer), and in huge, large models you get 1 meg (a 20-bit far pointer). The other differences in these models are the size of the data segments and global heap (I think... long time no real-mode). Also, in protected-mode DOS (DPMI), memory is linear. Use djgpp: http://www.delorie.com/djgpp for this, its a GCC port for DPMI. It's also got an IDE similar to Turbo-C++, called RHIDE. You may or may not be able to use it with Dev. If you're successful, post to this mailing-list for the welfare of humanity and stuff. HTH, and sorry for the late reply. ___________________________________________________________ Abhijit Shylanath mu...@gm... http://mudeth.tripod.com/ |