Unsupported instructions bug in AVR assembler 2

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.
I've just had a bunch of problems with a small assembler program, I wrote. I am using an old 2313, and I took some code from a larger AVR which happened to contain "call". But the 2313 only supports "rcall".
Using AVR Studio 4.11 SP 3, with AVR assembler version 2 (2.0.31), I don't get any warnings or errors when trying to assemble something with "call", "jmp" or even "spm" for a 2313.

Is this a known bug (I couldn't find anything in the known issues or by searching this forum). And is there a way around it?

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

This had been discussed before at
https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=22768

I just tried this with AVRStudio 4.11SP3 with this code

.include "2313def.inc"

.CSEG
	.ORG	0
	jmp	RESET

	.ORG	0x2A	
RESET: 
Lbl_1:	call	Lbl_2
	spm
Lbl_2:	ret

and got this in the output window

Quote:
Building project...
AVRASM: AVR macro assembler 2.0.31 (build 58 Apr 21 2005 14:17:40)
Copyright (C) 1995-2005 ATMEL Corporation
C:\Download\Atmel\AVRFreaks\Test\Test.asm(2): Including file 'C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes\2313def.inc'
C:\Download\Atmel\AVRFreaks\Test\Test.asm(6): error: jmp k: Unsupported instruction on AT90S2313
C:\Download\Atmel\AVRFreaks\Test\Test.asm(10): error: call k: Unsupported instruction on AT90S2313
C:\Download\Atmel\AVRFreaks\Test\Test.asm(11): error: spm: Unsupported instruction on AT90S2313
Assembly failed, 3 errors, 0 warnings

Are you sure that you are using version 2 of the assmebler. Did you change the .include to the 2313?

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

So it has. And that is a bit embarassing, as I even participated in that discussion myself :oops:

Anyway, I tried your little sample code, and here is what I get:

Quote:
Building project...
AVRASM: AVR macro assembler 2.0.31 (build 58 Apr 21 2005 14:17:40)
Copyright (C) 1995-2005 ATMEL Corporation
D:\Avr\Prog\S2313\teststudio4\test.asm(1): Including file 'D:\Avr\Prog\S2313\teststudio4\2313def.inc'
AT90S2313 memory use summary [bytes]:
Segment Begin End Code Data Used Size Use%
---------------------------------------------------------------
[.cseg] 0x000000 0x00005c 12 0 12 9999999 0.0%
[.dseg] 0x000060 0x000060 0 0 0 9999999 0.0%
[.eseg] 0x000000 0x000000 0 0 0 9999999 0.0%
Assembly complete, 0 errors. 0 warnings

I don't get it. It looks like I have a bad installation or something.

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

Hmm,
My 2313def.inc is dated "Tuesday, January 11, 2005, 10:30:54 AM" and is 13,289 bytes long.

Looking at the help file in AVRStudio (AVR tools->AVR Assembler 2->Command-line invocation syntax), it states that the illegal instruction is a command line option and the default is on. Almost the last line in the 2313def.inc is

#pragma AVRPART CORE INSTRUCTIONS_NOT_SUPPORTED break

This is described in the Preprocessor section and this might make the assembler use illegal instruction error as default.

Could that be the difference?

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

WOHOOO. There's the answer.
I have used an old....... VERY old 2313def.inc, that I've just had lying around since AVR Studio 3 (or maybe even earlier). Deleting it, makes the assembler take its own include file, and everything works. I guess it's just an old habit I have, to take the processor include file with me from project to project.

Anyway, thanks a million. Now I can have a good nights sleep without worries :D

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

Svuppe wrote:
WOHOOO. There's the answer.
I have used an old....... VERY old 2313def.inc, that I've just had lying around since AVR Studio 3 (or maybe even earlier). Deleting it, makes the assembler take its own include file, and everything works. I guess it's just an old habit I have, to take the processor include file with me from project to project.

PLEASE don't do this. This habit is the cause of a lot of problems. The devicedef.inc files are part of the assembler/AVR Studio distribution, and may change with each new version. There is a number of reasons for such changes, including hardware changes (reflecting changes in data sheet), correction of errors in the files, or software changes (in this case, new assembler). The important lesson here is that these files are NOT part of your project, but a part of the tool, in the same sense that stdio.h is not a part of your C program.

We do our best to keep the include files backward-compatible, and you should normally not experience problems when these files are updated. IF you do, it's usually a good reason for it, and it's better to discover it early in the form of an assembly error than later in the form of a bug in your program.

BTW, AVR Assembler 2 supports the C convention for including files. The form

.include 

or its equivalent

#include 

will not look in the current working diectory for include files, and is recommended for "system" include files, like the devicedef.inc files. Note however that this form is not supported by AVR Assembler 1.

--
Roland Kruse
Atmel AVR Tools

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

I remember that once way, way, WAY back in the early years of the AVR, the include file had to be together with the assembler file(s) in order to compile at all. And I've just stuck with that practice ever since.
But now I've learned my lesson, and have deleted the device-includes from all my projects.