From e4be71eae5af189bf81c9079814da4422ef82be3 Mon Sep 17 00:00:00 2001 From: Myun2 Date: Thu, 23 Sep 2010 22:42:16 +0900 Subject: [PATCH] test Add. --- roast_ex/test/js_test/js_test.cpp | 122 ++++++++++++++++ roast_ex/test/js_test/roast_test_2nc.sln | 20 +++ roast_ex/test/js_test/roast_test_2nc.vcproj | 214 ++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+) create mode 100644 roast_ex/test/js_test/js_test.cpp create mode 100644 roast_ex/test/js_test/roast_test_2nc.sln create mode 100644 roast_ex/test/js_test/roast_test_2nc.vcproj diff --git a/roast_ex/test/js_test/js_test.cpp b/roast_ex/test/js_test/js_test.cpp new file mode 100644 index 0000000..8395bf2 --- /dev/null +++ b/roast_ex/test/js_test/js_test.cpp @@ -0,0 +1,122 @@ +#include +#include +#include "roast/asm/x86/lexical.hpp" +#include "roast/stream/memory_stream.hpp" + +using namespace ::roast; +using namespace ::roast::lexical; +using namespace ::roast::assem::x86::lexical; + +#define BUF_SIZE (1024) + +int main() +{ + unsigned char actual_buf[BUF_SIZE]; + unsigned char expect_buf[BUF_SIZE]; + memset(actual_buf,0,sizeof(actual_buf)); + memset(expect_buf,0,sizeof(expect_buf)); + + // Read Expect (from NASM Binary) + FILE *fp_expect = fopen("mov_test", "rb"); + if ( fp_expect == NULL ){ + printf("mov_test Open Error!\n"); + return 1; + } + size_t expect_length = fread(expect_buf, 1, sizeof(expect_buf), fp_expect); + fclose(fp_expect); + + ///////////////////////////////////////////////////////////////////////// + + stream::memory_stream actual_strm(actual_buf,sizeof(actual_buf)); + + typedef seq< + seq< + // 8bit Register to Register + mov, + mov, + mov, + mov, + + // 16bit Register to Register + mov, + mov, + mov, + mov, + mov, + mov, + + _true_analyze + + >, + // 8/16bit Immediate to Register + mov >, + mov >, + mov >, + mov >, + + // 8/16bit Immediate to Memory + mov, imm8<0x12> >, + mov, imm16<0x1234> >, + + // 8/16bit Memory to Register + mov >, + mov >, + mov >, + mov >, + + // 8/16bit Register to Memory + mov, bl>, + mov, al>, + mov, bx>, + mov, ax>, + + // Segument Register + mov, + mov, + mov, + mov, + mov, + mov, + mov, + mov, + + _true_analyze + + > actual_t; + + actual_t o; + //o.generate(actual_strm, sized_ptr((void*)boot_img,size) ); + o.generate(actual_strm, actual_strm ); + + ///////////////////////////////////////////////////////////////////////// + + size_t comp_length = sizeof(actual_buf) - actual_strm.restsize(); + if ( expect_length > comp_length ) + comp_length = expect_length; + + for(size_t i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0