Help needed using XMS in my programs.. 
Author Message
 Help needed using XMS in my programs..

Could someone please help me out here,

I have wrote a few small utils for my BBS but my latest util
I have ran into another problem with.
This latest util uses different archivers like
PKZIP ARJ ARC ACE etc...

to use the programs im using the exec command in TP7
when i try adding a file to an ARJ archive Im running out of
memory...
Is there a way I can swap my program to XMS memory to free
up the Dos memory and then run the Exec command.and
after the Exec has finished then pull my program back to dos memory
If possible I could do with some detailed info on this and also a
small example if possible.
Thanks In Advance
Mike Collins



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed using XMS in my programs..

Mike, Collins schrieb:

Quote:
> Could someone please help me out here,

> I have wrote a few small utils for my BBS but my latest util
> I have ran into another problem with.
> This latest util uses different archivers like
> PKZIP ARJ ARC ACE etc...

I suggest you use a multitasking OS like REAL/32. You can find
more information on my URL, follow the links to the creator.

You can setup up to 8 distinct DOS sessions and so circumvent
the memory problems in the 640k area. This is a suggestion only,
but proven to work perfectly. If you need more assistance, let me
know via e-mail.

Kindest Regards,
Franz Glaser, Austria
http://members.eunet.at/meg-glaser



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed using XMS in my programs..

Quote:

>I have wrote a few small utils for my BBS but my latest util
>I have ran into another problem with.
>This latest util uses different archivers like
>PKZIP ARJ ARC ACE etc...
>to use the programs im using the exec command in TP7
>when i try adding a file to an ARJ archive Im running out of
>memory...
>Is there a way I can swap my program to XMS memory to free
>up the Dos memory and then run the Exec command.and
>after the Exec has finished then pull my program back to dos memory
>If possible I could do with some detailed info on this and also a
>small example if possible.

Before you even think about that method, have you set the memory in
your program?   If not, your program uses all available memory so, of
course, you can't run ARJ.
--
Al - aklein at villagenet dot com


Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed using XMS in my programs..



Quote:

>>I have wrote a few small utils for my BBS but my latest util
>>I have ran into another problem with.
>>This latest util uses different archivers like
>>PKZIP ARJ ARC ACE etc...

>>to use the programs im using the exec command in TP7
>>when i try adding a file to an ARJ archive Im running out of
>>memory...
>>Is there a way I can swap my program to XMS memory to free
>>up the Dos memory and then run the Exec command.and
>>after the Exec has finished then pull my program back to dos memory
>>If possible I could do with some detailed info on this and also a
>>small example if possible.

>Before you even think about that method, have you set the memory in
>your program?   If not, your program uses all available memory so, of
>course, you can't run ARJ.

Yep I have tried setting it up
But to be honest I found a very useful unit here called XHEAP posted
by Osmo

Using that unit I removed the {$M directive and instead of calling
exec directly i called it thru the XHEAP unit which moves  my program
to the XMS/DISK and gives me all the memory i want
Thanks anyway.
Mike Collins



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed using XMS in my programs..

Could you be so kind and send me this fantastic XHEAP module?

--
Rafa3 o?y?ski
Varico, Pozna?, Poland
http://www.varico.com



Quote:



> >>I have wrote a few small utils for my BBS but my latest util
> >>I have ran into another problem with.
> >>This latest util uses different archivers like
> >>PKZIP ARJ ARC ACE etc...

> >>to use the programs im using the exec command in TP7
> >>when i try adding a file to an ARJ archive Im running out of
> >>memory...
> >>Is there a way I can swap my program to XMS memory to free
> >>up the Dos memory and then run the Exec command.and
> >>after the Exec has finished then pull my program back to dos memory
> >>If possible I could do with some detailed info on this and also a
> >>small example if possible.

> >Before you even think about that method, have you set the memory in
> >your program?   If not, your program uses all available memory so, of
> >course, you can't run ARJ.

> Yep I have tried setting it up
> But to be honest I found a very useful unit here called XHEAP posted
> by Osmo

> Using that unit I removed the {$M directive and instead of calling
> exec directly i called it thru the XHEAP unit which moves  my program
> to the XMS/DISK and gives me all the memory i want
> Thanks anyway.
> Mike Collins



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed using XMS in my programs..


Quote:

>Could you be so kind and send me this fantastic XHEAP module?

Here it is. If you do not have XMS available then it executes the
program in the unused part of the heap (between heapptr and heapend)

Unit Xheap;

Interface

uses dos;

{$ifdef msdos }

type string128=string[128];

procedure exec(const com,par:string128);
Function MaxProg:word;  { kilobytes }

Const Swapstack{:boolean}=true;    { Change if you wish }
Const UseXMS{:boolean}=true;
{$endif}

Const envsize:word=1000;

Procedure Shell(const st:string);
Procedure Push;

Implementation

{$ifdef msdos}

{-------------------------- XMS routines -----------------------}

Var Handle:word;
    xmsentry:pointer;

Procedure GetXMSentry;
var rg:registers;
begin
  fillchar(rg,sizeof(rg),0);
  rg.ax:=$4300;
  intr($2f,rg);
  if rg.al<>$80 then xmsentry:=nil
   else begin
      rg.ax:=$4310;
      intr($2f,rg);
      xmsentry:=ptr(rg.es,rg.bx);
    End;
End;

Function FreeXms:word;
begin
  if Xmsentry=Nil then FreeXms:=0
    else asm
         mov ah,8;
         call xmsentry

         end;
End;

Function XInit(Kb:word):byte;
var h:word;
begin
  h:=0;
  if xmsentry=nil then Xinit:=255
    else
     asm
           mov dx,kb
           mov ah,9
           call XmsEntry
           cmp ax,1


           mov h,dx



  handle:=h;
End;

Procedure XWrite(p:pointer; count:longint);
type  emm=record
            count:longint;
            zero:word;
            P:pointer;
            handle:word;
            Pos:longint;
          End;
const e:emm=(count:0;zero:0;p:nil;handle:0;pos:0);
begin
  e.count:=count;
  e.p:=p;
  e.handle:=handle;
  asm
   mov ah,$b
   mov si,offset e
   call XmsEntry
  end;
End;

Procedure XRead(p:pointer; count:longint);
type  emm=record
            count:longint;
            handle:word;
            Pos:longint;
            zero:word;
            P:pointer;
          End;
const e:emm=(count:0;handle:0;pos:0;zero:0;p:nil);
begin
  e.count:=count;
  e.p:=p;
  e.handle:=handle;
  asm
   mov ah,$b
   mov si,offset e
   call XmsEntry
  end;
End;

procedure XDone; assembler;
  asm
  mov dx,handle
  mov ah,$a
  call xmsentry
  end;

{-----------------------  End XMS routines ----------------------- }

var xmsinuse:boolean;
    len:longint; { no of bytes in XMS }
    ints:word;   { segment address }

Type Words=Record
             lo,hi:Word;
           End;

     wp=^word;
     pp=^longint;

function topmem:word;
begin
  topmem:=wp(ptr(prefixseg,2))^;
End;

Function p2i(p:pointer):longint;
begin
  p2i:=longint(words(p).hi) shl 4+words(p).lo;
End;

var sporigin:word;
    startptr:pointer;  { Start of the swapped area }

procedure HeapOut;
var rg:registers;
    endPtr:pointer;    { end of the program }
    startaddr:longint;
    fx:word;
Begin
  ints:=0;
  {$ifdef test}
  writeln('HeaOut in');
  {$endif}
  if swapstack and (p2i(ptr(sseg,sporigin))<p2i(heaporg))
     then startptr:=ptr(sseg,sporigin)
     else startptr:=heaporg;

  inc(words(startptr).hi,words(startptr).lo shr 4);
  words(startptr).lo:=words(startptr).lo and 15;

  len:=p2i(heapptr)-p2i(startptr);
  if usexms and (xinit((len+1023) shr 10)=0) then begin
     xwrite(startptr,len);
     xmsinuse:=true;                           { Write the heap into XMS }
     endPtr:=startptr;
  End
  else begin
     if usexms then fx:=freexms shr 10      { lets get what XMS we can get }
               else fx:=0;
     if (fx>0) and (xinit(fx)=0) then begin
        len:=longint(fx)*1024;
        startaddr:=p2i(heapptr)-len;
        words(startptr).hi:=startaddr shr 4;
        words(startptr).lo:=startaddr and 15;
        xwrite(startptr,len);
        xmsinuse:=true;
        endptr:=startptr;
     end else begin
       xmsinuse:=false;
       EndPtr:=HeapPtr;
     End;
  End;
  rg.ah:=$4a;
  rg.bx:=words(Endptr).hi-prefixseg+65;
  if rg.bx>=topmem-prefixseg then exit;   { No reduction }

  ints:=words(endptr).hi+1;
  rg.es:=prefixseg;
  MsDos(rg);
  if rg.flags and fcarry>0 then begin
     if xmsinuse then xdone;
     Runerror(250);
  End;

  move(ptr(0,0)^,ptr(ints,0)^,1024);
  {$ifdef test}
  writeln('HeaOut out');
  {$endif}

End;

Procedure HeapIn;
var rg:registers;
    done:boolean;
    i:integer;
Begin
  {$ifdef test}
  writeln('HeaIn in');
  {$endif}

  if ints>0 then
     asm
     push ds
     mov ds,ints
     xor si,si
     xor di,di
     mov es,di
     mov cx,512

     cld
     cli
     rep movsw
     sti

     pop ds
     end;

  repeat
    {$ifdef test}
    writeln('repeat');
    {$endif}
    done:=true;
    rg.ah:=$4a;
    rg.bx:=topmem-prefixseg;
    rg.es:=prefixseg;
    MsDos(rg);
    if rg.flags and fcarry>0 then begin
      done:=false;
      if rg.ax<>8 then begin
         if xmsinuse then xdone;
         Runerror(251);
      End;
      rg.ah:=$49;
      rg.es:=prefixseg+rg.bx+1;
      msdos(rg);
      if rg.flags and fcarry>0 then begin
         if xmsinuse then xdone;
         Runerror(252);
      End;
    End;
  until done;
  if xmsinuse then begin
     xread(startptr,len);
     xdone;
  End;
  {$ifdef test}
  writeln('Heapin Out');
  {$endif}
End;

var spsave:word;

var cm,pr:string128;

procedure exec(const com,par:string128);
begin
  {$ifdef test}
  writeln('exec in');
  {$endif}
  cm:=com;  { one has to copy the strings to the data segment as it is the }
  pr:=par;  { only secure place after heapout }
  spsave:=0;
  if swapstack then begin
     if sptr>2048 then asm mov spsave,sp; mov sp,2048 end;
     sporigin:=sptr+16;
  End;

  heapOut;
  if ints>0 then dos.exec(cm,pr)
            else dos.doserror:=8;
  Heapin;

  if spsave>0 then asm mov sp,spsave end;
  {$ifdef test}
  writeln('exec out');
  {$endif}
End;

var rg:registers absolute cm;

Function MaxProg:word;  { kilobytes }
begin
  {$ifdef test}
  writeln('maxprog in');
  {$endif}

  spsave:=0;
  if swapstack then begin
     if sptr>2048 then asm mov spsave,sp; mov sp,2048 end;
     sporigin:=sptr+16;
  End;

  heapOut;
  if ints>0 then begin
    rg.ah:=$48;
    rg.bx:=736 shl 6;
    msdos(rg);
    if rg.flags and fcarry=0 then runerror(254);
  End
  else rg.bx:=0;
  Heapin;

  if spsave>0 then asm mov sp,spsave end;
  maxProg:=rg.bx shr 6;
  {$ifdef test}
  writeln('maxprog out');
  {$endif}
End;

{$endif}

Function commandparams:string;
var s:string[7];
begin
  if envsize>0 then begin
    str(envsize,s);
    commandparams:=' /e:'+s;
  End
  else commandparams:='';
End;

Procedure Shell(const st:string);
begin
  swapvectors;
  exec(getenv('comspec'),CommandParams+' /c '+st);
  swapvectors;
end;

Procedure Push;
begin
  swapvectors;
  exec(getenv('comspec'),CommandParams);
  swapvectors;
end;

{$ifdef msdos}
begin
 GetXMSEntry;
{$endif}
End.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Shelling programs in TP7 using XMS

2. Need help; program using random numbers

3. Help needed calculating XMS present

4. Need HELP FINISHING PROGRAM (posted program) PASCAL

5. Help needed (running a program from a program).

6. Help needed (running a program from a program).

7. using XMS for small records

8. Using XMS for data storage

9. Emergency Help Needed: C2pascal program needed

10. XMS programming

11. Swapping programs to disk/XMS/EMS before EXEC

12. Need help with Hailstone Sequence program please Help

 

 
Powered by phpBB® Forum Software