delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/13/20:32:52

Date: Sun, 14 Jan 1996 14:27:42 +1200
From: Bill Currie <bill_currie AT MAIL DOT TAIT DOT CO DOT NZ>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Peter: Probelem with file: Parse error. -Reply


>>> Peter Plum <enoch AT terranet DOT terranet DOT ab DOT ca> 14/1/96  11:43 am >>>
I receive the following error......

" GNU C++ Compile: BASM3.cpp
BASM3.cpp: In function `int main()':
BASM3.cpp:10: parse error before `{' "

...when compiling the following program BASM.CPP...

#include <stdio.h>
#define COUNT 55 void ShowCount( int cnt )
{
	printf("The count is %d!\n", cnt );
} int main( void )
{
	asm
		{
		mov ax, COUNT
		push ax
#if defined(__TINY__) || defined(__SMALL__) || defined(__medium__) 
		call near ptr ShowCount
#else
		call far ptr ShowCount
#endif
		pop cx
		}
RETURN 0;
}



WHY????  Thanks in advance.


Quite simple realy, the syntax of inline assembly in GCC is _VERY_ different to that
of Borland/Turbo C/C++.

Following is an example of valid inline assembly.  For more information type 'info gcc
"C Extensions" "Extended Asm"' at the command line (minus the sigle quotes).  This
gives you the help on gcc inline assembly.


/*##########################################################################*/
void Pal(uchar ColorNo, uchar R, uchar G, uchar B)
  /* This sets the Red, Green and Blue values of a certain color */
{
	asm ("
		movw	$0x3c8,%%dx
		movb	%0,%%al
		outb	%%al,%%dx
		incw	%%dx
		movb	%1,%%al
		outb	%%al,%%dx
		movb	%2,%%al
		outb	%%al,%%dx
		movb	%3,%%al
		outb	%%al,%%dx
		"
		:
		:"g"(ColorNo),"g"(R),"g"(G),"g"(B)
		:"%eax","%edx"
	);
}


- Raw text -


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