{"id":15060098,"url":"https://github.com/riprsa/brookshearmachineasm","last_synced_at":"2026-01-02T20:04:03.673Z","repository":{"id":249993578,"uuid":"833174981","full_name":"riprsa/BrookshearMachineASM","owner":"riprsa","description":"Brookshear (VOLE) Machine Assembly translator in Go","archived":false,"fork":false,"pushed_at":"2024-07-24T14:00:14.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T05:14:35.114Z","etag":null,"topics":["assembler","assembly","brookshear","go","golang","vole"],"latest_commit_sha":null,"homepage":"","language":"Go","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/riprsa.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":"2024-07-24T13:56:01.000Z","updated_at":"2024-09-28T17:07:11.000Z","dependencies_parsed_at":"2024-07-24T16:23:11.851Z","dependency_job_id":null,"html_url":"https://github.com/riprsa/BrookshearMachineASM","commit_stats":null,"previous_names":["riprsa/brookshearmachineasm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riprsa%2FBrookshearMachineASM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riprsa%2FBrookshearMachineASM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riprsa%2FBrookshearMachineASM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riprsa%2FBrookshearMachineASM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riprsa","download_url":"https://codeload.github.com/riprsa/BrookshearMachineASM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243685583,"owners_count":20330982,"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":["assembler","assembly","brookshear","go","golang","vole"],"created_at":"2024-09-24T22:52:46.497Z","updated_at":"2026-01-02T20:04:03.594Z","avatar_url":"https://github.com/riprsa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Brookshear Machine ASM\n\nMy simple assembly for Brookshear Machine (also known as VOLE machine), because I hate bytes.\n\nThis repo contains a compiler and a translator, both written in Go, and few examples of the ASM. Check out [How to use](#how-to-use) to try it.\n\n## Registers\n\nYou can use following registers in your code:\n\u003e r0, r1, r2, r3, r4, r5, r6, r7\n\u003e r8, r9, rA, rB, rC, rD, rE, rF\n\n## Counter\n\nBrookshear Machine has a counter which points to current instruction. Because an instruction takes two bytes, while memory cell is only 1 byte, the counter is always even.\n\n## Memory\n\nMemory consists of 256 cells, each cell is 1 byte. Each cell has a `value` and an `address`. By definition, `value` and `address` are written as hex, but for `value` you have to write it with prefix `0x`. Example:\n\u003e`value`: `0xAF`\n\u003e`address`: `4D`\n\n## Labels\n\nLabels are a way to use a place in memory for jumps and variable declarations. Labels do not take space in actual memory. Labels are written in upper cased and should not contain spaces. Declaration looks like this:\n\n`.label \u003cNAME\u003e:`\n\nPrefer to use SNAKE_CASE for labels for readability.\n\n## Variabels\n\nVariable allows you to access a value of an address using its name. Variables change the mentioned space in memory. You have to declare them before any other commands. There are two types of variables. The first one called plain variable:\n\n`var \u003cname\u003e \u003caddress\u003e \u003cvalue\u003e`\n\nThe second one called labeled variable:\n\n`var \u003cname\u003e \u003clabel\u003e`\n\nPrefer to use CamelCase for variabels for readability.\n\n## Arrays\n\nArrays are similar to variables, they just edit a specific place in memory with a sequence of values:\n\n`array \u003caddress\u003e \u003cvalue...\u003e`\n\nNote that `address` here should be in hex without `0x` prefix, while values should have this prefix\n\n## Instructions\n\nLoad variable's value to a register: (opcode 1)\n```assembly\nvar A F0 0x05\nload A r5 ; now r5 contains hex value 5\n```\n\nLoad immediate value to a register: (opcode 2)\n```assembly\nloadi 0x03 r5 ; now r5 contains hex value 3\n```\n\nStore a register to a variable: (opcode 3)\n```assembly\nvar B F0 0x00\nloadi 0xB3 r5\nstore r5 B ; now B contains hex value B3\n```\n\nMove a register to another register: (opcode 4)\n```assembly\nloadi 0x09 r1\nmove r1 r2 ; now r2 contains hex value 09\n```\n\nTwo’s complement add of a register and another one, result to a third register: (opcode 5)\n```assembly\nvar A F0 0x02\nvar B F1 0x03\nload A r1\nload B r2\nadd r1 r2 r0 ; now r0 contains sum of A and B =\u003e hex value 05\n```\n\nFloat add of a register and another register, result to a third register: (opcode 6)\n```assembly\nvar A F0 0x02\nvar B F1 0x03\nload A r1\nload B r2\naddf r1 r2 r0 ; figure out it yourself, i never tested it lmao\n```\n\nBitwise OR of a register and another register, result to a third register: (opcode 7)\n```assembly\nloadi 0xAA r1 ; 1010 1010\nloadi 0x55 r2 ; 0101 0101\nor r1 r2 r0 ; 1010 1010 or 0101 0101 =\u003e 1111 1111\n```\n\nBitwise AND of a register and another register, result to a third register: (opcode 8)\n```assembly\nloadi 0xAA r1 ; 1010 1010\nloadi 0x55 r2 ; 0101 0101\nand r1 r2 r0 ; 1010 1010 and 0101 0101 =\u003e 0000 0000\n```\n\nBitwise XOR of a register and another register, result to a third register: (opcode 9)\n```assembly\nloadi 0xAF r1 ; 1010 1111\nloadi 0x5F r2 ; 0101 1111\nxor r1 r2 r0 ; 1010 1111 and 0101 1111 =\u003e 1111 0000\n```\n\nRotate the bit pattern in a register one bit to the right `number` times. Each time place the bit that started at the low-order end at the high-order end. `number` is a half-byte (one hex symbol): (opcode A)\n```assembly\nrotate r1 5 ; here you need to use value without 0x, because i am lazy to fix it\n```\n\nChange counter to a label if a register equals r0: (opcode B)\n```assembly\n.label MAIN:\nmov r0 r0 ; beause label itself is not an instruction, it needs a dummy one to simulate action\njeq MAIN r0 ; this jump will loop forever...\nhalt\n```\n\nHalt execution. Ends program: (opcode C)\n```\nloadi 0x01 r0 ; smth useful\nhalt ; now stopped\n```\n\nChange counter to a label if a register is greater than r0: (opcode D)\n```assembly\nloadi 0x01 r1\nloadi 0x02 r2\nmov r1 r0 ; comparing works only with r0\njgt GREATER r2 ; if r2 \u003e r1 ...\nloadi 0xFF r0 ; if !(r2 \u003e r1), write -1 to r0\nhalt ; ensure it is stopped\n.label GREATER:\nloadi 0x01 r0 ; if r2 \u003e r1, write 1 to r0\nhalt\n```\n\n## Examples\n\nYou can find few examples in `./examples` folder. Please go thru them, because you will understand how to work with assembly more deeply. I also want to make insist you read `reverse.asm`, if you need to work with arrays/strings.\n\n## How to use\n\nDue to my laziness, you have to compile the program. Sorry, I won't provide binaries.\n\nClone repo, then run `go run main.go -asm ./examples/comparing.asm -o a.out`.\n\nTo use the compiler run `go run main.go -asm ./examples/comparing.asm -e`.\n\nChange path to use your own `.asm` file, also check variable `DEBUG` in the `translator.go`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friprsa%2Fbrookshearmachineasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friprsa%2Fbrookshearmachineasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friprsa%2Fbrookshearmachineasm/lists"}