Home/Support/Support Forum/How to do conditional jumps on the Rabbit 2000?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to do conditional jumps on the Rabbit 2000?

0 votes
How can I do a conditional jump on the original Rabbit 2000 in code running from flash with wait states?

According to the user manual, for djnz, jp, jr when the branch is not taken, the fetch of the next instruction is short by one wait state. Which I guess means that an undefined byte is fetched and executed as instruction.
asked Sep 25, 2020 in Rabbit by spth New to the Community (24 points)

Please log in or register to answer this question.

2 Answers

0 votes
One could simulate

jr nc, target

by

push hl
push af
ld hl, #tlbl
addc hl, hl
rr hl
pop af
push af
ld hl, #tlbl
addc hl, hl
rr hl
pop af
push af
ld hl, #tlbl
addc hl, hl
rr hl
pop af
push af
ld hl, #tlbl
addc hl, hl
rr hl
pop af
jp (hl)
tlbl:
pop hl
jp target
pop hl

but that doesn't look very efficient. Maybe it makes more sense to instead just configure the Rabbit 2000 with one more wait state than the memory requires.
answered Sep 25, 2020 by spth New to the Community (24 points)
0 votes
There probably aren't many Rabbit 2000 CPUs (from before revision A) out there. It's possible that there weren't even Rabbit products using wait states that shipped with CPUs prior to the Rabbit 2000A.

Could you limit SDCC to using the r2ka target and state that hardware with original Rabbit 2000 processors and wait states enabled won't work correctly.
answered Oct 1, 2020 by TomCollins Veteran of the Digi Community (2,184 points)
SDCC has seoarate r2k (Rabbit 2000) and r2ka (Rabbit 2000A, 2000B, 2000C, 3000) and r3ka (Rabbit 3000A) ports.
Even the r2k port doesn't work around all the wait state bugs. Instead the manual states that one additional wait state needs to be configured by the user for the original Rabbit 2000, and SDCC only works around bugs that can result in more than one wait state being omitted.
...