1

I'm using masm and dosbox. In my program I have 3 procedures similar to the proc down_left (below). In each of these 4 proc are used the same names: "down_edge, right_edge, left_edge, up_edge, corner, done, next, normal, czykrawedzboczna".

How can I make these names local for each proc? I tried something like "LOCAL down_edge, right_edge, ....". But it doesn't work.

proc down_left          
    pusha
    LOCAL down_edge, right_edge, left_edge, up_edgelcorner, done, next, normal, czykrawedzboczna
    mov ah,es:[bishop]      ;x - biskupa
    mov al,es:[bishop+1]    ;y - biskupa 

    cmp ah,0
    jne next
        cmp al,8
        je done
    next:

    cmp al,8
    je down_edge            ; dolna krawedz 

    cmp ah,0                     ;Czy x=0, y<{0,1,2,3,4,5,6,7,8}
    jne normal
        mov cl,0
        czykrawedzboczna:            ;lewa krawedz
            cmp al,cl
            je left_edge
            add cl,1
            cmp cl,8
            ja normal   
       jmp czykrawedzboczna

    normal:
        dec ah
        dec al 
        jmp done     

    down_edge: 
        dec ah
        jmp done  
    left_edge: 
        dec al
        jmp done

    done:
        xor bx,bx
        mov bl,nr ah al 
        inc es:[tablica+bx]    
        mov es:[bishop],ah      ;x - biskupa  ZAPISZ BIERZACE POLOZENIE BISKUPA
        mov es:[bishop+1],al    ;y - biskupa 
    popa              
    ret
down_left  endp       
rkhb
  • 14,159
  • 7
  • 32
  • 60
Nowak Grzegorz
  • 207
  • 1
  • 12
  • You already achieved what you tried to do: the `LOCAL` directive in MASM makes variables local(=located on the stack). But the `LOCAL` directive **has to be** immediately after the `PROC` directive. So, move `pusha`! – zx485 Mar 30 '17 at 21:04
  • Is it possible to make it work in emu8086? I found something like: http://stackoverflow.com/questions/35003578/how-to-make-local-the-label-in-a-8086-procedure – Nowak Grzegorz Mar 30 '17 at 21:10
  • And they say it may be a problem. – Nowak Grzegorz Mar 30 '17 at 21:10
  • I tried it in emu8086 and it doesn't work. To try it in masm i need debug my code. And to debug my code I need emu8086. – Nowak Grzegorz Mar 30 '17 at 21:17
  • By the way: Is there something like carriage return, what will take me back to the begin of first line? – Nowak Grzegorz Mar 31 '17 at 01:20

2 Answers2

0

Labels in newer MASM (>=6) are local between PROC and ENDP. Older MASM need additionally a langtype in the .MODEL directive, e.g. .MODEL small, C.

Emu8086 doesn't provide local "procedure"-labels. You could tricky work with macros, but I advise against it

Regarding debugging in DOSBox, google for "turbo debugger".

rkhb
  • 14,159
  • 7
  • 32
  • 60
0

If u are using emu8086, and you need to call macro multiple times, u must declare your labels in macro section like LOCAL label1,label2