Skip to content

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

Draft
ZERICO2005 wants to merge 1 commit intomasterfrom
crt_equzero
Draft

added equzero/cmpequ (same as cmpzero/cmpu but only outputs Zero flag)#755
ZERICO2005 wants to merge 1 commit intomasterfrom
crt_equzero

Conversation

@ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Mar 16, 2026

__*equzero and __*cmpequ are identical to __*cmpzero and __*cmpu except that they only output to the Zero flag. Currently they just alias __*cmpzero and __*cmpu, but the intent is that they 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

__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

Pros:

  • No changes to the compiler are needed.
  • __*equzero and __*cmpequ give a more clear intent that only the zero flag is needed from the comparison.

Cons:

  • The carry flag is unknown when the two arguments are equal for __*cmpequ. Whereas the carry flag will be cleared when the two arguments are equal for __*cmpzero.

…of __*cmpzero/__*cmpu that only outputs the Zero flag
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