dasm-assembler / dasm

Macro assembler with support for several 8-bit microprocessors
https://dasm-assembler.github.io/
GNU General Public License v2.0
213 stars 39 forks source link

Do you support custom opcodes? #145

Open GZYangKui opened 11 months ago

GZYangKui commented 11 months ago

I am implementing an emulator and would like to customize some exclusive operation codes for the emulator. Do you currently support custom operation codes?

GrantMTG commented 11 months ago

Define Constant Byte doesn't work for you?

GZYangKui commented 11 months ago

I have defined a constant with a value equal to $55 in my emulator, which is a debugging instruction. Then, when I embed this constant into the program and compile using dasm, the following error will occur:

BMAN. s (8): error: Unknown Mnemonic 'DEBUG' BMAN. s (18): error: Unknown Mnemonic 'DEBUG'

DEBUG EQU $ff
RESET:
SEI; Reset PPU Disable NMI, turn off background and sprites
LDA # 0
STA PPU_ CTRL_ REG2
STA PPU_ CTRL_ REG1
CLD; The NES 6502 CPU has no BCD mode, reset the flag just in case
LDX # $FF; Set the stack pointer to the initial position
TXS
DEBUG
neilsf commented 11 months ago

Define a macro:

MAC DEBUG DC. B $FF ENDM

DEBUG

Regards

杨奎 @.***> ezt írta (időpont: 2023. nov. 6., H 3:56):

I have defined a constant with a value equal to $55 in my emulator, which is a debugging instruction. Then, when I embed this constant into the program and compile using dasm, the following error will occur:

BMAN. s (8): error: Unknown Mnemonic 'DEBUG' BMAN. s (18): error: Unknown Mnemonic 'DEBUG'

DEBUG EQU $ff RESET: SEI; Reset PPU Disable NMI, turn off background and sprites LDA # 0 STA PPU CTRL REG2 STA PPU CTRL REG1 CLD; The NES 6502 CPU has no BCD mode, reset the flag just in case LDX # $FF; Set the stack pointer to the initial position TXS DEBUG

— Reply to this email directly, view it on GitHub https://github.com/dasm-assembler/dasm/issues/145#issuecomment-1794008559, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHO446Q5SW6V3MBRD7PKITYDBGWFAVCNFSM6AAAAAA66IEKN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJUGAYDQNJVHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

GrantMTG commented 11 months ago

A macro is nice and clean, but you shouldn't need it for one line. Just use the equate and make sure the DC.B is not in coilumn 1.

DEBUG EQU is not the same and DC.B.

Assuming DEBUG isn't a reserved word

DEBUG EQU $FF

DC.B DEBUG

would also work. Whichever you prefer.