{"id":21089514,"url":"https://github.com/farinap5/ndr-c","last_synced_at":"2025-09-17T19:21:46.980Z","repository":{"id":233056684,"uuid":"762774802","full_name":"farinap5/ndr-c","owner":"farinap5","description":"Custom architecture and compiler written in C","archived":false,"fork":false,"pushed_at":"2024-08-07T12:37:45.000Z","size":212,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-20T05:52:49.812Z","etag":null,"topics":["compiler","lexer","neander","parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/farinap5.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-24T16:52:12.000Z","updated_at":"2024-08-07T12:40:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"025632c1-d2b9-4f76-8098-9964bd2c3bbb","html_url":"https://github.com/farinap5/ndr-c","commit_stats":null,"previous_names":["farinap5/ndr-c"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farinap5/ndr-c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farinap5%2Fndr-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farinap5%2Fndr-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farinap5%2Fndr-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farinap5%2Fndr-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farinap5","download_url":"https://codeload.github.com/farinap5/ndr-c/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farinap5%2Fndr-c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275649362,"owners_count":25503208,"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-17T02:00:09.119Z","response_time":84,"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":["compiler","lexer","neander","parser"],"created_at":"2024-11-19T21:29:18.727Z","updated_at":"2025-09-17T19:21:46.954Z","avatar_url":"https://github.com/farinap5.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neander Machine\n\nThis project is a study on compilers. Here, a custom processor architecture is defined, along with a set of custom machine language instructions. In addition to the virtual machine, there is the compiler, which is capable of recognizing and compiling a simple grammar of mathematical expressions.\n\nThis project attempts to answer some questions such as:\n\n1. How can I perform certain mathematical expressions without using stack memory and with a very limited set of instructions?\n2. How can I generate code from a parser?\n3. How can I create an efficient virtual machine?\n\nThis project contains:\n\n- Compiler/parser\n- Assembler\n- Virtual Machine\n\nCreate folder `comp` before running _make_ file.\n\nSimple execution:\n\n```bash\nmake run FILE=equation.mth\n```\n\nClear data under `comp/`.\n\n```bash\nmake clear\n```\n\nYou can write expressions like the following: (2 + 3) + 2.\n\nFirst, the expression passes through the parser, which calls the lexer to collect each token.\n\nThe parser may execute the following actions and create the assembly code.\n\n```\nOpen parentesis\nWrite 2 to addr 192\nWrite 3 to addr 193\nSymbol +\nClose parentesis\nWrite 2 to addr 194\nSymbol +\n```\n\nWhile the parser, using a recursive descent analyzer, creates the tree of operations, it generates the assembly code, which will be compiled afterward.\n\n```\nADDR\n    c0 $add0\n    c1 $add1\n    c2 $add2\nEND\n```\n\nThe assembly (with customized syntax) includes several sections. The `ADDR` section contains address mappings, which are arbitrarily defined. In this example, the parser maps the label `$add0` to the address `c0`. Everything stored in `c0` is accessible via the label `$add0`.\n\n```\nDATA\n    0 fa\n    1 fb\n    0 fc\n    02 $add0\n    03 $add1\n    02 $add2\nEND\n```\n\nThe `DATA` section is where the data is stored for each previusly defined address (variable value). In this example, the value `02` is mapped to the address `$add0`. This means that any operation referencing the label `$add0` will access the value `02`. Similarly, other values are mapped to their respective addresses. It is possible to address instead labes like `0` mapped to `fa`.\n\n```\nTEXT\n    LDA $add0\n    ADD $add1\n    STA $add0\n\n    LDA $add0\n    ADD $add1\n    STA $add0\n\n    HLT\nEND\n```\n`TEXT` section has the assembly code. It consumes the addresses or labels. Jump instructions may use labels as well. Take a look at [neander](https://www.inf.ufrgs.br/arq/wiki/doku.php?id=neander) and `ndr-c/assembler/assembler.c` for all instructions.\n\nThe order of the sections must be preserved.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarinap5%2Fndr-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarinap5%2Fndr-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarinap5%2Fndr-c/lists"}