How do you set bytes directly with DASM?

1.5k Views Asked by At

I'm learning 6502 assembly language, and having trouble working something out. I've been trying out a JavaScript 6502 assembler/emulator, and noticed that most examples have a section that looks like:

colors:
  dcb 0,0,0,0,0,$9,$9,1,1,0,0,0,0,0

I've tried to Google what dcb means, and the closest I've got is decimal-coded binary. From looking at the source code, it looks like the assembler is taking the values and inserting each one as a separate byte at the current point in the code.

I'm using DASM locally to assemble my code, and it doesn't support dcb. Is there an equivalent way in DASM to set byte values directly in the code like this?

2

There are 2 best solutions below

0
On

.DC works fine, but the direct equivalent in DASM is

colors:
    dc.b 0,0,0,0,0,$9,$9,1,1,0,0,0,0,0

The b is for bytes, as AusCBloke said. You could replace it with w for words (2 bytes) or l for long words (4 bytes).

You have correctly surmised that the purpose of dc.x is to inject constant values at the current location.

0
On

Well, as is often the way, asking the question helped me find the answer. According to this page, .DC is used for this purpose.

So the example in the question would look like:

colors:
  .DC 0,0,0,0,0,$9,$9,1,1,0,0,0,0,0