delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/08/16:11:38

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP! INT21 - 3D problem!!!!
Date: Sat, 8 Mar 1997 14:44:02 +0000
Organization: None
Distribution: world
Message-ID: <xpJf9FAysXIzEwAP@talula.demon.co.uk>
References: <01bc2b7c$ce3fad70$7229cfa9 AT p590>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 36
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Hooper writes:
>I really look forward to hearing from someone about this.  I feel like I am
>missing.something really obvious.

You are :-) But unfortunately the solution isn't so easy...

>char *filename = "ZZZ";
>int main(int argc, char *argv[])
>{
>asm ("movb   $0x00,%al\n\t"
>       "movb   $0x3d,%ah\n\t"
>       "movl   _filename,%edx\n\t"
>       "int    $0x21\n\t");
>
>       return 0;
>}  

That would be fine in real mode, but this is protected mode. Your
pointer to the filename is a virtual address, relative to the data
segment of your program, but DOS works with real mode segmented pointers
that can only access the first megabyte of memory.

Some extenders will automatically transfer such data from one address
space to the other, but for it to work reliably you need to do the
conversion yourself. Use dosmemput() to transfer your filename string to
the transfer buffer (__tb, look in the djgpp FAQ for more info), and
then use __dpmi_int() to call the DOS routine.

Or you could save yourself several years of effort and use functions
from libc, eg. fopen(), that handle all this stuff for you :-)


/*
 *  Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
 *  Beauty is a French phonetic corruption of a short cloth neck ornament.
 */

- Raw text -


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