dcpu16py icon indicating copy to clipboard operation
dcpu16py copied to clipboard

support for "EQU" in assembler

Open jtauber opened this issue 12 years ago • 12 comments

Just like we have DAT (similar to the DFB in old 8-bit CPU assemblers) I think we need something like an EQU instruction in our assemblers for setting constants.

Has anyone seen an EQU equivalent in any of Notch's work (or in any other assemblers)?

jtauber avatar Apr 08 '12 20:04 jtauber

What would it do?

andre-d avatar Apr 08 '12 20:04 andre-d

It would set a label to the given value (rather than the memory location of the label)

So for example, you could set vidmem to be 0x8000 once so your assembly code could just use vidmem instead of 0x8000.

jtauber avatar Apr 08 '12 20:04 jtauber

basically, to avoid magic numbers in assembly code

jtauber avatar Apr 08 '12 20:04 jtauber

for example, say I use 0x1000 to store the cursor. I'd rather write:

SET [cursor], vidmem than SET [0x1000], 0x8000

jtauber avatar Apr 08 '12 20:04 jtauber

Oh, assembler time definition, yeah, right. I have been working around it by using labels and dat allover the place (not fun over time, and slower)

andre-d avatar Apr 08 '12 20:04 andre-d

yeah, labels + dat works but it adds a level of indirection

jtauber avatar Apr 08 '12 20:04 jtauber

I looked trough most stuff that Notch put out and never notices anything like that, but I guess it will be added, as its nothing the CPU must do but rather the assembler.

enkore avatar Apr 09 '12 00:04 enkore

Correct, it is an assembler feature common to many assemblers. I don't know if any DCPU-16 assemblers have it yet though.

andre-d avatar Apr 09 '12 01:04 andre-d

We could add this with a prepended dot to make clear, that this is assembler specific:

.equ label value

Nearly every assembler uses this style to create his own extensions... btw. we can also add inclusion functionality; I guess that's something useful, too:

.include "file.asm"

enkore avatar Apr 09 '12 11:04 enkore

another one to consider would be .org to indicate where to put the code

jtauber avatar Apr 09 '12 11:04 jtauber

Ah you mean some way of setting the base address? That would be sweet, yea.

btw, I just wrote a short proposal for the Standards Comittee about equ, let's see what they say: https://github.com/0x10cStandardsCommittee/0x10c-Standards/issues/27

(edit) As .org is something entirely different I created another proposal for this: https://github.com/0x10cStandardsCommittee/0x10c-Standards/issues/29

enkore avatar Apr 09 '12 11:04 enkore

Update: Jarvix is, as far as I know, currently working on a RFCX about exactly this and some other stuff (conditional compilation and stuff like that)

enkore avatar Apr 12 '12 12:04 enkore