Menu ▾ ▴

#455 [z80] move init of local statics from GSINIT to DATA section

None
open
nobody
5
6 days ago
2015-08-21
alvin
No

Related to:
[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

Related

Bugs: #3015
Feature Requests: #1036
Feature Requests: #291
Wiki: z80

Discussion

  • Philipp Klaus Krause

    Isn't this a duplicate of RFE [#380]?

    Philipp

     

    Related

    Feature Requests: #380


    Last edit: Maarten Brock 2015-08-21
  • Maarten Brock

    Maarten Brock - 6 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,5 @@
     Related to:
    -https://sourceforge.net/p/sdcc/feature-requests/291/
    +[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.
    
    • Group: -->
     

    Related

    Feature Requests: #291


Log in to post a comment.