vasm for Motorola 68000 cannot assign the distance between two labels to a symbol

97 Views Asked by At

Vasm should support calculating the distance between two labels by subtracting end - start to get their difference, but I'm getting assembler errors when I try.

I do have this simple example code, where I create an AMIGA Copper-List which is stored in the code between two labels:

CLstart:
  dc.w      COLOR00,$0000
  dc.w      $780f,                      $fffe
  dc.w      COLOR00,$0f00
  dc.w      $d70f,$fffe
  dc.w      COLOR00,$0fb0
  dc.w      $ffff,$fffe
CLend:

To have it flexible, I like to have the assembler calculate the size of the Copper-List for me so I don't need to re-calculate it by hand every time I change it.

So I do this:

;Sonstige Label
Execbase    = 4
Chip        = 2                                  ; Ramtype: Chip-RAM anfordern

CLsize = CLend - CLstart
;*** Vorprogramm

;Speicher für Copper-List anfordern

Start:
  move.l    Execbase,a6                  
  moveq     #CLsize, d0                   ;Parameter für AllocMem setzen

So I calculate CLsize with the vasm directive =

I try to compile it with this line:

vasmm68k_mot -m68000 -Fhunk -linedebug -o e:\Amiga\Assembler\Testing\mywork\build\copperdemo.o e:\Amiga\Assembler\Testing\mywork\copperdemo.s

And I get the following errors:

error 10 in line 40 of "e:\Amiga\Assembler\Testing\mywork\copperdemo.s": number or identifier expected
>  moveq     #CLsize, d0                   ;Parameter für AllocMem setzen

error 9 in line 40 of "e:\Amiga\Assembler\Testing\mywork\copperdemo.s": instruction not supported on selected architecture
>  moveq     #CLsize, d0                   ;Parameter für AllocMem setzen

So the first error is actually what I do not understand. Obviously CLsize is not getting calculated and therefore the Assembler does not know what to do with CLsize as a number in this particular line.

The line next to it works as expected:

moveq    #Chip,d1

I tried different things, but do not understand why the calculation of the two labels do not assign it to the symbol and why I cannot use the symbol then in the moveq expression.

I moved the calculation to the end, so that all labels are defined, but does not work. I tried to use an equ statement, but this doesn't work either:

CLsize equ CLend - CLstart
1

There are 1 best solutions below

0
Christoph Linden On

Okay, here is the answer (after a day of wasted time) for others to understand:

CLsize = CLend - CLstart does not work, as vasm by default will ignore everything after the first space (CLend here).

And then the error message makes sense, because CLend is a long value and does not fit into moveq operation (only 8bit value is allowed).

The correct formula would be

CLsize=CLend-CLstart

Or you can use the option -spaces to change the behaviour of the assembler to ignore spaces and only use ; as comment marker.