AVR-GCC: Error: garbage at end of line

北慕城南 提交于 2019-12-06 09:03:47

问题


I have problem with stack init lines because avr-gcc returns

LED_Blink.asm:10: Error: garbage at end of line

On lines:

ldi r17, low(RAMEND)
ldi r17, high(RAMEND)

And I am confused. I have already defined RAMEND. I used avr-gcc with this command:

avr-gcc -x assembler -mmcu=atmega328p LED_Blink.asm

My assembly code:

.equ    SPL, 0x3d
.equ    SPH, 0x3e
.equ    RAMEND, 0x8ff

.equ    PORTB, 0x05
.equ    DDRB, 0x04
.org    0x000000
rjmp main
main:
    ldi r17, low(RAMEND)
    out SPL, r17
    ldi r17, high(RAMEND)
    out SPH, r17

    ldi r16, 0xff
    out DDRB, r16
    out PORTB, r16
loop:
    ldi r16, 32
    rcall outer_loop
    cbi PORTB, 5
    ldi r16, 32 
    rcall outer_loop
    sbi PORTB, 5
    rjmp loop
outer_loop:
    clr r24
    clr r25
delay_loop:
    adiw r24, 1
    brne delay_loop
    dec r16
    brne outer_loop
    ret

回答1:


low and high don't mean anything to the GNU assembler for AVR, I think you want to use lo8 and hi8 to take the low and high bytes, respectively.



来源:https://stackoverflow.com/questions/34368602/avr-gcc-error-garbage-at-end-of-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!