{"id":16168115,"url":"https://github.com/haydenheroux/hasm-cpp","last_synced_at":"2026-04-30T10:10:41.284Z","repository":{"id":155400786,"uuid":"275748841","full_name":"haydenheroux/hasm-cpp","owner":"haydenheroux","description":"A simple interpreter for my esoteric language HASM.","archived":false,"fork":false,"pushed_at":"2020-08-27T06:00:51.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T06:18:21.330Z","etag":null,"topics":["assembly","cpp","esoteric"],"latest_commit_sha":null,"homepage":"https://hayden977.github.io/hasm-cpp/","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/haydenheroux.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":"2020-06-29T06:25:28.000Z","updated_at":"2020-08-27T06:00:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf9f59e1-ff4e-4aa5-9a32-b94908177677","html_url":"https://github.com/haydenheroux/hasm-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/haydenheroux/hasm-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haydenheroux%2Fhasm-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haydenheroux%2Fhasm-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haydenheroux%2Fhasm-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haydenheroux%2Fhasm-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haydenheroux","download_url":"https://codeload.github.com/haydenheroux/hasm-cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haydenheroux%2Fhasm-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32461003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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","cpp","esoteric"],"created_at":"2024-10-10T03:10:34.094Z","updated_at":"2026-04-30T10:10:41.256Z","avatar_url":"https://github.com/haydenheroux.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hasm-cpp\n\n\n## Table of Contents\n* [About](#about)\n* [Getting Started](#getting-started)\n  * [Building](#building)\n* [Usage](#usage)\n  * [Arguments](#arguments)\n  * [Syntax](#syntax)\n  * [Memory Layout](#memory-layout)\n* [Contributions](#contributons)\n  * [TODO](#todo)\n* [Acknowledgements](#acknowledgements)\n* [Contact](#contact)\n\n\n## About\nHASM and its sister project, SASM, is an esoteric language designed for any system.\nHASM takes its name and many features from assembly-style languages.\nMinimal syntactic sugar, combined with a simple instruction set, makes the simplest programs in HASM a challenge.\n\nThe HASM interpreter is written in C++ for all platforms.\nDevelopment of HASM started in January 2020, in Python.\nThe original (partly functional) project can be found on my [Gists](https://gist.github.com/Hayden977/f26fb8bfc31401f9e48e542a77773554).\n\n\n## Getting Started\n\n\n### Building\nBy default, HASM is built with g++ on all platforms.\nIn the base directory, there are compilation scripts for Windows and Linux systems.\nRunning the script for your platform will create the `hasm` executable in the `bin` directory.\nFor Linux systems, the compilation script will need to be made executable using `chmod`. \nExample build and execution processes for both systems are shown below.\n\n#### Linux\n```Bash\ncd hasm-cpp\nchmod +x ./compile.sh\n./compile.sh\ncd ./bin\n./hasm\n```\n\n#### Windows\n```Batch\ncd hasm-cpp\ncompile\ncd bin\nhasm\n```\n\n\n## Usage\nAs of version 1.3 (8/27/2020), running `hasm` in the `bin` directory will result in the following output.\n```\n[HASM]:\n```\nThis field accepts any valid instruction (see [Syntax](#syntax)), as well as the special commands `place` and `peek`.\n`Peek` is only active when the `silent` flag is set, using the argument `-s`. \nOther command line arguments can be found in the [Arguments](#arguments) section.\nIf the silent flag is not set, the status of the HASM memory space is printed after every command or instruction.\nBy default, you can exit the HASM interpreter by typing `quit` or `q` at the prompt, or by pressing `^C`.\n\n### Arguments\n\n| Argument | Effect                                 | Exits? |\n| -------- | -------------------------------------- | ------ |\n| -c       | Sets the character flag                | n      |\n| -d       | Treats the following `-e` as devices   | n      |\n| -e       | Executes the specified file at startup | n      |\n| -f       | Sets the flag shift flag (use with -e) | n      |\n| -h       | Displays a help message                | Y      |\n| -l       | Write commands to the specified file   | n      |\n| -s       | Sets the silent flag                   | n      |\n| -v       | Displays a version message             | Y      |\n\n#### Character Mode\nIn character mode, the contents of the HASM memory space is shown as character.\nThe character flag can be used in combination with the silent flag.\nCharacter mode is designed for showing string of text in the memory.\nThe character flag allows programs involving \"strings\" to be used.\n\n#### Execute at Startup\nWith version 1.2 (7/5/20), the HASM interpreter now has the ability to execute files at startup.\nTo execute a file, start the interpreter with the `-e` flag. \nSpecify the path of the file to be read after the `-e` flag. \nThe contents of the file will be treated the same as many interpreter commands.\nComments can be specified using the ';' symbol, or can be left in the file unaltered.\nHowever, using the ';' symbol will lead to the interpreter skipping the line, saving some performance.\nMultiple execute flags can be chained to read multiple files.\n\n#### Silent Mode\nIn silent mode, the `[HASM]:` message is not shown.\nAdditionally, the contents of the HASM memory space is hidden.\nThe contents of the memory space can be accessed using the `peek` command.\nSilent mode is designed for minimalist users, or for users who are presenting their development.\nAs of version 1.1, there is no way to toggle the silent flag within the interpreter.\n\n### Syntax\n\n#### mov\nAlias: `m`\n\nUsage: `mov SOURCE DESTINATION`\n\nSets the memory at the address DESTINATION to the contents of the memory at the address SOURCE.\nAdditionally, zeros out the memory at the address SOURCE.\n\nExample: `mov 5 6 # Move the memory at 5 to the memory at 6`\n\n#### psh\nAlias: `ps`\n\nUsage: `psh SOURCE`\n\nDecrements the stack pointer to move to the new address.\nIf the stack pointer is within bounds (greater than 0), the contents of the memory at SOURCE is placed at the stack pointer.\nIf the stack pointer is out of bounds, the stack pointer is reset to the location before the command was sent.\nAdditionally, the `mem_out` flag is set.\n\nExample: `psh 3 # Pushes the memory at 3 onto the stack`\n\n#### pop\nAlias: `pp`\n\nUsage: `pop DESTINATION`\n\nSets the contents of the memory at DESTINATION to the value at the stack pointer.\nAdditionally resets the value at the stack pointer to be 0.\nIf the stack pointer is within bounds (greater than 16), the stack pointer is incremented.\nOtherwise, the stack pointer is left untouched.\n\nExample: `pop 8 # Pops the value at the stack pointer to the memory at the address 8`\n\n#### add\nAlias: `a`\n\nUsage: `add SOURCE DESTINATION`\n\nAdds the contents of the memory at the address SOURCE to the contents of the memory at the address DESTINATION.\nIf the memory at the address DESTINATION is less than 0, the `neg` flag is set.\n\nExample: `add 9 5 # Adds the value at the address 9 to the value at the address 5`\n\n#### sub\nAlias: `s`\n\nUsage: `sub SOURCE DESTINATION`\n\nSubtracts the contents of the memory at the address SOURCE from the contents of the memory at the address DESTINATION.\nIf the memory at the address DESTINATION is less than 0, the `neg` flag is set.\n\nExample: `sub 2 5 # Subtracts the value at the address 2 from the value at the address 5`\n\n#### inc\nAlias: `i`\n\nUsage: `inc DESTINATION`\n\nIncrements the contents of the memory at the address DESTINATION by one.\nIf the memory at the address DESTINATION is less than 0, the `neg` flag is set.\n\nExample: `inc 1 # Increments the value at the address 1 by one`\n\n#### dec\nAlias: `d`\n\nUsage: `dec DESTINATION`\n\nDecrements the contents of the memory at the address DESTINATION by one.\nIf the memory at the address DESTINATION is less than 0, the `neg` flag is set.\n\nExample: `dec 1 # Decrements the value at the address 1 by one`\n#### place\nAlias: `p`\n\nUsage: `place VALUE DESTINATION`\n\nPlaces the integer representation of the VALUE parameter into the memory at the address DESTINATION.\nThis is a interpreter only command, and is not part of the HASM instruction set.\n\nExample: `place 65 1 # Places the value 65 at the address 1`\n\n#### peek\nAlias: `pe`\n\nPrints the contents of the memory and the contents of the stack. \n`Peek` only works in silent mode.\nIn \"normal\" mode, the contents of the memory and the stack would be printed anyways, so no operations occur.\n\nExample: `peek # Prints the contents of the memory and stack`\n\n\n#### quit\nAlias: `q`\n\nExits the HASM interpreter.\n\nExample `quit # Exits the interpreter`\n\n### Memory Layout\n\n#### Flags and Registers\nAll flags and registers are stored in the main memory area [0 - 31].\nThe flags and registers can be read and written to with no protection.\nThe table below contains information about each flag.\n\n| Address | Flag      | Usage                                                                                    | Boolean? |\n| ------- | --------- | ---------------------------------------------------------------------------------------- | -------- |\n| 0       | `jmp`     | Address for the next jump operation                                                      | n        |\n| 1       | `greater` | If the previous greater-than operation succeeded                                         | Y        |\n| 2       | `less`    | If the previous less-than operation succeeded                                            | Y        |\n| 3       | `neg`     | If the last math operation resulted in a negative number                                 | Y        |\n| 4       | `zero`    | If the last zero comparison operation resulted in true                                   | Y        |\n| 5       | `none`    | If the last move operation placed a zero at a location where there was previously a zero | Y        |\n| 6       | `out`     | If the stack was full when a `psh` operation was attempted                               | Y        |\n| 7       | `used`    | If the `jmp` address was modified by a move operation                                    | Y        |\n\n\n## Contributions\nAs of June 2020, HASM is closed to outside contributions. \nHowever, help is always appreciated, especially on the following tasks.\n\n### TODO\n\n#### Instructions\n* ~~`inc` Increment the value of a register by 1~~\n* ~~`dec` Decrement the value of a register by 1~~\n\n#### Interpreter Features\n* Possible C port?\n* ~~Scanning and executing files on startup (command line argument)~~\n\n##### Interfacing\nAs of right now there is no way for HASM to communicate with external processes.\nThe long term vision of HASM is to implement the instructions on a physical device.\nThis opens up the possibility for other devices to write to HASM's memory space.\nHowever as HASM is only in software, there is no way to do this.\n\n~~My ideal solution would be an external device system, accompanied with a command such as `dev`.~~\n~~The `dev` command would open up a device sub-menu, which has a driver (written in HASM) that writes to the memory.~~\n~~These devices should be able to update on every instruction / cycle, which can be emulated with a `-d` flag.~~\n~~If anyone has ideas as to how I could implement this contact me with any of the methods listed under [Contact](#contact).~~\nUpdate (8/27/2020): I have added the `-d` flag, which allows all following execute flags to be executed on every command.\n\n##### Flagging Behaviors\nWithin the coming updates there will be a new argument for handling the behavior of commands in the flag memory space.\nWhen a command is executed and if the supplied address(es) are within the flag memory, the command will operate differently.\nThe range for the flag memory space can be found in [Flags and Registers](#flags-and-registers).\nWhen the argument is not supplied, the command behaves like it would regardless of if it is within the flag memory space.\n\n#### Code Cleanup\nFrom a personal standpoint, HASM has room for improvement in terms of being compliant with the C++ standards.\nPerformance does not seem to be an issue (for example, low process time on all systems).\nHowever, this does not mean there is no room for improvement.\nAgain, contact me with any of the methods listed under [Contact](#contact).\n\n\n## Acknowledgements\n* [StackOverflow](https://stackoverflow.com/a/14267455) for the `tokenize` function\n\n## Contact\nMaintained by [Hayden977](https://github.com/hayden977).\nTwitter: `@Hayden977_`\nDiscord: Hayden977#9614\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaydenheroux%2Fhasm-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaydenheroux%2Fhasm-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaydenheroux%2Fhasm-cpp/lists"}