hth313 wrote:
If you have a bare metal system with ROM and RAM then you have to separate code from modifiable data. If you load a program into a RAM based system by some kernel or operating system based environment you can place things more or less how you see fit.
Calyspi is based on ROM/RAM separation, but can do the other kind too (--hosted given to the linker). The main difference between the two is that a hosted system loads initialized data into place, while on an embedded/ROM based system such data initializers are placed in ROM and copied to RAM during C startup, which is done automatically.
To have a lot of flexibility Calypsi uses many sections with different properties. They cannot just be stack after each others with no regard of memory type for reasons outlined above. There are also sections based on different address spaces, e.g. bank 00 memory, far semantics, as well as some others.
is the need to specify if it's in ROM or RAM because the startup code is not available to the user? otherwise you could just comment out the data copying code and re-assemble it before compiling and it would be functionally identical.
you would just need to trust that the user knows the hardware it's compiling for.
but thanks for the commandline parameter, that seems to have worked. it stopped complaining about the sections.
hth313 wrote:
With the current release you can do more placement without specifying where sections are placed as the linker is fairly capable of figuring it out and generate a suitable placement for you. You still need to tell what memory ranges you have and the kind of memory it is (this is the type attribute, which can be ANY, so everything goes, if that is what you want). See section 6.1.2 Placing sectons in memory.
hth313 wrote:
If you want your own sections you can just create them using a #pragma or with the .section directive in the assembler. They will end up with the linker who will tell you that need to mention them in the placement, by a diagnostic message.
oh i see, so i'll just do the cc65 way and have a seperate assembly/object file that contains nothing but the header for the output file.
but what about the data i mentioned that is needed for the header? what symbols do i need to import to know the size of the file, or where to jump to once everything is loaded into RAM?
hth313 wrote:
DP is fixed in the run-time. It will get set at startup and does not move. This allows for having a couple of pseudo registers and it can also act as a short address area (tiny) for frequently addressed static data.
You can move it as you see fit in your own assembly routines, but you need to restore it before you give control back.
The reasons I decided to make it fixed is that the 65816 already provide fast access to the stack. It also avoids code to adjust it back and forth while still having a couple of scratch locations in the DP area. Another reason is to avoid complexity that could arise in very deranged cases if you have a large stack frame (beyond 256 bytes) and need to use addressing modes only on DP and they happen to be out of range. I think the WDC compiler limits the stack frame to 256 bytes, so it cannot run into this problem.
It is a tradeoff. As mentioned, you get fast access static (tiny) data area which is not provided by WDC.
why would the DP not work with stack frames larger than 256 bytes? The DP doesn't wrap after 256 addresses so by placing it on the top of the stack and using the 16-bit index registers you can easily address beyond the top 256 bytes into the entire stack, and the rest of Bank 0.
you can basically see the 16-bit index registers as the base address, and the 1 byte operand as the offset to that address.
it's functionally similar to the stack addressing mode, but without the 256 byte limit as the stack addressing mode only uses a single byte as offset instead of an index register.
on a different note i still can't get anything to compile even with the --hosted commandline parameter, here the error:
Code:
symbol '__program_start' referenced from section 'reset' at offset 000000 in cstartup.o: value 147945 is out of range, allowed range is -32768 to 65535
and the scm file:
Code:
(define memories'(
(memory DirectPage (address (#x000100 . #x0001FF))
(section (registers ztiny)))
(memory LoRAM (address (#x000200 . #x00EFFF))
(section stack heap))
(memory IO (address (#x00F000 . #x00F0FF)))
(memory VRAM (address (#x010000 . #x01FFFF)))
(memory HiRAM (address (#x020000 . #x08FFFF))
(section reset data_init_table farcode code farswitch far huge cfar chuge zfar zhuge cstack))
(block cstack (size #x004000))
(block stack (size #x004000))
(block heap (size #x004000))
(base-address _DirectPageStart DirectPage 0)
(base-address _NearBaseAddress LoRAM 0)
))
the commands were just:
Code:
CC65816 --64bit-doubles --code-model large --data-model large -I Include -O2 -l -o Temp\test.o test.c
LN65816 --hosted Config\SBC_816.scm clib-lc-ld-double64.a Temp\test.o
(no header yet i want some thing working first)