z88dk adds extra pop bc to functions..

If you like transforming your statements into code, this is the place for you

Moderator: Programming Moderators

Post Reply
User avatar
ckirby101
Posts: 73
Joined: Mon May 29, 2017 7:09 pm

z88dk adds extra pop bc to functions..

Post by ckirby101 » Sun Jan 14, 2018 1:23 pm

Started to notice a weird crash.. so started to investigate.. whats happening is z88Dk is adding extra pop BC instructions..

look at this c file function:

Code: Select all

//***************************************************************************************
// WaitForBOF
//***************************************************************************************
void __FASTCALL__ WaitForBOF(void)
{
#asm
WaitForBOF:
	ld	bc,0x243B
	ld	a,0x1f
	out	(c),a
	ld	bc,0x253B
	in	a,(c)
	cp	192
	jr	nz,WaitForBOF
#endasm

}
here's the compile tmp file:

Code: Select all

; Function WaitForBOF flags 0x00000208 __smallc __z88dk_fastcall 
; void WaitForBOF()
._WaitForBOF
	C_LINE	164,"utils.c"
;#asm
	C_LINE	165,"utils.c"
	C_LINE	165,"utils.c"
	C_LINE	167,"utils.c"
WaitForBOF:
	C_LINE	168,"utils.c"
	ld	bc,0x243B
	C_LINE	169,"utils.c"
	ld	a,0x1f
	C_LINE	170,"utils.c"
	out	(c),a
	C_LINE	171,"utils.c"
	ld	bc,0x253B
	C_LINE	172,"utils.c"
	in	a,(c)
	C_LINE	173,"utils.c"
	cp	192
	C_LINE	174,"utils.c"
	jr	nz,WaitForBOF
	C_LINE	175,"utils.c"
;}
	C_LINE	178,"utils.c"
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	ret
notice the weird extra Pop Bc instructions added to bottom???


this is my make file

zcc +zxn -m -clib=new -startup=31 racing.c utils.c Bank_00.c Bank_01.c Bank_03.c Bank_04.c Bank_06.c Bank_07.c -o build\racing -subtype=sna -create-app -no-cleanup --c-code-in-asm



any suggestions?? im stumped ...

User avatar
ckirby101
Posts: 73
Joined: Mon May 29, 2017 7:09 pm

Re: z88dk adds extra pop bc to functions..

Post by ckirby101 » Sun Jan 14, 2018 1:29 pm

oddly if i move that function into a different file it compiles correctly..

Code: Select all

; Function WaitForBOF2 flags 0x00000208 __smallc __z88dk_fastcall 
; void WaitForBOF2()
._WaitForBOF2
	C_LINE	106,"racing.c"
;#asm
	C_LINE	107,"racing.c"
	C_LINE	107,"racing.c"
	C_LINE	109,"racing.c"
WaitForBOF:
	C_LINE	110,"racing.c"
	ld	bc,0x243B
	C_LINE	111,"racing.c"
	ld	a,0x1f
	C_LINE	112,"racing.c"
	out	(c),a
	C_LINE	113,"racing.c"
	ld	bc,0x253B
	C_LINE	114,"racing.c"
	in	a,(c)
	C_LINE	115,"racing.c"
	cp	192
	C_LINE	116,"racing.c"
	jr	nz,WaitForBOF
	C_LINE	117,"racing.c"
;}
	C_LINE	120,"racing.c"
	ret

User avatar
ckirby101
Posts: 73
Joined: Mon May 29, 2017 7:09 pm

Re: z88dk adds extra pop bc to functions..

Post by ckirby101 » Sun Jan 14, 2018 4:03 pm

Looks like its caused by a state not getting reset upon compiling a new function..

reported

https://github.com/z88dk/z88dk/issues/574

User avatar
ckirby101
Posts: 73
Joined: Mon May 29, 2017 7:09 pm

Re: z88dk adds extra pop bc to functions..

Post by ckirby101 » Mon Jan 15, 2018 7:42 am

bug in z88dk has now been fixed..

Post Reply