Buy Contact NSDSP Home

Hex Block Structure

The struct hex_block represent a Hex block within a Hex Map object. It is referred to by a pointer of type hex_block_t

The hex_block_t reference is not persistent. You need to use it immediately after you retrieve the pointer because it becomes invalid when you call any library function except hex_block_resize.

Type

typedef struct hex_block {
  unsigned int addr;
  unsigned int len;
  void* data;
} *hex_block_t;

Members

addr - address of the Hex block. Note that this address refers to the HEX file address, not to the address in program memory. You can modify the address as needed.

For PIC12, PIC16, PIC24, dsPIC30, and dsPIC33 the HEX addresses are doubled. For example memory address 0x200 will be represented as 0x400 in the HEX file and in the Hex Block structure.

len - length of the block. You cannot modify it directly. Use the hex_block_resize function instead.

data - contents of the Hex block (as it would be presented in the Hex file). You can modify it as needed.

Some of the target devices have oddly sized instructions. For such target devices care must be taken to handle the data correctly, as follows:

PIC12 and PIC16 - instruction size is 12 or 14 bits. Each instruction occupies 2 bytes within data pointed to by the data member.

PIC24, dsPIC30, dsPIC33 - instruction size is 24 bits. Each instruction occupies 4 bytes within data pointed to by the data member. The last of these 4 bytes must always be zero.

You can use hex_block_next function to iterate through all the Hex blocks within the Hex Map object.

Northern Software Home NSDSP Contact Us Purchase/View Cart

© 2007-2025 Northern Software Inc. All Rights Reserved.