{"id":15060562,"url":"https://github.com/gabrielemaurina/pyssembly","last_synced_at":"2026-01-03T11:06:09.795Z","repository":{"id":62583762,"uuid":"262845010","full_name":"GabrieleMaurina/pyssembly","owner":"GabrieleMaurina","description":"A python assembly emulator","archived":false,"fork":false,"pushed_at":"2020-05-11T12:14:05.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T17:47:52.064Z","etag":null,"topics":["assembly","assembly-language","assembly-language-programming","emulator","pseudo-assembly","python-assembly-emulator"],"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/GabrieleMaurina.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}},"created_at":"2020-05-10T17:58:23.000Z","updated_at":"2023-02-01T02:25:55.000Z","dependencies_parsed_at":"2022-11-03T21:37:59.282Z","dependency_job_id":null,"html_url":"https://github.com/GabrieleMaurina/pyssembly","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/GabrieleMaurina%2Fpyssembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrieleMaurina%2Fpyssembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrieleMaurina%2Fpyssembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrieleMaurina%2Fpyssembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrieleMaurina","download_url":"https://codeload.github.com/GabrieleMaurina/pyssembly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695589,"owners_count":20332629,"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","assembly-language","assembly-language-programming","emulator","pseudo-assembly","python-assembly-emulator"],"created_at":"2024-09-24T23:00:22.492Z","updated_at":"2026-01-03T11:06:04.765Z","avatar_url":"https://github.com/GabrieleMaurina.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pyssembly\n##### A python assembly emulator.\nThis tool allows to execute pseudo assembly code and it is meant for teaching purposes.\n\n### Install\n`python -m pip install pyssembly`\n\n### Usage\n`python -m pyssembly \u003ccode.pys\u003e`\n\n### Examples\nLots of examples are available in the `examples` folder.\n\n##### Print the result of 137 * 2322:\n1) create file `multiplication.pys` containing:\n```\nmov a 137\nmul a 2322\nout a \"\\n\"\n```\n2) run it with: `python -m pyssembly multiplication.pys`\n3) result: `318114`\n\n##### Read 2 numbers from stdin and return average:\n1) create file `average.pys` containing:\n```\nin a \"First number: \"\nin b \"Second number: \"\nint a a \nint b b \nmov avg a\nadd avg b\ndiv avg 2\nout \"The average between \" a \nout \" and \" b \nout \" is: \" avg \nout \"\\n\" null\n```\n2) run it with: `python -m pyssembly average.pys`\n3) result:\n```\nFirst number: 26\nSecond number: 17\nThe average between 26 and 17 is: 21.5\n```\n\n### Pseudo assembly\nThe language that pyssembly is able to execute is a pseudo assembly. All instructions have the form:\n\n`\u003cinstruction\u003e \u003coperand a\u003e \u003coperand b\u003e`\n\nAll instructions that return a result, store such result in the first operand (a).\n\n##### Comments\nTo comment a line write ';' at the beginning. For example:\n\n`;this is a comment`\n\n##### Labels\nTo label a line, to use it as destination in a jmp statement, simply write a single word in the line. For example:\n\n`this-is-a-label`\n\n##### Null\nThe null value is simply the keyword `null`. Like so:\n\n`out \"Hello world\" null`\n\n##### Arrays\nArrays are accessed using the `[]` sintax. For example:\n\n`mov arr[0] 6`\n\nArrays are actually dictionaries and anything can be a key.\n\n### Instruction set\n\n##### General\n* `mov a b`: store b into a\n* `jmp a b`: if a, jump to b (b can be a label or a line number)\n* `in a b`: print b to stdout, read string from stdin, store it into a\n* `out a b`: print a and b to stdout\n\n##### Conversions\n* `bool a b`: boolean(b)\n* `int a b`: integer(b)\n* `flt a b`: float(b)\n* `str a b`: string(b)\n\n##### Math\n* `add a b`: a + b\n* `sub a b`: a - b\n* `mul a b`: a * b\n* `div a b`: a / b\n* `pow a b`: a\u003csup\u003eb\u003c/sup\u003e\n* `log a b`: log\u003csub\u003eb\u003c/sub\u003e\u003csup\u003ea\u003c/sup\u003e\n* `root a b`: a\u003csup\u003e1/b\u003c/sup\u003e\n* `idiv a b`: a // b\n* `mod a b`: a % b\n\n##### Random\n* `rnd a b`: generate random float, a\u003c=rf\u003c=b\n* `irnd a b`: generate random integer, a\u003c=ri\u003c=b\n\n##### Trigonometry\n* `sin a b`: sin(b)\n* `cos a b`: cos(b)\n* `tan a b`: tan(b)\n* `asin a b`: asin(b)\n* `acos a b`: acos(b)\n* `atan a b`: atan(b)\n* `atan2 a b`: atan2(a, b)\n\n##### Boolean\n* `eq a b`: a == b\n* `neq a b`: a != b\n* `les a b`: a \u003c b\n* `leq a b`: a \u003c= b\n* `grt a b`: a \u003e b\n* `geq a b`: a \u003e= b\n* `not a b`: not b\n* `and a b`: a and b\n* `or a b`: a or b\n* `xor a b`: a xor b\n* `nand a b`: a nand b\n* `nor a b`: a nor b\n* `nxor a b`: a nxor b\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielemaurina%2Fpyssembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielemaurina%2Fpyssembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielemaurina%2Fpyssembly/lists"}