asar icon indicating copy to clipboard operation
asar copied to clipboard

[feature request] Allow math for bit index in spc700 bit instructions

Open exodustx0 opened this issue 5 months ago • 0 comments

arch spc700
norom
org 0

set $12.3+4

error: (Eunknown_command): Unknown command. [set $12.3+4]

However, a workaround exists:

arch spc700
norom
org 0

!foo #= 3+4
set $12.!foo

E2 12

bitmatch, the function that matches the bit index in bit instructions, currently requires the bit index to be constant; my request is for bitmatch to accept a math expression for the bit index. This would make bit instructions more usable in macros, or at least less ugly, with the intermediary define. The trivial workaround might suggest that this feature request isn't particularly pressing, but I will note that finding the necessity of the workaround was not trivial.

As an example, my use case: I keep bitflag enums in defines, both masks and bit indices, and I have the following to make use of them:

MACRO	INTERNAL__BranchOnEnumBitflag(addr, name, dst, op)
	%		INTERNAL__AssertEnumBitflag(<name>)

	!INTERNAL__bit	#= !<name>_Shift&7 ; intermediary define for doing the math in
	<op>	(<addr>)+(!<name>_Shift>>3).!INTERNAL__bit, <dst>
	UNDEF	"INTERNAL__bit"
ENDMACRO

MACRO	BranchIfEnumBitflagSet(addr, name, dst)
	%		INTERNAL__BranchOnEnumBitflag(<addr>, <name>, <dst>, BBS)
ENDMACRO

MACRO	BranchIfEnumBitflagClear(addr, name, dst)
	%		INTERNAL__BranchOnEnumBitflag(<addr>, <name>, <dst>, BBC)
ENDMACRO

exodustx0 avatar Jul 24 '25 12:07 exodustx0