gpt4 book ai didi

embedded - SDCC 代码银行

转载 作者:行者123 更新时间:2023-12-02 06:28:05 24 4
gpt4 key购买 nike

我需要在 8051 微 Controller 中使用代码库来容纳所有代码。 SDCC 表示支持,但我在链接步骤中遇到了问题。

我有一个包含 3 个文件的测试项目:main.c、func1.c 和bank.asm。主函数应该调用 func1(),然后进入 while 循环。但 func1() 位于不同的代码库中。

// main.c
int func1(void) banked;

void main()
{
int i = func1();

while(i)
{
}
}

// func1.c
#pragma codeseg BANK1

int func1(void) {
return 99; }

//bank.asm
.area HOME (CODE)
.area GSINIT0 (CODE)
.area GSINIT1 (CODE)
.area GSINIT2 (CODE)
.area GSINIT3 (CODE)
.area GSINIT4 (CODE)
.area GSINIT5 (CODE)
.area GSINIT (CODE)
.area GSFINAL (CODE)
.area CSEG (CODE)
.area HOME (CODE)

__sdcc_banked_call::
ret ;make the call

__sdcc_banked_ret::
ret ;return to caller

我有一个构建批处理文件来编译所有内容并将其链接在一起。

sdcc -c func1.c
sdcc -c main.c
asx8051 -ol bank.asm
sdcc "-Wl -b BANK1=0x018000" main.rel func1.rel bank.rel

我收到此链接器错误:

?ASlink-Error-Insufficient ROM/EPROM/FLASH memory.

如何获得此链接?

最佳答案

来自 SDCC 手册:

Segments may be placed anywhere in the 4 meg address space using the usual --*-loc options. Note that if any segments are located above 64K, the -r flag must be passed to the linker to generate the proper segment relocations, and the Intel HEX output format must be used. The -r flag can be passed to the linker by using the option -Wl-r on the SDCC command line. However, currently the linker can not handle code segments > 64k.

因此,将 -Wl-r 添加到链接器行。

关于embedded - SDCC 代码银行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1606926/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com