how to use ASSEMBLY and C together

Can someone please help me, I am working on Arduino Uno, I know how to write programs in C for arduino, I am now trying to use assembly as well. I know how to use inline assembly within C code. But don't know how to wirte a separate file (.S file) and combine both .ino and .S and compile them together.

I am using Arduino IDE for all coding. So please help me and tell me how can I use both assembly and C together.

a good source would be to study this Arduino Inline Assembly Tutorial blog posts start at the bottom of the page with the Arduino Inline Assembly Tutorial #1 (Basic asm)

You can implement the library method described here: Writing AVR assembler code with the Arduino IDE

startsco:
Can someone please help me, I am working on Arduino Uno, I know how to write programs in C for arduino, I am now trying to use assembly as well. I know how to use inline assembly within C code. But don't know how to wirte a separate file (.S file) and combine both .ino and .S and compile them together.

I am using Arduino IDE for all coding. So please help me and tell me how can I use both assembly and C together.

I had trouble getting started (as in just working out how to get an S file into the IDE) with this too. I think that there should be a simpler way, however the following is what I do and it works fine.

Assume starting a new project.

  1. Create a new file (file -> new) in the IDE and give it a name (file ->save as).

  2. Close the IDE and go to the folder that you just saved into. There you will find the main "ino" file.

  3. Create a new file with the same base name as the "ino" file, but with the "S" extension.

  4. Reopen the IDE and you'll find that both files are now there (in separate tabs).

As I say. I think there's probably an easier way, but this still works for me. :slight_smile:

BTW. Let me know if you need more info or examples to get started.

stuart0:
I think there's probably an easier way

There is:

  • Click the downwards pointing triangle button on the top right side of the Arduino IDE window, under the Serial Monitor magnifying glass icon.
  • Click "New Tab"
  • Type in the name you want for your assembly file with the .S extension, make sure to use a capital S. It can be any name you like, it doesn't need to match the project name.
  • Click "OK". The .S file will now be added as a new tab.

pert:
There is:

...an even simpler way that allows one to keep one's fingers on the keyboard.

@stuart0, you really do need to read the replies to your posts...
http://forum.arduino.cc/index.php?topic=433714.msg2989161#msg2989161

Yep I read it. And yep did it (at the time). That's how I knew there was an easier way. However I didn't remember it, as is not intuitive enough. Also, at the time I assumed that was just a shortcut for something already on the file menu so didn't even try to commit it memory.

When it came to start a new project I soon realized that I couldn't find that option anywhere in the file menu. By then however I'd already figured out that the IDE always opened the S file tab automatically so long as the file is already there in the folder. So TBH I found it easier to just do it that way. It's not fast, but it works and is easy to remember. :grin:

I'll probably remember the little downward triangle though. It's somewhat initiative, as at least it's in the tab area of the screen. It would be even better if it was an option on the file menu though.