Message board for the users of flat assembler.
> Non-x86 architectures > DCPU-16
As with anything notch does, I am really excited about this:
People have already written assemblers for the specification, but I think it would be great to adapt fasm to be able to use it for this. Not least because it would then be very easy to add more complex instructions in the form of macros.
It should be possible with just macros, but I've had a few problems with even basic instructions, as I can't change the output for [0x1000] and similar statements.
I have tried something like:
[ fix MEM(
] fix )
To try and change it to be a macro that I can then do something with, but that didn't work. The alternative would be some way to detect if a parameter is enclosed in  from a macro.
Cogito Cogito Ergo Essum
|04 Apr 2012, 14:58||
It's relatively easy to do it with fasm's macros, but with one serious problem: fasm calculates label values with byte granularity, while this CPU uses addresses with word granularity. So I had to create a special macro LABEL to define labels, otherwise you'd always have to divide all label values by 2 when using them.
Here are my macros:
A equ eax B equ ebx C equ ecx X equ edx Y equ ebp Z equ esp I equ esi J equ edi @A = 0 @B = 1 @C = 2 @X = 3 @Y = 4 @Z = 5 @I = 6 @J = 7 @SET = 0x1 @ADD = 0x2 @SUB = 0x3 @MUL = 0x4 @DIV = 0x5 @MOD = 0x6 @SHL = 0x7 @SHR = 0x8 @AND = 0x9 @BOR = 0xA @XOR = 0xB @IFE = 0xC @IFN = 0xD @IFG = 0xE @IFB = 0xF @JSR = 0x01 macro parse_operand value define v value @nextword = -1 match =POP,v \