C30 how do you tell the compiler high / low word?

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
Just getting the hang of C30 and in 8 bit assembly you could use...

X = high(0x1234)
Y = low(0x1234)

to tell the assembler to put 12 into X and 34 into Y

Now I'm looking for a 16 bit word equivalent in C30.
 
Just getting the hang of C30 and in 8 bit assembly you could use...

X = high(0x1234)
Y = low(0x1234)

to tell the assembler to put 12 into X and 34 into Y

Now I'm looking for a 16 bit word equivalent in C30.

not sure I understand the question ?

X = 0x1234 >> 8;
Y = 0x1234 & 0x00ff;

or

X = 0x11223344 >> 16;
Y = 0x11223344 & 0xffff;
 
Here's one method from Forum.Microchip for pulling the hi and lo bytes from an INT;

Code:
unsigned char Lo = 0;
unsigned char Hi = 0;

#define LOBYTE(x) (char)((x)&0xFF)
#define HIBYTE(x) (char)((x)/256)

Lo = LOBYTE(CCPR1);
Hi = HIBYTE(CCPR1);
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…