TASM; LOCAL和LOCALS指令 [英] TASM; LOCAL and LOCALS directives

查看:174
本文介绍了TASM; LOCAL和LOCALS指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TASM 4.1在汇编器上编写程序,但偶然发现了一个我无法解决2天的问题. 问题在于TASM不会将宏中的标签识别为本地标签,并且在组装时会给我一个错误(符号已在其他地方定义).到目前为止,我已经尝试了以下操作:

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. 将LOCALS放在.asm文件的开头,并使用@@作为本地标签(这是对类似问题的答案之一).产生零影响.
  2. 在宏中使用LOCAL列出我所有以@@开头的本地标签(同样,如网上所建议的那样).但是,这在组装时产生了更多错误:符号种类已经不同"和期望的指针类型"
  3. 将LOCALS @@放在宏的开头.就像第一种情况一样,零影响.
  4. 将LOCALS放在.asm文件的开头,并使用LOCAL列出标签.与#2效果相同.
  5. 将LOCALS放在.asm文件的开头,并在宏内使用LOCALS @@.没有效果.
  6. 在.asm文件的开头放置LOCALS @@.没有效果.

这是我第一次尝试编程,因此如果我错过了一些导致此问题的琐碎事情,我深表歉意.这是我多次使用时遇到的麻烦的宏:

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

更新:

好的,我似乎已经找到了解决方案.对我有用的是在.asm文件的开头声明LABELS,并在宏本身中为每个标签使用LOCAL,如下所示:

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
...

将它们列出为一行(本地@@ label1,@@ label2,@@ label3等)不起作用.

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

也许有人会觉得这很有用.

Maybe someone will find this useful.

推荐答案

我不确定您的解决方案如何解决该问题,但LOCALS指令仅启用@@前缀,而@@前缀仅使标签在本地当前过程(PROC).仅LOCAL伪指令可以使标签在宏本地,并且仅在宏定义的开头使用时才可以.解决方案编号2应该对您有用,但是也许您在混淆了宏的TASM中在LOCAL指令的上下文中使用@@前缀.但是,我无法使用较早版本的汇编器TASM 3.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

这篇关于TASM; LOCAL和LOCALS指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆