delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/13/02:23:39

Date: Tue, 13 Feb 2001 09:19:54 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jeremiah <xdebugx AT emeraldis DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: inline asm
In-Reply-To: <000601c09577$53707660$168baad0@0021682320>
Message-ID: <Pine.SUN.3.91.1010213091928.25782G@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 12 Feb 2001, Jeremiah wrote:

>    regs.x.ax = 0x3800;        /* AH = 38h, AL = 00h  */
>    regs.x.ds = __tb >> 4;     /* transfer buffer address in DS:DX  */
>    regs.x.dx = __tb & 0x0f;
>    __dpmi_int (0x21, &regs);  /* call DOS  */
>    if (regs.x.flags & 1)      /* is carry flag set?  */
>      /* The call failed; use the default symbol.  */
>      return strdup ("$");
>    else
>      {
>        /* The call succeeded.  The local currency symbol is stored
>           as an ASCIIZ string at offset 2 in the transfer buffer.  */
>        char *p = (char *)malloc (2);
>        if (p != 0)
>          dosmemget (__tb + 2, 2, p);
>        return p;
>      }
> 
> It says it puts the string at offset 2 int the transfer buffer.  Does it
> always start the data at offset 2?

No, it's just that this particular function of Int 21h returns a
buffer where the currency symbol is at offset 2 from the buffer's
beginning.  The documentation of this Int 21h function (e.g., in the
Interrupt List) tells these details.

These lines in the above snippet:

    regs.x.ds = __tb >> 4;     /* transfer buffer address in DS:DX  */
    regs.x.dx = __tb & 0x0f;

set things up so that the data returned by DOS is put into the
transfer buffer starting with its beginning, i.e. from offset zero.
If I wanted to start from offset 2, I'd change the second line above
to this:

    regs.x.dx = __tb & 0x0f + 2;

> On: dosmemget (__tb +2,2,p); is the second 2 the number of bytes to
> put into p?

Yes.  See the documentation of dosmemget ("info libc alpha dosmemget")
for more details.

- Raw text -


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