TASM; LOCAL and LOCALS directives

别等时光非礼了梦想. 提交于 2020-01-06 21:02:50

问题


I am writing a program on assembler using TASM 4.1 and I have stumbled upon a problem I have been unable to fix for 2 days. The problem is that TASM just won't recognize labels in macro as local labels and would give me an error when assembling (Symbol already defined elsewhere). So far I have tried the following things:

  1. Putting LOCALS at the very beginning of .asm file and using @@ for local labels (as was suggested in one of the answers to a similar problem). Produced zero effect whatsoever.
  2. Using LOCAL inside a macro to list all my local labels starting with @@ (again, as was suggested on the web). However, this produced even more errors when assembling: "Symbol already different kind" and "Expecting pointer type"
  3. Putting LOCALS @@ at the beginning of macro. Just like with the first case, zero effect.
  4. Putting LOCALS at the beginning of .asm file and listing labels using LOCAL. Same effect as with #2.
  5. Putting LOCALS at the beginning of .asm file and using LOCALS @@ inside macro. No effect.
  6. Putting LOCALS @@ at the beginning of .asm file. No effect.

This is my very first time trying to program, so I apologize if I missed some trivial thing that causes this problem. Here is the macro that I have troubles using more than once:

dot_connect_oct1 macro dot1_x, dot1_y, dot2_x, dot2_y, colour

        ;;code

    @@check_1:
        ;;code
        jz @@exit_1

        ;;code
        jg @@draw_1_2

    @@draw_1_1:
        ;;code
        jmp @@check_1

    @@draw_1_2:
        ;;code
        jmp @@check_1

    @@exit_1:
endm

Update:

Alright, I seem to have found the solution. What worked for me was declaring LABELS at the beginning of .asm file and using LOCAL in the macro itself for each label like this:

LOCAL @@label1
LOCAL @@label2
LOCAL @@label3
...

Listing them in one line (LOCAL @@label1, @@label2, @@label3, ...) does not work.

Maybe someone will find this useful.


回答1:


I'm not sure how your you solution solved the problem but the LOCALS directive only enables the @@ prefix, and the @@ prefix only makes labels local to the current procedure (PROC). Only the LOCAL directive can make labels local to macros and only if used at the start of the macro definition. Solution number 2 should have worked for you, but perhaps your use of the @@ prefix in the context of LOCAL directive in macro confused TASM. However I can't reproduce this problem with an earlier version of the assembler, TASM 3.1.

So what you should be doing is declaring local macro labels without the @@ prefix, since it's not necessary and actual does something else than what you're expecting. Something like this:

dot_connect_oct1 macro dot1_x, dot1_y, dot2_x, dot2_y, colour
    LOCAL check_1, draw_1_1, draw_1_2, exit_1

check_1:
    jz exit_1

    ...
endm


来源:https://stackoverflow.com/questions/29896060/tasm-local-and-locals-directives

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!