{"id":13838115,"url":"https://github.com/erenyenigul/ism","last_synced_at":"2025-07-10T21:31:24.903Z","repository":{"id":142829472,"uuid":"602030878","full_name":"erenyenigul/ism","owner":"erenyenigul","description":"Write programs in Apple Notes 📝. Multi-platform stack machine implemented in Siri Shortcuts.","archived":false,"fork":false,"pushed_at":"2023-08-15T06:17:33.000Z","size":185,"stargazers_count":98,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-21T01:34:37.862Z","etag":null,"topics":["apple-shortcuts","shortcuts","siri-shortcuts","stack-machine"],"latest_commit_sha":null,"homepage":"","language":null,"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/erenyenigul.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}},"created_at":"2023-02-15T10:57:07.000Z","updated_at":"2024-10-19T09:52:30.000Z","dependencies_parsed_at":"2024-01-15T18:46:43.597Z","dependency_job_id":"f0e98bb6-ab8a-4d8d-9d8f-a647e8dba2f5","html_url":"https://github.com/erenyenigul/ism","commit_stats":null,"previous_names":["erenyenigul/ism"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erenyenigul/ism","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erenyenigul%2Fism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erenyenigul%2Fism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erenyenigul%2Fism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erenyenigul%2Fism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erenyenigul","download_url":"https://codeload.github.com/erenyenigul/ism/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erenyenigul%2Fism/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264666020,"owners_count":23646570,"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":["apple-shortcuts","shortcuts","siri-shortcuts","stack-machine"],"created_at":"2024-08-04T15:01:37.909Z","updated_at":"2025-07-10T21:31:24.575Z","avatar_url":"https://github.com/erenyenigul.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"\n# ios stack machine (ism)\n\n### ever wondered if you can use Apple Notes to write code? \n(probably not.)\nWell, now you **can**!\n\nIOS Stack Machine (ISM) is an interpreter implemented in Siri Shortcuts, thus it works in all Apple devices that have Shortcuts app installed.\n## Installation\n\nYou can download and get started with the shortcut from [here](https://www.icloud.com/shortcuts/fd4017088eda4d33acf8bc1ac8fa4bc0).\n\n## Quick Start: Hello World\n\nAfter installing ISM to your device, go ahead and open Notes app and create a new note. The name of your note should end with `.ism`, so that ISM can see your code. That's why after naming your note, append `.ism`to the end of title.\n\nTo the next line, append this code.\n\n```asm\nprintln Hello world!\n```\nIn ISM, every line must contain a single instruction. First word in the line is the instruction name and the rest are the arguments. Beware that number of spaces between each argument, or between argument and the instruction matters. There should be a single space.\n\nAlso, as you've seen, you don't need to use double quotes (`\"`) to indicate strings.\n\nAfter you done the steps, the whole thing must look like this:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"docs/hello-world.png\" alt= “” width=\"400\" \u003e\n\u003c/p\u003e\n\nThen go to Shortcuts, and run IOS Stack Machine. You will get a prompt asking which file to run. If you don't see your note in the list, please check your note to see if the title has `.ism` in the end.\n\n## Manipulate the Stack: `push` \u0026 `pop`\n\nISM is a stack machine, meaning it operates using an internal stack. To manipulate this stack in the most basic sense, you can use these two operations:\n\n- `push`\n\n  Adds a constant to the top of the stack.\n  \n  e.g.\n     ```\n       push 10      // Stack: top -\u003e      10|\n       push 4       // Stack: top -\u003e    4 10|\n       push 2       // Stack: top -\u003e  2 4 10|\n     ```\n- `pop`\n\n  Removes the item on top of the stack. Currently, the value gets lost. (This behaviour may change in the future: the popped value may be put in register A)\n  \n  e.g\n  ```\n     push 10      // Stack: top -\u003e      10|\n     push 4       // Stack: top -\u003e    4 10|\n     pop          // Stack: top -\u003e      10|\n     pop          // Stack: top -\u003e        |\n  ```\n\n## I/O Instructions: `println` \u0026 `readln`\n\nTo print a message, you can do `println ISM Rocks!`. However, if you like to see the top of the stack, you can call `println` without any arguments. It may be useful for debugging.\n\n`readln` allows you to take input from the user. It pushes the input to the stack. You can also use with an argument, such as `readln Give me a number`, to change the prompt message. \n\n## Binary Instructions: `add`, `sub`, `div`, `mul` \u0026 `eq`\n\nBinary operations pop 2 items from the top of the stack, and then push the result back. For example, `add` operation in the below program pops 1 and 2, pushes 3 back to the stack:\n\n```\npush 1\npush 2\nadd\nprintln\n```\nThis program outputs 3. You can also use `sub`, `div` and `mul` the same way.\n\nAbove we used `println` without any arguments. This way of using `println` allows you to see what is the top element of the stack.\n\nOne other binary operation is `eq`, which checks if 2 items are equal. For example:\n\n```\npush 9\npush 8\neq\nprintln       // prints 0\n```\n\n```\npush 42\npush 42\neq\nprintln       // prints 1\n```\nIf two elements are equal, eq returns 1 and 0 otherwise.\n\n## Branching: `jump`, `jnz` \u0026 `jpop`\n\nISM doesn't have for \u0026 while loops and if-else statements. It only allows jumping, which anyone can use to implement those higher level expressions. \n\n- `jump` instruction\n    Jumps execution to the provided line. Can be used to skip some part of the code:\n    \n    ```\n    notename.ism\n    jump 3\n    println This won't we printed unless some other jump will lead here.\n    println Hello from line 3!\n    ```\n- `jnz`instruction\n    Jumps execution to the provided line **if** the top of the stack is **not zero**. (Pops from stack)\n    This instruction can be used to implement branching in your code. \n    \n    ```\n    gimmeanumber.ism\n    readln Give me a number. (It is better be 10 or I am angry!)\n    push 10\n    eq\n    jnz 7\n    println You made me angry!!!\n    jump 8\n    println Thank you for listening to me! I am happy as ever!\n    ```\n    \n- `jpop` instruction\n   Pops a number from the stack, and then jumps to the line with this number. Does not take any arguments.\n    \n### Relative Jump\n   If you want to jump to a line by a relative value, you can use `$`. e.g. `jump $2` will lead you 2 lines below.  \n    \n## Memory: `load`and `store`\n\nYou can assign variables with `store` instruction.\n\n- `store`\n  Pops from the stack, and writes to memory.\n\n```\npush 3\nstore x // x is now 3\n```\n\n- `load`\n  Gets the value of the specified variable, and pushes to the stack.\n \n ```\n push 4\n push 1\n add\n store x\n load x\n println // prints 5\n```\n\n## Copy the top of the stack: `copy`\n\nIf you need to copy the top of the stack, use `copy` instruction. It will get the value on the top (without pop), and push it again. \n\n```\npush 3\ncopy\nadd\nprintln // prints 6!\n```\n\n## Example: Fibonacci\n\n```\nfibbonaci.ism\nprintln This program prints a fibbonaci number.\npush 4\npush 1\npush 2\n\nload A\nload B\n\ncopy\nstore A\n\nadd\nstore B\n\npush -1\nadd\ncopy\njnz 5\nload B\nprintln\n```\n\n## Misc.\n\nAll functionality of Shortcuts can be added to ISM. However currently, the instruction set is pretty small. One misc. instruction ISM has is `open`. You can use this instruction to open an application in your device. \n\ne.g. \n```\nopen Spotify // or\nopen App Store\n```\n\n## Limitations\n\n- Since it is implemented in Shortcuts, ISM runs very slow. This was something I already expected before I start the project.\n- There are no `break` functionality in Shortcuts, so I had a little problem while working on `jump` operation. To overcome this I defined a constant value of `999999999999`, which is a really large number. No ISM program can have more lines than this constant (lines that are re-executed after a jump also count in this sum.)\n\n## Contribution\n\nAny contribution is appreciated. But beware that since Shortcuts file format is binary, version control will probably be like hell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferenyenigul%2Fism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferenyenigul%2Fism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferenyenigul%2Fism/lists"}