+//
+// Handle the creation of labels
+//
+int HandleLabel(char * label, int labelType)
+{
+ // Check for dot in front of label; means this is a local label if present
+ int environment = (*label == '.' ? curenv : 0);
+ SYM * symbol = lookup(label, LABEL, environment);
+
+ if (symbol == NULL)
+ {
+ symbol = NewSymbol(label, LABEL, environment);
+ symbol->sattr = 0;
+// symbol->sattre = RISCSYM;
+ symbol->sattre = 0;
+ }
+ else if (symbol->sattr & DEFINED)
+ return errors("multiply-defined label '%s'", label);
+
+ // Put symbol in "order of definition" list if it's not already in it
+ AddToSymbolDeclarationList(symbol);
+
+ if (orgactive)
+ {
+ symbol->svalue = orgaddr;
+ symbol->sattr |= ABS | DEFINED | EQUATED;
+ }
+ else
+ {
+ symbol->svalue = sloc;
+ symbol->sattr |= DEFINED | cursect;
+ }
+
+ lab_sym = symbol;
+
+ if (0 == environment)
+ curenv++;
+
+ // Make label global if it has a double colon
+ if (labelType == DCOLON)
+ {
+ if (environment != 0)
+ return error(locgl_error);
+
+ symbol->sattr |= GLOBAL;
+ }
+
+ return 0;
+}
+
+