How can one do inline assembler under Sys5?

Jeff Bowles bowles at lll-crg.llnl.gov
Wed Apr 6 04:17:19 AEST 1988


If you have certain releases of the System V compiler, you have
extended assembler statements. The following is documented in the
paging "C Compilation System" release notes for the 3B2, I think,
and hasn't made it into other docs yet. It's the same mechanism
you'll find in /usr/include/sys/inline.h on many V.3 releases.

It's useful to inspect the output ("cc -S") - you'll notice that you
can generate certain sequences if the argument is in a register
(or constant or memory) and the like.
	Jeff Bowles

------------------------------------------------------------------------

asm	int retzero()
{
	movl	$0, %eax
}

asm	int clr(z)
{
%mem	z;
	movl	$0, z
}

asm	int com(z)
{
%reg	z;
	imull	$-1,z,z
%mem	z;
	neg	z
}

main()
{
	int z = -1;
	register zreg = -1;

	z = retzero();
	printf("Z = %d\n", z);
	z = -1;
	printf("Z = %d\n", z);
	clr(z);
	printf("Z = %d\n", z);
	z = -1;
	printf("Z = %d\n", z);
	printf("Reg = %d\n", zreg);
	com(z);
	com(zreg);
	printf("Z = %d\n", z);
	printf("Reg = %d\n", zreg);
}



More information about the Comp.unix.microport mailing list