Section 9.5: Subroutines (Frame 10)                     [prev][home][next]

Here's the right way to to do it:

SOMEFUNC:
             LDI   0
             STD  SUM              ; SUM = 0
             STD  COUNT            ; COUNT = 0
             ; start computing!
             RET
SUM:         NUM  0
COUNT:       NUM  0

There are no safeguards in place in assembler for global variables. Every variable is essentially global! This is why assembler programmers have to be very careful and follow accepted practices to avoid common mistakes.