#include "asm.h"

/*

LOAD ASSEMBLY LANGUAGE, CONVERT IT TO MACHINE LANGAUGE AND EXECUTE THE CODE...

Author: Matthew William Coan
Date: Sat Aug 31 17:47:54 EDT 2013

*/

using namespace std;
using namespace asm_tools;

int
main(int argc, char ** argv, char ** envp)
{
   if(argc != 2) {
      cerr << "usage: " << argv[0] 
           << " <input>.asm" 
           << endl;
      exit(1);
   }

   try {
      Program prog("test.bin");

      program_ptr = &prog;

      prog.load(argv[1]); 

      prog.gen_code();

      prog.register_function("printf", (void*)printf);

      prog.register_function("getchar", (void*)getchar);

      prog.register_function("exit", (void*)exit);

      prog.link();

      prog.dump(cout);

      prog.run();
   }
   catch(...) {
      cerr << "unknown exception..." << endl;
      exit(1);
   }

   return 0;
}
