{"id":16032798,"url":"https://github.com/threez/simple_vm","last_synced_at":"2025-04-01T13:16:22.230Z","repository":{"id":550834,"uuid":"181199","full_name":"threez/simple_vm","owner":"threez","description":"A basic simple vm to learn more about compiling, byte code and virtual mashines","archived":false,"fork":false,"pushed_at":"2012-04-09T14:14:20.000Z","size":128,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T08:12:33.761Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/threez.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-04-20T21:12:24.000Z","updated_at":"2019-08-13T14:19:51.000Z","dependencies_parsed_at":"2022-07-07T23:21:22.389Z","dependency_job_id":null,"html_url":"https://github.com/threez/simple_vm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2Fsimple_vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2Fsimple_vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2Fsimple_vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2Fsimple_vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threez","download_url":"https://codeload.github.com/threez/simple_vm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246644097,"owners_count":20810687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T21:40:38.444Z","updated_at":"2025-04-01T13:16:22.199Z","avatar_url":"https://github.com/threez.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= SimpleVM\n\nThis project is a simple virtual machine implementation to learn more about\nimplementing virtual machines and programming languages.\n  \n== Architecture\n\nThe virtual machine is implemented as a stack-full vm that has an additional ram to store variable values that are addressable by 32 bit integers.\n\n== Simple Language\n\nA language that only deals with 4 byte integers. The language supports loops and conditions. Here is a simple example, the calculation of the fibonacci sequence.\n\n  declarations \n    integer i1, i2, n, s1. \n  begin \n    read n;\n    i1 := 0;\n    i2 := 1;\n    while n \u003e 0 do\n      s1 := i1;\n      i1 := i2;\n      i2 := s1 + i2;\n      n := n - 1;\n    end;\n    write i1;\n  end\n  \nThe *read* and *write* functions help to read and write to the console.\n\n== Virtual Machine Instruction Set\n\nThe vm has a simple instruction set that can read and write integers and simple math and program flow mechanisms.\n\n=== [DATA, argument]\n\nargument: 32 bit integer\n\nstack: no changes\n\nThis operation declares the count + 1 of used variables in the vm. E. g. [DATA, 3] would reserve 3 variables with the addresses 1, 2, 3. The address 0 is a special address that will be used for jumping in the future.\n\n=== [HALT, argument]\n\nargument: 8 bit integer\n\nstack: no changes\n\nTHis operation stops the execution of the vm immediately with return code that is specified by argument.\n  \n=== [READ_INT]\n\nargument: %\n\nstack:\n  before: []\n  after: [integer]\n\nThis operation reads an 32 bit integer from the stdin device and pushes it to the stack.\n  \n=== [WRITE_INT]\n\nargument: %\n  \nstack:\n  before: [integer]\n  after: []\n  \nThis operation pops a 32 bit integer from the stack and outputs it to the stdout device\n\n=== [STORE, argument]\n\nargument: 32 bit integer address of the variable\n\nstack:\n  before: [integer]\n  after: []\n  \nThis operation pops a 32 bit integer value from the stack and stores it in the variable space that is passed (argument).\n\n=== [JMP_FALSE, argument]\n\nargument: 32 bit integer address of the new instruction pointer position\n  \nstack:\n  before: [integer]\n  after: []\n  \nThis operation pops a 32 bit integer value from the stack and checks it. If the value is equal to 0 the vm will jump to the new instruction pointer that was passed with the operation, otherwise it will ignore the jump.\n\n=== [GOTO, argument]\n\nargument: 32 bit integer address of the new instruction pointer position\n\nstack: no changes\n\nThis operation moves the instruction pointer to the passed position.\n\n=== [LD_INT, argument]\n\nargument: 32 bit integer value\n\nstack:\n  before: []\n  after: [integer]\n\nThis operation pushes a 32 bit integer value onto the stack and\n\n=== [LD_VAR, argument]\n\nargument: 32 bit integer address\n\nstack:\n  before: []\n  after: [integer]\n\nPut the value at the address on the stack.\n\n=== [LT]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nChecks if the integer1 is lower than integer2 and pushes a 1 to the stack if the expression is true or a 0 if it is false.\n\n=== [EQ]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nChecks if the integer1 is equal to integer2 and pushes a 1 to the stack if the expression is true or a 0 if it is false.\n\n=== [GT]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nChecks if the integer1 is grater then integer2 and pushes a 1 to the stack if the expression is true or a 0 if it is false.\n\n=== [ADD]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nAdds the integer1 and integer2 and pushes the result onto the stack.\n\n=== [SUB]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nSubstracts the integer1 and integer2 (integer1 - integer2) and pushes the result onto the stack.\n\n=== [MULT]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nMultiply the integer1 and integer2 and pushes the result onto the stack.\n\n=== [DIV]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nAdds the integer1 and integer2 and pushes the result onto the stack.\n\n=== [PWR]\n\nargument: %\n\nstack:\n  before: [integer2, integer1]\n  after: [integer]\n  \nPowers the integer1 by the value of integer2 and pushes the result onto the stack.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreez%2Fsimple_vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreez%2Fsimple_vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreez%2Fsimple_vm/lists"}