What is the difference between a regular label and procedure?

250 views Asked by At

Recently I have started making code on 6502-based systems, and I have used the ca65 macro assembler. However I found out that it supports procedures using .proc . So I have been wondering what is the difference between these blocks of code:

mainLabel:
    jsr subroutine

subroutine:
    ;Code
    rts

and this code:

mainLabel:
    jsr procedure

.proc procedure
    ;Code
    rts
.endproc

When I try running my programs using these 2 syntaxes I seem to get the same result. From what I can tell from the ca65 documentation, procedures prevent code from outside it from entering labels within it.

1

There are 1 answers

0
puppydrum64 On

It's the same as far as the CPU is concerned. The benefit to using .proc is so that you can use common label names like loop, again, etc. locally in multiple different functions without the assembler throwing a fit that you used the same label twice. Otherwise you'd have to come up with increasingly contrived label names for every function you write. (Trust me, I've been there.) Let the computer do that for you!