首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

基于栈的虚拟机,可执行字节码

后端 19.1KB 37 需要积分: 1
立即下载

资源介绍:

定义了基础的字节码,可以读取并且识别字节码,并用栈机执行,可用于开发自己的脚本语言
# BytecodeVM A basic Virtual machine operating on bytecode. It operates on a stack and shares memory for instructions and data (van neumann architecture). It can compile to a binary file and run from a file, or compile and run directly from the assembly file. Currently a command line program but I plan to integrate it into ETEngine as a visual node based programming language. Commands: * compile [filename.bca] compiles a .bca assembly file to a binary .bce executable * run [filename.bce] runs a bytecode executable file * cRun [filename.bca] compiles and directly runs an assembly file without saving the executable ### Instruction Set | Opcode | Description | |:----------:|-------------| | LITERAL | Push next 4 bytes | | LITERAL_ARRAY | Get x from next 4 bytes; Push x sets of 4 bytes - temporary | | LOAD ; LOAD_ARG ; LOAD_LCL | Pop a; Push RAM[a] | | STORE ; STORE_LCL | Pop b; Pop a; RAM[b] = a | | ADD | Pop b; Pop a; Push a + b | | SUB | Pop b; Pop a; Push a - b | | LESS | Pop b; Pop a; Push a < b | | GREATER | Pop b; Pop a; Push a > b | | NOT | Pop a; Push !a | | EQUALS | Pop b; Pop a; Push a == b | | JMP | Pop a; goto a; | | JMP_IF | Pop b; Pop a; if a goto b | | CALL | put current state in a stack frame; store RTN; Pop a; goto a; | | RETURN | Restore to previous stack frame; append working stack; goto RTN | | PRINT | Pop x; for x Print Pop - temporary, will be a library function based on null terminated strings | | PRINT_INT | Pop a; Print string of a | | PRINT_ENDL | Start a new line in console | LOAD and STORE have segment modifiers that can be used as base addresses within functions | Segment | Description | |:----------:|-------------| | LCL | pointer to first local variable | | ARG | pointer to first argument | | Variable Type | Description | |:----------:|-------------| | static | a fixed address variable, referenced directly | | argument | a variable that sits in the working stack of the previous function's frame | | local | a local variable within the stack frame of the current function | There is no concept of scope so all variables should be unique Variables are declared implicitly upon their first occurance with the exception of arguments Variables declared before the first function are static, after the first function they are local The assembler also features Symbols (variables and labels) * Variables start with # and are statically allocated at compile time * Jump labels start with @ * Subroutines start with $ and are followed by argument declarations ### Planned I plan to add: * indexed library function support (executes function at pushed index) * Dynamic memory allocation * Support for standard types int float char bool (maybe short, long, double etc) unsigned or signed * Built in support for variable length arrays, strings and vectors

资源文件列表:

BytecodeVM-master.zip 大约有27个文件
  1. BytecodeVM-master/
  2. BytecodeVM-master/.gitignore 627B
  3. BytecodeVM-master/LICENSE.md 1.05KB
  4. BytecodeVM-master/Programs/
  5. BytecodeVM-master/Programs/DynamicAlloc/
  6. BytecodeVM-master/Programs/DynamicAlloc/DynAlloc.bca 223B
  7. BytecodeVM-master/Programs/Functions/
  8. BytecodeVM-master/Programs/Functions/Functions.bca 1.42KB
  9. BytecodeVM-master/Programs/Functions/Functions.bce 389B
  10. BytecodeVM-master/Programs/Functions/Functions.pseudo 333B
  11. BytecodeVM-master/Programs/HelloWorld/
  12. BytecodeVM-master/Programs/HelloWorld/HelloWorld.bca 709B
  13. BytecodeVM-master/Programs/HelloWorld/HelloWorld.bce 161B
  14. BytecodeVM-master/README.md 2.76KB
  15. BytecodeVM-master/build/
  16. BytecodeVM-master/build/genie.lua 1.28KB
  17. BytecodeVM-master/source/
  18. BytecodeVM-master/source/AssemblyCompiler.cpp 12.63KB
  19. BytecodeVM-master/source/AssemblyCompiler.h 1.3KB
  20. BytecodeVM-master/source/AtomicTypes.h 339B
  21. BytecodeVM-master/source/Opcode.cpp 276B
  22. BytecodeVM-master/source/Opcode.h 1.18KB
  23. BytecodeVM-master/source/SymbolTable.cpp 3.99KB
  24. BytecodeVM-master/source/SymbolTable.h 1.21KB
  25. BytecodeVM-master/source/VirtualMachine.cpp 19.67KB
  26. BytecodeVM-master/source/VirtualMachine.h 1.73KB
  27. BytecodeVM-master/source/main.cpp 3.65KB
0评论
提交 加载更多评论
其他资源 无标题代码代码代码代码代码
无标题代码代码代码代码代码
广东省各地市县2003~2022年经济指标数据.zip
广东省各地市县2003~2022年经济指标数据.zip
translator-rs-x86_64-unknown-linux-musl (1).zip
translator-rs-x86_64-unknown-linux-musl (1).zip
flask简单自学(docker形式)
flask简单自学(docker形式)
交换机自动化备份配置(H3C)
​ 介绍: 在日常运维过程中,需要定时备份设备的配置,在设备数量过于庞大的情况下,对我们的运维工作会造成极大地不便,通过python自动化能够完美解决人工手动保存设备配置的问题。而且自动化运维在未来也一定是大势所趋,在没有厂家网管软件的加持下,通过python是当下最好的选择。 代码介绍: 本次自动化代码中,共3个文件  backup.py:通过运行此python程序实现定时备份设备配置文件 command.txt:设备查看全部配置文件命令 sw.txt:需要备份的设备IP,每次输入一个IP需要换行处理 代码执行效果:  执行代码后,会自动新建一个文件夹,而文件夹的名字会获取当前日期来进行命名 而文件夹内则是存储当日保存的设备配置文件,配置文件的命令是通过抓取交换机的设备名+当前日期(年月日时分秒)来进行命名的。    代码可以通过修改,来满足管理员的需求,你想7天一备份,10天一备份都可以,下面是通过修改代码来满足需求的步骤。 第92行和第93行是设备的SSH账号和密码,请自行修改 USERNAME = "h3c" # 交换机登录用户 PASSW
亲和力传播聚类算法详解
包含内容:亲和力传播聚类算法步骤详解(有例子),亲和力传播聚类算法matlab代码(与亲和力传播聚类算法步骤详解一一对应)
亲和力传播聚类算法详解
701480892193306misgon_cyberdog工程代码.zip
701480892193306misgon_cyberdog工程代码.zip
1111111111111111111111111111111111111111111
111111111111111111111111111111111