Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem compiling AVR code for Arduino UNO #17

Closed
dwhire opened this issue Jan 29, 2015 · 2 comments
Closed

Problem compiling AVR code for Arduino UNO #17

dwhire opened this issue Jan 29, 2015 · 2 comments

Comments

@dwhire
Copy link

dwhire commented Jan 29, 2015

I have been able to run the C version of micro-ecc on my Arduino. However I get errors when
compiling the ASM procs. Please help. I don't know AVR ASM. I just would like to use the faster option. Thank you.
Dave Henderson

Compiler errors reported:

C:/Arduino/myArduinoLibs/Ecc/asm_avr.inc:137: error: can't find a register in class 'POINTER_Y_REGS' while reloading 'asm'
C:/Arduino/myArduinoLibs/Ecc/asm_avr.inc:137: error: can't find a register in class 'POINTER_Y_REGS' while reloading 'asm'
(repeats above line 6 times)
C:/Arduino/myArduinoLibs/Ecc/asm_avr.inc:137: error: 'asm' operand has impossible constraints
(repeats above line 6 times)

Code:

static uint8_t vli_add(uint8_t *p_result, uint8_t *p_left, uint8_t *p_right)
{
uint8_t i = uECC_BYTES;
uint8_t l_carry = 0;
uint8_t l_left;
uint8_t l_right;
asm volatile (
"clc \n\t"

    "1: \n\t"
    "ld %[left], x+ \n\t"  /* Load left byte. */
    "ld %[right], y+ \n\t" /* Load right byte. */
    "adc %[left], %[right] \n\t" /* Add. */
    "st z+, %[left] \n\t"  /* Store the result. */
    "dec %[i] \n\t"
    "brne 1b \n\t"

    "adc %[carry], %[carry] \n\t"    /* Store carry bit in l_carry. */

    "sbiw r28, " STR(uECC_BYTES) " \n\t" /* Restore Y */

    : "+z" (p_result), "+x" (p_left), [i] "+r" (i),
        [carry] "+r" (l_carry), [left] "=&r" (l_left), [right] "=&r" (l_right)
    : "y" (p_right)
    : "cc", "memory"
);

return l_carry;

}

@kmackay
Copy link
Owner

kmackay commented Jan 29, 2015

When using the inline assembly for AVR, you need to build with optimizations enabled (-O1 or higher)

@kmackay kmackay closed this as completed Feb 3, 2015
@atlazar
Copy link

atlazar commented Jan 6, 2017

I also have Arduino UNO. Constantly get same linker errors (try with -O1 or -Os flags). After many attempts to resolve this, I found by chance what change from

#define uECC_SUPPORT_COMPRESSED_POINT 1

to

#define uECC_SUPPORT_COMPRESSED_POINT 0

in uECC.h resolve this issue. Maybe this helps somebody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants