Astudio 6 Assembler crash with relative branch in macros.

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

Please,

Someone knows why relative branches don't work properly in assembler macros runing on
Astudio5 & Astudio6?

Example:

;
;------- 8 bit Timer manager 
;
.MACRO   Timer
;
;@0 = Affected 8 bit timer
;
         lds       W,@0                          
         tst       W                             

         breq      DST_1 <- Here crash!!   

         dec       W                             
         sts       @0,W       
Dst_1:
         nop
;
.ENDMACRO

Astudio builder report "Relative jump out of reach"

Instead in this case:

;
;------- 8 bit Timer manager 
;
.MACRO   Timer
;
;@0 = Affected 8 bit timer
;
         lds       W,@0                          
         tst       W       

         in        WH,SREG
         sbrs      W,Z
         rjmp      Dst_1

         dec       W                             
         sts       @0,W                          
Dst_1:
         nop
;
.ENDMACRO

$ Fixed code tags - JS $

Astudio6 builder works proprely

Thank You

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

Hi,

I was not able to reproduce any problem with the above code, using Atmel Studio 6 and assembler v. 2.1.51. If you want help with this, or suspect a bug in the assembler, you need to post enough code to actually reproduce the problem. It would also be helpful to know which device you are using.

- roland

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

I'm not yet an AStudio6 user, but it looks to me like your macro will try to insert the same label ( "DST_1" ) each time it's invoked. That would be a problem for all but the first use of the macro. Glancing through the Atmel AVR Assembler help pages, I don't see a way to generate "local-within-macro" labels, so you may have to count those two instructions you want to skip up on your fingers, add one for the breq instruction itself, and change your branch statement to

breq PC + 3

Also, what's "W"? You're not trying to assemble PIC code for an AVR, are you?

Finally, assuming W has been defined as some meaningful-to-AVR register, you shouldn't need the NOP instruction at the end of your macro. Normally, people program in assembler if they're interested in saving space.