{"id":21320382,"url":"https://github.com/turkeymcmac/instruction-switch","last_synced_at":"2026-05-17T13:32:52.204Z","repository":{"id":114506591,"uuid":"165416821","full_name":"TurkeyMcMac/instruction-switch","owner":"TurkeyMcMac","description":"Generate code for handling complex switches based on bit patterns.","archived":false,"fork":false,"pushed_at":"2019-01-26T15:57:42.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T11:32:10.341Z","etag":null,"topics":["assembly","codegen"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/TurkeyMcMac.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":"2019-01-12T17:39:20.000Z","updated_at":"2019-01-26T15:57:44.000Z","dependencies_parsed_at":"2023-05-17T11:45:33.656Z","dependency_job_id":null,"html_url":"https://github.com/TurkeyMcMac/instruction-switch","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/TurkeyMcMac%2Finstruction-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Finstruction-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Finstruction-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurkeyMcMac%2Finstruction-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TurkeyMcMac","download_url":"https://codeload.github.com/TurkeyMcMac/instruction-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801601,"owners_count":20350105,"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":["assembly","codegen"],"created_at":"2024-11-21T19:47:31.037Z","updated_at":"2026-05-17T13:32:52.199Z","avatar_url":"https://github.com/TurkeyMcMac.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# instruction-switch\nGenerate code for handling complex switches based on bit patterns. The name was\ngiven because I hope to use it for decoding machine code instructions. The\nprogram generates the body of a C function which you can `#include` in another\nfile.\n\n## Installation\nTo make the executable usable, do the following on the command line:\n```\nmake install\n```\n\nIf you can't use make and/or awk, here are the manual steps:\n 1. copy `src/main.rb` to the file `instrswitch`\n 2. Put the shebang or whatever at the file beginning: `#!/usr/bin/env ruby`\n 3. Look through the new file and replace all file names which are arguments to\n    `load` statements with the absolute paths to those files (they are all in\n    the `src` directory)\n 4. Make the new file executable using `chmod +x instrswitch` or something\n 5. Copy `instrswitch` to a directory in your PATH\n\n## Usage\n### Generation\nCall the executable with the form\n```\ninstrswitch -i \u003cinstruction table\u003e \u003e -o \u003cdestination\u003e\n```\nwhere the instruction table is a TSV file in the following format:\n```\nname\u003cTAB\u003eformat\n\u003cinstruction name\u003e\u003cTAB\u003e\u003cinstruction format\u003e\n```\n\nEach instruction format is a sequence of up to 64 characters. 0s and 1s indicate\na bit which is invariant for that instruction. Other characters indicate a bit\nwhich can vary. All other characters except '_' or ' ' also correspond to an\nargument of the instruction, and will be recorded.\n\nThe generated code is minified, so run it through `indent` before viewing it.\n\n### Including in C Code\nTwo macros must be defined above where the autogenerated file is included:\n * `DO_INSTR_(name, arg_count, args)`: This takes the name of the matching\n   instruction as a symbol and the comma-separated argument list within\n   parentheses. `arg_count` is the number of arguments to the instruction.\n * `DO_ERROR_`: This token is used in the case that none of the possible\n   instructions match the pattern.\n\n## Format Overlap\nThe instruction formats given must be completely unambiguous. For example, this\nis legal:\n```\nadd\u003cTAB\u003e0aaabbb1\nsub\u003cTAB\u003e1aaabbb1\n```\nBut it would be illegal to add:\n```\nneg\u003cTAB\u003e1aaa1111\n```\nBecause their is no way to tell between the `sub` and `neg` instructions.\n\n## Examples\nAfter you have built the program, there is an example of its usage in\n`examples/utf8`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturkeymcmac%2Finstruction-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturkeymcmac%2Finstruction-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturkeymcmac%2Finstruction-switch/lists"}