www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/19/23:39:21

From: peter AT agnes DOT dida DOT physik DOT uni-essen DOT de (Peter Gerwinski)
Newsgroups: comp.os.msdos.djgpp,comp.lang.pascal.misc
Subject: Re: GNU Pascal, go32.h
Followup-To: comp.os.msdos.djgpp,comp.lang.pascal.misc
Date: 19 Jan 1997 23:51:34 GMT
Organization: Universitaet Essen, Germany
Lines: 66
Message-ID: <5buc26$44c@sun3.uni-essen.de>
References: <5bjdp5$3a7 AT acs1 DOT star DOT net>
Reply-To: peter DOT gerwinski AT uni-essen DOT de
NNTP-Posting-Host: agnes.dida.physik.uni-essen.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

According to Brin:
> I am trying to use the farptr.h library and the go32.h libaray. [...]
> To use them I need _dos_ds, which is defined in the C library go32.h
> but is not a function or a procedure, but is: #define.  I tried
> incluing go32.h but got errors (due to it being a C file I think).

Yes.  GNU Pascal does not parse C source. ;-)

> How can I import _dos_ds?

Only by re-writing the functionality of the macro (#define), i.e.
translating it to Pascal.  In this case it is access to a component
of a struct (a record in Pascal):

    Type
      ByteInt   = __byte__ Integer;      (* 8 bit signed Integer    *)
      Byte      = __unsigned__ ByteInt;  (* 8 bit unsigned Integer  *)
      ShortInt  = __short__ Integer;     (* 16 bit signed Integer   *)
      ShortWord = __unsigned__ ShortInt; (* 16 bit unsigned Integer *)
      (* Integer = __long__ Integer *)   (* 32 bit signed Integer   *)
      Word      = __unsigned__ Integer;  (* 32 bit unsigned Integer *)
      

    Go32InfoBlockRecord = record
      size_of_this_structure_in_bytes,
        linear_address_of_primary_screen,
        linear_address_of_secondary_screen,
        linear_address_of_transfer_buffer,
        size_of_transfer_buffer,  (* >= 4k *)
        pid: Word;
      master_interrupt_controller_base,
        slave_interrupt_controller_base: Byte;
      selector_for_linear_memory: ShortWord;
      linear_address_of_stub_info_structure,
        linear_address_of_original_psp: Word;
      run_mode,
        run_mode_info: ShortWord;
    end (* Go32InfoBlockRecord *);


    Var
      Go32InfoBlock: asmname '_go32_info_block' Go32InfoBlockRecord;


Then by typing

    Go32InfoBlock.selector_for_linear_memory

you get the functionality of _dos_ds.  Now, of course, you can define
it as a macro

    (*$define _dos_ds Go32InfoBlock.selector_for_linear_memory *)

but then the definition is case sensitive.

Or: Write a C function which uses the macro, then use that function
from Pascal.  But that's less effective.

Hope this helps,

    Peter

      e-mail:  peter DOT gerwinski AT uni-essen DOT de
home address:  D\"usseldorfer Str. 35, 45145 Essen, Germany
         WWW:  http://agnes.dida.physik.uni-essen.de/~peter/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019