Yahoo Groups archive

AVR-Chat

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

Message

Message 6218

2005-10-26 by Martin Jay McKee

Hello All,

I’ve been following the list for quite some time now and had all my questions answered before I knew I had the question! However something has come up that I do need help with. I’m working on a program with a lot of state information in it (ASM) and lots of state transitions. My problem is that I get a run of compare/ jump statements, al’la:

STATE_1

clz

cpi State, Value_1

brne STATE_2

; Do Something

rjmp EXIT_STATE

STATE_2

clz

cpi State, Value_2

brne STATE_3

; Do Something

rjmp EXIT_STATE

… continues

STATE_N

clz

cpi State, Value_N

brne EXIT_STATE

; Do Something

; Fall Through (rjmp EXIT_STATE)

EXIT_STATE

My problem is that all the states are basically equally likely. I’d like to find a way to minimize the difference between the run times of the subroutine for states 1 and state N. The states are sequential (or at least close enough that it’s not worrying about) and memory use isn’t an option. Also I’m more interested in balance between the execution rate then brute speed, though, as always, faster is better. Does anyone have any ideas on how to solve this little problem? Any ideas are much appreciated, thank you in advance.

Martin Jay McKee

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.