From ee49da91a4ba591cd4860e32276ed23d28df4af7 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 11 Jan 2023 00:51:41 +0800 Subject: [PATCH] feat: demo of next_step interface --- src/core_demo.cc | 90 ++++++++++++++++++++++++++++++++---------------- src/core_demo.h | 2 +- src/main.cc | 6 +++- 3 files changed, 66 insertions(+), 32 deletions(-) diff --git a/src/core_demo.cc b/src/core_demo.cc index 940bae9..442b546 100644 --- a/src/core_demo.cc +++ b/src/core_demo.cc @@ -149,10 +149,10 @@ void move_2x2(uint64_t code, int addr) { } -void next_step(uint64_t raw_code, uint64_t mask) { +void next_step(uint64_t raw_code) { - int addr = 17; - raw_code = RawCode(CommonCode("4fea134")).unwrap(); +// int addr = 17; +// raw_code = RawCode(CommonCode("4fea134")).unwrap(); // move_1x1(raw_code, addr * 3); // int addr = 9; @@ -169,35 +169,65 @@ void next_step(uint64_t raw_code, uint64_t mask) { // std::cout << RawCode(raw_code).dump_case(); -// printf("mask -> %016lX\n", mask); - for (int i = 0; i < 1000000000; ++i) { -// for (int i = 0; i < 50000000; ++i) { - move_1x1(raw_code, addr * 3); - } - - std::cout << "cache size: " << cache_size << std::endl; - - for (int i = 0; i < cache_size; ++i) { - std::cout << "=======" << std::endl; - - std::cout << RawCode(cache[i].code).dump_case(); - - if (i != 0) { - auto _mask = cache[i].mask; - std::cout << std::endl; - for (int n = 0; n < 20; ++n, _mask >>= 3) { - if (_mask & 0b111) { - std::cout << "+ "; - } else { - std::cout << ". "; - } - if ((n & 0b11) == 0b11) { - std::cout << std::endl; - } + auto temp_code = raw_code; + for (int addr = 0; temp_code; addr += 3, temp_code >>= 3) { + + switch (temp_code & 0b111) { + case B_1x1: + move_1x1(raw_code, addr); + break; + case B_1x2: + move_1x2(raw_code, addr); + break; + case B_2x1: + move_2x1(raw_code, addr); + break; + case B_2x2: + move_2x2(raw_code, addr); + break; + default: + continue; // B_space or B_fill + } + if (cache_size != 1) { + for (int i = 1; i < cache_size; ++i) { + std::cout << RawCode(cache[i].code).dump_case(); + printf("MASK -> %016lX\n", cache[i].mask); } +// std::cout << "found: " << cache_size - 1 << std::endl; } - - std::cout << "=======" << std::endl << std::endl; } + + + + +// for (int i = 0; i < 1000000000; ++i) { +// for (int i = 0; i < 50000000; ++i) { +// move_1x1(raw_code, addr * 3); +// } + +// std::cout << "cache size: " << cache_size << std::endl; +// +// for (int i = 0; i < cache_size; ++i) { +// std::cout << "=======" << std::endl; +// +// std::cout << RawCode(cache[i].code).dump_case(); +// +// if (i != 0) { +// auto _mask = cache[i].mask; +// std::cout << std::endl; +// for (int n = 0; n < 20; ++n, _mask >>= 3) { +// if (_mask & 0b111) { +// std::cout << "+ "; +// } else { +// std::cout << ". "; +// } +// if ((n & 0b11) == 0b11) { +// std::cout << std::endl; +// } +// } +// } +// +// std::cout << "=======" << std::endl << std::endl; +// } } diff --git a/src/core_demo.h b/src/core_demo.h index 9078ecb..0bcca0a 100644 --- a/src/core_demo.h +++ b/src/core_demo.h @@ -16,4 +16,4 @@ struct cache_t { int addr; }; -void next_step(uint64_t raw_code, uint64_t mask); +void next_step(uint64_t raw_code); diff --git a/src/main.cc b/src/main.cc index cbd2f93..c32997e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -143,7 +143,11 @@ int main() { // next_step(CommonCode("4FEA134").to_raw_code().unwrap(), 0); // mask unset - next_step(0, 0); + auto raw_code = RawCode(CommonCode("4fea134")).unwrap(); + +// for (int i = 0; i < 1000000000; ++i) { + next_step(raw_code); +// } return 0; }