Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: ARM asm?

  1. #1

    ARM asm?

    Hi. First-time poster here.

    Does Teensyduino C support the asm statement to embed ARM code for a Teensy3?

    If not, can C code be written to compile to a very tight loop, say ~5 cycles? Example loop:
    loop:
    read entire port C into reg
    compare reg with immediate value
    branch to loop if not equal

    Thanks.

  2. #2
    I just tried it and it seems to work. I added __asm__("ldr r0,[r1]\n\t"); to the Blink example and it compiled.

    Is there documentation somewhere about which registers are OK to modify and how to get register values into C variables, etc.?

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Yes, there is documentation for this. Here's a link:

    http://www.ethernut.de/en/documents/arm-inline-asm.html

  4. #4
    Thanks!!!!

  5. #5
    In Teensyduino, is there a way to view the assembly code produced by the compiler?

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Yes, but not in Arduino.

    You can run arm-none-eabi-objdump -d file.elf to turn the .elf file into an assembly language listing. The arm-none-eabi-objdump program is in hardware/tools/arm-none-eabi/bin.

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,250
    If you are running outside of the Arduino IDE, you can add the -save-temps option (or the newer -save-temps=obj which works better for some complex environments), and it will create .ii/.s files as part of the compilation (-save-temps drops the file in the current directory, -save-temps=obj drops the files in the output directory).

  8. #8
    Thanks. I found a tutorial for noobs like me which describes Paul's suggestion:
    http://rcarduino.blogspot.com/2012/0...-assembly.html

    Someday I might try working outside the IDE. I love the painless ease of it. I'm a noob to Arduino and ARM, but not to microcontrollers. I used to work with 8748s and 41s! Not so painless, those (but nice in the day). One of my present projects is to replace an old 8749 with a Teensy.

  9. #9
    Maybe not so painless. I installed Teensyduino 1.16 over Arduino 1.0.5 on Mac OS X 10.6.8 and the Blink sketch works. I can modify it and download and run it but when I try the serial monitor I get this:

    Arduino: 1.0.5 (Mac OS X), Board: "Teensy 3.0"
    Binary sketch size: 18,400 bytes (of a 131,072 byte maximum)
    Estimated memory use: 3,452 bytes (of a 16,384 byte maximum)
    processing.app.SerialNotFoundException: Serial port '/dev/tty.usbserial-A50201WT' not found. Did you select the right one from the Tools > Serial Port menu?

    Well, that port doesn't show up in that menu. Did I miss a step during installation?

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Quote Originally Posted by Citabria View Post
    Serial port '/dev/tty.usbserial-A50201WT' not found. Did you select the right one from the Tools > Serial Port menu?
    That doesn't look like a serial port associated with Teensy. Normally on Macs they have names like /dev/cu.usbmodem12341. "usbserial-A50201WT" is very likely something else connected to your Mac.

    Of course, the serial port only appears on your Mac *after* you upload and Teensy begins running the program you uploaded. Also, before you upload, Tools > USB Type needs to be set to "Serial". The others will create non-serial devices, which obviously won't show up as a serial port name.

    The option "Serial+Keyboard+Mouse+Joystick" requires Mac OS-X 10.7 (Lion) or later. Sorry, it doesn't work on Snow Leopard. Apple simply didn't start supporting Serial+otherstuff devices until Lion. Microsoft also didn't support this until XP-SP3 and Vista-SP1, and there was a time long ago when Linux didn't support it (though Linux has supported it far longer and with fewer bugs than Apple or Microsoft).
    Last edited by PaulStoffregen; 12-20-2013 at 07:22 AM.

  11. #11
    Thanks again. I selected the port you mentioned and it works. The other port was left over from the Arduino Nano I had plugged in before.

    Nice work on the Teensy BTW!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •