MoonBit月兔编程语言 现代编程思想 第十四课 案例:堆栈虚拟机
local.set 控制流: if/else call 7 类型定义 数据 1. enum Value { I32(Int) } // 只考虑32位有符号整数 指令 1. enum Instruction { 2. Const(Int) // 常数 3. Add; Sub; Modulo; Equal // // 函数调⽤ 5. Local_Get(String); Local_Set(String) // 取值、设值 6. If(Int, List[Instruction], List[Instruction]) // 条件判断 7. } 8 类型定义 函数 1. struct Function { 2. name : String 3. // 只考虑⼀种数据 称和数量 4. params : List[String]; result : Int; locals : List[String] 5. instructions : List[Instruction] 6. } 程序 1. struct Program { 2. functions : List[Function] 3. start : Option[String] 4. }0 码力 | 31 页 | 594.38 KB | 1 年前3
RISC-V 手册 v2(一本开源指令集的指南)主席和计算机协会(ACM,Association for Computing Machinery)主席。在 20 世纪 80 年代,他领导了四代精简指令集计算机(RISC,Reduced Instruction Set Computer) 项目,伯克利最新的 RISC 因此得名“RISC Five”。他和 Andrew Waterman 都是 RISC- V 四位架构师中的一员。除了 RISC 以 。 过去几年深入接触RISC-V后,我心中时常呈现出一种愿景——RISC-V很可能像Linux 那样开启开源芯片设计的黄金时代。事实上,伯克利的科研侠客们发明RISC-V就是希望 “Instruction Sets Want to be Free”——全世界任何公司、大学、研究机构与个人都可以开 发兼容RISC-V指令集的处理器,都可以融入到基于RISC-V构建的软硬件生态系统,而不需 要为指令集付一分钱。这是伟大的理想! Intel Corporation. Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 2: Instruction Set Reference. September 2016. 22 S. P. Morse. The Intel 8086 chip and the future of microprocessor0 码力 | 164 页 | 8.85 MB | 1 年前3
简明 X86 汇编语言教程 它的值,然而 并不提倡这样做,因为如果你不是非常明白自己在做什么,那么你可能造成堆栈的 破坏。对于绝大多数情况而言,这对程序是致命的。(SS 是默认的段或选择器) IP: Instruction Pointer, 指令指针 SP: Stack Pointer, 堆栈指针 好了,上面是最基本的寄存器。下面是一些其他的寄存器,你甚至可能没有听说过它们。 (都是 32 位宽): LOCK 封锁总线.:封锁数据指令 LOCK(Lock Bus Instruction) 该指令是一个前缀指令形式,在其后面跟一个具体的操作指令。LOCK 指令可以保证是在其 后指令执行过程中,禁止协处理器修改数据总线上的数据,起到独占总线的作用。该指令的 执行不影响任何标志位。 指令的格式:LOCK INSTRUCTION Causes the processor's LOCK# signal signal to be asserted during execution of the accompanying instruction (turns the instruction into an atomic instruction). In a multiprocessor environment, the LOCK# signal insures that the processor0 码力 | 63 页 | 598.28 KB | 1 年前3
RISC-V 开放架构设计之道 1.0.0过去几年深入接触 RISC-V 后,我心中时常呈现出一种愿景——RISC-V 很可能 像 Linux 那样开启开源芯片设计的黄金时代。事实上,伯克利的 “科研侠客们” 发明 RISC-V,就是希望 “Instruction Sets Want to be Free”——全世界任何公司、大学、 研究机构与个人都可以开发兼容 RISC-V 指令集的处理器,都可以融入基于 RISC-V 构建的软硬件生态系统,而 此外,我们还调整了书名《The RISC-V Reader》的翻译。第 1 版译本将书名翻译 为《RISC-V 手册》,余子濠认为这容易与 RISC-V 的官方指令集手册《The RISC-V Instruction Set Manual》混淆,讨论后决定在第 2 版译本中更改为《RISC-V 开放架 构设计之道》。 最 后, 我 们 也 决 定 将 第 2 版 译 本 以 电 子 版 的 形 式 发 Association)主席和计算机协会(ACM,Association for Computing Machinery)主 席。在 1980 年代,他领导了四代精简指令集计算机(RISC,Reduced Instruction Set Computer)项目,伯克利最新的 RISC 因此得名 “RISC Five”(第五代 RISC)。他 和安德鲁·沃特曼(Andrew Waterman)均为四位 RISC-V0 码力 | 223 页 | 15.31 MB | 1 年前3
AI大模型千问 qwen 中文文档[ { "instruction": "user instruction (required)", "input": "user input (optional)", "output": "model response (required)", "system": "system prompt (optional)", "history": [ ["user instruction in the the first round (optional)", "model response in the first␣ �→round (optional)"], ["user instruction in the second round (optional)", "model response in the␣ �→second round (optional)"] ] } ] • sharegpt sharegpt 格式的数据集应遵循以下格式: [ { "conversations": [ { "from": "human", "value": "user instruction" }, { "from": "gpt", "value": "model response" } ], "system": "system prompt (optional)", "tools": "tool0 码力 | 56 页 | 835.78 KB | 1 年前3
2.1.3 如何用Go模拟CPUGo模拟6502控制单元 • 指令结构(instruction) • 操作码(valid opcode) • 寻址模式 (address mode) • Implied • Accumulator • Immediate • Absolute • Zeropage, X, Y • Indirected, X, Y • 指令长度(instruction length) • 指令周期(cycle) generate转化一下 https://www.masswerk.at/6502/6502_instruction_set.html Go模拟6502控制单元 • 不过6502支持的指令:151个 • html解析器生成对应的指令 https://www.masswerk.at/6502/6502_instruction_set.html Go模拟6502控制单元 • 指令执行过程: • 读取指令码(opcode)0 码力 | 42 页 | 7.10 MB | 1 年前3
FISCO BCOS 2.1.0 中文文档CASE(CALLCODE) { ON_OP(); if (m_OP == Instruction::DELEGATECALL && m_rev < EVMC_HOMESTEAD) throwBadInstruction(); if (m_OP == Instruction::STATICCALL && m_rev < EVMC_BYZANTIUM) throwBadInstruction(); if (m_OP == Instruction::CALL && m_message->flags & EVMC_STATIC && m_SP[2] != 0) throwDisallowedStateChange(); 总结 EVM是一个状态执行的机器,输入是solidity编译后的二进制指令和节点的状 态数据,输出是 not-enough gas exception 9(0x9) BlockGasLimitReached GasLimit exception 10(0xa) BadInstruction wrong instruction exception status (decimal/hexadecimal) message definition 11(0xb) BadJumpDestination wrong jump0 码力 | 1058 页 | 740.85 KB | 1 年前3
FISCO BCOS 2.3.0 中文文档CASE(CALLCODE) { ON_OP(); if (m_OP == Instruction::DELEGATECALL && m_rev < EVMC_HOMESTEAD) throwBadInstruction(); if (m_OP == Instruction::STATICCALL && m_rev < EVMC_BYZANTIUM) throwBadInstruction(); if (m_OP == Instruction::CALL && m_message->flags & EVMC_STATIC && m_SP[2] != 0) throwDisallowedStateChange(); m_bounce = &VM::caseCall; } BREAK void VM::caseCall() long (RC version) 9(0x9) BlockGasLimitReached GasLimit exception 10(0xa) BadInstruction wrong instruction exception 11(0xb) BadJumpDestination wrong jump destination exception 12(0xc) OutOfGas out-of-gas0 码力 | 1227 页 | 10.79 MB | 1 年前3
FISCO BCOS 2.2.0 中文文档CASE(CALLCODE) { ON_OP(); if (m_OP == Instruction::DELEGATECALL && m_rev < EVMC_HOMESTEAD) throwBadInstruction(); if (m_OP == Instruction::STATICCALL && m_rev < EVMC_BYZANTIUM) throwBadInstruction(); if (m_OP == Instruction::CALL && m_message->flags & EVMC_STATIC && m_SP[2] != 0) throwDisallowedStateChange(); m_bounce = &VM::caseCall; } BREAK void VM::caseCall() long (RC version) 9(0x9) BlockGasLimitReached GasLimit exception 10(0xa) BadInstruction wrong instruction exception 11(0xb) BadJumpDestination wrong jump destination exception 12(0xc) OutOfGas out-of-gas0 码力 | 1156 页 | 10.03 MB | 1 年前3
FISCO BCOS 2.4.0 中文文档CASE(CALLCODE) { ON_OP(); if (m_OP == Instruction::DELEGATECALL && m_rev < EVMC_HOMESTEAD) throwBadInstruction(); if (m_OP == Instruction::STATICCALL && m_rev < EVMC_BYZANTIUM) throwBadInstruction(); if (m_OP == Instruction::CALL && m_message->flags & EVMC_STATIC && m_SP[2] != 0) throwDisallowedStateChange(); m_bounce = &VM::caseCall; } BREAK void VM::caseCall() long (RC version) 9(0x9) BlockGasLimitReached GasLimit exception 10(0xa) BadInstruction wrong instruction exception 11(0xb) BadJumpDestination wrong jump destination exception 12(0xc) OutOfGas out-of-gas0 码力 | 1314 页 | 11.21 MB | 1 年前3
共 111 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12













