home *** CD-ROM | disk | FTP | other *** search
- #include <dvmam.h>
- #include <conio.h>
- #include <dos.h>
-
- unsigned long bytes_available(void);
- unsigned long bytes_total(void);
-
- void main(void)
- {
- int b[10];
- char buf[14],buf2[14];
- int i;
- int result=0;
- char * set[10]= {"1","2","3","4","5","6","7","8","9","0"};
- int x;
-
- clrscr();
- memory_setup(5120);
-
- printf("CPU type: 80%d\n",cpu_type());
- if (emm_installed()) printf("Expanded memory available.\n");
- if (kbytes_ext()>0 && cpu_type()==286 || cpu_type()==386)
- printf("Extended memory available.\n");
-
- for (x=1; x<5; x++)
- {
- printf("\n");
-
- /**************************************/
- /* print the memory type we are using */
- /**************************************/
-
- switch (x)
- {
- case 1: printf("Using conventional memory\n");
- set_memory_usage(USE_CONV);
- break;
- case 2: printf("Using expanded memory\n");
- set_memory_usage(USE_EMS);
- break;
- case 3: printf("Using extended memory\n");
- set_memory_usage(USE_EXT);
- break;
- case 4: printf("All memory types in use.\n");
- set_memory_usage(USE_CONV+USE_EMS+USE_EXT);
- break;
- }
-
- /********************************************************/
- /* Show the amount of memory available and total memory */
- /********************************************************/
-
- printf("Memory available: %lu of %lu bytes\n",bytes_available(),bytes_total());
-
- printf("Allocating 10 5k blocks: ");
-
- /*************************/
- /* Allocate 10 5k blocks */
- /*************************/
-
- result=0;
- for (i=0; i<10; i++) if ((b[i]=alloc_mem(5120))==-1) result=1;
-
- if (result) printf("Failed!\n"); else printf("Ok\n");
-
- /*****************/
- /* Setup strings */
- /*****************/
-
- i=0;
- result=0;
- do
- {
- i++;
- strcpy(buf2,"String test ");
- strcat(buf2,set[i-1]);
- movedata(FP_SEG( (char far *) buf2),FP_OFF( (char far *) buf2),
- FP_SEG(dvmam_dta),FP_OFF(dvmam_dta),13);
- result=save_memory(b[i-1]);
- }
- while (i<10 && !result);
-
- if (!result && i==10) printf("Initial strings established\n"); else
- printf("Error saving initial strings\n");
-
- /**********************/
- /* Do the string test */
- /**********************/
-
- i=0;
- result=0;
- do
- {
- i++;
- strcpy(buf,"String test ");
- strcat(buf,set[i-1]);
- result=load_memory(b[i-1]);
- movedata(FP_SEG(dvmam_dta),FP_OFF(dvmam_dta),
- FP_SEG( (char far *) buf2),FP_OFF( (char far *) buf2),13);
- if (result==0) result=strcmp(buf,buf2);
- }
- while (i<10 && !result);
-
- if (!result && i==10) printf("String test successful\n"); else
- printf("String test failed\n");
-
- /*************************/
- /* Deallocate all memory */
- /*************************/
-
- printf("Deallocating memory: ");
-
- for (i=0; i<10; i++) if ((result=dealloc_mem(b[i]))==-1) i=10;
-
- if (result) printf("Failed\n"); else printf("Ok\n");
- }
-
- printf("\nTesting across memory types: ");
-
- /**************************************************/
- /* Set memory with all memory types going at once */
- /**************************************************/
-
- set_memory_usage(USE_CONV);
- b[0]=alloc_mem(5120);
- b[1]=alloc_mem(5120);
-
- set_memory_usage(USE_EXT);
- b[2]=alloc_mem(5120);
- b[3]=alloc_mem(5120);
-
- set_memory_usage(USE_EMS);
- b[4]=alloc_mem(5120);
- b[5]=alloc_mem(5120);
-
- result=0;
- for (i=0; i<6; i++) if (b[i]==-1) result=1;
-
- if (result) printf("Failed\n"); else printf("Ok\n");
-
- /*****************/
- /* Setup strings */
- /*****************/
-
- i=0;
- result=0;
- do
- {
- i++;
- strcpy(buf2,"String test ");
- strcat(buf2,set[i-1]);
- movedata(FP_SEG( (char far *) buf2),FP_OFF( (char far *) buf2),
- FP_SEG(dvmam_dta),FP_OFF(dvmam_dta),13);
- result=save_memory(b[i-1]);
- }
- while (i<6 && !result);
-
- if (!result && i==6) printf("Initial strings established\n"); else
- printf("Error saving initial strings\n");
-
- /**********************/
- /* Do the string test */
- /**********************/
-
- i=0;
- result=0;
- do
- {
- i++;
- strcpy(buf,"String test ");
- strcat(buf,set[i-1]);
- result=load_memory(b[i-1]);
- movedata(FP_SEG(dvmam_dta),FP_OFF(dvmam_dta),
- FP_SEG( (char far *) buf2),FP_OFF( (char far *) buf2),13);
- if (!result) result=strcmp(buf,buf2);
- }
- while (i<6 && !result);
-
- if (!result && i==6) printf("String test successful\n"); else
- printf("String test failed\n");
-
- result=0;
- printf("Deallocating memory: ");
-
- /*************************/
- /* Deallocate the memory */
- /*************************/
-
- for (i=0; i<6; i++) if ((result=dealloc_mem(b[i]))==-1) i=10;
- if (result) printf("Failed\n"); else printf("Ok\n");
-
- memory_shutdown();
-
- }