Resources for Assembly Language Programming for mbed student projects

28 Sep 2010 . Edited: 28 Sep 2010

I wanted to have students write a short lab example of ARM assembly language programming on the mbed (probably just read in a pin from a switch and send it back out to an LED and loop). I found other resources for disassembly in a forum post and we have an ARM assembly language textbook and of course the handbook's processor data manuals and schematics along with the ARM RealView Assembler Reference Guide. It will make them appreciate compilers! They have already used MIPS assembly language in another class.

I recall seeing a forum comment that in-line assembly is not supported in the compiler, but that a ".s" file is. I found some info on using .s files with the online compiler in this forum post. Are there any other simple cookbook examples/instructions around showing or explaining how to do assembly with the mbed compiler or other resources I have missed that would help?

I think long term it might make sense to setup this topic as a cookbook page (with warnings about assembly for beginners) 

28 Sep 2010

There's really not much to describe. The steps are there, so just decide what you want to implement and do it.

29 Sep 2010 . Edited: 29 Sep 2010

Got a working example calling ASM (in .s file) from C with one arg. A couple of the steps could be explained to make it a bit easier. Also the documentation I found on exactly how the compiler passes C args to assembly language seems not to be as complete as one would expect. Perhaps it is somewhere else.

It does not seem to want to publish the *.s file.

29 Sep 2010

Check the EABI docs for the argument passing. In the most common case, the first four arguments are passed in R0-R3 and the rest on the stack ([SP], [SP,#4] etc).

29 Sep 2010

Thanks, that doc makes it a lot clearer. I saw a couple examples showing R0 and R1 args, but it was mum on what goes on when there are more than 2 args and when the stack comes into play.

 

30 Sep 2010

Are there any ARM emulators that would run in Windows, are free, easy to use, and would be helpful for students learning ARM assembly language?

Most schools still use MIPS assembly language as the example since they have it in the popular textbooks and have a couple easy to use assembler/emulators that are free (i.e., SPIM and MARS(Java based)).

30 Sep 2010

There is QEMU - free and open-source. However, the standard distro does not include emulation for LPC1768-specific hardware, so you will have to either stick to generic non-hardware-specific code, target one of the included processors/boards, or add LPC1768 emulation yourself.

13 Feb 2011

Thanks - I got it all working with the free Keil Tools demo version and setup a cookbook page for others a few weeks back. The students were able to figure it out from the cookbook page and just did an ARM ASM lab assignment last week.

http://mbed.org/cookbook/Assembly-Language now has updated info on how to use Assembly Language.