渔夫的烟斗 发表于 2022-8-15 13:48

XC8怎么定义大数组?超过256

XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256XC8怎么定义大数组?超过256

ynwa 发表于 2022-8-15 16:53

定义全局或者静态数据都可以超过Bank(256个大小)。如果是局部数据不能超过bank。

tpgf 发表于 2022-9-7 12:05

ynwa 发表于 2022-8-15 16:53
定义全局或者静态数据都可以超过Bank(256个大小)。如果是局部数据不能超过bank。 ...

居然还是这样的 我以前都不知道呢

qcliu 发表于 2022-9-7 12:20

局部变量只能在Bank内部吗

drer 发表于 2022-9-7 13:23

这样的话会不会太浪费资源

coshi 发表于 2022-9-7 13:37

如果是全局或者静态 那就太耗费资源了

kxsi 发表于 2022-9-7 13:45

所有单片机的bank都是256个字节大小的吗

wiba 发表于 2022-9-7 14:10

可以使用链表吗

Stahan 发表于 2022-9-10 22:50

这会不会浪费

wutaosamuel 发表于 2022-9-26 11:46

因为每个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]
查看完整版本: XC8怎么定义大数组?超过256