How to use local labels in procedures 8086 assembler?

╄→尐↘猪︶ㄣ 提交于 2020-01-07 07:47:17

问题


I wrote simple

.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

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

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

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


回答1:


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

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

See http://www.ousob.com/ng/masm/ng54fa6.php.



来源:https://stackoverflow.com/questions/43823315/how-to-use-local-labels-in-procedures-8086-assembler

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