?? avr.c
字號:
mask = 0x8000; while( *pc ){ if( '0' == *pc ){ // Current bit of opcode is a 0 if( code_word & mask ){ // Current bit of code_word is a 1 match = FALSE; break; } } else if( '1' == *pc ){ // Current bit of opcode is a 1 if( !( code_word & mask ) ){ // Current bit of code_word is a 0 match = FALSE; break; } } // Go to the next bit pc++; mask >>= 1; } if( match ){ #ifdef DEBUG printf( "DEBUG - Word2Instruction: We Have A Match at index = %d\n", index ); #endif strcpy( pInstruction->name, pInstSet->name ); pInstruction->arg0_format = pInstSet->arg[ 0 ]; pInstruction->arg1_format = pInstSet->arg[ 1 ]; pInstruction->arg0_type = pInstSet->arg0_type; pInstruction->arg1_type = pInstSet->arg1_type; #ifdef DEBUG_2 printf( "pInstSet->name = %s\n", pInstSet->name ); printf( "pInstSet->opcode = %s\n", pInstSet->opcode ); printf( "pInstSet->arg[ 0 ] = '%c'\n", pInstSet->arg[ 0 ] ); printf( "pInstSet->arg[ 1 ] = '%c'\n", pInstSet->arg[ 1 ] ); #endif // The args are hard to get out of the code_word. We will use a // process borrowed from above. One big difference though is that // here we start on the least significant bit. pc = pInstSet->opcode + 15; mask = 0x0001; arg0 = 0; arg1 = 0; argC = 0; mask0 = 0x0001; mask1 = 0x0001; maskC = 0x0001; while( pc >= pInstSet->opcode ){ #ifdef DEBUG_2 printf( "*pc = %c\n", *pc ); printf( "mask = 0x%04X\n", mask ); printf( "arg0 = 0x%04X\n", arg0 ); printf( "arg1 = 0x%04X\n", arg1 ); printf( "argC = 0x%04X\n", argC ); printf( "mask0 = 0x%04X\n", mask0 ); printf( "mask1 = 0x%04X\n", mask1 ); printf( "maskC = 0x%04X\n", maskC ); #endif if( ARG_none != pInstSet->arg0_type && pInstSet->arg[ 0 ] == *pc ){ // Current bit of opcode is current bit of arg0 if( code_word & mask ){ arg0 |= mask0; } mask0 <<= 1; } else if( ARG_none != pInstSet->arg1_type && pInstSet->arg[ 1 ] == *pc ){ // Current bit of opcode is current bit of arg1 if( code_word & mask ){ arg1 |= mask1; } mask1 <<= 1; } else if( 'C' == *pc ){ // We have to test and see if C equals arg[ 0 ] if( code_word & mask ){ argC |= maskC; } haveC = TRUE; maskC <<= 1; } // Go to the next higher bit in the opcode mask <<= 1; pc--; } pInstruction->arg0 = AdjustArg( arg0, pInstSet->arg0_type ); pInstruction->arg1 = AdjustArg( arg1, pInstSet->arg1_type ); // If we're trying for a C equals arg[ 0 ] instruction this will // correctly set match match = !( haveC ) || ( argC == arg0 ); } pInstSet++; index++; } if( '\0' == pInstSet->name[ 0 ] ) index = 0; #ifdef DEBUG_3 printf( "DEBUG - Word2Instruction Ending with index = %d\n", index ); printf( "DEBUG - pInstruction->name = %s\n", pInstruction->name ); printf( "DEBUG - pInstruction->arg0_format = '%c'\n", pInstruction->arg0_format ); printf( "DEBUG - pInstruction->arg1_format = '%c'\n", pInstruction->arg1_format ); printf( "DEBUG - pInstruction->arg0_type = %d\n", pInstruction->arg0_type ); printf( "DEBUG - pInstruction->arg1_type = %d\n", pInstruction->arg1_type ); printf( "DEBUG - pInstruction->arg0 = 0x%02X\n", pInstruction->arg0 ); printf( "DEBUG - pInstruction->arg1 = 0x%02X\n", pInstruction->arg1 ); #endif return( index );}unsigned short TAvr::AdjustArg( unsigned short arg, eArgTypes eArgType ){ switch( eArgType ){ case ARG_16_31: arg += 16; break; case ARG_neg64_63: // Take times 2 (because in the assembler source // "brbc 0, -1" and "brbc 0, -2" are the same thing), // and then sign extend it. arg <<= 1; if( 0x80 & arg ) arg |= 0xFF00; break; case ARG_cm0_cm255: // complement bits break; case ARG_neg2KB_2KB: // Take times 2 (because in the assembler source // "rcall 2" and "rcall 3" are the same thing), // and then sign extend it. arg <<= 1; if( 0x1000 & arg ) arg |= 0xF000; break; case ARG_24_26_28_30: // 0 => 24 // 1 => 26 // 2 => 28 // 3 => 30 arg = 2 * ( arg + 12 ); break; case ARG_specialX: case ARG_specialY: case ARG_specialZ: arg = (unsigned short)' '; break; case ARG_specialIncX: case ARG_specialIncY: case ARG_specialIncZ: arg = (unsigned short)'+'; break; case ARG_specialDecX: case ARG_specialDecY: case ARG_specialDecZ: arg = (unsigned short)'-'; break; case ARG_none: case ARG_0_31: case ARG_0_7: case ARG_0_63: case ARG_0_255: case ARG_longCall: case ARG_copyArg: case ARG_0_PAIR: // Do nothing break; default: { char msg[ 80 ]; // FIXME - Magic Number sprintf( msg, "AdjustArg: Unhandled Arg Type: %d\n", eArgType ); throw TGenericError( msg ); break; } } return arg;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -