www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/16/11:38:15

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A way of emulating a BASIC routine in C.
Date: Sun, 16 May 1999 10:50:01 -0400
Organization: BrunNet
Lines: 35
Message-ID: <373EDB19.E0E21167@unb.ca>
References: <373E56C8 DOT 6383CA0C AT yahoo DOT com>
NNTP-Posting-Host: ftnts1c35.brunnet.net
Mime-Version: 1.0
X-Mailer: Mozilla 4.51 [en] (Win95; U)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

leroy wrote:

> Hi all,
> I'm writing a BASIC to C converter for DJGPP, I'm wondering about two
> things.
> Firstly the basic routine CALL ABSOLUTE takes a pointer to a string
> containing CPU opcodes (not ASM mnemonics), how could I emulate this in
> C?
>
> Secondly with DJGPP does the DPMI host trap all real-mode requests or
> just the ones it knows about?
> If it does could I implement a BASIC Call absolute routine, written for
> real-mode and would it run in pmode without having to modify anything?

    I'm working on a program to convert QuickBasic into C++.  I just started a
few days ago, so I don't have much other than variable declarations, for
loops, do-loop's supported.  But I think I know how to solve your problem.
    AFAIK, you can't just call 16-bit code and expect it to run accordingly
from protected mode.  The way around this is to use
#include <dpmi.h>
int __dpmi_simulate_real_mode_procedure_retf(__dpmi_regs *_regs);

    What I would do is allocate some DOS memory, then fill it with the array
that CALL ABSOLUTE is passed, then fill in the '_regs' struct (including
CS:IP) and call the function.  That should do what you want.

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT HotMail DOT com
          ICQ: 32959047




- Raw text -


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