ln = lat->lnodes; ln->word = wd; ln->n=0; ln->v=0; ln = lat->lnodes+1; ln->word = wd; ln->n=0; ln->v=0; ln = lat->lnodes+nNode-1; ln->word = wd; ln->n=0; ln->v=0; ln = lat->lnodes+nNode-2; ln->word = wd; ln->n=0; ln->v=0; ln = lat->lnodes+2; for (i = 0; i< VHASHSIZE; i++) for ( wd = voc->wtab[i]; wd != NULL; wd = wd->next ) if ((wd != voc->nullWord) && (wd != voc->subLatWord)) { ln->word = wd; ln++; } la =lat->larcs; la->start = lat->lnodes; la->end = lat->lnodes+1; la->lmlike = 0.0; la = lat->larcs+1; la->start = lat->lnodes+nNode-2; la->end = lat->lnodes+nNode-1; la->lmlike = 0.0; la = lat->larcs+2; la->start = lat->lnodes+nNode-2; la->end = lat->lnodes+1; la->lmlike = 0.0; la = lat->larcs+3; for (i = 0; i < voc->nwords; i++) { la->start = lat->lnodes+1;
afs_int32 STC_ReadLabel(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId) { afs_int32 code; #ifdef xbsa if (CONF_XBSA) return (TC_BADTASK); /* ReadLabel does not apply if XBSA */ #endif if (callPermitted(acid) == 0) return (TC_NOTPERMITTED); code = ReadLabel(label); /* Synchronous */ return code; }
void ReadVertex(Graph *graph, FILE *fp, LabelList *labelList, ULONG *vertexListSize, ULONG *pLineNo, ULONG vertexOffset) { ULONG vertexID; ULONG labelIndex; // read and check vertex number vertexID = ReadInteger(fp, pLineNo) + vertexOffset; if (vertexID != (graph->numVertices + 1)) { fprintf(stderr, "Error: invalid vertex number at line %lu.\n", *pLineNo); exit(1); } // read label labelIndex = ReadLabel(fp, labelList, pLineNo); AddVertex(graph, labelIndex, vertexListSize); }
void ReadEdge(Graph *graph, FILE *fp, LabelList *labelList, ULONG *edgeListSize, ULONG *pLineNo, BOOLEAN directed, ULONG vertexOffset) { ULONG sourceVertexID; ULONG targetVertexID; ULONG sourceVertexIndex; ULONG targetVertexIndex; ULONG labelIndex; // read and check vertex numbers sourceVertexID = ReadInteger(fp, pLineNo) + vertexOffset; if (sourceVertexID > graph->numVertices) { fprintf(stderr, "Error: reference to undefined vertex number at line %lu.\n", *pLineNo); exit(1); } targetVertexID = ReadInteger(fp, pLineNo) + vertexOffset; if (targetVertexID > graph->numVertices) { fprintf(stderr, "Error: reference to undefined vertex number at line %lu.\n", *pLineNo); exit(1); } sourceVertexIndex = sourceVertexID - 1; targetVertexIndex = targetVertexID - 1; // read and store label labelIndex = ReadLabel(fp, labelList, pLineNo); AddEdge(graph, sourceVertexIndex, targetVertexIndex, directed, labelIndex, edgeListSize, FALSE); }
void main (int argc, char** argv) { FILE* fptr; char filename[10]; char label[32], opcode[32], operand[32]; int loc = 0; int line = 0; int loop; int is_empty_line; int is_comment; int loader_flag = 0; int search_symtab, x; int xe = 0; if (argc ==2) strcpy(filename, argv[1]); else if (argc == 3 && strcmp(argv[1], "xe") == 0) { strcpy(filename, argv[2]); xe=1; } else { printf("\n./sxass [xe] filename"); exit(1); } fptr = fopen(filename,"r"); if (fptr == NULL) { printf("ERROE: Unable to open the %s file.\n",filename); exit(1); } while (fgets(Buffer,256,fptr) != NULL) { is_empty_line = strlen(Buffer); Index = 0; j = 0; strcpy(label,ReadLabel()); if (Label[0] == '.') is_comment = 1; else is_comment = 0; if (is_empty_line>1 && is_comment!=1) { Index = 0; j = 0; IMRArray[ArrayIndex] = (IntermediateRec*)malloc(sizeof(IntermediateRec));/* [A] */ IMRArray[ArrayIndex]->LineIndex = ArrayIndex; strcpy(label,ReadLabel()); strcpy(IMRArray[ArrayIndex]->LabelField,label); SkipSpace(); if (line == 0) { strcpy(opcode,ReadOprator()); strcpy(IMRArray[ArrayIndex]->OperatorField,opcode);/* [A] */ if (!strcmp(opcode,"START")) { SkipSpace(); strcpy(operand,ReadOperand()); strcpy(IMRArray[ArrayIndex]->OperandField, operand);/* [A] */ LOCCTR[LocctrCounter] = StrToHex(operand); start_address = LOCCTR[LocctrCounter]; } else { LOCCTR[LocctrCounter] = 0; start_address = LOCCTR[LocctrCounter]; } } else { strcpy(opcode, ReadOprator()); strcpy(IMRArray[ArrayIndex]->OperatorField,opcode); SkipSpace(); strcpy(operand,ReadOperand()); strcpy(IMRArray[ArrayIndex]->OperandField,operand); if (strcmp(opcode,"END")) { if (label[0] != '\0') { if (SearchSymtab(label)) { fclose(fptr); printf("ERROE: Duplicate Symbol\n"); FoundOnSymtab_flag = 0; exit(1); } RecordSymtab(label); } if (SearchOptab (opcode)) LOCCTR[LocctrCounter] = loc + (int) (OPTAB[Counter].Format-'0'); else if (!strcmp(opcode,"WORD")) LOCCTR[LocctrCounter] = loc + 3; else if (!strcmp(opcode,"RESW")) LOCCTR[LocctrCounter] = loc + 3 * StrToDec(operand); else if (!strcmp(opcode,"RESB")) LOCCTR[LocctrCounter] = loc + StrToDec(operand); else if (!strcmp(opcode,"BYTE")) LOCCTR[LocctrCounter] = loc + ComputeLen(operand); else{ fclose(fptr); printf("ERROE: Invalid Operation Code, %s\n", opcode); exit(1); } } } loc = LOCCTR[LocctrCounter]; IMRArray[ArrayIndex]->Loc = LOCCTR[LocctrCounter-1]; LocctrCounter++; ArrayIndex++; } FoundOnOptab_flag = 0; line += 1; } program_length = LOCCTR[LocctrCounter-2]- LOCCTR[0]; printf("Pass 2 Processing...\n"); unsigned long inst_fmt;// unsigned long inst_fmt_opcode; unsigned long inst_fmt_index; unsigned long inst_fmt_address; for (loop = 1; loop<ArrayIndex; loop++){ inst_fmt_opcode = 0; inst_fmt_index = 0; inst_fmt_address = 0; strcpy(opcode,IMRArray[loop]->OperatorField); if (SearchOptab(opcode)){ inst_fmt_opcode = OPTAB[Counter].ManchineCode; inst_fmt_opcode <<=16; IMRArray[loop]->ObjectCode = inst_fmt_opcode; strcpy(operand,IMRArray[loop]->OperandField); if (operand[strlen(operand)-2] == ',' && operand[strlen(operand)-1] == 'X'){ inst_fmt_index = 0x008000; operand[strlen(operand)-2] = '\0'; } else inst_fmt_index = 0x000000; for(search_symtab = 0; search_symtab<SymtabCounter; search_symtab++){ if(!strcmp(operand, SYMTAB[search_symtab].Label)) inst_fmt_address = (long)SYMTAB[search_symtab].Address; } inst_fmt = inst_fmt_opcode + inst_fmt_index + inst_fmt_address; IMRArray[loop]->ObjectCode = inst_fmt; } else if (!strcmp(opcode, "WORD")){ strcpy(operand,IMRArray[loop]->OperandField); IMRArray[loop]->ObjectCode = StrToDec(operand); } else if (!strcmp(opcode,"BYTE")){ strcpy(operand,IMRArray[loop]->OperandField); IMRArray[loop]->ObjectCode = 0; if(operand[0]=='C' || operand[0]=='c' && operand[1]=='\''){ for (x = 2; x<=(int) (strlen(operand)-2); x++){ IMRArray[loop]->ObjectCode=IMRArray[loop]->ObjectCode + (int)operand[x]; IMRArray[loop]->ObjectCode<<=8; } } if(operand[0]=='X' || operand[0]=='x' && operand[1]=='\''){ char *operand_ptr; operand_ptr = &operand[2]; *(operand_ptr+2)='\0'; for (x=2; x<=(int) (strlen(operand)-2); x++){ IMRArray[loop]->ObjectCode=IMRArray[loop]->ObjectCode + StrToHex(operand_ptr); IMRArray[loop]->ObjectCode<<=8; } } IMRArray[loop]->ObjectCode>>=8; } else