How do you program Machine Lauguage into Arduino / ATmega

I just want to know how to program a machine language ( Op code of the ATmega ) using the IDE ? I know the IDE use a C++ to program the chip, what about ML ? Did you need a another "IDE" or programing environment ? I hope it is cheep.

The underlining Arduino C++ Gcc compiler does allow one to embed assembly language instructions if you wish. This allows the best of both worlds, high level programming for functions that don't need the possible efficiencies that can be gained sometimes dropping down to assembly instructions.

http://www.arduino.cc/playground/Main/AVR

http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

Look like I can do it. Thank retrolefty for the info. It look like I have a lot of reading about the ATmega. Just like going the college. I have a lot of “homeworks” to be doone about the subject. Lots of learning.

Do you really mean machine language, or assembly language?
If the former, you'd better learn about boot records too.

Why do you want to learn assembly language? The compiler is quite good in optimizing, and if speed is an issue other algorithms may be much faster.

A good way to learn assemby is to write code in C and let some AVR tools generate the assembly code. You can compare them and learn. google avr-objdump.exe and manual or so.

these tools can be found under - C:\Program Files (x86)\arduino-0022\hardware\tools\avr\bin - (OK this is my windows path)

Why do you want to learn assembly language?

Isn't it a good idea for some people to learn assembly language? After all someone has to write the compilers that the users of high level languages rely on.

Don

floresta:

Why do you want to learn assembly language?

Isn't it a good idea for some people to learn assembly language? After all someone has to write the compilers that the users of high level languages rely on.

Don

Right on. Our tools must stand on the shoulders of someone. :wink:

retrolefty:

floresta:

Why do you want to learn assembly language?

Isn't it a good idea for some people to learn assembly language? After all someone has to write the compilers that the users of high level languages rely on.

Don

Right on. Our tools must stand on the shoulders of someone. :wink:

I've been looking at learning assembly language. With using a device, you have no idea how it works. By programming and building it, you know how. But even in doing this, you leave the precise details down to another piece of code-the compiler. To me, the appeal of assembly is telling the AVR exactly what to do, step by step. And with the new knowledge, much more complex & efficient codes can be created.

Onions.

You can go in levels, and first learn how to do all that with C and leave all the arduino provided functions.

Why do you want to learn assembly language?

Thanks for all your reasons they are all true, but I liked to know why the OP wanted to learn ... // still some reasons missing BTW :wink:

From a remark from the OP in another thread, I think he has an expectation that he will need to do so to get the performance he requires. No details of the project he has in mind were mentioned, so it's hard to be certain, but I rather doubt that it will be necessary.

performance is a very good reason to learn assembly, but

  • you should estimate the max performance in assembly to check if it is feasable
  • you should think about other algorithms to solve the problem (there can be a greater gain)
  • you should rethink your datatypes
  • ...

If performance was such an issue that only assembly could be a solution I would spend my time learning a faster processorboard e.g. mbed, that is a factor x faster.

Senso:
You can go in levels, and first learn how to do all that with C and leave all the arduino provided functions.

Amen to that - I did a whole program for market in machine language (not Arduino of course) and I can vouch for it being a lot of work, especially for parts that don't need the speed or size adjusting. Do most of the code in the easiest language possible, and then tweak the key areas in a lower level language. With good coding, you may not even need to tweak at all.

Of course, there are exceptions: if you're doing intensive audio processing or video output on the Arduino, you might as well start in assembler - it's where you'll end up...

I used to do all projects in ASM both commercial and personal, mainly because cross-compilers were very expensive at the time. After a while you find that you have such a library of macros and functions that it's almost like writing in C.

These days it's seldom necessary but I agree it's good to know what's under the hood. I have a project coming up (on an ATtiny84) that will probably be written in ASM, so it still has it's place.


Rob

@AWOL
ML mean Assembly Language.

My main raison is to learn, to do small routine within IDE C++ where I need speed, program size and timing and —> Port Control.

I learn CPU whey back in the early 1990’s using 8085 and 8086 at DeVry Institute of Technology. Let say I want to send in data in Parallel ( 74244 - Tri-State gate ← I hope I am right ) the port select will open the gate and send the data to example : 8 LEDs
The data is send “At the same time” But with the ATmega… using digitalWrite ( pin, State ) Does Not Send at the same time.

I am aware it is a new way of design, am I new at microcontroller. I even get myself into PICAXE. So it is a new ball game, but I can still apply the routine I saw in the books I have and re-modify it. The my “Two 7 Segment multiplexer” came from. The idea of using a BCD converter and use my “LED binary counter”.

I know I am a bit “old school” , Heh , I will learn it and apply to some of the future projects and designs. I will even re-design one of my Tech Project. ( A robot explorer ) <— not complete by the way.

Thank you for the insights. This forum is a great spot for ideas.

using digitalWrite ( pin, State ) Does Not Send at the same time.

That's true, however if that's all you need to do then you don't need to drop into ASM, C code like

PORTB = 0x55;

Will be just as good.


Rob

Techone:
The data is send "At the same time" But with the ATmega... using digitalWrite ( pin, State ) Does Not Send at the same time.

You don't need to use ML for this:

From what I gather, the digitalWrite() is used to hide the different port addresses of the different AVR models from view. One call will work on all of them (more or less), but with added time to write.

Thank David for the link. :slight_smile: It will be usefull.

And thank Nomad for the tips. :slight_smile:

And thank to you all for the info. :slight_smile:

I did not have "something" in mind, I just want to know if it is possible to program ML the IDE.

Answer : YES And can be combine with C++.

I agree programing a high level is easier than ML, but when it come to :

  1. Program Size
  2. Speed
  3. Efficiency

Than ML will be better. Well for PC programing that is.

My opinion.

but when it come to :

  1. Program Size
  2. Speed
  3. Efficiency

Than ML will be better.

No, not necessarily.

@AWOL

Where ( subject - tread ) should I ask this question = When do I share my programs / projects for the Arduino ?