We are considering changing from a microcontroller with a ROM capacity of 64K bytes or less to a microcontroller with a ROM capacity of over 64K bytes.When the memory model changes from Small to Large, are there any points to be aware of with pointers, arrays, etc.?
As the memory model goes from Small to Large, the size of pointers to functions changes from 2 bytes to 3 bytes. Please note that when using an array of pointers to functions. The sizeof operation result for a single pointer to a function in the Large model is 3, but in the case of an array of pointers to functions, a 1-byte padding is inserted after each element. So with 5 elements, the size of the array is ((pointer size 3 bytes) + (padding 1 byte)) * (number of elements 5) = 20 bytes. For details, see "126.96.36.199 Arrays other than char type" in "CCU8 Programming Guide".
Also, when calculating the number of elements in an array, it is generally calculated by dividing the size of the entire array by the size of the elements in the array. Therefore, the following macro may be defined as a macro for calculating the number of array elements. #define ARR_NUM(array) (sizeof(array)/sizeof(array)) If the pointer size is 3 bytes, the total array size includes 1 byte padding for each element, so the number of elements is calculated incorrectly. In this case, you need to change it as follows. #define ARR_NUM(array) (sizeof(array)/(sizeof(array) == 3 ? 4 : sizeof(array)))