Keil C51 STARTING A FUNCTION AT A SPECIFIC ADDRESS 編譯函數到指定位址

QUESTION

How do I start my functions at a specific place in memory?

ANSWER

All you have to do is look at your map file to see what segment name your function is given. For example, if your segment name is ?PR?FUNCTION?TEXT2 then, in µVision2, go to the BL51 locate tab, under options for target. In the CODE input line, add ?PR?FUNCTION?TEXT2 (100h). This locates that function at address 100h. Rebuild your project and check your map file. You will notice that your function starts at address 0x100.

資料轉載 : http://www.keil.com/support/docs/1408.htm

keil c51 locating program start address 如何修改 keil c51 程式編譯的起始位址

QUESTION

How do I start my C51 program at an address other than 0000h?

ANSWER

There are three steps to relocate your C51 program to start at a different offset. Specifically, you must do the following:

  1. Change the startup code to begin at the target reset vector.
  2. Locate the interrupt vectors at their new location.
  3. Specify the code area for the linker.

The following instructions assume you want to relocate your program to 8000h.

To change the startup code…

  1. Copy the STARTUP.A51 file from the \C51\LIB directory to your project directory.
  2. Search for CSEG AT 0000h and change it to CSEG AT 8000h.
  3. Add the startup code to your project.

To locate the interrupt vectors…

In µVision…

  1. Select the C51 Compiler command from the Options menu.
  2. Select the Object tab.
  3. Change the Offset for the interrupt vectors to 0x8000.

In µVision Version 2…

  1. Select Options for Target from the Project menu.
  2. Select the C51 tab.
  3. Check the Interrupt vectors at address checkbox.
  4. Change the offset to 0x8000.

To specify the code area for the linker…

In µVision Version 1…

  1. Select the BL51 Code Banking Linker command from the Options menu.
  2. Select the Size/Location tab.
  3. Change the Code segment location to 8000 (note that 0x and H are not required here).

In µVision Version 2…

  1. Select Options for Target from the Project menu.
  2. Select the Target tab.
  3. Change the EPROM starting address to 0x8000.

Or, if you don’t use the memory layout dialog…

  1. Select Options for Target from the Project menu.
  2. Select the L51 Locate tab.
  3. Uncheck the Use Memory Layout from Target Dialog checkbox.
  4. Enter the base address of 0x8000 for the Code space.

Finally

Rebuild your program and check the M51 map file to make sure your program begins at the appropriate address.

 

資料轉載 :  http://www.keil.com/support/docs/189.htm