| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | how to determine alailable conventional memory using c/asm? |
Hу здорово, уважаемый All!
using borland c++ 3.1/DOS
i need to determine available conv.mem
i tried to use asm to call INT 12h, but it doesn`t work in modern computers
(always returning 640Kb)
also tried to use asm to call dos`s INT 48h, but it always returned
constant value after a several malloc`s.
i also tried to use a standart DOS.H lib to call
allocmem(0xFFFF,&seg), but it just returns a largest block available(i
think it is same as INT 48h)
so i wrote a very DUMB code to get know available conv.mem size in bytes
it works, and it does what i need, but it so dumb. I know it should be a
right way to do the thing. Tell me please.
And here is the code: (don`t laugh :)
------------------------------------------------
//... some includes
void sayfreemem(void){
size_t i=65535;
char *str;
//step by 1000
while(i) {
if ( (str = (char *) malloc(i)) ){
free(str);
break;
}
i-=1000;
}//while
//step by 100
while(i) {
i+=100;
if (!(str = (char *) malloc(i)))
break;
else
free(str);
}//while
//step by 10
i-=10;
while(i) {
if ((str = (char *) malloc(i))){
free(str);
break;
}
i-=10;
}//while
//step by 1
while(++i) {
if (!(str = (char *) malloc(i)))
break;
else
free(str);
}//while
printf("\n available mem: %u\n",i);
}//func
main (){
char *str;
//....some code
sayfreemem(); //says 4example: available mem: 43455
str = (char *) malloc(100);
sayfreemem(); //says: available mem: 43353
//....some code
free(str);
}//main
------------------------------------------------
wbr, Dmitry
[win98 up: 10+14:58:44]
--- ed[at]fi.usvpu.ru icq: 50080573
* Origin: Frozen Time BBS (2:5080/236)SEEN-BY: 633/267 270 @PATH: 5080/236 196 80 68 5 3830/9 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.