Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: Mixing C and assembly with special requirements.

2012-03-27 by fireweaver

On 3/27/2012 9:27 AM, Don Kinzer wrote:
>
>
> --- In AVR-Chat@yahoogroups.com, fireweaver<firewevr@...>  wrote:
>> I don't know how this will appear since the
>> group forbids attachments.
> It got quite mangled, of course.  If you don't have a server where you can store files you can use a service like DropBox.  An account with a 2GB limit is free.
>
> I converted your code to an avr-gcc compatible ISR.  As you surmised, it did grow in size and number of cycles.  If I counted correctly, the worst case is 70 cycles, not counting the cycles to get into the ISR.  It is also about twice the size of your original code.  You can see the code (untested) here:
> http://dl.dropbox.com/u/43035239/decoder.S
>
> Incidentally, unless I'm missing something, the code sequence below from your post doesn't do what you intend.  It looks like the code is supposed to load an offset from the table, selected by the combined previous state/next state, and then jump to that offset.  However, the LPM instruction to actually load from Flash is missing.  As it stands, the code will jump to a table entry and start executing but the table contains offsets, not instructions.
>
>> ldi     ZH,high( X_actions)
>> mov     ZL,encoder_state
>> andi    ZL,15
>> subi    ZL,0xFF-low(X_actions)
>> ijmp
> Don Kinzer
> ZBasic Microcontrollers
> http://www.zbasic.net
So  I should write:

ldi     ZH,high( X_actions)
mov     ZL,encoder_state
andi    ZL,15
subi    ZL,0xFF-low(X_actions)
lpm     ZL,Z                      ;<---
ijmp

???

The intent is to do a case jump to one of the four action routines.

erikc

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.