473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Using m68k assembly in c

Hi all,
I have a source code in c that uses some assembly for the motorola
m68360 chip.
Here is the part I dont understand:

#define OR_REG32(reg,val) __asm__("or.l %0,%1" : : "n" (val), "o"
(reg))

1) I dont understand the semicolon with a space between them syntax,
it look likes scope resolution but it isn't (I think). I also dont
understand the %0 and %1 syntax, haven't seen them before.

2) Anyone know how to implement this in the code without using the
#define? Does anyone have experience with this type (using asm mixed
with c code) of programming that could guide me?

Thanx in advance.
Nov 14 '05 #1
5 2150
On 9 Dec 2003 20:55:51 -0800, pa*********@yahoo.com (par_c) wrote in
comp.lang.c:
Hi all,
I have a source code in c that uses some assembly for the motorola
m68360 chip.
Here is the part I dont understand:

#define OR_REG32(reg,val) __asm__("or.l %0,%1" : : "n" (val), "o"
(reg))

1) I dont understand the semicolon with a space between them syntax,
it look likes scope resolution but it isn't (I think). I also dont
understand the %0 and %1 syntax, haven't seen them before.

2) Anyone know how to implement this in the code without using the
#define? Does anyone have experience with this type (using asm mixed
with c code) of programming that could guide me?

Thanx in advance.


Please do not cross-post to comp.lang.c on issues like this in the
future. There is no such thing as assembly language defined or
supported by the C language, and such compiler specific non-standard
extensions are 100% off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 14 '05 #2
pa*********@yahoo.com (par_c) wrote in message news:<ef*************************@posting.google.c om>...
Hi all,
I have a source code in c that uses some assembly for the motorola
m68360 chip.
Here is the part I dont understand:

#define OR_REG32(reg,val) __asm__("or.l %0,%1" : : "n" (val), "o"
(reg))

1) I dont understand the semicolon with a space between them syntax,
it look likes scope resolution but it isn't (I think). I also dont
understand the %0 and %1 syntax, haven't seen them before.

2) Anyone know how to implement this in the code without using the
#define? Does anyone have experience with this type (using asm mixed
with c code) of programming that could guide me?

Thanx in advance.

Hi!

Its impossible to say anything definite without refering
to the manual for the compiler that this code was first
written for. So my first advice is to find out what compiler
the code was intended for and then ask your question in a
more appropriate group. If that is not possible try looking
at how the macro is being used. That can tell you a lot.

My guess is that the purpose of the code is to bitwise OR a
specific register with a value (perhaps a special purpose
hardware register). This is not possible to do in C.

You should always try to avoid any inline assembly bacause it
confuses the optimizer.

//Erik
Nov 14 '05 #3
>You should always try to avoid any inline assembly bacause it
confuses the optimizer.


One reason why gcc-inline assembler is a little bit more complicated
is, that it can work very well together with the optimizer.

---
42Bastian
Do not email to ba*******@yahoo.com, it's a spam-only account :-)
Use <same-name>@epost.de instead !
Nov 14 '05 #4
In <3f**************@News.CIS.DFN.DE> ba*******@yahoo.com (42Bastian Schick) writes:
You should always try to avoid any inline assembly bacause it
confuses the optimizer.


One reason why gcc-inline assembler is a little bit more complicated
is, that it can work very well together with the optimizer.


It basically tells the compiler which registers and objects are used
for input purposes and which for output purposes, so the compiler can
figure out what's going on inside the asm statement.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5
ba*******@yahoo.com (42Bastian Schick) wrote in message news:<3f**************@News.CIS.DFN.DE>...
You should always try to avoid any inline assembly bacause it
confuses the optimizer.


One reason why gcc-inline assembler is a little bit more complicated
is, that it can work very well together with the optimizer.

---
42Bastian
Do not email to ba*******@yahoo.com, it's a spam-only account :-)
Use <same-name>@epost.de instead !

Inline ASM, used correctly can produce huge advantages. Consider
algorithms for 32 bit math on a 16 bit bus, or floating point
implementations. All of these algorithms rely heavily on testing the
carry-bit. This flag cannot be read easily from C or most other
languages.

Assembly allows the flag to be checked directly, rather than checking
the result of an addition operation to see if it is less than either
of the addends.

Note that ASM should still not be used unnecessarly, but in the right
place a few clock cycles go a long way.

"Premature optimization is the root of all evil" - Knuth.

---
Jared Dykstra
www.bork.org/~jared
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mountain Bikn' Guy | last post by:
This code (adapted from the examples in the docs) doesn't make complete sense to me. I have it working, but I'm wondering why I need to declare an assembly reference in 2 places. TIA. Dave ...
43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
3
by: TT (Tom Tempelaere) | last post by:
Hi there I am making a service project in C#, and I'm in the process of writing the installer. I made an installer class by using the "Add Installer" menu-item in the design window of the service,...
1
by: Marc Falesse | last post by:
Hello, My application needs to serialize a class, which was generated with xsd.exe from a XSD. It was working .NET 1.1 and it is working with .NET 2.0 very well. Now I need my assembly to be a...
3
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
0
by: Bill Nguyen | last post by:
I ran into this error using ClickOne to deploy a .NET 2.0 app. CrystalReports for .NET 2.0 is included in the delployment. The error indicates that an incorrect version of CrystalReports.Engine DLL...
17
by: Janiv Ratson | last post by:
Hello, I have written a C# dll in VS2005. One interface and class are exported using Interop Services. I want to use this c# dll in my MFC application, using VS2003. It compiles after I imported...
0
by: per9000 | last post by:
Hi all, we use CVS to manage versions of our code. Since the CVS keeps track of everything we need I want to synchronize the assembly info with CVS. The problem is that if I update the assembly...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.