How can one do inline assembler under Sys5?
Chuck Sites
chuck at coplex.UUCP
Tue Apr 5 07:05:13 AEST 1988
In article <396 at coplex.UUCP>, chuck at coplex.UUCP (Chuck Sites) writes:
> Could anyone out there tell me what the syntax is for the
> C compiler (cc) to do inline assembly lanuage under Unix
> System 5.
I wanted to followup on this subject again since it might help some other developers
out there. I had lots of nice mail from others out there most of which said, "basically
Chuck, it can't be done." Thanks guys :-) I was quite pleased to find out this is not
the case and 'YES', there is a way to perform inline assembly language with the standard
unix (cc) compiler with stock System 5. Look in /usr/include/prof.h for a good example.
(Thanks for the tip Jeff, but what is /usr/include/sys/inline.h?) Anyway it works like:
some_function(x)
int x;
{
asm(" mov %dx,%ax"); /* Inline assembler at work */
asm(" mov %cx,%ax"); /* One minor annoying thing ... */
asm(" mov %bx,%ax"); /* Only one line of assembler per */
asm(" nop"); /* asm() call seems to be allowed */
asm("Yes I know this line will cause an error ");
asm("But after all, this is a demo function ");
}
compile with 'cc function.c -S' if you want to examine the assembly lang output.
It is a quite awkward construct to use in practice but at least it's something.
I have found this on two different Unix system 5's so I suspect it's a pretty standard
method of doing inline assembler.
I have found that most of the assembler directives are fairly standard regardless of
the platform they're on like .global, .text, .data. But apparently thier are others
specific to the segmented achitecture of the 286. Does any one have doc's on these?
Care to post-em?
+-----------------------------------------------+ +---------+
/:::::::::Copper Electronics Inc::::::::::::::::/| /:::::::::/|
+-----------------------------------------------+/| +---------+/|
| CHUCK SITES chuck at coplex.UUCP |/| | ___ |/|
| UUCP: {mit-eddie}!bloom-beacon!coplex!chuck |/+ | / / \ |/+
| FLAME ADDRESS: /dev/null |/ | \/__/ |/
+-----------------------------------------------+ +---------+
More information about the Comp.unix.microport
mailing list