Studio 4 operand error

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

Can some one told me why my compiler give operand error out of range 0x22 with this code on mega8
Loop:
SBIC ASSR,TCN2UB
RJMP Loop
The same with TCR2UB

Thank you

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

Because SBIC has a limited address range, and ASSR is not within this range.

Stefan Ernst

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

Read m8 datasheet, memory section sub-section "I/O memory" .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

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

Alternative instruction for that job?

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

petros047 wrote:
Alternative instruction for that job?
in
andi
brne

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Loop:
        in      r16,ASSR
        sbrc    r16,TCN2UB
        rjmp    Loop

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

Thanks every one
I suppose this will work
LOOP:
in r16,assr
andi r16,~(1<<TCN2UB)
BRNE LOOP

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

petros047 wrote:
I suppose this will work
No. Why the '~'?

BTW: You can test more than one bit at once with the andi.

Stefan Ernst

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

Because i have to wait until become zero, wrong syntax?

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

petros047 wrote:
Because i have to wait until become zero, wrong syntax?
No, wrong semantic.

Stefan Ernst

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

To add to that: remove the ~ and change BRNE to BREQ

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

Thanks a lot I try it tonight hope it will work now

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

clawson wrote:
and change BRNE to BREQ
Eh?

Stefan Ernst

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

Sorry more caffeine needed here!

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

What's wrong with my SBRC above - another extra instruction to learn?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

MBedder wrote:
What's wrong with my SBRC above
Nothing is wrong, but it is quite likely that he has to wait for more than one bit in that register, and with andi he can do that in one loop.
MBedder wrote:
another extra instruction to learn?
Why not? Andi and brne are common instructions, he will need them sooner or later anyway.

Stefan Ernst

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

His initial code was SBIC on an out of coverage SFR. He asked for an alternative instruction, and I gave him exactly what he was asking for - SBRC, so why invent the non-existing demands about checking multiple bits?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.