XC8怎么定义大数组?超过256
XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256定义全局或者静态数据都可以超过Bank(256个大小)。如果是局部数据不能超过bank。 ynwa 发表于 2022-8-15 16:53
定义全局或者静态数据都可以超过Bank(256个大小)。如果是局部数据不能超过bank。 ...
居然还是这样的 我以前都不知道呢 局部变量只能在Bank内部吗 这样的话会不会太浪费资源 如果是全局或者静态 那就太耗费资源了 所有单片机的bank都是256个字节大小的吗 可以使用链表吗 这会不会浪费 因为每个bank的大小是256Bytes, 所以数组大小有限制, 比如: char, int试过简单的链表, xc8 还是能用的
可以参考:
struct CharArray {
char Char; /* 253 bytes */
struct CharArray* next; /* 3 bytes */
};
struct IntArray {
int Int; /* 252 bytes */
uint8_t size; /* 1 bytes */
struct IntArray* next; /* 3 bytes */
};
struct VirtualTable {
void* Virtual; /* 252 bytes */
uint8_t size; /* 1 bytes */
struct VirtualTable* next; /* 3 bytes */
};
如果指针玩的好的, 可以试试下面的这种链表或者虚表, 但是没测试过:
// char* Char size smaller than 256
struct CharPArray {
char* Char; /* 3 bytes */
uint8_t size; /* 1 bytes */
struct CharPArray* next; /* 3 bytes */
}
// single char* Str size smaller than 256
struct CharString {
char* Str; /* 12 bytes */
uint8_t size; /* 4 bytes */
}
页:
[1]