From e04b7b2949ed706c3167d0783ff7828317d886cd Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Sat, 27 Jun 2026 04:51:06 +0000 Subject: [PATCH] Add README.md --- README.en.md | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..75fc505 --- /dev/null +++ b/README.en.md @@ -0,0 +1,102 @@ +# BF VM + +A Brainfuck virtual machine project featuring multiple interpreter implementations and auxiliary tools. + +## Project Overview + +This project implements a Brainfuck virtual machine system supporting multiple operational modes, including assembly instruction interpretation, memory tape manipulation, and an integrated object system. + +## Features + +### Core Components + +- **asm.py** - MiniAsm Assembly Interpreter + - Supports basic assembly instructions (assignment, arithmetic, memory operations) + - while loop control flow + - Input/output operations + +- **asm5.py** - Extended Interpreter + - Built-in object system (Int, Str, List, Dict, Set, etc.) + - Memory tape (MemTape) operations + - Python module bridging + - import mechanism + +- **small1.py** - Small Language Interpreter + - Custom Small language parsing + - User-defined function support + - Type constructors + +### Hardware Simulation + +- **RAM Operations** - Memory read/write +- **Disk Operations** - Disk state persistence +- **COM1 Operations** - Serial communication + +## Usage + +### Running Brainfuck Code + +Refer to examples in `main.md`: + +```brainfuck +[?>] : Loop sending characters from RAM to COM1 Tx until encountering 0 +% : Execute command +[#.] : Loop reading from COM1 Rx and outputting until buffer is empty +``` + +### Using the asm.py Interpreter + +```python +from asm import MiniAsmInterpreter + +interpreter = MiniAsmInterpreter() +interpreter.load(code) +interpreter.run() +``` + +### Using Built-in Objects in asm5.py + +```python +from asm5 import IntObject, StrObject, ListObject, MemTape + +# Create objects +num = IntObject(42) +text = StrObject("Hello") +lst = ListObject([1, 2, 3]) + +# Memory tape operations +tape = MemTape() +tape.val = 100 +``` + +## Project Structure + +``` +bf_vm/ +├── asm.py # Basic assembly interpreter +├── asm5.py # Extended interpreter +├── main.md # Virtual machine documentation +├── small1.py # Small language interpreter +├── small1.html # HTML page +├── small_lang/ # Small language examples +│ ├── 1.sml +│ ├── small1.PY +│ ├── test.small +│ ├── test.sml +├── x86/ # x86 virtual machine +│ ├── main.py +│ └── vm.py +└── LICENSE # MIT License +``` + +## Example Code + +See Small language examples in `test.sml` and `small_lang/test.sml`. + +## License + +MIT License + +## Author + +dzz120dzz \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fb5281 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +# BF VM + +一个 Brainfuck 虚拟机项目,包含多种解释器实现和辅助工具。 + +## 项目简介 + +本项目实现了一个 Brainfuck 虚拟机系统,支持多种操作模式,包括汇编指令解释、内存磁带操作、内置对象系统等功能。 + +## 功能特性 + +### 核心组件 + +- **asm.py** - MiniAsm 汇编解释器 + - 支持基本的汇编指令(赋值、算术、内存操作) + - while 循环控制流 + - 输入/输出操作 + +- **asm5.py** - 扩展版解释器 + - 内置对象系统(Int, Str, List, Dict, Set 等) + - 内存磁带(MemTape)操作 + - Python 模块桥接 + - import 机制 + +- **small1.py** - Small 语言解释器 + - 自定义 Small 语言解析 + - 用户函数支持 + - 类型构造器 + +### 硬件模拟 + +- **RAM 操作** - 内存读写 +- **Disk 操作** - 磁盘状态持久化 +- **COM1 操作** - 串口通信 + +## 使用方法 + +### 运行 Brainfuck 代码 + +参考 `main.md` 中的示例: + +```brainfuck +[?>] : 循环发送 RAM 中的字符到 COM1 Tx,直到遇到 0 +% : 执行命令 +[#.] : 循环从 COM1 Rx 读取并输出,直到缓冲区空 +``` + +### 使用 asm.py 解释器 + +```python +from asm import MiniAsmInterpreter + +interpreter = MiniAsmInterpreter() +interpreter.load(code) +interpreter.run() +``` + +### 使用 asm5.py 内置对象 + +```python +from asm5 import IntObject, StrObject, ListObject, MemTape + +# 创建对象 +num = IntObject(42) +text = StrObject("Hello") +lst = ListObject([1, 2, 3]) + +# 内存磁带操作 +tape = MemTape() +tape.val = 100 +``` + +## 项目结构 + +``` +bf_vm/ +├── asm.py # 基础汇编解释器 +├── asm5.py # 扩展版解释器 +├── main.md # 虚拟机文档 +├── small1.py # Small 语言解释器 +├── small1.html # HTML 页面 +├── small_lang/ # Small 语言示例 +│ ├── 1.sml +│ ├── small1.PY +│ ├── test.small +│ ├── test.sml +├── x86/ # x86 虚拟机 +│ ├── main.py +│ └── vm.py +└── LICENSE # MIT 许可证 +``` + +## 示例代码 + +参见 `test.sml` 和 `small_lang/test.sml` 中的 Small 语言示例。 + +## 许可证 + +MIT License + +## 作者 + +dzz120dzz \ No newline at end of file -- Gitee