delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/24/17:00:15

From: Jeramie DOT Hicks AT mail DOT utexas DOT edu (Jeramie Hicks)
Newsgroups: comp.os.msdos.djgpp
Subject: Mixing asm and C
Date: Sat, 24 Oct 1998 21:48:50 GMT
Organization: The University of Texas at Austin, Austin, Texas
Lines: 40
Message-ID: <363247ad.81580547@newshost.cc.utexas.edu>
NNTP-Posting-Host: resnet-22-134.dorm.utexas.edu
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've been working on this code for about a week now with no result.
Could somebody point out what I'm doing wrong? All I want to do is
load a COM program into a chunk of allocated memory and then run it.
It's part of some OS-level concepts I'm playing with. Thanks...

Here's the DJGPP EXE that serves as the loader:

typedef void (*functptr) (void);
main()
{
char *comdata;
functptr codeptr;
unsigned int ret = 0;
// allocate comdata to size of COM program
// fread COM program into comdata
codeptr = (functptr) comdata;
codeptr();
asm (" movl %%eax, %0" : "=r"(ret));   // ret = eax
printf("%d",ret);
}


and then, the COM program compiled with MASM 6.1 with the /AT switch:



.model TINY
.386
.code
equalfive proc
	mov eax, 5
	ret
equalfive endp
end equalfive


Many, many thanks!
- Jeramie Hicks
University of Texas at Austin
(no, it's not homework)

- Raw text -


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