Told cell and unit apart
This commit is contained in:
1 parent
10b533a6df
commit
cbbacbbdd2
8 files changed
+20
-20
No files matched your search
+1
-1
@@ -66,7 +66,7 @@ stp
|
||||
.anchor add_buf_1
|
||||
bit_move_to %5
|
||||
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
bit_add %1 %2 %5 %4 add_buf_1
|
||||
|
||||
.tp add_buf_1
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ rnz
|
||||
%macro unsafe_and 3
|
||||
.anchor before_unsafe_and
|
||||
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
bit_unsafe_and %1 %2 %3
|
||||
.tp %1
|
||||
ror
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ flb
|
||||
%endmacro
|
||||
|
||||
%macro erase 0
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
set_0
|
||||
ror
|
||||
%endrepeat
|
||||
@@ -81,7 +81,7 @@ rnz
|
||||
|
||||
%macro copy_to_buffer 1
|
||||
.anchor before_copy_to_buffer
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
bit_copy_to_buffer %1
|
||||
ror
|
||||
stp
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ rnz
|
||||
%macro unsafe_or 3
|
||||
.anchor before_unsafe_or
|
||||
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
bit_unsafe_or %1 %2 %3
|
||||
.tp %1
|
||||
ror
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ rnz
|
||||
%macro unsafe_xor 3
|
||||
.anchor before_unsafe_xor
|
||||
|
||||
%repeat _UNIT_SIZE
|
||||
%repeat _CELL_SIZE
|
||||
bit_unsafe_xor %1 %2 %3
|
||||
.tp %1
|
||||
ror
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
typedef uint32_t r8asm_label;
|
||||
typedef int32_t r8asm_data;
|
||||
typedef uint32_t unit_size_type;
|
||||
typedef int32_t unit_offset_type;
|
||||
typedef uint32_t cell_size_type;
|
||||
typedef int32_t cell_offset_type;
|
||||
typedef uint32_t mem_size_type;
|
||||
typedef uint32_t argc_type;
|
||||
|
||||
@@ -60,11 +60,11 @@ extern mem_size_type dataptr;
|
||||
|
||||
extern std::map<std::string, R8MetaOp> r8asm_insmap;
|
||||
|
||||
extern unit_size_type UNIT_SIZE;
|
||||
#define UNIT_MAX (((uint64_t)1 << UNIT_SIZE) - 1)
|
||||
extern cell_size_type CELL_SIZE;
|
||||
#define CELL_MAX (((uint64_t)1 << CELL_SIZE) - 1)
|
||||
|
||||
// #define DEFAULT_UNIT_SIZE (sizeof(unit_size_type) * 8)
|
||||
#define DEFAULT_UNIT_SIZE 8 // Just for test.
|
||||
#define DEFAULT_UNIT_MAX (((uint64_t)1 << DEFAULT_UNIT_SIZE) - 1)
|
||||
// #define DEFAULT_cell_SIZE (sizeof(cell_size_type) * 8)
|
||||
#define DEFAULT_CELL_SIZE 8 // Just for test.
|
||||
#define DEFAULT_CELL_MAX (((uint64_t)1 << DEFAULT_CELL_SIZE) - 1)
|
||||
|
||||
#endif
|
||||
+4
-4
@@ -20,7 +20,7 @@ r8asm_data read_opr(R8Operand arg,
|
||||
void expand_xor(std::vector<rot8_bytecode> &tape, R8Operand arg) {
|
||||
r8asm_data opr = read_opr(arg);
|
||||
|
||||
for (unit_size_type i = 0; i < UNIT_SIZE; i++) {
|
||||
for (cell_size_type i = 0; i < CELL_SIZE; i++) {
|
||||
if ((opr & 1) == 1)
|
||||
tape.push_back(rot8_bytecode::FLB);
|
||||
tape.push_back(rot8_bytecode::ROR);
|
||||
@@ -46,10 +46,10 @@ void expand_tp(std::vector<rot8_bytecode> &tape, R8Operand arg,
|
||||
bool count_offset = true) {
|
||||
r8asm_data opr = read_opr(arg);
|
||||
|
||||
unit_offset_type offset = (unit_offset_type)opr - (unit_offset_type)dataptr;
|
||||
cell_offset_type offset = (cell_offset_type)opr - (cell_offset_type)dataptr;
|
||||
bool stepforward = (offset > 0);
|
||||
offset = abs(offset);
|
||||
for (unit_offset_type i = 0; i < offset; i++) {
|
||||
for (cell_offset_type i = 0; i < offset; i++) {
|
||||
tape.push_back(stepforward ? rot8_bytecode::STP : rot8_bytecode::BTP);
|
||||
}
|
||||
if (count_offset)
|
||||
@@ -68,7 +68,7 @@ void expand_erase(std::vector<rot8_bytecode> &tape, R8Operand arg) {
|
||||
std::vector<rot8_bytecode> tmp = {rot8_bytecode::BIZ, rot8_bytecode::FLB,
|
||||
rot8_bytecode::RNZ,
|
||||
rot8_bytecode::ROR}; // [-]+
|
||||
for (unit_size_type i = 0; i < UNIT_SIZE; i++)
|
||||
for (cell_size_type i = 0; i < cell_SIZE; i++)
|
||||
tape.insert(tape.end(), tmp.begin(), tmp.end());
|
||||
return;
|
||||
}*/
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
#include "r8asm/r8asm_core.hh"
|
||||
unit_size_type UNIT_SIZE = DEFAULT_UNIT_SIZE;
|
||||
cell_size_type CELL_SIZE = DEFAULT_CELL_SIZE;
|
||||
mem_size_type dataptr = 0;
|
||||
|
||||
std::map<std::string, r8asm_label> labels = {{std::string("main"), 0}};
|
||||
std::map<std::string, r8asm_data> datas = {
|
||||
{std::string("_UNIT_MAX"), DEFAULT_UNIT_MAX},
|
||||
{std::string{"_UNIT_SIZE"}, DEFAULT_UNIT_SIZE}};
|
||||
{std::string("_CELL_MAX"), DEFAULT_CELL_MAX},
|
||||
{std::string{"_CELL_SIZE"}, DEFAULT_CELL_SIZE}};
|
||||
|
||||
std::map<std::string, R8MetaOp> r8asm_insmap = {
|
||||
{"stp", rot8_bytecode::STP}, {"btp", rot8_bytecode::BTP},
|
||||
|
||||
Reference in new issue
Block a user