Add a new .cap pseudo function to the assembler that allows to check for

certain capabilities of the CPU or target system.
This commit is contained in:
Kugel Fuhr
2025-06-30 21:37:43 +02:00
parent a4a24280f2
commit d4e57278c6
12 changed files with 434 additions and 6 deletions

View File

@@ -1423,6 +1423,10 @@ writable.
</verb></tscreen>
See also: <tt><ref id=".CAP" name=".CAP"></tt>
<sect1><tt>.ISIZE</tt><label id=".ISIZE"><p>
Reading this pseudo variable will return the current size of the Index
@@ -1594,6 +1598,56 @@ either a string or an expression value.
<sect1><tt>.CAP, .CAPABILITY</tt><label id=".CAP"><p>
Builtin function. The function allows to check for capabilities of the
currently selected CPU or target system. It must be called with a comma
separated list of identifiers and returns non zero if all of the given
capabilities are available. Otherwise it returns zero.
Existing capabilities are:
<descrip>
<tag><tt>CPU_HAS_BRA8</tt></tag>
Checks for the availability of a short (8 bit) branch.
<tag><tt>CPU_HAS_INA</tt></tag>
Checks for the availability of accu inc/dec instructions.
<tag><tt>CPU_HAS_PUSHXY</tt></tag>
Checks for the capability to push and pop the X and Y registers.
<tag><tt>CPU_HAS_ZPIND</tt></tag>
Checks for the availability of the "zeropage indirect" addressing mode.
<tag><tt>CPU_HAS_STZ</tt></tag>
Checks for the availability of the "store zero" instruction.
</descrip>
Case is ignored when checking the identifiers. The <tt/.cap/ function is
easier to use than checking <tt/.cpu/ and requires no intimate knowledge
of all instruction sets. For more detailed checking <tt/.cpu/ is still
available.
Example:
<tscreen><verb>
.if .cap(CPU_HAS_BRA, CPU_HAS_PUSHXY)
phx
bra L1
.else
txa
pha
jmp L1
.endif
</verb></tscreen>
See also: <tt><ref id=".CPU" name=".CPU"></tt>
<sect1><tt>.CONCAT</tt><label id=".CONCAT"><p>
Builtin string function. The function allows to concatenate a list of string