I'm getting an invalid instruction error when I run a program (in sz80) that I compile with sdcc -mz80.
Some background info.. I'm trying to get a python interpreter (tinypy) to run on small 8 bit chips like z80. I've had to heavily modify the code since it was created to run on gcc but sdcc doesn't allow some things that gcc does (like passing a struct by value) and the only way I have figured out is to pass by reference (via a pointer), etc. I would supply some code but still trying to track this down (and I"m not sure what is causing it). At this time, I'm not expecting anyone to "fix my code" but I'm just wanting it to be known that an invalid instruction is being generated. If someone is interested in my project it is located on github.com project:earney/tinypy
The command line args I'm using for each of the files is:
sdcc -mz80 --verbose -DSDCC -DDEBUG_LEVEL=0 --std-c99 --disable-warning 126 --opt-code-size -I/usr/sbin/share/sdcc/include -I. -I./tinypy -c tinypy/vmmain.c -o build/vmmain.rel
I created a breakpoint at 0xd000 and stepped through until I reach the invalid instruction at 0xd007.
Stop at 0x00d000: (104) Breakpoint
SZ-A-PNC Flags= 0x31 49 1 A= 0x30 48 0
00-1-001
BC= 0x4848 [BC]= 21 33 ! DE= 0xcc62 [DE]= 62 98 b HL= 0xcc85 [HL]= 85 133 .
IX= 0xfff0 [IX]= fc 252 . IY= 0x4eb6 [IY]= 16 22 . SP= 0xffff [SP]= 01 1 .
F? 0xd000 22 85 cc LD (#0xcc85),HL
F 0x00d000
Simulated 142864 ticks in 0.026752 sec, rate=0.482884
0> n
Stop at 0x00d003: (109)
SZ-A-PNC Flags= 0x31 49 1 A= 0x30 48 0
00-1-001
BC= 0x4848 [BC]= 21 33 ! DE= 0xcc62 [DE]= 62 98 b HL= 0xcc85 [HL]= 85 133 .
IX= 0xfff0 [IX]= fc 252 . IY= 0x4eb6 [IY]= 16 22 . SP= 0xffff [SP]= 01 1 .
? 0xd003 84 ADD A,H
F 0x00d003
0> n
Stop at 0x00d004: (109)
SZ-A-PNC Flags= 0xa0 160 . A= 0xfc 252 .
10-0-000
BC= 0x4848 [BC]= 21 33 ! DE= 0xcc62 [DE]= 62 98 b HL= 0xcc85 [HL]= 85 133 .
IX= 0xfff0 [IX]= fc 252 . IY= 0x4eb6 [IY]= 16 22 . SP= 0xffff [SP]= 01 1 .
? 0xd004 21 85 a3 LD HL,#0xa385
F 0x00d004
0> n
Stop at 0x00d007: (109)
SZ-A-PNC Flags= 0xa0 160 . A= 0xfc 252 .
10-0-000
BC= 0x4848 [BC]= 21 33 ! DE= 0xcc62 [DE]= 62 98 b HL= 0xa385 [HL]= 85 133 .
IX= 0xfff0 [IX]= fc 252 . IY= 0x4eb6 [IY]= 16 22 . SP= 0xffff [SP]= 01 1 .
? 0xd007 fd UNKNOWN/INVALID
F 0x00d007
0>
The next instruction after the invalid instruction is:
0> pc 0xd008
Warning: maybe not instruction at 0x00d008
? 0xd008 48 LD C,B
Any suggestions on how I can modify the args passed to sdcc to prevent this?
Thanks!
Billy
Have you looked at the .rst file to see what is supposed to be at 0xd007?
It could be that no invalid instructions are generated, but your program jumps into the middle of an instruction or into data.
Thank you.. I cannot find a .rst file, and I've looked in the manual and I cannot figure out how to make the linker output a .rst file when compiling multiple files. Do you know the command line argument I should be using?
Thanks!
Billy
Hi,
Can you provide the hex file, please.
Daniel