{"id":20637632,"url":"https://github.com/vishalthehuman/hack-vm-translator","last_synced_at":"2026-05-16T18:08:48.931Z","repository":{"id":169751481,"uuid":"645773612","full_name":"VishalTheHuman/Hack-VM-Translator","owner":"VishalTheHuman","description":"The Hack VM Translator is a program that translates Hack VM code into Hack Assembly code. It is used in the Nand2Tetris course to convert high-level code written in the Hack VM language into low-level code that can be executed on the Hack computer platform.","archived":false,"fork":false,"pushed_at":"2024-05-02T01:04:27.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T08:41:08.338Z","etag":null,"topics":["assembly","assembly-language","elements-of-computing-systems","hack","hack-vm","mini-project","nand2tetris","pushpop","virtual-machine","vm","vm-translator","vmtranslator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VishalTheHuman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-26T12:02:24.000Z","updated_at":"2024-05-02T01:04:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"98395cd2-33f4-432d-a8b2-99bc7c707ad1","html_url":"https://github.com/VishalTheHuman/Hack-VM-Translator","commit_stats":null,"previous_names":["vishalthehuman/hack-vm-translator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VishalTheHuman/Hack-VM-Translator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VishalTheHuman%2FHack-VM-Translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VishalTheHuman%2FHack-VM-Translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VishalTheHuman%2FHack-VM-Translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VishalTheHuman%2FHack-VM-Translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VishalTheHuman","download_url":"https://codeload.github.com/VishalTheHuman/Hack-VM-Translator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VishalTheHuman%2FHack-VM-Translator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274882092,"owners_count":25367394,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["assembly","assembly-language","elements-of-computing-systems","hack","hack-vm","mini-project","nand2tetris","pushpop","virtual-machine","vm","vm-translator","vmtranslator"],"created_at":"2024-11-16T15:15:20.423Z","updated_at":"2026-05-16T18:08:43.903Z","avatar_url":"https://github.com/VishalTheHuman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Hack-VM-Translator 💻📟**\n![Hack-VM-Translator](assets/Hack-VM-Translator.png)\n\n## **Description**\n🟡 The **Hack VM Translator** is a software tool used in the Nand2Tetris course to translate high-level code written in the Hack VM language into low-level code written in Hack Assembly language. The translator is responsible for converting the VM code into a series of assembly language instructions that can be executed on the Hack computer platform. The Hack VM Translator in this project is done in python. \u003cbr\u003e\n🟢 The virtual machine is stack-based: all operations are done on a stack. It is also function-based: a complete VM program is organized in program units called functions, written in the VM language. Each function has its own stand-alone code and is separately handled. The VM language has a single 16-bitdata type that can be used as an integer, a Boolean, or a pointer. \u003cbr\u003e\u003cbr\u003e**The language consists of four types of commands:**\u003cbr\u003e\u003cbr\u003e\n    🟥   **Arithmetic commands** perform arithmetic and logical operations on the stack.\u003cbr\u003e\n    🟧\t**Memory access commands** transfer data between the stack and virtual memory segments.\u003cbr\u003e\n    🟨\t**Program flow commands** facilitate conditional and unconditional branching operations.\u003cbr\u003e\n    🟩\t**Function** calling commands call functions and return from them.\u003cbr\u003e\n## **Types of Memory Segments 📝**\n    • static \n    • local\n    • argument\n    • constant\n    • this\n    • that\n    • pointer\n    • temp\n\n## **Types of Arithmetic/Logical Commands 💬**\n    • add\n    • sub\n    • neg\n    • eq\n    • gt\n    • lt\n    • and\n    • or\n    • not\n\n## **Types of Memory Access Commands 📖**\n    • pop segment i\n    • push segment i\n\n## **Types of Branching Commands 🌿**\n    • label label\n    • goto label\n    • if-goto label\n\n## **Types of Function Commands 😶‍🌫️**\n    • function functionName nVars\n    • call functionName nArgs\n    • return\n\n## **Example**\n### **StaticTest.vm**\n```\n// This file is part of www.nand2tetris.org\n// and the book \"The Elements of Computing Systems\"\n// by Nisan and Schocken, MIT Press.\n// File name: projects/07/MemoryAccess/StaticTest/StaticTest.vm\n\n// Executes pop and push commands using the static segment.\npush constant 111\npush constant 333\npush constant 888\npop static 8\npop static 3\npop static 1\npush static 3\npush static 1\nsub\npush static 8\nadd\n```\n\n### **StaticTest.asm**\n```\n@256\nD=A\n@SP\nM=D\n@2048\nD=A\n@LCL\nM=D\n@3000\nD=A\n@ARG\nM=D\n@5000\nD=A\n@THIS\nM=D\n@7000\nD=A\n@THAT\nM=D\n@16\nD=A\n@14\nM=D\n//push constant 111\n@111\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//push constant 333\n@333\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//push constant 888\n@888\nD=A\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//pop static 8\n@StaticTest.8\nD=A\n@R15\nM=D\n@SP\nAM=M-1\nD=M\n@R15\nA=M\nM=D\n//pop static 3\n@StaticTest.3\nD=A\n@R15\nM=D\n@SP\nAM=M-1\nD=M\n@R15\nA=M\nM=D\n//pop static 1\n@StaticTest.1\nD=A\n@R15\nM=D\n@SP\nAM=M-1\nD=M\n@R15\nA=M\nM=D\n//push static 3\n@StaticTest.3\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//push static 1\n@StaticTest.1\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//sub\n@SP\nM=M-1\nA=M\nD=M\n@SP\nM=M-1\nA=M\nM=M-D\n@SP\nM=M+1\n\n//push static 8\n@StaticTest.8\nD=M\n@SP\nA=M\nM=D\n@SP\nM=M+1\n\n//add\n@SP\nM=M-1\nA=M\nD=M\n@SP\nM=M-1\nA=M\nM=D+M\n@SP\nM=M+1\n\n\n(END)\n@END\n0;JMP\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishalthehuman%2Fhack-vm-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvishalthehuman%2Fhack-vm-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishalthehuman%2Fhack-vm-translator/lists"}