{"id":16608429,"url":"https://github.com/curve/easybonsai3","last_synced_at":"2025-04-05T00:16:25.535Z","repository":{"id":39020144,"uuid":"215127643","full_name":"Curve/EasyBonsai3","owner":"Curve","description":"A cross-platform project to extend bonsai","archived":false,"fork":false,"pushed_at":"2023-03-05T13:10:46.000Z","size":3081,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T16:42:56.964Z","etag":null,"topics":["bonsai"],"latest_commit_sha":null,"homepage":"https://curve.github.io/EasyBonsai3/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Curve.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":"2019-10-14T19:24:30.000Z","updated_at":"2022-05-27T11:33:15.000Z","dependencies_parsed_at":"2023-02-18T07:30:33.947Z","dependency_job_id":null,"html_url":"https://github.com/Curve/EasyBonsai3","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2FEasyBonsai3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2FEasyBonsai3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2FEasyBonsai3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curve%2FEasyBonsai3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Curve","download_url":"https://codeload.github.com/Curve/EasyBonsai3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266566,"owners_count":20910837,"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":["bonsai"],"created_at":"2024-10-12T01:26:09.950Z","updated_at":"2025-04-05T00:16:25.479Z","avatar_url":"https://github.com/Curve.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cp\u003e\n    \u003ch1\u003e\n      \u003cbr/\u003e\n      EasyBonsai\u003csup\u003e3\u003c/sup\u003e\n    \u003c/h1\u003e\n    \u003ch4\u003eA project that aims to simplify and improve Bonsai\u003c/h4\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/Curve/EasyBonsai3/blob/master/LICENSE\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/license/Curve/EasyBonsai3.svg?style=for-the-badge\" alt=\"License\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Curve/EasyBonsai3/actions?query=workflow%3A%22Build+and+release+on+push%22\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/workflow/status/Curve/EasyBonsai3/Build%20and%20release%20on%20push?style=for-the-badge\" alt=\"Builds\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n*Changes to EasyBonsai2: Heavily improved code, which also results in faster compile-times!*\n\n# Introduction\nEasyBonsai is a extension for [Bonsai](https://bonsai.pinyto.de/assembler/)  which adds more advanced instructions and is also compileable to Bonsai.\n# Install\n## Use the latest binaries\nFrom [here](https://github.com/Curve/EasyBonsai3/releases/tag/latest), or [try it on the web](https://curve.github.io/EasyBonsai3/)!\n\n## Or compile it yourself\n\u003cb\u003eImportant: \u003c/b\u003e\n- Please compile with C++17 or above\n\nWindows/Linux:\n- Compile the project with a compiler of your choice\n\nWeb:\n- Compile with emscripten\n  ```em++ main.cpp -D BONSAI_WEB -std=c++17 --bind```  \n# Index\n- [Introduction](#introduction)\n- [Install](#install)\n\t- [Use the latest binaries](#use-the-latest-binaries)\n\t- [Or compile it yourself](#or-compile-it-yourself)\n- [Index](#index)\n- [Features](#features)\n\t- [Relative Jmps](#relative-jmps)\n\t- [Compare](#compare)\n\t- [Mov](#mov)\n\t- [And / Or](#and--or)\n\t- [Labels / Goto](#labels--goto)\n\t- [Variable Naming](#variable-naming)\n\t- [Add / Sub](#add--sub)\n\t- [Inc / Dec](#inc--dec)\n\t- [Functions](#functions)\n- [Usage](#usage)\n- [Examples](#examples)\n\t- [Exponentiate Function](#exponentiate-function)\n# Features\n### Relative Jmps\nAllows you to jump relatively (This will skip Reg-Instructions aswell as Label-Definitions)\n```nasm\n0: jmp +2\n1: jmp 0\n2: hlt ; \u003c-- jmps here\n```\n### Compare\nAssembler-like compare instruction, that will compare two memory-cells.\n```nasm\n0: cmp 0, 1\n1: je 10 ; will jump to line 10 if [0] == [1]\n1: jne 10 ; will jump to line 10 if [0] != [1]\n2: jl 20 ; will jump to line 20 if [0] \u003c [1]\n3: jg 30 ; will jump to line 30 if [0] \u003e [1]\n```\nJE/JNE/JL/JG do not support relative jumping.\n\n### Mov\nAllows you to copy the content of one memory-cell into another, also allows you to just set one memory-cell to zero.\n```nasm\n0: mov 0, 1 ; [0] is now equal to [1]\n1: mov 1, NULL ; [1] is now 0.\n```\n### And / Or\nAllows you to perform a simple and/or operation on two memory-cells.\n```nasm\n0: and 0, 1\n1: jmp 10 ; will jump to line 10 if [0] and [1] are greater than zero.\n2: jmp 20 ; will jump to line 10 if either [0] or [1] are zero.\n3: or 2, 3\n4: jmp 30 ; will jump to line 30 if [2] or [3] are greater than zero.\n5: jmp 40 ; will jump to line 40 if [2] and [3] are zero.\n```\n### Labels / Goto\nSimple labels.\n```nasm\n0: goto end ; will jump to line 2\n1: jmp .end ; will jump to line 2, the dot is important!\n2: end: hlt\n```\n```nasm\n0: goto end\n1: jmp .end\n2: end:\n3: hlt ; works exactly as the code example before.\n```\n### Variable Naming\nAllows you to give memory-cells names.\n```nasm\n0: reg TEST, 0\n1: reg TEST2 ; Since we didn't provide a memory cell that should be used the compiler will automatically assign one to it.\n2: inc TEST ; will increase memory-cell [0]\n3: dec TEST ; will decrease memory-cell [0]\n4: jmp TEST ; this will **not** work, because jmp instructions cant access memory-cells \n5: hlt\n```\n### Add / Sub\nAllows you to perform simple addition and subtraction with memory-cells.\n```nasm\n0: add 0, 1 ; will add the value of memory-cell [1] to memory-cell [0]\n1: hlt\n```\n```nasm\n0: sub 0, 1 ; will subtract the value of memory-cell[1] from memory-cell [0]\n1: hlt\n```\n### Inc / Dec\nAllows you to increase a memory-cell by a given value\n```nasm\n0: inc 0, 10 ; will increase memory-cell [0] by 10\n0: dec 1, 5  ; will decrease memory-cell [1] by 5\n```\n### Functions\n#### Declaration\nA function is delcared like this:\n```nasm\n(fun functionName(parameter1, parameter2):\n; code\n)\n```\n#### Calling \u0026 Parameters\nParameters can be accessed by their name inside of the function body.\n- Example\n\t```nasm\n\t(fun functionName(parameter1, parameter2):\n\tdec parameter1\n\tadd parameter1, parameter2\n\t; code...\n\t)\n\t```\nParameters are passed by **REFERENCE**. It is recommended to always have variables that you can save the function parameters into if you plan on modifying them.\n\nTo call a function the `call` instruction is used.\n- Example\n\t```nasm\n\t(fun function():\n\t; code...\n\t)\n\t\n\tcall function\n\t; code...\n\t```\nTo pass parameters to the function call the `push` variable is used.\n- Example\n\t```nasm\n\t(fun function(param1, param2):\n\t; code...\n\t)\n\tpush a\n\tpush b\n\tcall function \n\t```\n\n#### Return\nTo return a function the `ret` instruction is used.\n- Example\n\t```nasm\n\t(fun functionName(param1, param2):\n\tinc param1\n\tret\n\t)\n\t```\nYou can also return a value\n- Example\n\t```nasm\n\t(fun functionName(param1, param2):\n\tinc param1\n\tret param1\n\t)\n\t```\nThe return value will be saved inside of the **eax** register, you can access this register by simply using it like a variable.\n-\tExample\n\t```nasm\n\t(fun functionName(param1, param2):\n\tinc param1\n\tret param1\n\t)\n\tpush a\n\tpush b\n\tcall functionName\n\tmov someOtherVariable, eax ; eax will hold the return value!\n\t```\n#### Tips\nIt is recommended to use *relative jumps* inside of functions. Using Labels inside of the function will most likely not work as it will often lead to label-redefinition.\n### Int\nThe `int` instruction is **only useable in the cli version of easybonsai**.\nWhat it does is pause the program (wait for the user to press the return key) and print all current registers.\n\n# Usage\n- Compile your code\n\t```bash\n\t\u003e ./EasyBonsai3-Linux --input input.bon\n\t\u003e ./EasyBonsai3-Linux --input input.bon --output output.bon\n\t\u003e ./EasyBonsai3-Linux --input input.bon --output output.bon --usedVars 1\n\t\u003e ./EasyBonsai3-Linux --input input.bon --output output.bon --usedVars 1,2,3\n\t```\n\t- Example Output:\n\t\t```bash\n\t\t[02:16:38] [EasyBonsai3] Using input file: input.txt\n\t\t[02:16:38] [EasyBonsai3] Using output file: output.bon\n\t\t[02:16:38] [EasyBonsai3] User defined variables:\n\t\t[02:16:38] [Debug] Detected Labels: { [equal,8], [greater,2], [less,5], [start,0] }\n\t\t[02:16:38] [Debug] Detected Address-Macros: {  }\n\t\t[02:16:38] [Debug] Detected Used-Addresses: { 0, 1 }\n\t\t[02:16:38] [Debug] Setting Help-Register to [$0: 2]\n\t\t[02:16:38] [Debug] Setting Compare-Registers to [$1: 3] and [$2: 4]\n\t\t[02:16:38] [EasyBonsai3] Additional defined registers: 3, 4, 2\n\t\t[02:16:38] [EasyBonsai3] Compilation finished in 104ms!\n\t\t```\n\t*usedVars* will tell the compiler to not use the provided vars as registers, you will only need to define this, if you don't use those memory-cells in your code and don't want them to be used.\n\n- Run your code  \n\t*Why? Because running the code in the web version is often times slower, and for bigger code you may want faster execution times*\n\t```bash\n\t\u003e ./EasyBonsai3-Linux --run output.bon\n\t\u003e ./EasyBonsai3-Linux --run outbut.bon --setVars 0:0,1:100\n\t```\n\t*setVars* usage: `register:value`, it will set the provided register to the value provided before running the code.\n\t- Example Output:\n\t\t```bash\n\t\t[19:56:25] [EasyBonsai3] Running output.bon\n\t\t[19:56:26] [Debug] Setting Register $0 to 0\n\t\t[19:56:26] [Debug] Setting Register $1 to 100\n\t\t[19:56:26] [EasyBonsai3] Execution finished in 262ms!\n\t\t[19:56:26] [EasyBonsai3] Registers after execution:\n\t\t[19:56:26] [EasyBonsai3] [$0]: 100\n\t\t[19:56:26] [EasyBonsai3] [$1]: 100\n\t\t[19:56:26] [EasyBonsai3] [$2]: 0\n\t\t[19:56:26] [EasyBonsai3] [$3]: 0\n\t\t[19:56:26] [EasyBonsai3] [$4]: 1\n\t\t```\n\n# Examples\n### Exponentiate Function\nA small example that demonstrates most of the EasyBonsai-Extensions to provide a function which can be used to exponentiate a given number with a given exponent.\n\n```nasm\nreg number, 0\nreg exponent, 1\n\nreg NumBuffer, 2\nreg FacBuffer, 3\n\nreg Result, 4\n\nreg Num2Buffer, 5\nreg ExpoBuffer, 6\nreg ONumBuffer, 7\n\n(fun multiply(num, fac):\nmov FacBuffer, fac\nmov NumBuffer, NULL\ntst FacBuffer\njmp +2\nret NumBuffer\ndec FacBuffer\nadd NumBuffer, num\njmp -5\n)\n(fun expo(num, expon):\nmov ExpoBuffer, expon\ndec ExpoBuffer\nmov ONumBuffer, num\nmov Num2Buffer, num\ntst ExpoBuffer\njmp +2\nret Num2Buffer\npush Num2Buffer\npush ONumBuffer\ncall multiply\nmov Num2Buffer, eax\ndec ExpoBuffer\njmp -8\n)\n\npush number\npush exponent\ncall expo\nmov Result, eax\nhlt\n```\n\nThis example code has 43 lines, after compilation it has a total of 263 lines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurve%2Feasybonsai3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurve%2Feasybonsai3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurve%2Feasybonsai3/lists"}