mori0091/libmsx

global / static variables with initializer seems broken

mori0091 opened this issue · 0 comments

Describe the bug
When making 32KiB rom, initialization of global / static variables in startup routine (crt0) may fail.
Because the initialization routine is called before changing the slot of page 2 to ROM.

To Reproduce

  • Use lib/32k.4000/crt0.rel
  • Set ADDR_CODE to something large value so that the INITIALIZER (and/or its related routine / data) are placed on page 2. (see the following Makefile fragment)
# include ${LIBMSX_HOME}/mk/32k.4000.mk
IMAGE_SIZE = 32768
ADDR_HEAD = 0x4000
ADDR_CODE = 0x70f4  # set ADDR_CODE to something large value
ADDR_DATA = 0xc000

CRT0 = ${LIBMSX_HOME}/lib/32k.4000/crt0.rel
  • Then check if all global / static variables are correctly initialized.
  • Or use the sound driver. (If initialization of global / static variables failed, the sound driver does not works correctly)

Expected behavior
Both of 16KiB and 32KiB ROM image, initialization routine shall works correctly.

Development environment (please complete the following information):

  • OS and version: Ubuntu 20.04 on WSL2
  • Compiler and version: sdcc 3.8.0
  • Emulator and version: openMSX 17.0
  • BIOS and version: C-BIOS_MSX2+_JP 0.29, or else

Target Platform

  • MSX
  • MSX2
  • MSX2+
  • MSXturboR

Additional context