I can now set CRT_ORG_CODE to something lower than 0x8000 when building an SNA file but I have encountered another problem.
I'm trying to put my IM2 interrupt service routine at 0x6000 (257 bytes long filled with 0x61 bytes). Then I have an empty ISR at 0x6161 occupying three bytes and thus have room for the CRT_ORG_CODE at 0x6164. This works fine when building a TAP file. However, when building an SNA file and trying to run it in ZEsarUX or CSpect, it crashes. If I move CRT_ORG_CODE to 0x6200, the SNA file works. Is this because of a bug in z88dk or a limitation in the SNA format or is the memory right below 0x6200 used for some other purpose?
Here is a simple test program that demonstrates the problem (without any IM2 ISR). If CRT_ORG_CODE is set to 0x6164, the program crashes. However, if set to 0x6200 or higher it works.
Code: Select all
/*
* Build:
* zcc +zx -vn -O3 -startup=30 -clib=new -m test_sna.c -o test_sna -create-app -Cz"--sna"
*
* Run:
* CSpect.exe -zxnext -s7 -mmc=.\ test_sna.sna
*/
#include <input.h>
#include <stdio.h>
// CRT_ORG_CODE = 0x6164 doesn't work for snapshot
// images but, for example, 0x6200 works.
#pragma output CRT_ORG_CODE = 0x6164
//#pragma output CRT_ORG_CODE = 0x6200
#pragma output REGISTER_SP = 0
#pragma output CLIB_MALLOC_HEAP_SIZE = 0
#pragma output CLIB_STDIO_HEAP_SIZE = 0
#pragma output CLIB_FOPEN_MAX = -1
int main(void)
{
printf("Hello world!\n");
in_wait_key();
return 0;
}