如何在程序8086汇编程序中使用本地标签? [英] How to use local labels in procedures 8086 assembler?

查看:165
本文介绍了如何在程序8086汇编程序中使用本地标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的简单

.MODEL  small

.STACK 100h
.DATA 
    liczba dw 0h
    licznik dw 0
    potega dw 1
    liczbaString dw ?

    buff db 26
.CODE
  Program:
    mov ax, @DATA
    mov ds, ax

    call PobierzString
    call PetlaIteracjiZnaku

    ;zwraca do ax pobraną liczbę
    PetlaIteracjiZnaku PROC
        mov si, liczbaString
        call ZnajdzDlugoscString
        mov si, liczbaString
        add si, 2
        mov bl, 1
        petla:
            xor ax, ax
            mov al, [si]
            cmp al, 24h; sprawdza czy nie jest koniec wprowadzanej liczby '$'
            je return
            sub al, 30h ; odejmuję 30 żeby zamienić znak na liczbę
            mul bx
            add [liczba], ax
            mov ax, bx
            mov bx, 0Ah
            mul bx
            mov bx, ax
            inc si
        jmp petla
        return:
            ret
    PetlaIteracjiZnaku ENDP

    ; ! si - caly string 
    ; - ax - dlugosc stringu
    ZnajdzDlugoscString PROC
        mov al, 0h
        petla:
            mov dl, [si]
            cmp dl, 24h
            je return
            inc al
        jmp petla
        return: 
            ret
    ZnajdzDlugoscString ENDP

    PobierzString PROC
        xor ax,ax
        mov ah, 0Ah 
        mov dx, offset buff
        int 21h     
        mov liczbaString, dx
        ret
    PobierzString ENDP
    Koniec:
    mov     ah, 4ch
    int     21h

    end Program

但是我无法使用tasm进行编译,因为出现错误:

But I can't compile it with tasm because I get error:

已经定义的符号elswere是:PETLA
符号已定义elswere:RETURN

Symbol already defined elswere: PETLA
Symbol already defined elswere: RETURN

如何在程序中使用本地标签?我尝试在使用过程范围来避免添加.PETLA%%PETLA本地标签?,但是仍然不起作用.
我不知道该如何实现...

How to use local labels for procedures? I tried to add .PETLA and %%PETLA as in Use procedure scope to avoid local labels? but it still doesn't work.
I have no idea how to achive this...

推荐答案

要在带有TASM的过程中使用本地标签,您需要:

To use local labels in procedures with TASM you need to:

  • 使用@@前缀作为标签名称;和
  • LOCALS @@放在文件的开头.
  • Use the @@ prefix for your label name; and
  • Place LOCALS @@ in the beginning of your file.

您可以使用不同的前缀代替@@,但是@@是常见的前缀.

You can use a diferent prefix instead of @@, but @@ is the common one.

请参见 http://www.ousob.com/ng/masm/ng54fa6. php .

这篇关于如何在程序8086汇编程序中使用本地标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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