[err]202505132350

This commit is contained in:
starcells committed 2026-05-13 23:50:54 +08:00
1 parent 725b2ae2ce
commit d18723c203
5 files changed
+61 -26

No files matched your search

+10 -12
View File
@@ -1,12 +1,10 @@
%macro test_erase 1
.tp %1
.loop _UNIT_MAX
biz
flb
rnz
ror
.endloop
%endmacro
.xor 15
test_erase $
inp
.anchor arg1
step
inp
.anchor arg2
step
.anchor ans
and arg1 arg2 ans
.tp ans
out
+38
View File
@@ -0,0 +1,38 @@
%macro step 1
stp %1
stp %1
%endmacro
%macro back 1
btp %1
btp %1
%endmacro
%macro and 3
.anchor before_and
.tp %1
stp
xor _UNIT_MAX
btp
.loop
biz
.tp %2
biz
.tp %3
flb
biz
flb
rnz
ror
rnz
.tp %2
ror
rnz
.tp %1
ror
.endloop
.tp before_and
%endmacro
+1 -9
View File
@@ -2,15 +2,7 @@
#include <variant>
#include <vector>
std::map<std::string, R8Macro> r8asm_macromap = {
{std::string("STEP"),
{1,
{{rot8_bytecode::STP, std::string("%1")},
{rot8_bytecode::STP, std::string("%1")}}}},
{std::string("BACK"),
{1,
{{rot8_bytecode::BTP, std::string("%1")},
{rot8_bytecode::BTP, std::string("%1")}}}}};
std::map<std::string, R8Macro> r8asm_macromap;
R8Operand read_arg(std::vector<R8Operand> &actual_args, R8Operand formal_para,
argc_type argc) {
+4 -4
View File
@@ -106,11 +106,11 @@ r8asm_translate_single_ins(std::vector<std::string> const raw_ins) {
}
void R8Src::preprocess() {
std::vector<R8Instruction> codeblock;
std::vector<R8Instruction> tmp_codeblock;
while (!this->codeblocks.empty()) {
auto i = this->codeblocks.top();
this->codeblocks.pop();
codeblock.clear();
tmp_codeblock.clear();
auto raw_codeblock =
std::ranges::subrange(std::next(i.first), i.second);
/*
@@ -119,12 +119,12 @@ void R8Src::preprocess() {
subrange:--------------------4 5 6---------------
*/
for (auto j : raw_codeblock)
codeblock.push_back(r8asm_translate_single_ins(j));
tmp_codeblock.push_back(r8asm_translate_single_ins(j));
if ((*i.first)[0] == "%macro") {
r8asm_macromap.insert_or_assign(
(*i.first)[1], R8Macro{(argc_type)std::get<r8asm_data>(
r8asm_arg_stoi((*i.first)[2])),
codeblock});
tmp_codeblock});
} else if ((*i.first)[0] == "%repeat") {
for (auto count =
std::get<r8asm_data>(r8asm_arg_stoi((*i.first)[1]));
+8 -1
View File
@@ -1,9 +1,16 @@
#include <iostream>
#include "r8asm/r8asm.hh"
#include "r8asm/r8asm_parse.hh"
int main(int argc, char *argv[]) {
auto src = read_src(argc > 1 ? argv[1] : "asm/asm.r8asm");
auto lib = read_src("/home/admin/Git/R8ASM/asm/lib.r8asm");
/*
for (auto i : lib.raw_src)
for (auto j : i)
std::cout << j << ';';*/
lib.preprocess();
auto src = read_src("asm/asm.r8asm");
auto out_tape = r8asm_tape_out(expand_macros(r8asm_preprocess(src)));
for (auto i : out_tape)
std::cout << ROT8_BC_TO_CHAR(i);