1
\$\begingroup\$

I've got the following program, in AVR assembly:

.DEF    WR = R16

.ORG 0

SER    WR
OUT    0x24, WR

When I call avr-as beeep.s, where beeep.s contains the previous code, I get an error message:

beeep.s: Assembler messages:
beeep.s:1: Error: unknown pseudo-op: `.def'
beeep.s:5: Error: constant value required
beeep.s:5: Error: register number above 15 required
beeep.s:6: Error: constant value required

I can't find the origin of my error... What did I do wrong ?

\$\endgroup\$
10
  • 1
    \$\begingroup\$ It looks like you are trying to compile the code written for avrasm with GNU as, which seem to have a different directives (which are not machine instructions but "pseudo-ops"). \$\endgroup\$
    – Eugene Sh.
    Commented Jun 9, 2015 at 21:34
  • \$\begingroup\$ @EugeneSh. So what instructions should I use ? Or, what Assembler ? \$\endgroup\$
    – Spirine
    Commented Jun 9, 2015 at 21:35
  • \$\begingroup\$ Take a look here. Or just use the Atmel's provide assembler. \$\endgroup\$
    – Eugene Sh.
    Commented Jun 9, 2015 at 21:39
  • \$\begingroup\$ @EugeneSh. But .dev is in this instructions set, and the same error message occurs when I replace .DEV with .dev... \$\endgroup\$
    – Spirine
    Commented Jun 9, 2015 at 21:41
  • \$\begingroup\$ Yes, but the meaning and usage are completely different. \$\endgroup\$
    – Eugene Sh.
    Commented Jun 9, 2015 at 21:43

2 Answers 2

1
\$\begingroup\$

Change .DEF with .EQU:

.EQU    WR, R16

.ORG 0

SER    WR
OUT    0x24, WR
\$\endgroup\$
0
\$\begingroup\$

As described on http://www.nongnu.org/avr-libc/user-manual/assembler.html one should NOT be using avr-as directly but use avr-gcc instead.

E.g: avr-gcc -mmcu=atmega8 -x assembler-with-cpp example.s

See Note [2] of the example program on the page to see how to assign symbolic name to register.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.