From cd8fa3906631c6ba4dda3f37077eb0770daf769a Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 24 Feb 2023 22:40:29 -0500 Subject: [PATCH 1/3] optional BRK signature on all 6502 CPUs, not just 65816 (also COP) --- src/ca65/instr.c | 16 ++++---- test/asm/listing/109-brk-signature.s | 36 ++++++++++++++++++ .../asm/listing/ref/109-brk-signature.bin-ref | Bin 0 -> 28 bytes 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 test/asm/listing/109-brk-signature.s create mode 100644 test/asm/listing/ref/109-brk-signature.bin-ref diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 745072a09..2ed5ba734 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -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", 0x0000005, 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", 0x0000005, 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", 0x0000005, 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", 0x0000005, 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", 0x0000005, 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", 0x0000005, 0x00, 6, PutAll }, { "BSR", 0x0040000, 0x63, 0, PutPCRel4510 }, { "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", 0x0000005, 0x02, 6, PutAll }, { "CPA", 0x0b8f6fc, 0xc0, 0, PutAll }, /* == CMP */ { "CPX", 0x0c0000c, 0xe0, 1, PutAll }, { "CPY", 0x0c0000c, 0xc0, 1, 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", 0x0000005, 0x00, 6, PutAll }, { "BSR", 0x0020000, 0x44, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, diff --git a/test/asm/listing/109-brk-signature.s b/test/asm/listing/109-brk-signature.s new file mode 100644 index 000000000..b150e088a --- /dev/null +++ b/test/asm/listing/109-brk-signature.s @@ -0,0 +1,36 @@ +; 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 + +.setcpu "6502X" +brk +brk $60 + +.setcpu "6502DTV" +brk +brk $60 + +.setcpu "65SC02" +brk +brk $60 + +.setcpu "65816" +brk +brk $60 +cop +cop $60 +; WDM is a NOP that gives +2 PC, probably not useful to make its signature byte optional +;wdm +wdm $60 + +.setcpu "4510" +brk +brk $60 + +.setcpu "HuC6280" +brk +brk $60 diff --git a/test/asm/listing/ref/109-brk-signature.bin-ref b/test/asm/listing/ref/109-brk-signature.bin-ref new file mode 100644 index 0000000000000000000000000000000000000000..0f46d29fd39f8d79bd403ca35bd6eb6aa7ced41c GIT binary patch literal 28 TcmZQzU|>i Date: Fri, 24 Feb 2023 23:00:30 -0500 Subject: [PATCH 2/3] 65C816 document brk optional signature, and mvn/mvp syntax --- doc/ca65.sgml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index b65d337bb..d4c002408 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -439,6 +439,14 @@ The assembler accepts command was given). +On 6502-derived platforms the + brk ; 1-byte: $00 + brk $34 ; 2-bytes: $00 $34 + + 65816 mode

@@ -456,6 +464,17 @@ mnemonics: TSA is an alias for TSC +The + 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 + + 6502X mode

From 3d41a5b51647fbc1c840d2d8167c76456faa3dec Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sat, 25 Feb 2023 08:23:47 -0500 Subject: [PATCH 3/3] allow immedite style syntax variation for BRK signature byte --- doc/ca65.sgml | 1 + src/ca65/instr.c | 20 +++++++++--------- test/asm/listing/109-brk-signature.s | 9 ++++++++ .../asm/listing/ref/109-brk-signature.bin-ref | Bin 28 -> 46 bytes 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index d4c002408..1bef0b551 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -445,6 +445,7 @@ byte. If omitted, the assembler will only produce only 1 byte. brk ; 1-byte: $00 brk $34 ; 2-bytes: $00 $34 + brk #$34 ; 2-bytes: $00 $34 diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 2ed5ba734..b72be6711 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -181,7 +181,7 @@ static const struct { { "BMI", 0x0020000, 0x30, 0, PutPCRel8 }, { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, - { "BRK", 0x0000005, 0x00, 6, 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", 0x0000005, 0x00, 6, 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", 0x0000005, 0x00, 6, 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", 0x0000005, 0x00, 6, 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", 0x0000005, 0x00, 6, 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", 0x0000005, 0x00, 6, 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", 0x0000005, 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", 0x0000005, 0x00, 6, PutAll }, + { "BRK", 0x0800005, 0x00, 6, PutAll }, { "BSR", 0x0020000, 0x44, 0, PutPCRel8 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 }, diff --git a/test/asm/listing/109-brk-signature.s b/test/asm/listing/109-brk-signature.s index b150e088a..e9c23dd63 100644 --- a/test/asm/listing/109-brk-signature.s +++ b/test/asm/listing/109-brk-signature.s @@ -5,32 +5,41 @@ 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 diff --git a/test/asm/listing/ref/109-brk-signature.bin-ref b/test/asm/listing/ref/109-brk-signature.bin-ref index 0f46d29fd39f8d79bd403ca35bd6eb6aa7ced41c..0eaa09faa5e113f3fe15fcb8e23837523fe04edc 100644 GIT binary patch literal 46 YcmZQzU|>i9LM#LmQvy?h6A&UK0hde%O8@`> literal 28 TcmZQzU|>i