Arduino Due assembly

hi !
I would like to learn assembly language for ARM .
I have a Arduino Due board , Arduino IDE , Atmel Studio 6.2 + Visual Micro
Everithing is working in normal way
But what I have to have to program in assembly ?
Documentation , compiler , what else ?
Where to find informations about that ?
thank you
Walter

You should first download the data sheet of the SAM3x8E (the MCU of the Due) (http://www.atmel.com/devices/sam3x8e.aspx).

If you are already familiar with CPU architectures and assembly, you will just need to adapt you knowledge to the structure of this MCU and its instruction set.

Assembly programming is not as easy as in C of course. You have really more code to write, since that's the duty of the C compiler to generate the numerous assembly instructions you now have to write. However, it's still programming. You must make explicit the storage mechanism of your variables (local vs global), you must take care of the content of the registers when you call a subroutine, etc. Several little funny things your C compiler handles for you :wink:

You may also mix C and assembly. That's what I did in Babix, my little preemptive multitask kernel for Due. In the related paper, I roughly explain the basis of such a mix. Otherwise, you may find information for instance at Extended Asm (Using the GNU Compiler Collection (GCC))

Regards,

Interesting. Thanks.

hi didou thanks for your answer
Well I know something about assmbly and architecture of calculator
I'm studyng about ARM architecture and assembly
What I would like to do is to understand something about and to optimize some routines for Arduino Due
I'm using Atmel Studio + Visual Micro to program the due and I'd like to know if it is possible to insert some "asm" code into the C program or directly assembly code without the arduino framework , I mean directly to the micro .I don't have any Atmel programmer such as Ace or else

Hi Walterp,

walterp:
I'm using Atmel Studio + Visual Micro to program the due and I'd like to know if it is possible to insert some "asm" code into the C program or directly assembly code without the arduino framework ,

The syntax of the directive to insert ASM I gave was for gcc. I imagine that the compiler provided by your devkit also has something similar (may be directly the same syntax). You should have a look at the doc of your devkit. I don't know this one. I use the "regular" Arduino stuff, which is simply gcc + the loader (bossac). I don't even use the editor ^^ Before, I even had my own Makefile but it is not yet updated to the new Arduino devkit distribution of header and source files :confused:

walterp:
I mean directly to the micro .I don't have any Atmel programmer such as Ace or else

Directly to the micro ? You need a loader to do so. You must "burn" your executable in the EPROM. The CPU cannot "eat" some code on the fly. May be I do not understand well what you mean.
Best,

-- F

I didou
The compiler which works under Atmel Studio + Visual Micro for Arduino I think it's the same which is used by arduino ide .to use Atmel Studio + Visual micro for arduino it needs to install arduino ide before ....

Hi didou !
I have discovered some news ....
In this example I'm able to use assembly in a C code from Atmel Studio , for arduino Due

void writeOutput()
{
	 configI2C();
	 byte output0=globalData.d_output._Word & 0x00FF;
	 byte output1=(globalData.d_output._Word & 0xFF00) >> 8 ;
	
	 Wire.beginTransmission(0x21);                     // seleziono il dispositivo MCP20317 con indirizzo 0x21
	 Wire.write(0x12);                                 // seleziono il suo registo GPIOA
	 Wire.write(output0);                              // scrivo il primo byte sulla porta  A
	 Wire.endTransmission();
	
	 Wire.beginTransmission(0x21);
	 Wire.write(0x13);                                  
	 Wire.write(output1);                              // scrivo il secondo byte sulla porta  B
	 Wire.endTransmission();
	 
	 asm("MOV r5, #20\n\t"
	     "MOV r8, #10\n\t"
	     "ADD r0, r1, r2\n\t"
	     "SUB r0, r0, r3\n\t"
	     "MOV r4, r6\n\t"
	     "MVN r7, r10");
}

Compiling without any problem , the logical is of course ranmize but compiled

Hi Walterp,

walterp:
Compiling without any problem , the logical is of course ranmize but compiled

Great ! Do not forget the clobbers list to properly tell your compiler which registers are killed by your inlines.
(Have a look at the thread Referencing a Pointer in Inline Assembly - #4 by didou - Arduino Due - Arduino Forum)

ok I'm watching ....

You should really consider buying The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors, 3rd edition, by Joseph Yiu.

Atmel's documentation tell you all about the peripherals they added, but there's only the most basic info about the ARM Cortex-M3. Joseph Yiu's book really is worthwhile, if you're going to be doing assembly on ARM.

hi Paul
I'm reading "Professional Embedded ARM Development" ...