Make the CPU_xxx constants from cpu.mac internal to the assembler and replace
cpu.mac by a file that just emits a warning when used.
This commit is contained in:
@@ -1,38 +1,4 @@
|
||||
; CPU bitmask constants (make sure this matches src/common/cpu.h)
|
||||
|
||||
CPU_ISET_NONE = $0001
|
||||
CPU_ISET_6502 = $0002
|
||||
CPU_ISET_6502X = $0004
|
||||
CPU_ISET_6502DTV = $0008
|
||||
CPU_ISET_65SC02 = $0010
|
||||
CPU_ISET_65C02 = $0020 ; Rockwell extensions
|
||||
CPU_ISET_65816 = $0040
|
||||
CPU_ISET_SWEET16 = $0080
|
||||
CPU_ISET_HUC6280 = $0100
|
||||
CPU_ISET_M740 = $0200
|
||||
CPU_ISET_4510 = $0400
|
||||
CPU_ISET_45GS02 = $0800
|
||||
CPU_ISET_W65C02 = $1000 ; WDC extensions
|
||||
CPU_ISET_65CE02 = $2000 ; CSG extensions
|
||||
|
||||
; CPU capabilities
|
||||
; make sure to only combine the instruction sets that are 100% compatible
|
||||
CPU_NONE = CPU_ISET_NONE
|
||||
CPU_6502 = CPU_ISET_6502
|
||||
CPU_6502X = CPU_ISET_6502X | CPU_ISET_6502
|
||||
CPU_6502DTV = CPU_ISET_6502DTV | CPU_ISET_6502
|
||||
CPU_65SC02 = CPU_ISET_65SC02 | CPU_ISET_6502
|
||||
CPU_65C02 = CPU_ISET_65C02 | CPU_ISET_6502 | CPU_ISET_65SC02
|
||||
CPU_W65C02 = CPU_ISET_W65C02 | CPU_ISET_6502 | CPU_ISET_65SC02 | CPU_ISET_65C02
|
||||
|
||||
; FIXME: CPU_ISET_65SC02 does not apply to the following, because the zp-indirect
|
||||
; addressing was replaced with zp-indirect,z-indexed in 652SCE02
|
||||
|
||||
CPU_HUC6280 = CPU_ISET_HUC6280 | CPU_ISET_6502 | CPU_ISET_65C02
|
||||
CPU_4510 = CPU_ISET_4510 | CPU_ISET_6502 | CPU_ISET_65C02 | CPU_ISET_65CE02
|
||||
CPU_45GS02 = CPU_ISET_45GS02 | CPU_ISET_6502 | CPU_ISET_65C02 | CPU_ISET_65CE02 | CPU_ISET_4510
|
||||
CPU_M740 = CPU_ISET_M740 | CPU_ISET_6502
|
||||
CPU_65CE02 = CPU_ISET_65CE02 | CPU_ISET_6502 | CPU_ISET_65C02
|
||||
|
||||
CPU_65816 = CPU_ISET_65816 | CPU_ISET_6502 | CPU_ISET_65SC02
|
||||
CPU_SWEET16 = CPU_ISET_SWEET16
|
||||
; This file is no longer needed as the symbols that were defined here are now
|
||||
; internal symbols generated by the assembler. It is kept to avoid breaking
|
||||
; old sources.
|
||||
.warning "'.macpack cpu' is no longer required"
|
||||
|
||||
134
doc/ca65.sgml
134
doc/ca65.sgml
@@ -1401,16 +1401,76 @@ writable.
|
||||
Reading this pseudo variable will give a constant integer value that
|
||||
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
|
||||
should be further examined by using one of the constants defined by the
|
||||
"cpu" macro package (see <tt/<ref id=".MACPACK" name=".MACPACK">/).
|
||||
should be further examined by using one of the following constants:
|
||||
|
||||
It may be used to replace the .IFPxx pseudo instructions or to construct
|
||||
even more complex expressions.
|
||||
<tscreen><verb>
|
||||
CPU_6502
|
||||
CPU_65SC02
|
||||
CPU_65C02
|
||||
CPU_65816
|
||||
CPU_SWEET16
|
||||
CPU_HUC6280
|
||||
CPU_4510
|
||||
CPU_45GS02
|
||||
CPU_6502DTV
|
||||
CPU_M740
|
||||
</verb></tscreen>
|
||||
|
||||
Above 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_SWEET16
|
||||
CPU_ISET_HUC6280
|
||||
CPU_ISET_4510
|
||||
CPU_ISET_45GS02
|
||||
CPU_ISET_6502DTV
|
||||
CPU_ISET_M740
|
||||
</verb></tscreen>
|
||||
|
||||
<!-- Sorry but explaining these with the changes from #2751 is too cringy for
|
||||
me - must be done by someone else. The remainder is from the old
|
||||
".macpack cpu" section"
|
||||
|
||||
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 (c_sp)
|
||||
.else
|
||||
ldy #$00
|
||||
lda (c_sp),y
|
||||
.endif
|
||||
</verb></tscreen>
|
||||
|
||||
it is possible to determine if the
|
||||
|
||||
<tscreen><verb>
|
||||
lda (c_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).
|
||||
|
||||
see section <ref id="6502-mode" name="6502 format"> and following.
|
||||
-->
|
||||
|
||||
<tt/.CPU/ may be used to replace the .IFPxx pseudo instructions or to
|
||||
construct even more complex expressions.
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.macpack cpu
|
||||
.if (.cpu .bitand CPU_ISET_65816)
|
||||
phx
|
||||
phy
|
||||
@@ -1422,7 +1482,6 @@ writable.
|
||||
.endif
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
See also: <tt><ref id=".CAP" name=".CAP"></tt>
|
||||
|
||||
|
||||
@@ -5042,69 +5101,6 @@ This macro package defines 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_SWEET16
|
||||
CPU_HUC6280
|
||||
CPU_4510
|
||||
CPU_45GS02
|
||||
CPU_6502DTV
|
||||
CPU_M740
|
||||
</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_SWEET16
|
||||
CPU_ISET_HUC6280
|
||||
CPU_ISET_4510
|
||||
CPU_ISET_45GS02
|
||||
CPU_ISET_6502DTV
|
||||
CPU_ISET_M740
|
||||
</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 (c_sp)
|
||||
.else
|
||||
ldy #$00
|
||||
lda (c_sp),y
|
||||
.endif
|
||||
</verb></tscreen>
|
||||
|
||||
it is possible to determine if the
|
||||
|
||||
<tscreen><verb>
|
||||
lda (c_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).
|
||||
|
||||
see section <ref id="6502-mode" name="6502 format"> and following.
|
||||
|
||||
<sect1><tt>.MACPACK module</tt><p>
|
||||
|
||||
This macro package defines a macro named <tt/module_header/. It takes an
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
.include "zeropage.inc"
|
||||
.include "apple2.inc"
|
||||
|
||||
.macpack cpu
|
||||
|
||||
.segment "ONCE"
|
||||
|
||||
initconio:
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
.export _lseek
|
||||
.import popax, popptr1
|
||||
.macpack cpu
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "errno.inc"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
.include "ser-error.inc"
|
||||
|
||||
.macpack module
|
||||
.macpack cpu
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
.export _strlen, _strlen_ptr4
|
||||
.importzp ptr4
|
||||
.macpack cpu
|
||||
|
||||
_strlen:
|
||||
sta ptr4 ; Save s
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
.import __MAIN_START__
|
||||
.import startup
|
||||
|
||||
.macpack cpu
|
||||
|
||||
.segment "EXEHDR"
|
||||
|
||||
.byte $73, $69, $6D, $36, $35 ; 'sim65'
|
||||
|
||||
@@ -192,6 +192,53 @@ static void CBMSystem (const char* Sys)
|
||||
|
||||
|
||||
|
||||
static void DefineCpuSymbols (void)
|
||||
/* Define all the symbols to evaluate .cpu. These were previously in cpu.mac. */
|
||||
{
|
||||
NewSymbol ("CPU_ISET_NONE", CPU_ISET_NONE);
|
||||
NewSymbol ("CPU_ISET_6502", CPU_ISET_6502);
|
||||
NewSymbol ("CPU_ISET_6502X", CPU_ISET_6502X);
|
||||
NewSymbol ("CPU_ISET_6502DTV", CPU_ISET_6502DTV);
|
||||
NewSymbol ("CPU_ISET_65SC02", CPU_ISET_65SC02);
|
||||
NewSymbol ("CPU_ISET_65C02", CPU_ISET_65C02);
|
||||
NewSymbol ("CPU_ISET_65816", CPU_ISET_65816);
|
||||
NewSymbol ("CPU_ISET_SWEET16", CPU_ISET_SWEET16);
|
||||
NewSymbol ("CPU_ISET_HUC6280", CPU_ISET_HUC6280);
|
||||
NewSymbol ("CPU_ISET_M740", CPU_ISET_M740);
|
||||
NewSymbol ("CPU_ISET_4510", CPU_ISET_4510);
|
||||
NewSymbol ("CPU_ISET_45GS02", CPU_ISET_45GS02);
|
||||
NewSymbol ("CPU_ISET_W65C02", CPU_ISET_W65C02);
|
||||
NewSymbol ("CPU_ISET_65CE02", CPU_ISET_65CE02);
|
||||
|
||||
/* Additional ones from cpu.mac. Not sure how useful they are after the
|
||||
** changes from #2751.
|
||||
*/
|
||||
NewSymbol ("CPU_NONE", CPU_ISET_NONE);
|
||||
NewSymbol ("CPU_6502", CPU_ISET_6502);
|
||||
NewSymbol ("CPU_6502X", CPU_ISET_6502X | CPU_ISET_6502);
|
||||
NewSymbol ("CPU_6502DTV", CPU_ISET_6502DTV | CPU_ISET_6502);
|
||||
NewSymbol ("CPU_65SC02", CPU_ISET_65SC02 | CPU_ISET_6502);
|
||||
NewSymbol ("CPU_65C02", CPU_ISET_65C02 | CPU_ISET_6502 | CPU_ISET_65SC02);
|
||||
NewSymbol ("CPU_W65C02", CPU_ISET_W65C02 | CPU_ISET_6502 | CPU_ISET_65SC02 |
|
||||
CPU_ISET_65C02);
|
||||
|
||||
/* FIXME: CPU_ISET_65SC02 does not apply to the following, because the
|
||||
** zp-indirect addressing was replaced with zp-indirect,z-indexed in
|
||||
** 652SCE02
|
||||
*/
|
||||
NewSymbol ("CPU_HUC6280", CPU_ISET_HUC6280 | CPU_ISET_6502 | CPU_ISET_65C02);
|
||||
NewSymbol ("CPU_4510", CPU_ISET_4510 | CPU_ISET_6502 | CPU_ISET_65C02 |
|
||||
CPU_ISET_65CE02);
|
||||
NewSymbol ("CPU_45GS02", CPU_ISET_45GS02 | CPU_ISET_6502 | CPU_ISET_65C02 |
|
||||
CPU_ISET_65CE02 | CPU_ISET_4510);
|
||||
NewSymbol ("CPU_M740", CPU_ISET_M740 | CPU_ISET_6502);
|
||||
NewSymbol ("CPU_65CE02", CPU_ISET_65CE02 | CPU_ISET_6502 | CPU_ISET_65C02);
|
||||
NewSymbol ("CPU_65816", CPU_ISET_65816 | CPU_ISET_6502 | CPU_ISET_65SC02);
|
||||
NewSymbol ("CPU_SWEET16", CPU_ISET_SWEET16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void SetSys (const char* Sys)
|
||||
/* Define a target system */
|
||||
{
|
||||
@@ -363,6 +410,9 @@ static void SetSys (const char* Sys)
|
||||
|
||||
}
|
||||
|
||||
/* Define the symbols for evaluating .cpu */
|
||||
DefineCpuSymbols ();
|
||||
|
||||
/* Initialize the translation tables for the target system */
|
||||
TgtTranslateInit ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user