SECTION V-1: Data Format Representation Hex Numbers

PIC Microcontroller Data Type:-

The PIC microcontroller has only one data type. It is 8 bits, and the size of each register is also 8 bits. The programmer break down data larger than 8 bits, 00 to FFH, or 0 to 255 in decimal to be processed by the CPU. The data types used by the PIC can be positive or negative.

Data Format Representation:-

There are 4 ways to represent a byte of data in the PIC assembler. The numbers can be in hex, binary, decimal or ASCII formats.

Hex Numbers:

There are 4 ways to show hex numbers:

  1. Can use 'h' or 'H' right after the number like this: MOVLW 88H or MOVLW 88h
  2. Put 0x or 0X in front of the number like this: MOVLW 0x88 or MOVLW 0X88
  3. Put nothing in front or back of the number like this: MOVLW 88
  4. Put 'h' in front of the number, but with this single quotes around the number like this: MOVLW h'88'

Some PIC assemblers might give you a warning, but no error, when you use 88H because the assembler already knows that data is in hex and there is no need to remind it. This is a good reminder when we do coding in assembly.

Below lines of code use the hex format:

MOVLW 25 ;WREG = 25H
ADDLW 0x11 ;WREG = 25H + 11H = 36H
ADDLW 12H ;WREG = 36H + 12H = 48H
ADDLW H'2A' ;WREG = 48H + 2AH = 72H
ADDLW 2CH ;WREG = 72H + 2CH = 9EH






The following are invalid:

MOVLW E5H ;invalid, it must be MOVLW 0E5H
ADDLW C6 ;invalid, it must be ADDLW 0C6




If the value starts with the hex digits A - F, then it must be preceded with a zero. The valid is given below.

MOVLW 0F ;valid, WREG = 0FH or 00001111 in binary


More From