# PIC sequential variables

Status
Not open for further replies.

#### throbscottle

##### Well-Known Member
Hi folks
I having a go a double dabble (or it's reverse) to convert an 8 digit unpacked BCD to binary. Rather than assign a variable name to each digit, I think I can do this:
If I use
Code:
digits idata
digit db 1,2,3,4,5,6,7,8

myprog code
...
end
I think I can loop through each digit by incrementing fsr and accessing indf, but how do I address the first (or any other, for that matter) digit?
Also, if I use
Code:
output res 4    ; it needs to end up a 32bit word, whatever
can I rrf my way through "output" instead of having 4 variable names to manage?

Many thanks

#### Pommie

##### Well-Known Member
Both should work. However, decide first whether you're using big or little endian. I prefer little endian - I.E lowest byte stored first.
You can then do,
Code:
    rrf  output+3,f    ;shift msbyte
rrf  output+2,f    ;shift next byte
rrf  output+2,f    ;shift next byte
rrf  output,f    ;shift lsbyte
Edit, you probably want to clear the carry before the shifts.

I used double dabble a few years ago but wrote it in C.

Mike.

#### throbscottle

##### Well-Known Member
That's great, thanks Mike.
It occurred to me after I posted the question, I need to change individual digits of the BCD input (which comes from a keypad). Do I use the same notation? eg digit+1, digit+2 etc?

#### throbscottle

##### Well-Known Member
Now I get
Code:
 Illegal directive (IDATA)
And yet it's perfectly happy with udata
Wahhhhhh....

Status
Not open for further replies.

Replies
32
Views
4K
Replies
0
Views
1K
Replies
2
Views
2K
Replies
6
Views
3K
Replies
6
Views
2K