Author |
Message |
Mark Rober #1 / 8
|
 DOS newbie help required
Quote:
> [Deleted] > >I was hoping that like UNIX, I'd just be able to malloc() a 16 MB buffer and > >bung the data straight in. However, a colleague (of self-confessed old and > >dubious DOS knowledge) tells me that in order to access such an amount of > >memory, I need to run in protected mode and use extended (EMS or XMS) memory. > >If this true ? and if so, how do I switch to protected mode, and how so I > >access and manipulate such memory.... > >Regards. > > Nick Pitfield. > You still have to tell DOS the memory model etc. What you want is a > protected mode compiler (32 bit compiler in DOS parlance. DOS people > think 32 bit code is a new thing). This will let your program run in > protected mode (32 bit flat memory model) and the library will provide > the glue to the Operating System. You could get Borland's 4.02 > compiler and the Power Pak for DOS, but the integrated development > environment runs in Windoze. You could also get DJGPP, a port of the > GNU compiler to the PC.
You already have the compiler you need - WATCOM includes a 32 bit DOS extender. The following code allocates a 4MB buffer - it can easily be changed to 16MB. I only have 8MB on my PC so I could not test this fully. /*-------------------------------------------------------------------*/ /* */ /* Save this into a file called main.c */ /* */ /* To compile this enter : */ /* wcl386 /l=dos4g /d2 main.c */ /* */ /* This compiles the program using the DOS4GW 32bit DOS extender */ /* supplied with WATCOM. */ /* */ /* To run once complied enter : */ /* main */ /* */ /*-------------------------------------------------------------------*/ #define SIZE 4 * 1024 * 1024 #include <stdlib.h> char *storage; void main( void) { storage = ( char * ) malloc( SIZE ); if ( storage == NULL ) { printf("Allocation failed\n"); } else { printf("%d Bytes of memory allocated\n", SIZE); } /* storage[x] = ... */ Quote: }
-- Mark Roberts
|
Sun, 13 Jul 1997 18:46:28 GMT |
|
 |
Jule #2 / 8
|
 DOS newbie help required
Quote:
>> You still have to tell DOS the memory model etc. What you want is a >> protected mode compiler (32 bit compiler in DOS parlance. DOS people >> think 32 bit code is a new thing). This will let your program run in >> protected mode (32 bit flat memory model) and the library will provide >> the glue to the Operating System. You could get Borland's 4.02 >> compiler and the Power Pak for DOS, but the integrated development >> environment runs in Windoze. You could also get DJGPP, a port of the >> GNU compiler to the PC.
Some of the statements you have made here are not necessarily true - for a start, protected mode != 32-bit. 32bit mode and PM are two different entities entirely, although you must be using PM to use 32bit. Protected Mode works (occasionally) on 286 machines - which cannot cope with 32 bit stuff. Also protected mode is not the same thing as a flat memory model - in fact it is very different from a flat memory model, it is a PROTECTED memory model, with multiple segments of variable length. It may be used to implement a flat memory model, but it by no means necessarily is, and I would say that using it as such removes some of the advantages that 80x86 processors have (even though thousands of programmers would disagree with me - I like having near and far pointers, etc...) --
Flames should be redirected to /dev/null - I don't know what I'm saying myself so don't expect it to make sense all the time! */
|
Sun, 13 Jul 1997 21:24:26 GMT |
|
 |
man.. #3 / 8
|
 DOS newbie help required
[...] : It may be used to implement a flat memory model, but it by no means : necessarily is, and I would say that using it as such removes some of the : advantages that 80x86 processors have (even though thousands of programmers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ?????????????? ;-) : would disagree with me - I like having near and far pointers, etc...) : --
: : Flames should be redirected to /dev/null - I don't know what : I'm saying my selfso don't expect it to make sense all the time! */ MGM
|
Wed, 23 Jul 1997 10:32:25 GMT |
|
 |
Eric P. Hus #4 / 8
|
 DOS newbie help required
Quote:
> [...] > : It may be used to implement a flat memory model, but it by no means > : necessarily is, and I would say that using it as such removes some of the > : advantages that 80x86 processors have (even though thousands of programmers > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ?????????????? ;-) > : would disagree with me - I like having near and far pointers, etc...)
Well, as for me, I can't stand the segmented addressing. I am an embedded systems programmer just recently moving into IBM PC land. And let me tell you, I long for my nice 32 bit pointers back that I can treat as 32 bit numbers or pointers with ease. I really think that DOS has hamstrung the 386, 486, etc. Here's a nice PC with 32 bit registers but hey, don't even think about using them. Here's 16 meg of memory, but really you only got 640K. (I'm having enought problems keeping the Intel Little Endia n format straight from my well-known Motorola Big Endian format, much less trying to deal with DOS stupidity.) These two factors have had me pulling my hair out for some time now. I'm forced to program 16 bit applications for DOS at work currently. But I sure won't do it on my next home PC (which will probably run Linux or OS2 or god forbid be a PowerPC :-)). I really think it's time to let DOS die, it's just been hacked once to many times. (Sadly, I don't think Windows 95 is going to cut it either). Not to start a flame war, but does anyone really like DOS? Does anyone think it is a good programming/application environment? I really think the only reason it is still around is the large user base already in place. Any apoligies for mistakes. I'm pretty much a DOS newbie too. Eric
|
Tue, 29 Jul 1997 07:16:07 GMT |
|
 |
Mike McCar #5 / 8
|
 DOS newbie help required
[stuff deleted] )Well, as for me, I can't stand the segmented addressing. I am an embedded systems programmer just recently moving into IBM PC land. And let me tell you, I long for my nice 32 bit pointers back that I can treat as 32 bit numbers or pointers with ease. You are mistaking 32 bit address space for unsegmented memory architecture. I also do embedded programming. Some of it is on 680x0 processors, and the first thing we did was add (on the 68020) a MMU or program the on-board (68030) MMU to GET segmented address spaces. The problem with the 8086 architecture is not that it is segmented, but rather that the segments are -small-. )I really think that DOS has hamstrung the 386, 486, etc. Here's a nice PC with 32 bit registers but hey, don't even think about using them. Here's 16 meg of memory, but really you only got 640K. (I'm having enought problems keeping the Intel Little Endian format straight from my well-known Motorola Big Endian format, much less trying to deal with DOS stupidity.) Little Endian, Big Endian, Big Deal. Each has advantages and disadvantages. DOS putting a 640K limit is much more a problem. )These two factors have had me pulling my hair out for some time now. I'm forced to program 16 bit applications for DOS at work currently. But I sure won't do it on my next home PC (which will probably run Linux or OS2 or god forbid be a PowerPC :-)). The biggest problem with Linux is it looks like UNIX - which I really don't like. I don't need time-slicing on my machine at home, and all the programs I need will fit into 640K, so my PC fills all my needs as it is. )I really think it's time to let DOS die, it's just been hacked once to many times. (Sadly, I don't think Windows 95 is going to cut it either). Not to start a flame war, but does anyone really like DOS? I surely prefer it to UNIX and its clones. The commands generally have meaning and comprise full words or close to it. LS to get a directory listing? )Does anyone think it is a good programming/application environment? I really think the only reason it is still around is the large user base already in place. The best reason in the world for any OS to exist is that there is a large application pool available. Come on, when was the last time you actually did productive works with the OS itself? Isn't it the -application- programs which actually do any real work? And DOS is superior for applications which require lots of raw horsepower, because it has -low- overhead. That's why it does well in high speed serial I/O applications. Which Linux, OS/2, and Windows are noted for doing poorly in. )Any apoligies for mistakes. I'm pretty much a DOS newbie too. )Eric Please format your future messages to fit on my screen. Mike ---- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
|
Sun, 03 Aug 1997 03:50:19 GMT |
|
 |
Greg Wooled #6 / 8
|
 DOS newbie help required
Apologies in advance for this off-topic post in comp.lang.c. Stop reading now if you wish. Quote:
> I surely prefer it to UNIX and its clones. The commands > generally have meaning and comprise full words or close to it. > LS to get a directory listing?
You could always create a shell alias, or a shell script, to use "dir" instead of "ls". Unix gives you that sort of flexibility. With a modern shell, you can use the alias which means you don't have to read a separate file. DOS's shell (COMMAND.COM), and the original Unix Bourne shell, only give you the script/batch file option. Quote: > Come on, when was the > last time you actually did productive works with the OS itself? > Isn't it the -application- programs which actually do any real > work?
This is the part to which I couldn't resist responding. The last time I did productive work with a bare OS was when I booted Linux at home, wrote a C program with a text editor, compiled it, and debugged it. All the tools used to do this are part of the bare OS. Can you compile a C program with MS-DOS by itself? DOS supplies the editor (even a choice of two now!), but not the compiler, linker or de{*filter*}. (To be fair, many commercial Unix vendors are also no longer supplying these tools, if they ever did. They should hang their heads in shame!) -- # Greg Wooledge /..\
|
Sun, 10 Aug 1997 05:14:38 GMT |
|
 |
Mike McCar #7 / 8
|
 DOS newbie help required
)Apologies in advance for this off-topic post in comp.lang.c. Stop reading )now if you wish. )
) )> I surely prefer it to UNIX and its clones. The commands )> generally have meaning and comprise full words or close to it. )> LS to get a directory listing? ) )You could always create a shell alias, or a shell script, to use "dir" )instead of "ls". Unix gives you that sort of flexibility. With a modern UGH. NEVER would I try to make one OS look like another this way. )> Come on, when was the )> last time you actually did productive works with the OS itself? )> Isn't it the -application- programs which actually do any real )> work? ) )This is the part to which I couldn't resist responding. The last time )I did productive work with a bare OS was when I booted Linux at home, )wrote a C program with a text editor, compiled it, and debugged it. All )the tools used to do this are part of the bare OS. The compiler is =not= part of the OS. The OS is the kernel and linked device drivers. Not even the shell is (technically) part of the OS, but I'll give you that one. The fact that LINUX comes -bundled- with some applications (like compilers and editors) is irrelevant. )Can you compile a C program with MS-DOS by itself? No. And you can't compile a C program with LINUX itself, either. )DOS supplies the )editor (even a choice of two now!), but not the compiler, linker or )de{*filter*}. (To be fair, many commercial Unix vendors are also no longer )supplying these tools, if they ever did. They should hang their heads )in shame!) A de{*filter*} comes bundled with DOS. So does a BASIC (shudder) interpreter. So if you want to claim the C compiler as part of the LINUX OS (I would not consider it so) then you must also consider the BASIC interpreter bundled with DOS to be on a par with it. And the debugging provided by the BASIC interpreter is superior to that supplied with most (perhaps all?) C compilers for UNIX look-alikes. Your arguments hold no attraction for me. I can't speak for others. Mike ---- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
|
Tue, 12 Aug 1997 06:08:46 GMT |
|
 |
Greg Wooled #8 / 8
|
 DOS newbie help required
Quote:
> The compiler is =not= part of the OS. The OS is the kernel and > linked device drivers. Not even the shell is (technically) part > of the OS, but I'll give you that one. The fact that LINUX > comes -bundled- with some applications (like compilers and > editors) is irrelevant.
If we use the POSIX specification as an example of an operating system definition, then your statement is incorrect. POSIX.1 specifies system calls which the kernel must support -- for example, open, creat, read, fork POSIX.2 specifies various utilities which are part of the OS -- for example, sh, grep, sed, pr I don't know the entire POSIX spec, so I'll stop there. But the OS is more than just the kernel and linked device drivers. It is a set of features, some of which happen to be a shell, an editor, etc. I'm not certain whether POSIX demands a compiler. However, since Linux comes with a compiler (as you stated), I think it's fair to say that the gcc compiler is part of the Linux operating system. A purist may disagree, but it runs just fine for me. :-) -- # Greg Wooledge /..\
|
Wed, 13 Aug 1997 00:20:20 GMT |
|
|
|