avr: inline assembly with lo8()/hi8() cuts symbols longer than 16 characters

Abierto
#205 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c

Línea de trabajo

The issue provides a minimal C example using inline assembly and reproduces the symbol truncation with AVR target flags; start by reading that example and tracing how EmbCC parses or emits inline assembly containing lo8() or hi8(). Check the AVR port context in arch/avr/avr_context.c for the affected long symbols. Done means the example compiles with those symbols intact and the AVR RTOS library can build.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

On AVR, an inline-assembly template that uses lo8() or hi8() anywhere has every symbol longer than 16 characters cut to its first 16, and the assembler then refuses it. EmbCC 0.1.0 (macOS aarch64 release), --target=avr -mmcu=atmega328p -Os.

void abcdefghijklmnopqrst(void);
void g(void) { __asm__ __volatile__("ldi r18, lo8(2303)\n\tcall abcdefghijklmnopqrst" ::: "r18"); }
embcc: g.c:2: error: 'abcdefghijklmnop' is not a number, a register or an expression this assembler knows

What changes the result:

Template Result
ldi r18, lo8(2303) then call abcdefghijklmnopqrst error
ldi r18, hi8(2303) then call … error
call … first, then ldi r18, lo8(2303) error
ldi r18, lo8(2303), nop, then jmp … error
ldi r18, 7 then call abcdefghijklmnopqrst compiles
call abcdefghijklmnopqrst alone, with or without operands compiles
a 16-character name after lo8() compiles

So the cut follows the presence of lo8/hi8 in the block, not their position or the operands.

Where EmbLinkRTOS meets it: the AVR port's kernel start, arch/avr/avr_context.c, loads the stack pointer with lo8(%[top])/hi8(%[top]) and then calls emb_arch_switch_to and jumps to embk_thread_launch, both 18 characters. The port's library does not compile, so no Uno image links. Passing the two bytes as separate "i" operands avoids it; the RTOS keeps lo8/hi8, which avr-gcc and Clang accept.

Part of #184 (AVR).

Lenguaje dominante
C
Estrellas
1
Forks
2
Merge medio
20 h 55 min
PR fusionados (30 d)
73

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de EmbLinkOs/EmbCC

Todos los issues de EmbLinkOs/EmbCC

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.