how to write code in a specific address using C?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to write code in a specific address using C?

跳至解决方案
1,839 次查看
ffogg
Contributor II

hello there,

 

i'm programming the MC9S08QG8 chip with Codewarrior v6.2 and using the C compiler.

 

I need to program a piece of program above address 0xF600 when the program begins

at address 0xE000 and ends at 0xE430 and now i must add some more routines starting

in 0xF600 (a little BIOS) any chance? And of course using 'C'

 

Thanks in advance.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
801 次查看
ffogg
Contributor II
thanks once more, it worked fine.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
801 次查看
ffogg
Contributor II

thanks mac, for your fast and well explained answer

tomorrow if everything is Ok i will try your solution.

I will comment you the final result.

 

Thanks again and have a good time.

0 项奖励
回复
801 次查看
bigmac
Specialist III

Hello, and welcome to the forum.

 

You would need to modify the PRM file for the project, to create a new segment starting at 0xF600.

 

NAMES END


SEGMENTS

    Z_RAM  =  READ_WRITE   0x0060 TO 0x00FF;
    RAM    =  READ_WRITE   0x0100 TO 0x025F;
    ROM    =  READ_ONLY    0xE000 TO 0xF5FF;

    HIROM  =  READ_ONLY    0xF600 TO 0xFFAD;

    ROM1   =  READ_ONLY    0xFFC0 TO 0xFFCF;
END

PLACEMENT

    _DATA_ZEROPAGE,

    MY_ZEROPAGE            INTO  Z_RAM;
    DEFAULT_RAM            INTO  RAM;

    _PRESTART,             /* startup code */
    STARTUP,               /* startup data structures */
    ROM_VAR,               /* constant variables */
    STRINGS,               /* string literals */
    VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
    DEFAULT_ROM,
    COPY                   INTO  ROM;

    BIOS_ROM               INTO  HIROM
END


STACKSIZE 0x50
VECTOR 0 _Startup

 

Then preceeding the functions required for the BIOS, you will need to use an appropriate #pragma so that the linker to places the code within the BIOS_ROM segment, rather than the DEFAULT_ROM segment.

 

Regards,

Mac

 

0 项奖励
回复
802 次查看
ffogg
Contributor II
thanks once more, it worked fine.
0 项奖励
回复