Arduino 1.6.5 IDE Not Properly Defining ATmega328P Ports When Compiling Assembly

Hi all.

If this post is redundant, apologies. A forum search did not yield any relevant hits.

I am writing a project that makes use of a library written in Atmel 328P assembly language. The Arduino 1.6.5 IDE successfully compiles the .S assembly files without any reported errors. However, the issue is that the 328P's port names are not being defined properly within the compiled assembly (.hex) files.

For example, the following code is supposed to light up the Arduino Genuino/Uno LED (pin 13) but does not:

    .include "includes/m328pdef.inc"
       ldi r16, 0b00100000
       out DDRC, r16
       out PORTC, r16
    Start:
       rjmp Start

The following corrected code (direct port addresses instead of port names) successfully lights up pin 13:

    .include "includes/m328pdef.inc"
       ldi r16, 0b00100000
       out 0x07, r16
       out 0x08, r16
    Start:
       rjmp Start

While this issue is easily corrected, it is annoying to have to do this (especially with larger assembly language files).

Does anyone know why the Arduino 1.6.5 IDE has port definition issues for Atmel ATmega328P assembly language? Is the issue due to a problem with an underlying IDE component (GCC, etc.)?

Thanks in advance.

-Z

zx11ninja

Posts: 14 Joined: Fri May 23, 2014 6:21 am

Top

The _SFR_IO_ADDR() macro is your friend.