int main() { //--- // Test ossiIpt::operator>> //--- std::string is1(" ( 0, 1 )"); std::string is2(" (2,3)"); std::string is3(" ( 4, 5 )"); std::string is4_5_6_7(" ( 6, 7 )(8, 9) ( 10, 11 ) ( 12, 13) 9876"); ossimIpt ip1; ossimIpt ip2; ossimIpt ip3; ossimIpt ip4; ossimIpt ip5; ossimIpt ip6; ossimIpt ip7; ip1.toPoint(is1); ip2.toPoint(is2); ip3.toPoint(is3); int i; std::istringstream istr(is4_5_6_7); istr >> ip4 >> ip5 >> ip6 >> ip7 >> i; //--- // Test ossiDpt::operator>> //--- std::string ds1(" ( 0.0, 1.1 )"); std::string ds2(" (2.2,3.3)"); std::string ds3(" ( 4.4, 5.5 )"); std::string ds4_5_6_7(" ( 6.6, 7.7 )(8.8, 9.9) ( 10.0, 11.0 ) ( 12.0, 13.0) 9876.12345678"); std::string ds8("12 20"); ossimDpt dp1; ossimDpt dp2; ossimDpt dp3; ossimDpt dp4; ossimDpt dp5; ossimDpt dp6; ossimDpt dp7; ossimDpt dp8; dp1.toPoint(ds1); dp2.toPoint(ds2); dp3.toPoint(ds3); double d; std::istringstream istr2(ds4_5_6_7); istr2 >> dp4 >> dp5 >> dp6 >> dp7 >> d; dp8.toPoint(ds8); // Test an invalid string "12 20" //--- // Test ossiDpt3d //--- std::string ds3d1 = " ( 0.0, 1.1, 2.2 )"; std::string ds3d2 = "(1.0,2.0,3.0)"; ossimDpt3d dp3d1; ossimDpt3d dp3d2; dp3d1.toPoint(ds3d1); dp3d2.toPoint(ds3d2); //--- // Test ossiGpt::operator>> //--- std::string gs1("(0.0,0.0,0.0,WGE)"); std::string gs2("(1.1,2.2,3.3,NAR-C)"); std::string gs3(" (4.4,5.5,6.6,NAS-C )"); std::string gs4_5_6_7(" (4.4,5.5,6.6,NAS-C )( 10.0, 10.0 ,5.0, TOY-C ) (17, -89, 50.0, xxx) (28.2, -44.5, 10000.0, NAS-B) 12345.6789"); ossimGpt gp1; ossimGpt gp2; ossimGpt gp3; ossimGpt gp4; ossimGpt gp5; ossimGpt gp6; ossimGpt gp7; double d2; gp1.toPoint(gs1); gp2.toPoint(gs2); gp3.toPoint(gs3); std::istringstream istr4(gs4_5_6_7); istr4 >> gp4 >> gp5 >> gp6 >> gp7 >> d2; //--- // Test ossimEcefPoint toString and toPoint methods. //--- std::string es1("(1.0,2.0,3.0)"); ossimEcefPoint ep1; ep1.toPoint(es1); std::string es2 = ep1.toString(10).string(); //--- // Test ossimEcefPoint toString and toPoint methods. //--- ossimEcefVector ev1; ev1.toPoint(es1); std::string es3 = ev1.toString(10).string(); std::cout << "\nis1: " << is1 << "\nip1: " << ip1 << "\nis2: " << is2 << "\nip2: " << ip2 << "\nis3: " << is3 << "\nip3: " << ip3 << "\nis4_5_6_7: " << is4_5_6_7 << "\nip4: " << ip4 << "\nip5: " << ip5 << "\nip6: " << ip6 << "\nip7: " << ip7 << "\ni: " << i << "\n\n\nds1: " << ds1 << "\ndp1: " << dp1 << "\nds2: " << ds2 << "\ndp2: " << dp2 << "\nds3: " << ds3 << "\ndp3: " << dp3 << "\nds4_5_6_7: " << ds4_5_6_7 << "\ndp4: " << dp4 << "\ndp5: " << dp5 << "\ndp6: " << dp6 << "\ndp7: " << dp7 << "\nds8: " << ds8 << "\ndp8: " << dp8 << "\nd: " << d << "\n\nds3d1: " << ds3d1 << "\nds3d2: " << ds3d2 << "\ndp3d1: " << dp3d1 << "\ndp3d2: " << dp3d2 << "\n\n\ngs1: " << gs1 << "\ngp1: " << gp1 << "\ngs2: " << gs2 << "\ngp2: " << gp2 << "\ngs3: " << gs3 << "\ngp3: " << gp3 << "\ngs4_5_6_7: " << gs4_5_6_7 << "\ngp4: " << gp4 << "\ngp5: " << gp5 << "\ngp6: " << gp6 << "\ngp7: " << gp7 << "\nd2: " << d2 << "\n\n\nes1: " << es1 << "\nep1: " << ep1 << "\nes2: " << es2 << "\nev1: " << ev1 << "\nes3: " << es3 << std::endl; return 0; }
//-------------------------------------------------------------------------- int ana(void) { int code = ua_next_byte(); int saved_code = code; char dtyp = dt_byte; if ( code < 0x60 ) { cmd.itype = A2[code]; } else { if ( code & 8 ) { cmd.auxpref |= aux_word; dtyp = dt_word; } else { cmd.auxpref |= aux_byte; dtyp = dt_byte; } cmd.itype = A2tail[(code>>4)-6]; } if ( cmd.itype == H8500_null ) return 0; switch ( code ) { case 0x02: // ldm.w @sp+, <reglist> // cmd.auxpref |= aux_word; phrase(cmd.Op1, SP, ph_post, dt_word); cmd.Op2.type = o_reglist; cmd.Op2.reg = ua_next_byte(); if ( !cmd.Op2.reg ) return 0; break; case 0x12: // stm.w <reglist>, @-sp // cmd.auxpref |= aux_word; cmd.Op1.type = o_reglist; cmd.Op1.reg = ua_next_byte(); if ( !cmd.Op1.reg ) return 0; phrase(cmd.Op2, SP, ph_pre, dt_word); break; case 0x01: // scb/f cmd.auxpref |= aux_f; break; case 0x06: // scb/ne cmd.auxpref |= aux_ne; break; case 0x07: // scb/eq cmd.auxpref |= aux_eq; break; case 0x08: // trapa #xx code = ua_next_byte(); if ( (code & 0xF0) != 0x10 ) return 0; cmd.Op1.type = o_imm; cmd.Op1.dtyp = dt_byte; cmd.Op1.value = code & 15; break; case 0x0F: // unlk reg(cmd.Op1, FP, dt_word); break; case 0x10: // jmp @aa:16 case 0x18: // jsr @aa:16 aa16(cmd.Op1, dt_code); cmd.Op1.type = o_near; cmd.Op1.addr += cmd.ea & ~0xFFFF; break; case 0x17: // link #xx:8 reg(cmd.Op1, FP, dt_word); imm8(cmd.Op2); break; case 0x1F: // link #xx:16 reg(cmd.Op1, FP, dt_word); imm16(cmd.Op2); break; case 0x03: // pjsr @aa:24 case 0x13: // pjmp @aa:24 { cmd.auxpref |= aux_disp24; uint32 page = ua_next_byte(); cmd.Op1.type = o_far; cmd.Op1.dtyp = dt_code; cmd.Op1.addr = (page<<16) | ua_next_word(); } break; case 0x04: // #xx:8 cmd.auxpref |= aux_byte; case 0x14: // #xx:8 imm8(cmd.Op1); break; case 0x05: // #aa:8.B cmd.auxpref |= aux_byte; aa8(cmd.Op1, dt_byte); break; case 0x15: // #aa:16.B cmd.auxpref |= aux_byte; aa16(cmd.Op1, dt_byte); break; case 0x0C: // #xx:16 cmd.auxpref |= aux_word; case 0x1C: // #xx:16 imm16(cmd.Op1); break; case 0x0D: // #aa:8.W cmd.auxpref |= aux_word; aa8(cmd.Op1, dt_word); dtyp = dt_word; break; case 0x1D: // #aa:16.W cmd.auxpref |= aux_word; aa16(cmd.Op1, dt_word); dtyp = dt_word; break; case 0x0E: // bsr d:8 case 0x20: case 0x21: case 0x22: case 0x23: // d:8 case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: d8(cmd.Op1); break; case 0x1E: // bsr d:16 case 0x30: case 0x31: case 0x32: case 0x33: // d:16 case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F: { cmd.auxpref |= aux_disp16; int32 disp = short(ua_next_word()); cmd.Op1.type = o_near; cmd.Op1.dtyp = dt_code; cmd.Op1.addr = cmd.ip + cmd.size + disp; } break; case 0x40: case 0x41: case 0x42: case 0x43: // cmp:e #xx:8, Rn case 0x44: case 0x45: case 0x46: case 0x47: case 0x50: case 0x51: case 0x52: case 0x53: // mov:e #xx:8, Rn case 0x54: case 0x55: case 0x56: case 0x57: cmd.auxpref |= aux_byte; imm8(cmd.Op1); reg(cmd.Op2, code, dtyp); break; case 0x48: case 0x49: case 0x4A: case 0x4B: // cmp:i #xx:16, Rn case 0x4C: case 0x4D: case 0x4E: case 0x4F: case 0x58: case 0x59: case 0x5A: case 0x5B: // mov:i #xx:16, Rn case 0x5C: case 0x5D: case 0x5E: case 0x5F: cmd.auxpref |= aux_word; imm16(cmd.Op1); reg(cmd.Op2, code, dtyp); break; case 0x60: case 0x61: case 0x62: case 0x63: // @aa:8, Rn case 0x64: case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6A: case 0x6B: case 0x6C: case 0x6D: case 0x6E: case 0x6F: aa8(cmd.Op1, dtyp); reg(cmd.Op2, code, dtyp); break; case 0x70: case 0x71: case 0x72: case 0x73: // Rn, @aa:8 case 0x74: case 0x75: case 0x76: case 0x77: case 0x78: case 0x79: case 0x7A: case 0x7B: case 0x7C: case 0x7D: case 0x7E: case 0x7F: reg(cmd.Op1, code, dtyp); aa8(cmd.Op2, dtyp); break; case 0x80: case 0x81: case 0x82: case 0x83: // mov:f @(d:8, R6), Rn case 0x84: case 0x85: case 0x86: case 0x87: case 0x88: case 0x89: case 0x8A: case 0x8B: case 0x8C: case 0x8D: case 0x8E: case 0x8F: ds8(cmd.Op1, R6, dtyp); reg(cmd.Op2, code, dtyp); break; case 0x90: case 0x91: case 0x92: case 0x93: // mov:f Rn, @(d:8, R6) case 0x94: case 0x95: case 0x96: case 0x97: case 0x98: case 0x99: case 0x9A: case 0x9B: case 0x9C: case 0x9D: case 0x9E: case 0x9F: reg(cmd.Op1, code, dtyp); ds8(cmd.Op2, R6, dtyp); break; case 0xA0: case 0xA1: case 0xA2: case 0xA3: // Rn, Rn case 0xA4: case 0xA5: case 0xA6: case 0xA7: case 0xA8: case 0xA9: case 0xAA: case 0xAB: case 0xAC: case 0xAD: case 0xAE: case 0xAF: reg(cmd.Op1, code, dtyp); break; case 0xB0: case 0xB1: case 0xB2: case 0xB3: // @-Rn, Rn case 0xB4: case 0xB5: case 0xB6: case 0xB7: case 0xB8: case 0xB9: case 0xBA: case 0xBB: case 0xBC: case 0xBD: case 0xBE: case 0xBF: phrase(cmd.Op1, code, ph_pre, dtyp); break; case 0xC0: case 0xC1: case 0xC2: case 0xC3: // @Rn+, Rn case 0xC4: case 0xC5: case 0xC6: case 0xC7: case 0xC8: case 0xC9: case 0xCA: case 0xCB: case 0xCC: case 0xCD: case 0xCE: case 0xCF: phrase(cmd.Op1, code, ph_post, dtyp); break; case 0xD0: case 0xD1: case 0xD2: case 0xD3: // @Rn, Rn case 0xD4: case 0xD5: case 0xD6: case 0xD7: case 0xD8: case 0xD9: case 0xDA: case 0xDB: case 0xDC: case 0xDD: case 0xDE: case 0xDF: phrase(cmd.Op1, code, ph_normal, dtyp); break; case 0xE0: case 0xE1: case 0xE2: case 0xE3: // @(d:8,Rn), Rn case 0xE4: case 0xE5: case 0xE6: case 0xE7: case 0xE8: case 0xE9: case 0xEA: case 0xEB: case 0xEC: case 0xED: case 0xEE: case 0xEF: ds8(cmd.Op1, code, dtyp); break; case 0xF0: case 0xF1: case 0xF2: case 0xF3: // @(d:16,Rn), Rn case 0xF4: case 0xF5: case 0xF6: case 0xF7: case 0xF8: case 0xF9: case 0xFA: case 0xFB: case 0xFC: case 0xFD: case 0xFE: case 0xFF: ds16(cmd.Op1, code, dtyp); break; } while ( cmd.itype > H8500_last ) // while MAPs are not resolved { int index = -(3+short(cmd.itype)); if ( index < 0 || index >= qnumber(tables) ) interr("ana1"); code = ua_next_byte(); if ( code < 0x20 ) { cmd.itype = tables[index].head[code]; } else { cmd.itype = tables[index].tail[(code>>3)-4]; reg(cmd.Op2, code, dtyp); } if ( index == 3 ) switch ( saved_code ) // MAP6 { case 0x01: case 0x06: case 0x07: if ( cmd.itype != H8500_scb ) return 0; break; case 0x11: if ( cmd.itype != H8500_prts && cmd.itype != H8500_prtd && cmd.itype != H8500_jmp && cmd.itype != H8500_pjmp && cmd.itype != H8500_jsr && cmd.itype != H8500_pjsr ) return 0; break; default: if ( cmd.itype != H8500_movfpe && cmd.itype != H8500_movtpe && cmd.itype != H8500_dadd && cmd.itype != H8500_dsub ) return 0; } switch ( cmd.itype ) { case H8500_null: return 0; case H8500_add_q: cmd.Op2 = cmd.Op1; switch ( code ) { case 0x08: immv(cmd.Op1, 1); break; case 0x09: immv(cmd.Op1, 2); break; case 0x0C: immv(cmd.Op1, -1); break; case 0x0D: immv(cmd.Op1, -2); break; } break; case H8500_bset: case H8500_bclr: case H8500_bnot: case H8500_btst: cmd.Op2 = cmd.Op1; if ( code < 0xC0 ) reg(cmd.Op1, code, dtyp); else immv(cmd.Op1, code & 15); break; case H8500_mov_g: if ( (code & 0xF8) == 0x80 ) break; cmd.Op2 = cmd.Op1; if ( code == 0x06 ) { if ( (cmd.auxpref & aux_word) == 0 ) cmd.auxpref |= aux_byte; cmd.Op1.type = o_imm; cmd.Op1.dtyp = dt_byte; cmd.Op1.value = ua_next_byte(); } else if ( code == 0x07 ) { if ( (cmd.auxpref & aux_byte) == 0 ) cmd.auxpref |= aux_word; cmd.auxpref |= aux_mov16; cmd.Op1.type = o_imm; cmd.Op1.dtyp = dt_word; cmd.Op1.value = ua_next_word(); } else reg(cmd.Op1, code, dtyp); break; case H8500_cmp_g: if ( code > 5 ) break; cmd.Op2 = cmd.Op1; if ( code == 0x04 ) { cmd.auxpref |= aux_byte; cmd.Op1.type = o_imm; cmd.Op1.dtyp = dt_byte; cmd.Op1.value = ua_next_byte(); } else { cmd.auxpref |= aux_word; cmd.Op1.type = o_imm; cmd.Op1.dtyp = dt_word; cmd.Op1.value = ua_next_word(); } break; case H8500_andc: case H8500_orc: case H8500_xorc: case H8500_ldc: case H8500_stc: cmd.Op2.reg += SR; if ( cmd.Op2.reg == RES1 || cmd.Op2.reg == CP ) return 0; if ( ((cmd.auxpref & aux_word) != 0) != (cmd.Op2.reg == SR) ) return 0; if ( cmd.itype != H8500_stc ) break; // no break case H8500_movtpe: { op_t x = cmd.Op1; cmd.Op1 = cmd.Op2; cmd.Op2 = x; } break; case H8500_pjmp: case H8500_pjsr: case H8500_jmp: case H8500_jsr: cmd.Op2.type = o_void; switch ( code & 0xF0 ) { case 0xC0: case 0xD0: phrase(cmd.Op1, code, ph_normal, dt_code); break; case 0xE0: ds8(cmd.Op1, code, dt_code); break; case 0xF0: ds16(cmd.Op1, code, dt_code); break; } break; case H8500_rtd: case H8500_prtd: if ( code == 0x14 ) imm8(cmd.Op1); else imm16(cmd.Op1); break; case H8500_scb: cmd.Op1 = cmd.Op2; d8(cmd.Op2); break; case H8500_dadd: case H8500_dsub: if ( (cmd.auxpref & aux_byte) == 0 ) return 0; cmd.auxpref &= ~aux_byte; break; } } if ( (idpflags & AFIDP_MIXSIZE) == 0 ) // Disassemble mixed size instructions? { if ( (cmd.auxpref & aux_word) && cmd.Op1.dtyp == dt_byte || (cmd.auxpref & aux_byte) && cmd.Op1.dtyp == dt_word ) if ( cmd.itype != H8500_mov_g ) return 0; } return cmd.size; }