8051 initialisation code & --iram_size

  • alexander_holland

    I wanted to build some 8051 binaries which skip the initialisation of iRAM. If I set iRAM to be 256 (which is what I have) then the clearing of the iRAM takes over 1000 cycles and as I am doing ASIC gate level simulation that translates to 10's of minutes.

    I thought that I could use --iram_size1 to skip the initialisation. I tried it and yes it does produce code which does not erase iRAM. But it seems to have another effect. The 8051 code (when compiled with --iram_size1) tries to execute code from an invalid location (i.e. if my program code compiles to 128 bytes the program will attempt to read from address 129 on the ROM bus!)

    I thought I could modify the file crtclear.asm to comment out the clear routine. I understand that I should be able to assemble it using asx8051, compile and assemble my C code and then link the two together.

    Something like :
    bin/asx8051 crtclear.asm
    bin/sdcc -c --model-small -Isdcc/include -I./include my_program.c
    bin/aslink ???????

    Unfortunately this is where my knowledge of SDCC breaks down. I cannot get the linker to work.

    Any ideas?


  • Maarten Brock

    Maarten Brock - 2014-03-15

    There are several ways to skin this cat. First you could add an _sdcc_external_startup() function that returns 1. This will skip all initializations. Second you can let sdcc call the linker with "sdcc my_program.rel crtclear.rel". And finally you can also call aslink with the appropriate linker script as explained in the doc/sdas/asmlnk.txt.

    I have no idea why the program would want to read from address 129 on the ROM bus except when this is where the copy for xdata initialization is located. Look in the generated .map file what is there.



Log in to post a comment.