I have compiled the following code (this is the minimum that reproduces the error - I stumbled upon it while writing the Arkos Tracker examples):
Code: Select all
// zcc +msx -subtype=rom -m main.c -create-app -o main
#include <intrinsic.h>
void main( void ) {
intrinsic_halt();
intrinsic_di();
intrinsic_ei();
// do nothing
}
I have checked by several means that the code above does _not_ generate the DI; HALT sequence (it's the other way around, but then that's perfectly valid code). I have dumped the ROM binary and checked the opcode values (0x76, 0xF3, 0xFB). I have disassembled the binary with z88dk-dis, I have checked the assembler generated in the comments in the .LIS file. EVerything seems OK and the DI; HALT sequence does not show in the code.
But then when disassemblying with z88dk-dis, I saw this:
Code: Select all
$ z88dk-dis -mz80 -x main.map -o 0x4000 -s 0x4010 main.rom
start:
di ;[4010] f3
ld sp,($fc4a) ;[4011] ed 7b 4a fc
ei ;[4015] fb
call $0138 ;[4016] cd 38 01
(...)
call $0024 ;[4034] cd 24 00
call crt0_init_bss ;[4037] cd 42 40
call _main ;[403a] cd 6f 40
cleanup:
di ;[403d] f3
halt ;[403e] 76
jr cleanup ;[403f] 18 fc
(...)
But according to my code, main() is never returning, so why is the cleanup code being executed?