Yahoo Groups archive

AVR-Chat

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

Message

Re: Jumptable

2005-05-17 by leon_heller

--- In AVR-Chat@yahoogroups.com, "Paul Maddox" <P.Maddox@s...> wrote:
> Leon,
> 
> Thanks, I hadn't spotted that in the instruction set.
> Just looking at IJMP, it may be simpler to use, no pushing/pulling 
from the 
> stack and its 1 less clock cycle (speed is king)...

I've just written a simple jump table program using ICALL:

  .include "tn2313def.inc"

     .def	temp=r16


     .cseg
	 .org	0
	 rjmp	reset

reset:
	ldi		temp,low(RAMEND)
	out		spl,temp
	ldi		temp,$03


loop:
	rol		temp
	ldi		zl,low(jump_table)
	ldi		zh,high(jump_table)
	add		zl,temp
	icall
	rjmp	loop


jump_table:
	rcall	zero
	ret
	rcall	one
	ret
	rcall	two
	ret
	rcall	three
	ret

zero:
	ret

one:
	ret

two:
	ret

three:
	ret


Change temp within the loop using the simulator to check that it 
works.

Leon

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.