delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/22/09:01:13

Date: Sun, 22 Nov 1998 14:50:07 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: gs AT xdtech DOT com
cc: djgpp AT delorie DOT com
Subject: Re: Assembly
In-Reply-To: <3655FEA8.15BC@xdtech.com>
Message-ID: <Pine.SUN.3.91.981122144915.17686b-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Sat, 21 Nov 1998 gs AT xdtech DOT com wrote:

> Help. My program just dosent compile with DJGPP. It's an assembly file. 
> I got it from Dan Gookin( it may have a link on his web page at 
> http://www.c-for-dummies.com, just in case there is some copyright 
> notice ). I renamed it from hellow.c to hellow.s and tried to make an 
> exe with as.exe. But it gives these messages:
> hellow.s: Assembler messages:
> hellow.s:1: Error: no such 386 instruction: `void'
> hellow.s:2: Error: Rest of line ignored. First ignored character is `{'.

You are stabbing in the dark instead of reading the docs, and get
rightfully punished for that ;-).

Your source uses inline assembly.  It is not an assembly code, it's
a C code with embedded assembly instructions.  So you *do* need to
call it hellow.c, NOT hellow.s, and you need to compile it with 
"gcc -c", like an ordinary C file, not with `as.exe'.

In addition, the inline assembly is in the wrong format: GCC uses the
AT&T assembly format instead of the Intel format, and the inline
assembly syntax that GCC itself accepts is very different from
Borland's.  These issues are described in sections 17.1 and 18.13 of
the DJGPP FAQ list.

Furthermore, the code you are trying to compile does not need to be
written as inline assembly at all.  All it does is call a DOS function
via Int 21h.  This can be easily written in C, see below.  Section
18.2 in the FAQ describes the facilities used by the code below, and
section 17.8 gives another example of converting inline assembly to C.

The latest version of the DJGPP FAQ list is available as
v2/faq211b.zip from the same place you get DJGPP.

#include <string.h>
#include <sys/types.h>
#include <sys/movedata.h>
#include <dpmi.h>
#include <go32.h>

int main(void)
{
        char *string = "Hello, Weirdo!$";
	__dpmi_regs regs;

	dosmemput (string, strlen(string), __tb);
	regs.x.ds = __tb >> 4;
	regs.x.dx = __tb & 0xf;
	regs.h.ah = 9;
	__dpmi_int (0x21, &regs);
	return 0;
}

- Raw text -


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