Board index » delphi » 32 bit Pascal with Novell

32 bit Pascal with Novell

Hi all,

I'm trying to solve a problem for someone who's porting a program from
Turbo Pascal (DOS, 16 bit) to TMT Pascal (DOS, 32 bit, mostly
Turbo-compatible). Most of the code works fine, but the Novell calls
aren't doing anything. Now the TMT FAQ says:

Quote
> Q: I need to call a real mode interrupt (say int 21h), and I have to set DS:DX to the

segment:offset of some data
variable. How can I do that?
Quote
> A: It's possible to emulate the real mode interrupt by means of special DPMI function,

which is implemented in MsDos and Intr
procedures (see our on-line help system for the DOS unit description).
Just keep in mind, that you have to allocate a data block in
the low memory area (1st megabyte) using AllocDosMemoryBlock or
DosMemoryAlloc function from the DPMI unit.

And I modified the code accordingly, but still no luck. TMT's tech
support haven't come up with anything, nor has a search of Google or
Novell's web site. A relevant section of code follows - any of you
have any idea what's going wrong? Any help would be much appreciated.

Thanks,

Function OpenSemNovell(Semaphore:Str80;Var Users:Byte;Var
HiHandle,LoHandle:Integer):Boolean;
Var Regs : Registers;
    TempSem : Str255;

  memseg: word;
  memaddr: dword;
  memptr: ^char;
  i: dword;
Begin
   TempSem:= MakeSemaphoreName(Semaphore);

  memseg := dosmemoryalloc(256);
  memaddr := dword(memseg) * 16;
  memptr := pointer(memaddr);
  for i := 0 to 255 do
  begin
    memptr^ := char(tempsem[i]);
    inc(memptr);
  end;

   Regs.AH := $C5;             { AH = General SEMAPHORE function }
   Regs.AL := 0;               { AL = Open a semaphore }
   Regs.DS := memseg;  { Data segment of semaphore }
   Regs.EDX := 0;  { Data segment offset of Sem.}
   regs.es := 0;
   regs.fs := 0;
   regs.gs := 0;
   Regs.CL := 1;               { Initial value of Semaphore count }
   Intr(33,Regs);              { Issue software interupt }

    dosmemoryfree(memseg);

   HiHandle := Regs.DX;
   LoHandle := Regs.CX;
   Users := Regs.BL;           { No. of users that have this semaphore
open }
   If Regs.AL <> 0 Then        { errors returned in Regs.AL }
    Begin
      OpenSemNovell := False;
      Case Regs.AL of
        $FF : Warning('Invalid initial value in OPEN SEMAPHORE');
        $FE : Warning('Invalid string length in OPEN SEMAPHORE');
        $96 : Warning('Out of work memory in file server');
        Else  Warning('Unknown error in OPEN SEMAPHORE');
      End;
    End
   Else OpenSemNovell := True;
  AddLockingRec(TempSem,HiHandle,LoHandle);
End;

--
"Mercy to the guilty is treachery to the innocent."
http://www.esatclear.ie/~rwallace
mail:rw(at)eircom(dot)net

 

Re:32 bit Pascal with Novell


Quote
In article <3d0db0f7.327603...@news.eircom.net>, Russell Wallace wrote:

>   memseg := dosmemoryalloc(256);
>   memaddr := dword(memseg) * 16;
>   memptr := pointer(memaddr);
>   for i := 0 to 255 do
>   begin
>     memptr^ := char(tempsem[i]);
>     inc(memptr);
>   end;

I don't know TMT, I speak from 32bit dos experience with FPC, but this
doesn't sound right.

memseg:memaddr are in low dos memory.

memptr:=pointer(memaddr);

is in the first megabyte of your protected memory, which isn't necessarily the
same.

Probably you either have to use a special move() procedure (FPC:segmove) to
move data from one segment to the other, or maybe TMT has a special type for
ptrs to dos space. (the definition of memptr must change then).

But it is possible that TMT does things different (e.g. map dos MB in the
first MB of protected memory).

Only doable way to find out things like that is to call support or use the
manual.

If you use TMT because it is free, I recommend you to switch to one of the
Free compilers. (like FPC, www.freepascal.org or GPC. IMHO FPC is more
suitable for TP porting)
This because they come with source and manuals.

If you don't get my explanation, get the FPC units manual here:

http://www.freepascal.org/docs/units.pdf   (entire PDF, several MBs) or
http://www.freepascal.org/docs-html/units/units.html (online HTML, poor mans layout)

read specially the GO32 unit (the DPMI extender of FPC) part and its examples.

Other Threads