void __start () { char xstack[2048]; /* No reason for this to be in a function, except that gcc seems to * require it. */ DEF_SYM (UAREA, UADDR); DEF_SYM (__u_xesp, &UAREA.u_xsp); DEF_SYM (__u_ppc, &UAREA.u_ppc); DEF_SYM (__u_donate, &UAREA.u_donate); DEF_SYM (__u_in_critical, &UAREA.u_in_critical); DEF_SYM (__u_interrupted, &UAREA.u_interrupted); DEF_SYM (__envs, UENVS); DEF_SYM (__ppages, UPPAGES); DEF_SYM (__sysinfo, SYSINFO); DEF_SYM (__si_system_ticks, &__sysinfo.si_system_ticks); DEF_SYM (__bc, UBC); DEF_SYM (__xr, UXN); DEF_SYM (__xn_free_map, UXNMAP); DEF_SYM (vpt, UVPT); #define SRL(val, shamt) (((val) >> (shamt)) & ~(-1 << (32 - (shamt)))) DEF_SYM (vpd, UVPT + SRL(UVPT, 10)); UAREA.u_xsp = (u_int) xstack + sizeof (xstack); UAREA.u_entipc1 = UAREA.u_entipc2 = 0; UAREA.u_entfault = (u_int) xue_fault; UAREA.u_entprologue = (u_int) xue_prologue; UAREA.u_entepilogue = (u_int) xue_epilogue; UAREA.u_fpu = 0; UAREA.pid = sys_geteid(); __brkpt = ((u_int) &end + PGMASK) & ~PGMASK; /* UAREA.u_ppc is inited to 0 in parent so if it is none zero it means that the quantum expired since the beginning of the program and we need to yield before our slice gets yanked */ if (UAREA.u_ppc) yield(-1); pw_init (); /* and off we go */ main (); __exit(); start_text_addr = __start; }
nodet* insert( nodet *p,int value) { int balance; if (p==NULL) return createNode(value); if (p->data>value) p->left=insert(p->left,value); else p->right=insert(p->right,value); p->height=max(height(p->left),height(p->right))+1; balance=balaced(p); if (balance>1 && p->left->data>value) return SRR(p); if (balance<-1 && p->right->data<value) return SRL(p); if (balance>1 && p->left->data<value) return DRR(p); if (balance<-1 && p->right->data>value) return DRL(p); else return p; }
/* ** Opcode 0xDD/0xFD ** IX/IY related instructions */ UBYTE Z80::indexInstructions(UWORD& I, UBYTE origOpcode) { UBYTE opcode = READ_MEM(PC++); switch (opcode) { case 0x8E: ADD8(A, READ_MEM(I + READ_MEM(PC++)), F_C); return 19; case 0x86: ADD8(A, READ_MEM(I + READ_MEM(PC++)), 0); return 19; case 0x09: ADD16(I, BC); return 15; case 0x19: ADD16(I, DE); return 15; case 0x29: ADD16(I, I); return 15; case 0x39: ADD16(I, SP); return 15; case 0xA6: AND(A, READ_MEM(I + READ_MEM(PC++))); return 19; case 0xBE: CP(A, READ_MEM(I + READ_MEM(PC++))); return 19; case 0x96: SUB8(A, READ_MEM(I + READ_MEM(PC++)), 0); return 19; case 0xAE: XOR(A, READ_MEM(I + READ_MEM(PC++))); return 19; case 0x35: { UBYTE v = I + READ_MEM(PC++); UBYTE s = READ_MEM(v); DEC8(s); WRITE_MEM(v, s); } return 23; case 0x2B: DEC16(I); return 10; case 0xE3: { UWORD s = READ_MEM16(SP); EX(s, I); WRITE_MEM16(SP, s); } return 23; case 0x23: INC16(I); return 10; case 0x34: { UBYTE v = I + READ_MEM(PC++); UBYTE s = READ_MEM(v); INC8(s); WRITE_MEM(v, s); } return 23; /* JP */ case 0xE9: PC = READ_MEM16(I); return 8; /* LD */ case 0x7E: A = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x46: B = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x4E: C = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x56: D = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x5E: E = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x66: H = READ_MEM(I + READ_MEM(PC++)); return 19; case 0x6E: L = READ_MEM(I + READ_MEM(PC++)); return 19; case 0xF9: SP = I; return 19; case 0x2A: I = READ_MEM16(READ_MEM16(PC)); PC += 2; return 20; case 0x21: I = READ_MEM16(PC); PC += 2; return 14; case 0x22: WRITE_MEM16(READ_MEM16(PC), I); PC += 2; return 20; case 0x70 + 7: WRITE_MEM(I + READ_MEM(PC++), A); return 19; case 0x70 + 0: WRITE_MEM(I + READ_MEM(PC++), B); return 19; case 0x70 + 1: WRITE_MEM(I + READ_MEM(PC++), C); return 19; case 0x70 + 2: WRITE_MEM(I + READ_MEM(PC++), D); return 19; case 0x70 + 3: WRITE_MEM(I + READ_MEM(PC++), E); return 19; case 0x70 + 4: WRITE_MEM(I + READ_MEM(PC++), H); return 19; case 0x70 + 5: WRITE_MEM(I + READ_MEM(PC++), L); return 19; case 0x36: WRITE_MEM(I + READ_MEM(PC), READ_MEM(PC + 1)); PC += 2; return 19; case 0xB6: OR(A, READ_MEM(I + READ_MEM(PC++))); return 19; case 0xE1: I = pop16(); return 14; case 0xE5: push16(I); return 15; case 0x9E: SUB8(A, READ_MEM(I + READ_MEM(PC++)), F_C); return 19; case 0xCB: { // DD CB UBYTE arg = READ_MEM(PC++); UBYTE extOpcode = READ_MEM(PC++); switch (extOpcode) { #define RES_I(b) case 0x86 + 8 * b: { UBYTE s = READ_MEM(I + arg); \ RES(s, b); WRITE_MEM(I + arg, s); } return 23; #define SET_I(b) case 0xC6 + 8 * b: { UBYTE s = READ_MEM(I + arg); \ SET(s, b); WRITE_MEM(I + arg, s); } return 23; #define BIT_I(b) case 0x46 + 8 * b: { UBYTE s = READ_MEM(I + arg); \ BIT(s, b); WRITE_MEM(I + arg, s); } return 23; /* BIT b,(I+N) */ BIT_I(0); BIT_I(1); BIT_I(2); BIT_I(3); BIT_I(4); BIT_I(5); BIT_I(6); BIT_I(7); /* RES b,(I+N) */ RES_I(0); RES_I(1); RES_I(2); RES_I(3); RES_I(4); RES_I(5); RES_I(6); RES_I(7); /* SET b,(I+N) */ SET_I(0); SET_I(1); SET_I(2); SET_I(3); SET_I(4); SET_I(5); SET_I(6); SET_I(7); case 0x16: { /* RL (I+N) */ UBYTE s = READ_MEM(I + arg); RL(s); WRITE_MEM(I + arg, s); } return 23; case 0x06: { /* RLC (I+N) */ UBYTE s = READ_MEM(I + arg); RLC(s); WRITE_MEM(I + arg, s); } return 23; case 0x1E: { /* RR (I+N) */ UBYTE s = READ_MEM(I + arg); RR(s); WRITE_MEM(I + arg, s); } return 23; case 0x0E: { /* RRC (I+N) */ UBYTE s = READ_MEM(I + arg); RRC(s); WRITE_MEM(I + arg, s); } return 23; case 0x26: { /* SLA (I+N) */ UBYTE s = READ_MEM(I + arg); SLA(s); WRITE_MEM(I + arg, s); } return 23; case 0x2E: { /* SRA (I+N) */ UBYTE s = READ_MEM(I + arg); SRA(s); WRITE_MEM(I + arg, s); } return 23; case 0x36: { /* SLL (I+N) */ UBYTE s = READ_MEM(I + arg); SLL(s); WRITE_MEM(I + arg, s); } return 23; case 0x3E: { /* SRL (I+N) */ UBYTE s = READ_MEM(I + arg); SRL(s); WRITE_MEM(I + arg, s); } return 23; default: std::cout << std::hex << "Unknown extended opcode (" << origOpcode << ":" << opcode << "): " << static_cast<int>(extOpcode) << std::endl; return 0; } } break; default: std::cout << std::hex << "Unknown extended opcode (" << origOpcode << "): " << static_cast<int>(opcode) << std::endl; break; } return 0; }
int LTP::srl(XML4NLP & xml) { if ( xml.QueryNote(NOTE_SRL) ) return 0; // dependency int ret = ner(xml); if (0 != ret) { ERROR_LOG("in LTP::srl, failed to perform ner preprocess"); return ret; } ret = parser(xml); if (0 != ret) { ERROR_LOG("in LTP::srl, failed to perform parsing preprocess"); return ret; } int stnsNum = xml.CountSentenceInDocument(); if (stnsNum == 0) { ERROR_LOG("in LTP::srl, number of sentence equals 0"); return kEmptyStringError; } for (int i = 0; i < stnsNum; ++i) { vector<string> vecWord; vector<string> vecPOS; vector<string> vecNE; vector< pair<int, string> > vecParse; vector< pair<int, vector< pair<const char *, pair< int, int > > > > > vecSRLResult; if (xml.GetWordsFromSentence(vecWord, i) != 0) { ERROR_LOG("in LTP::ner, failed to get words from xml"); return kReadXmlError; } if (xml.GetPOSsFromSentence(vecPOS, i) != 0) { ERROR_LOG("in LTP::ner, failed to get postags from xml"); return kReadXmlError; } if (xml.GetNEsFromSentence(vecNE, i) != 0) { ERROR_LOG("in LTP::ner, failed to get ner result from xml"); return kReadXmlError; } if (xml.GetParsesFromSentence(vecParse, i) != 0) { ERROR_LOG("in LTP::ner, failed to get parsing result from xml"); return kReadXmlError; } if (0 != SRL(vecWord, vecPOS, vecNE, vecParse, vecSRLResult)) { ERROR_LOG("in LTP::srl, failed to perform srl on sent. #%d", i+1); return kSRLError; } int j = 0; for (; j < vecSRLResult.size(); ++j) { vector<string> vecType; vector< pair<int, int> > vecBegEnd; int k = 0; for (; k < vecSRLResult[j].second.size(); ++k) { vecType.push_back(vecSRLResult[j].second[k].first); vecBegEnd.push_back(vecSRLResult[j].second[k].second); } if (0 != xml.SetPredArgToWord(i, vecSRLResult[j].first, vecType, vecBegEnd)) { return kWriteXmlError; } } } xml.SetNote(NOTE_SRL); return 0; }
nodet *DRL(nodet *p) { p->right=SRR(p->right); p=SRL(p); return p; }
nodet *DRR(nodet *p) { p->left=SRL(p->left); p=SRR(p); return p; }