__bad_interupt error

4 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I'm assembling a program with avr-gcc and I get the following message:

/usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o: In function `__bad_interrupt':
../../../../crt1/gcrt1.S:123: undefined reference to `main'

The command i'm using to assemble is:

avr-gcc -gstabs -mmcu=atmega8 -I/usr/avr/include/ mycode.S -o mycode.elf

I don't think it's anything to do with my code, it seems to be something to do with an external file (one that i've never even heard of or included!)

As you can probably tell i'm quite new to this! If anyone could help i'd be really greatful.

Oh, it's on ubuntu feisty (using only packages from the ubuntu repos) if that's any help.

Thanks in advance

Rob

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any C or asm program must provide a 'main' - you aren't. If this is an Asm project then label the entry to your code:

main:

and if there's C involved and you want entry to be into the C first then provide:

int main(void) {}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I do have a main label:

#cseg
.org 0x0

rjmp main

.org 0x0400
main: ...

is that right? the code compiles with avra - but i need gcc's debuging support.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ah - got it!

needed:

.global main

d'oh! you can tell i'm new to this assembly stuff!