00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include <assert.h>
00027 #include <iomanip>          
00028 #include <sstream>
00029 #if defined(_MSC_VER) && _MSC_VER <= 1200
00030 #pragma warning(disable:4786)
00031 #endif
00032 
00033 #include "exp.h"
00034 #include "register.h"
00035 #include "rtl.h"
00036 #include "cfg.h"
00037 #include "proc.h"
00038 #include "prog.h"
00039 #include "decoder.h"
00040 #include "st20decoder.h"
00041 #include "BinaryFile.h"
00042 #include "frontend.h"
00043 #include "st20frontend.h"
00044 #include "BinaryFile.h"     
00045 #include "boomerang.h"
00046 #include "signature.h"
00047 
00048 ST20FrontEnd::ST20FrontEnd(BinaryFile *pBF, Prog* prog, BinaryFileFactory* pbff) : FrontEnd(pBF, prog, pbff) {
00049     decoder = new ST20Decoder();
00050 }
00051 
00052 
00053 
00054 ST20FrontEnd::~ST20FrontEnd()
00055 {
00056 }
00057 
00058 
00059 std::vector<Exp*> &ST20FrontEnd::getDefaultParams()
00060 {
00061     static std::vector<Exp*> params;
00062     if (params.size() == 0) {
00063 #if 0
00064         for (int r=0; r<=2; r++) {
00065             params.push_back(Location::regOf(r));
00066         }
00067 #endif
00068         params.push_back(Location::memOf(Location::regOf(3)));
00069     }
00070     return params;
00071 }
00072 
00073 std::vector<Exp*> &ST20FrontEnd::getDefaultReturns()
00074 {
00075     static std::vector<Exp*> returns;
00076     if (returns.size() == 0) {
00077         returns.push_back(Location::regOf(0));
00078         returns.push_back(Location::regOf(3));
00079 
00080     }
00081     return returns;
00082 }
00083 
00084 ADDRESS ST20FrontEnd::getMainEntryPoint( bool &gotMain ) 
00085 {
00086     gotMain = true;
00087     ADDRESS start = pBF->GetMainEntryPoint();
00088     if( start != NO_ADDRESS ) return start;
00089 
00090     start = pBF->GetEntryPoint();
00091     gotMain = false;
00092     if( start == NO_ADDRESS ) return NO_ADDRESS;
00093 
00094     gotMain = true;
00095     return start;
00096 }
00097 
00098 
00099 bool ST20FrontEnd::processProc(ADDRESS uAddr, UserProc* pProc, std::ofstream &os, bool frag ,
00100         bool spec ) {
00101 
00102     
00103     if (!FrontEnd::processProc(uAddr, pProc, os, frag, spec))
00104         return false;
00105     
00106     pProc->setEntryBB();
00107 
00108     return true;
00109 }