Skip to content

added equzero (same as cmpzero but only outputs Zero flag)#755

Merged
ZERICO2005 merged 1 commit intomasterfrom
crt_equzero
Apr 5, 2026
Merged

added equzero (same as cmpzero but only outputs Zero flag)#755
ZERICO2005 merged 1 commit intomasterfrom
crt_equzero

Conversation

@ZERICO2005
Copy link
Copy Markdown
Contributor

@ZERICO2005 ZERICO2005 commented Mar 16, 2026

__*equzero is identical to __*cmpzero except that it only outputs to the Zero flag. Currently it just aliases __*cmpzero, but the intent is that it could maybe link to a smaller/faster routine.

__i48cmpzero:
; CC: 13 bytes
; Minimum  :  8F + 3R + 2
; arg == 0 : 11F + 3R + 3
; Maximum  : 14F + 3R + 3
	ex	de, hl
	add	hl, de
	or	a, a
	sbc	hl, de
	ex	de, hl
	ret	nz
	sbc	hl, de
	ret	p
	inc	e
	dec	de
	ret

; implementation 1
__i48equzero:
; CC: 9 bytes
; Minimum  :  6F + 3R + 2
; arg == 0 : 10F + 3R + 2
; Maximum  : 10F + 3R + 2
	add	hl, de
	or	a, a
	sbc	hl, de
	ret	nz
	sbc	hl, de
	add	hl, de
	ret

; implementation 2
__i48equzero:
; CC: 10 bytes
; Minimum  :  6F + 3R + 2
; arg == 0 : 11F + 3R + 2
; Maximum  : 11F + 3R + 2
	or	a, a
	sbc	hl, de
	add	hl, de
	ret	nz
	sbc	hl, hl
	adc	hl, de
	ret

@ZERICO2005 ZERICO2005 changed the title added equzero/cmpequ (same as cmpzero/cmpu but only outputs Zero flag) added equzero (same as cmpzero but only outputs Zero flag) Mar 31, 2026
@ZERICO2005 ZERICO2005 merged commit 1533db4 into master Apr 5, 2026
9 checks passed
@ZERICO2005 ZERICO2005 deleted the crt_equzero branch April 5, 2026 00:41
@ZERICO2005
Copy link
Copy Markdown
Contributor Author

yeah previously this commit also did have __*cmpequ as well with the same sort of idea of being __*cmpu but only outputting to the Z flag. But that is a much more niche optimization and likely not worth implementing into the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant