Related to:
https://sourceforge.net/p/sdcc/feature-requests/291/
The initialization of local static variables is done by executing code in the GSINIT section which is less optimal than simply placing the data into a DATA section.
Correct code is generated so there is no bug here.
sdcc -v
3.5.4 #9295 (MINGW32)
main()
{
static unsigned char lp[4] = {0x01, 0x02, 0x03, 0x04};
}
sdcc -mz80 -S test.c
;; space set aside in ram for local static var "lp[4]"
.area _DATA
_main_lp_1_1:
.ds 4
;; the array is initialized by executing code in the CRT
.area _GSINIT
;sdcc.c:4: static unsigned char lp[4] = {0x01, 0x02, 0x03, 0x04};
ld hl,#_main_lp_1_1
ld (hl),#0x01
inc hl
ld (hl),#0x02
ld hl,#_main_lp_1_1 + 2
ld (hl),#0x03
ld hl,#_main_lp_1_1 + 3
ld (hl),#0x04
Isn't this a duplicate of RFE [#380]?
Philipp
Related
Feature Requests: #380
Last edit: Maarten Brock 2015-08-21