Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w19g2000yqb.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: use assembly code in c code
Date: Thu, 21 Oct 2010 04:14:28 -0700 (PDT)
Organization: http://groups.google.com
Lines: 27
Message-ID: <051a2f13-149a-4e27-8bb9-23f4d88e4e26@w19g2000yqb.googlegroups.com>
References: <i9p1ec$kl4$1@fred.mathworks.com>
NNTP-Posting-Host: 62.73.211.40
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1287659668 28466 127.0.0.1 (21 Oct 2010 11:14:28 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 21 Oct 2010 11:14:28 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: w19g2000yqb.googlegroups.com; posting-host=62.73.211.40; 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: news.mathworks.com comp.soft-sys.matlab:680105

On Oct 21, 11:34 am, "Robbin " <robbini...@hotmail.com> 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
docs.

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.

Rune