当前位置: 首页 > 软件库 > 开发工具 > 编译器 >

miniC-hosting

授权协议 MIT License
开发语言 C/C++
所属分类 开发工具、 编译器
软件类型 开源软件
地区 不详
投 递 者 梁丘烨
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

What is it?

  1. A simple stack-based virtual machine that runs C in the browser.

  2. An interactive tutorial that covers C, how the VM works, and how the language is compiled, everything from the ground up.

Why?

This project demystifies compilers without getting lost in unnecessary details.MiniC visually explores how a compiler can break down the C language into simple instructions and how those are executed by a virtual CPU.

Can I see it?

  1. Sandbox

  2. Tutorial (for people with 0 programming experience or willing to learn C) :

    • Part 1 - Introduction
    • Part 2 - Expressions (part 1)
    • Part 3 - Expressions (part 2)
    • Part 4 - Variables and program structure

Subscribe

Get notified when new tutorials are released.

Feedback

Join the discussion on our subreddit.

Support

Consider supporting the project.

Documentation

Virtual Instruction Set

Note: BEFORE each instrunction, IP increases by 1

PUSH

  • increases SP by 1 and sets the value at SP to the argument ("Pushes the argument onto the stack")

LEA:

  • similar to PUSH
  • instead of pushing just the argument, it pushes BP + argument ("Loads the Effective Address")
  • used to push the address of a local variable on the stack ("LEA 2" is used to push the address of the second local variable on the stack)

DRF:

  • replaces the address on the top of the stack with the value at that address ("Dereferences the address")
  • e.g. to push the value of a local variable, we use LEA follwed by DRF

POP

  • decreases SP by 1 ("pops a value off the stacK")
  • used if the value on the top of the stack is not needed, to prevent the stack from growing indefinitely
  • e.g. after calling a function without indending to use its returned value

JMP

  • sets IP to the argument ("jump to the address gives as argument")
  • used to compile control structures such as "if" and "while"

JZ:

  • pops a value off the stack, and if that value is 0, it jumps to the argument ("jump if zero")
  • used to compile constrol structures such as "if" and "while"

FSTART:

  • a sequence of simpler instructions performed before each function ("Function START");
    • pushes the value of BP effectively saving it before setting BP
    • sets BP to SP
    • increase SP by the value of the argument, effectively making room for local variables
  • effectively sets up the stack so that BP so that BP points to the old BP, BP + 1 to the first local variable, BP + 2 to the second, etc.
  • before the function returns, BP will be restored to its old value

RET:

  • a sequence of simpler instructions performed before each function RETurns
    • remembers the value on the top of the stack. this is the function return value.
    • sets SP to BP, effectively popping all the local variables and the returned value
    • sets BP to the value on the top of the stack, effectively restoring BP to its value before FSTART
    • performs a POP
    • sets IP to the value on the top of the stack, effectively setting IP to point to the next instrunction after the CALL that created this function
    • performs a POP
    • decreases SP by the argument, effectively popping all the arguments pushed before the function was called
    • replaces the value on the top of the stack (which is the address of the current function) with the function return value remembered earlierall the previous POPs ensure that SP is now set to its original value before calling the function + 1. The top of the stack is the returned value of the function

CALL:a sequence of simpler instructions performed to CALL a function. it assumes that the address of the function followed by all the arguments have already been pushed

  • Pushes IP (which was already increased by 1), effectively pushing the address of the next instruction. This value will be used by the RET instrunction to set IP to the address of next instrunction after CALL
  • sets ip to SP - 1 - argument, with is the address of the FSTART instrunction of the function being called

ALLOC:

  • generated by the new operator
  • a sequence of simpler instructions performed to ALLOCate memory dynammically
    • remembers the value on the top of the stack, which is the requsted amount of memory
    • saves the value of HP
    • increases HP by the requsted amount of memory
    • pushes the previously saved value of HP onto the stack

ASSIGN:

  • used to chnage the value at some address to the value on the top of the stack (ASSiGNment), e.g. "a = 2;"
  • remembers VAL, the value on the top of the stack
  • sets the value at address SP - 1 to VAL
  • performs a POP
  • sets the value on the top of the stack to VAL. This leaves the door open to multiple variable assignment (such as "a = b = 3;")

PLUSEQ:

  • just like ASSIGN, but performs addition instead of replacing the value (e.g. a += 2;)

MINUSEQ:

  • just like ASSIGN, but performs subtraction instead of replacing the value (e.g. a -= 2;)

TIMESEQ:

  • just like ASSIGN, but performs multiplication instead of replacing the value (e.g. a *= 2;)

DIVEQ:

  • just like ASSIGN, but performs division instead of replacing the value (e.g. a /= 2;)

MODEQ:

  • just like ASSIGN, but performs the moduls operation instead of replacing the value (e.g. a %= 2;)

TIMES:

  • POPs the two values on the top of the stack, multiplies them, and pushes the result (e.g. 6 * 3)

DIV:

  • POPs the two values on the top of the stack, divides them, and pushes the result (e.g. 6 / 3)

MOD:

  • POPs the two values on the top of the stack, performs the modulus operation on them, and pushes the result (e.g. 6 % 3)

PLUS:

  • POPs the two values on the top of the stack, adds them, and pushes the result (e.g. 6 + 3)

MINUS:

  • POPs the two values on the top of the stack, substracts them, and pushes the result (e.g. 6 - 3)

Missing language features

  • only bool, int, char and pointers as data types and they all have the same size in memory

  • no malloc, but operator new is working (like in C++),

  • no static arrays and structs (dynamic arrays and pointer to structs work fine).

  • no arrays of structs (arrays of pointers to structs works fine).

  • no for and switch statements

  • no preprocessor directives

  • no bitwise operators

  • no ++, --, ternary operators

  • no union and no enum

  • no global variables

  • no function pointers

  • no free / delete operator

  • no function overloading

 相关资料
  • 我们使用基于mod-wsgi的主机。我遵循了以下URL中给出的步骤: http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ 编辑1:最新网址:http://flask.pocoo.org/docs/1.0/deploying/mod_wsgi/ Apache错误日志显示以下消息: WSGI文件看起来像这样: 文件夹树结构如下所示: 有人能帮我解决

  • 一、安全注意事项 期待被黑!   如果要为WebPagetest的公共实例运行测试位置,应该将测试系统视为被黑客入侵。你正在运行一台机器,Internet上的任何人都能浏览任何页面,甚至可以利用浏览器漏洞的页面。你可以采取很多保护措施来最大限度地降低风险,但是永远不能消除这种风险,所以不要将测试系统放在任何权限低的地方。 有些事情要考虑: 如果可以的话,将测试系统放入DMZ,隔离任何敏感内容 将测

  • 购买主机后,您必须将域名与您购买的主机连接。 如果您已从同一提供商处购买域名并托管,那么您的域名服务器已经设置好了。 如果您已购买域名并从不同的提供商托管,则必须手动将新的域名服务器添加到您的域中,以便它可以将您的域指向正确的服务器。 名称服务器是域名系统的一部分。 这些DNS服务器保留哪个域连接到哪个IP地址的记录。 名称服务器允许我们使用域而不是DNS服务器的IP地址。 当访问者键入您的域的U

  • 如果您已经注册了域名,则下一步是为您的网站获取虚拟主机。 网络托管是一项服务,为您的网站提供互联网空间。 如果您希望您的网站在线发布,那么您必须获得网络托管服务。 在网络托管服务中,您的网站存储在称为Web服务器的高性能计算机中,这些计算机连接到高速网络,并且每周7天每天24小时开机。 购买网络托管服务时,您可以在这些服务器上为您的网站租用空间。 基本上有三种类型的网络托管 - Shared Ho

  • 托管(也称为网站托管)是维护和组织网站并通过万维网提供对网站的访问的过程。 简而言之,您可以说,它是一种为互联网上的网站提供服务的平台。 Grav支持不同类型的托管服务 - Rochen Web Hosting WireNine Crucial Web Hosting Arvixe SiteGround Dreamhost Rochen网页寄存 它可以用作GetGrav.org和RocketThe

  • Awesome Static Hosting and CMS A collection of awesome static hosting providers, content management systems, and curated articles. Inspiration Most importantly, this list wouldn't exist without the ex

相关阅读

相关文章

相关问答

相关文档