bootstrap.gb icon indicating copy to clipboard operation
bootstrap.gb copied to clipboard

FarCall bugs

Open dannye opened this issue 7 years ago • 0 comments

In this snippet from rst.asm:

FarCall_:
	ld  [wFarCallHold + 0], a
	put [wFarCallHold + 1], h
	put [wFarCallHold + 2], l

	[ ... ]

	ld hl, wFarCallHold + 1
	ld a, [hli]
	ld h, [hl]
	ld l, a

This ends up swapping h and l Could just put l before h

Also, at the end, this bit attempts to save the potential return value in a and/or f while pulling the rom bank off the stack, but leaves a hole in the stack:

	push af

	add sp, 2
	pop af ; hROMBank
	add sp, -4
	rst Bankswitch

	pop af
	ret

It needs an extra add sp, 2 at the end:

	push af

	add sp, 2
	pop af ; hROMBank
	add sp, -4
	rst Bankswitch

	pop af
	add sp, 2
	ret

dannye avatar Jan 06 '19 11:01 dannye