Mail Archives: djgpp/2001/02/13/02:23:39
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, ®s); /* 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 -