how to write code in a specific address using C?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to write code in a specific address using C?

Jump to solution
1,593 Views
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.

Labels (1)
Tags (1)
0 Kudos
1 Solution
555 Views
ffogg
Contributor II
thanks once more, it worked fine.

View solution in original post

0 Kudos
3 Replies
555 Views
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 Kudos
555 Views
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 Kudos
556 Views
ffogg
Contributor II
thanks once more, it worked fine.
0 Kudos