• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
Most Helpful 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.

Latest threads

EE World Online Articles

Loading
Top