Documented changes to .CPU and new .MACPACK cpu
git-svn-id: svn://svn.cc65.org/cc65/trunk@2510 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -413,7 +413,7 @@ already known, after evaluating the left hand side, the right hand side is
|
|||||||
not evaluated.
|
not evaluated.
|
||||||
|
|
||||||
|
|
||||||
<sect1>Available operators<p>
|
<sect1>Available operators<label id="operators"><p>
|
||||||
|
|
||||||
Available operators sorted by precedence:
|
Available operators sorted by precedence:
|
||||||
|
|
||||||
@@ -950,15 +950,10 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
<sect1><tt>.CPU</tt><label id=".CPU"><p>
|
<sect1><tt>.CPU</tt><label id=".CPU"><p>
|
||||||
|
|
||||||
Reading this pseudo variable will give a constant integer value that
|
Reading this pseudo variable will give a constant integer value that
|
||||||
tells which instruction set is currently enabled. Possible values are:
|
tells which CPU is currently enabled. It can also tell which instruction
|
||||||
|
set the CPU is able to translate. The value read from the pseudo variable
|
||||||
<tscreen><verb>
|
should be further examined by using one of the constants defined by the
|
||||||
0 --> 6502
|
"cpu" macro package (see <tt/<ref id=".MACPACK" name=".MACPACK">/).
|
||||||
1 --> 65SC02
|
|
||||||
2 --> 65C02
|
|
||||||
3 --> 65SC816
|
|
||||||
4 --> SunPlus SPC
|
|
||||||
</verb></tscreen>
|
|
||||||
|
|
||||||
It may be used to replace the .IFPxx pseudo instructions or to construct
|
It may be used to replace the .IFPxx pseudo instructions or to construct
|
||||||
even more complex expressions.
|
even more complex expressions.
|
||||||
@@ -966,15 +961,16 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
.if (.cpu = 0) .or (.cpu = 1) .or (.cpu = 2)
|
.macpack cpu
|
||||||
txa
|
.if (.cpu .bitand CPU_ISET_65816)
|
||||||
pha
|
phx
|
||||||
tya
|
phy
|
||||||
pha
|
.else
|
||||||
.else
|
txa
|
||||||
phx
|
pha
|
||||||
phy
|
tya
|
||||||
.endif
|
pha
|
||||||
|
.endif
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
@@ -1744,6 +1740,8 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
generic Defines generic macros like add and sub.
|
generic Defines generic macros like add and sub.
|
||||||
longbranch Defines conditional long jump macros.
|
longbranch Defines conditional long jump macros.
|
||||||
|
cbm Defines the scrcode macro
|
||||||
|
cpu Defines constants for the .CPU variable
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
Including a macro package twice, or including a macro package that
|
Including a macro package twice, or including a macro package that
|
||||||
@@ -2826,6 +2824,66 @@ The package defines the following macros:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect1><tt>.MACPACK cbm</tt><p>
|
||||||
|
|
||||||
|
The cbm macro package will define a macro named <tt/scrcode/. It takes a
|
||||||
|
string as argument and places this string into memory translated into screen
|
||||||
|
codes.
|
||||||
|
|
||||||
|
|
||||||
|
<sect1><tt>.MACPACK cpu</tt><p>
|
||||||
|
|
||||||
|
This macro package does not define any macros but constants used to examine
|
||||||
|
the value read from the <tt/<ref id=".CPU" name=".CPU">/ pseudo variable. For
|
||||||
|
each supported CPU a constant similar to
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
CPU_6502
|
||||||
|
CPU_65SC02
|
||||||
|
CPU_65C02
|
||||||
|
CPU_65816
|
||||||
|
CPU_SUNPLUS
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
is defined. These constants may be used to determine the exact type of the
|
||||||
|
currently enabled CPU. In addition to that, for each CPU instruction set,
|
||||||
|
another constant is defined:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
CPU_ISET_6502
|
||||||
|
CPU_ISET_65SC02
|
||||||
|
CPU_ISET_65C02
|
||||||
|
CPU_ISET_65816
|
||||||
|
CPU_ISET_SUNPLUS
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
The value read from the <tt/<ref id=".CPU" name=".CPU">/ pseudo variable may
|
||||||
|
be checked with <tt/<ref id="operators" name=".BITAND">/ to determine if the
|
||||||
|
currently enabled CPU supports a specific instruction set. For example the
|
||||||
|
65C02 supports all instructions of the 65SC02 CPU, so it has the
|
||||||
|
<tt/CPU_ISET_65SC02/ bit set in addition to its native <tt/CPU_ISET_65C02/
|
||||||
|
bit. Using
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
|
lda (sp)
|
||||||
|
.else
|
||||||
|
ldy #$00
|
||||||
|
lda (sp),y
|
||||||
|
.endif
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
it is possible to determine if the
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
lda (sp)
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
instruction is supported, which is the case for the 65SC02, 65C02 and 65816
|
||||||
|
CPUs (the latter two are upwards compatible to the 65SC02).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>Module constructors/destructors<label id="condes"><p>
|
<sect>Module constructors/destructors<label id="condes"><p>
|
||||||
|
|
||||||
<em>Note:</em> This section applies mostly to C programs, so the explanation
|
<em>Note:</em> This section applies mostly to C programs, so the explanation
|
||||||
|
|||||||
Reference in New Issue
Block a user