As discussed here: https://sourceforge.net/p/sdcc/discussion/1865/thread/0a43dc12bf/ I have trouble using the constseg option with z80 version of SDCC.
Here is the sample code (ssdcc.c):
#include <stdlib.h>
#include <stdio.h>
const wchar_t array[] = L"";
const int i = 7;
const unsigned char TestByte = 1;
const unsigned short TestWord = 0xFFFF;
const char TestString[] = "ABCD";
void main()
{
printf("Hello!");
}
Here is the build command line:
sdcc -mz80 s_sdcc.c --constseg CONSTTEST
Tested with Windows version of:
And here is the resulting .asm file:
[...]
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area _CODE
;s_sdcc.c:11: void main()
; ---------------------------------
; Function main
; ---------------------------------
_main::
;s_sdcc.c:13: printf("Hello!");
ld hl, #___str_0
push hl
call _printf
pop af
;s_sdcc.c:14: }
ret
_array:
.byte 0,0,0,0
_i:
.dw #0x0007
_TestByte:
.db #0x01 ; 1
_TestWord:
.dw #0xffff
_TestString:
.ascii "ABCD"
.db 0x00
.area _CONSTTEST
___str_0:
.ascii "Hello!"
.db 0x00
.area _CODE
.area _CODE
.area _CONSTTEST
.area _INITIALIZER
.area _CABS (ABS)
Expected: All const data to be under _CONSTTEST segment.
Problem: Only "Hello!" data are in the right segment. All other const data are under _CODE segment.
Note: Both --constseg command line parameter and constseg pragma have the same problem.
I cannot reproduce the issue using SDCC from current svn. All the const data is in
_CONSTSTESTfor me. Please reopen, if you can still reproduce the bug using current SDCC from svn trunk or rabbit branch.