From: Rune Allnor <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: use assembly code in c code
Date: Thu, 21 Oct 2010 04:14:28 -0700 (PDT)
Lines: 27
Message-ID: <>
References: <i9p1ec$kl4$>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1287659668 28466 (21 Oct 2010 11:14:28 GMT)
NNTP-Posting-Date: Thu, 21 Oct 2010 11:14:28 +0000 (UTC)
Injection-Info:; posting-host=; posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
 2.0.50727; InfoPath.2; MS-RTC LM 8),gzip(gfe)
Xref: comp.soft-sys.matlab:680105

On Oct 21, 11:34 am, "Robbin " <> wrote:
> hi everyone,
> I'm trying to figure out if its possible to use straight assembly code in C?

Yes, it is. Check the docs of your C compiler.

> i have C-mex files which calles external c functions. these c functions have a sort of memory management and to protect this, i need semaphores. i found the assembly instruction CMPXCHG/cmp to do this for me. but how can i implement this in the external c functions, so that matlab knows that its assembly when its compiling?

*Matlab* has no information about such issues, nor does it
need to know. This is an issue with the C compiler. Check the

A word of warning, though: With C you need to know what you are
doing, or you might end up in severe trouble. With assembler
you *really* need to know not only what you are doing, but what
the computer does and how it does it.

Since I have to tell you these things - stay away from assembler.
You are just not up to it.