Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Declaring multiple byte constants in MPLAB

4 views
Skip to first unread message

Will

unread,
Jul 26, 2004, 10:44:32 AM7/26/04
to
I have a program which does a lot of 24 bit math and because of that
uses a lot of 24 bit constants. Right now I have it set up to declare
the constants as:

;Constant = 0x123456
#define CONSTANT_2 0x12
#define CONSTANT_1 0x34
#define CONSTANT_0 0x56

This works, but is a little clunky when I want to change them (I have
a lot).
Is there a way to declare it as one big number similar to the
following?

#define CONSTANT 0x123456

If so, how do I reference the various bytes in my program? I'm using
MPLab v6.20 and writing straight assembly (no C code). An example of
where I would use this would be:

movlw CONSTANT_2
movwf ARG_A_2
movlw CONSTANT_1
movwf ARG_A_1
movlw CONSTANT_0
movwf ARG_A_0
;Do something with ARG_A

I've tried using the upper, high, and low declarations and they
sometimes work, sometimes don't. I haven't figured out a pattern to
it. But I'm also trying to plan for future code that might go to 32
bit constants. What could I do in that case other than what I'm
already doing? Thanks for any help!
-Will

0 new messages