changed tables to UrAsm syntax (we have DEFX exactly for such cases)
[bz80asm.git] / labman.zas
blobb814e0efb9c81ad6fc2de5c25d483483fb63f5a5
1 ; label manager
3 ; this stores 4-byte integer at IX
4 ; used inly once, to store label value
5 ; number is H'L'HL (HL is high word)
6 ; this is called from assembler after
7 ; calling VAR to store PC value into
8 ; newly created label (see ASMB)
9 ; actually, only H'L' matters here, and
10 ; it contains the value to store
11 STORE:
12   ret
15 ; create new label
16 ; this is called from assembler to
17 ; create a new label (or replace an existing one)
18 ; the code is in (see ASMB)
19 ; the assembler doesn't try to check for duplicate labels
20 ; IY points to the first char of label name
21 ; after parsing, IY should point right after the parsed label
22 ; labels always starts with dot, and the dot is already consumed
23 ; it doesn't matter what this subroutine returns, it only
24 ; has to parse and create a label
25 ; STORE will be called immediately after calling this
26 ; you can use IX register to pass address of label data block
27 ; other registers can be considered dead
28 VAR:
29   ld    hl,msg_getvar
30   call  printstr
31   ld    a,(iy)
32   call  isAlpha
33   jp    c,error_identifier_expected
34   ld    b,0
35   push  iy
36 .idloop:
37   ld    a,(iy)
38   call  isIdChar
39   jr    c,.idend
40   inc   b
41   inc   iy
42   jr    .idloop
43 .idend:
44   ; print id
45   pop   iy
46 .iddumploop:
47   ld    a,(iy)
48   call  EMIT
49   inc   iy
50   djnz  .iddumploop
51   ld    a,'>'
52   call  EMIT
53   ld    a,13
54   call  EMIT
56   ret
58 msg_getvar: defx "NEWLABEL:<"