Macroassembler by Michal Kowalski, syntacs question

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Macroassembler by Michal Kowalski, syntacs question

Post by barrym95838 »

I support the notion that a BRK by itself should assemble to a $00 by itself, and a BRK #$EA should assemble to $00 $EA without complaint ... now I just need to write or modify an assembler to support that behavior, because expecting someone else to do it for me at this late date would be vainly optimistic.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Macroassembler by Michal Kowalski, syntacs question

Post by BigDumbDinosaur »

Chromatix wrote:
BigDumbDinosaur wrote:
Chromatix wrote:
It would indeed be logical to assemble "BRK #0" as 00 00, and some assemblers accept that syntax, but that's not what was specified here. This difference from standard assembler behaviour could indeed be considered a bug.
In the case of the Kowalski assembler, it's not a bug. It's a design feature that gives the programmer the option to have any signature byte assembled after a BRK instruction. The default if this feature is enabled is to assemble $EA (NOP) as the signature byte. If this feature is disabled, only $00 will be assembled for a BRK instruction.
Except that that's demonstrably *not* what happens here, and it makes it *more* difficult to assemble an arbitrary desired trailing byte.

The code given was

Code: Select all

BRK NOP NOP
and it assembled to

Code: Select all

00 00 EA EA
According to your description, it should have assembled to

Code: Select all

00 EA EA EA
According to every other assembler I know about, it would become

Code: Select all

00 EA EA
I have no problem with

Code: Select all

BRK #0
being assembled as

Code: Select all

00 00
.
I just tested the Kowalski assembler with a BRK instruction and the signature byte option enabled. The code assembled was $00 $EA.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

Re: Macroassembler by Michal Kowalski, syntacs question

Post by Klaus2m5 »

You can set the BRK opcode behavior here:
Kowalski_set_BRK_behavior.png
Kowalski_set_BRK_behavior.png (13.78 KiB) Viewed 2287 times
barrym95838 wrote:
I support the notion that a BRK by itself should assemble to a $00 by itself, and a BRK #$EA should assemble to $00 $EA without complaint ... now I just need to write or modify an assembler to support that behavior, because expecting someone else to do it for me at this late date would be vainly optimistic.
This is what macros are for:

Code: Select all

; BRK instruction to assemble with or without signature
;   no matter what the assembler thinks it should do
myBRK   .macro ...
        .db 0
        .if %0>0
               .db %1
        .endif
        .endm
	
; usage example
        *=$200

        myBRK                   ; native BRK
        myBRK $12               ; BRK with signature byte

        .end
6502 sources on GitHub: https://github.com/Klaus2m5
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Re: Macroassembler by Michal Kowalski, syntacs question

Post by BitWise »

Dev65 generates one byte unless an immediate operand is specified.

Code: Select all

00:00C4' 00                :         BRK
00:00C5' 0011              :         BRK #$11
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Macroassembler by Michal Kowalski, syntacs question

Post by BigEd »

Best of both worlds!
Post Reply