Merge pull request #2010 from bbbradsmith/ca65_brk_optional_signature

optional BRK signature on all 6502 CPUs, not just 65816
This commit is contained in:
Bob Andrews 2023-03-04 13:21:28 +01:00 committed by GitHub
commit b9cf6266e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 10 deletions

View File

@ -439,6 +439,15 @@ The assembler accepts
<tt><ref id=".P4510" name=".P4510"></tt> command was given).
</itemize>
On 6502-derived platforms the <tt/BRK/ instruction has an optional signature
byte. If omitted, the assembler will only produce only 1 byte.
<tscreen><verb>
brk ; 1-byte: $00
brk $34 ; 2-bytes: $00 $34
brk #$34 ; 2-bytes: $00 $34
</verb></tscreen>
<sect1>65816 mode<p>
@ -456,6 +465,17 @@ mnemonics:
<item><tt>TSA</tt> is an alias for <tt>TSC</tt>
</itemize>
The <tt/MVN/ and <tt/MVP/ instructions accept two different argument forms.
Either two bank bytes may be given with a <tt/#/ prefix,
or two far addresses whose high byte will be used.
<tscreen><verb>
mvn #^src, #^dst ; bank of src to bank of dst
mvn src, dst ; bank of src to bank of dst
mvp #$12, #$78 ; bank $12 to $78
mvp $123456, $789ABC ; bank $12 to $78
</verb></tscreen>
<sect1>6502X mode<label id="6502X-mode"><p>

View File

@ -181,7 +181,7 @@ static const struct {
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
@ -252,7 +252,7 @@ static const struct {
{ "BMI", 0x0020000, 0x30, 0, PutPCRel8 },
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
@ -342,7 +342,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x12, 0, PutPCRel8 }, /* DTV */
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
@ -418,7 +418,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
@ -510,7 +510,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
{ "CLC", 0x0000001, 0x18, 0, PutAll },
@ -622,7 +622,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BSR", 0x0040000, 0x63, 0, PutPCRel4510 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
@ -747,7 +747,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000005, 0x00, 6, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BRL", 0x0040000, 0x82, 0, PutPCRel16 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },
@ -756,7 +756,7 @@ static const struct {
{ "CLI", 0x0000001, 0x58, 0, PutAll },
{ "CLV", 0x0000001, 0xb8, 0, PutAll },
{ "CMP", 0x0b8f6fc, 0xc0, 0, PutAll },
{ "COP", 0x0000004, 0x02, 6, PutAll },
{ "COP", 0x0800005, 0x02, 6, PutAll },
{ "CPA", 0x0b8f6fc, 0xc0, 0, PutAll }, /* == CMP */
{ "CPX", 0x0c0000c, 0xe0, 1, PutAll },
{ "CPY", 0x0c0000c, 0xc0, 1, PutAll },
@ -833,7 +833,7 @@ static const struct {
{ "TYA", 0x0000001, 0x98, 0, PutAll },
{ "TYX", 0x0000001, 0xbb, 0, PutAll },
{ "WAI", 0x0000001, 0xcb, 0, PutAll },
{ "WDM", 0x0000004, 0x42, 6, PutAll },
{ "WDM", 0x0800004, 0x42, 6, PutAll },
{ "XBA", 0x0000001, 0xeb, 0, PutAll },
{ "XCE", 0x0000001, 0xfb, 0, PutAll }
}
@ -909,7 +909,7 @@ static const struct {
{ "BNE", 0x0020000, 0xd0, 0, PutPCRel8 },
{ "BPL", 0x0020000, 0x10, 0, PutPCRel8 },
{ "BRA", 0x0020000, 0x80, 0, PutPCRel8 },
{ "BRK", 0x0000001, 0x00, 0, PutAll },
{ "BRK", 0x0800005, 0x00, 6, PutAll },
{ "BSR", 0x0020000, 0x44, 0, PutPCRel8 },
{ "BVC", 0x0020000, 0x50, 0, PutPCRel8 },
{ "BVS", 0x0020000, 0x70, 0, PutPCRel8 },

View File

@ -0,0 +1,45 @@
; test of optional signature byte for BRK on all 6502-derived CPUs
; and also COP on 65C816
.setcpu "6502"
brk ; 1 byte
brk 0 ; 2 bytes
brk $60 ; 2 bytes
brk #$60 ; 2 bytes
.setcpu "6502X"
brk
brk $60
brk #$60
.setcpu "6502DTV"
brk
brk $60
brk #$60
.setcpu "65SC02"
brk
brk $60
brk #$60
.setcpu "65816"
brk
brk $60
brk #$60
cop
cop $60
cop #$60
; WDM is a NOP that gives +2 PC, probably not useful to make its signature byte optional
;wdm
wdm $60
wdm #$60
.setcpu "4510"
brk
brk $60
brk #$60
.setcpu "HuC6280"
brk
brk $60
brk #$60

Binary file not shown.