{"id":30624518,"url":"https://github.com/errorcodezero/mpc","last_synced_at":"2025-10-14T04:14:36.228Z","repository":{"id":309236285,"uuid":"1035537790","full_name":"errorcodezero/mpc","owner":"errorcodezero","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-29T20:58:32.000Z","size":56,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-11T03:57:33.783Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/errorcodezero.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,"zenodo":null}},"created_at":"2025-08-10T15:59:37.000Z","updated_at":"2025-08-10T19:48:50.000Z","dependencies_parsed_at":"2025-08-10T19:17:49.323Z","dependency_job_id":"4c79c3b7-ec38-4135-acd5-b5c897c44ded","html_url":"https://github.com/errorcodezero/mpc","commit_stats":null,"previous_names":["errorcodezero/mpc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/errorcodezero/mpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorcodezero%2Fmpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorcodezero%2Fmpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorcodezero%2Fmpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorcodezero%2Fmpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/errorcodezero","download_url":"https://codeload.github.com/errorcodezero/mpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorcodezero%2Fmpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017984,"owners_count":26086213,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"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":[],"created_at":"2025-08-30T17:17:37.832Z","updated_at":"2025-10-14T04:14:36.208Z","avatar_url":"https://github.com/errorcodezero.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPC\n\nMultiPlayer CPU. Big endian.\n\n## Overview\n\nMPC is a virtual machine implementation that supports various opcodes for computation, memory operations, and stack management. The VM operates in a client-server architecture where clients can connect to execute instructions on the virtual machine.\n\n## Building and Running\n\n### Build the project\n```bash\ncargo build --release\n```\n\n### Start the server\n```bash\ncargo run -- server --ip 127.0.0.1 --port 3000\n```\n\n### Connect a client\n```bash\ncargo run -- client --ip 127.0.0.1 --port 3000\n```\n\n## Instruction Set\n\nAll instructions are 2 bytes (16 bits) encoded as nibbles. The format is:\n`[OPCODE][ARG1][ARG2][ARG3]` where each part is a 4-bit nibble.\n\n### 0x0 - HALT\n**Description**: Stops the virtual machine execution\n**Format**: `0x0000`\n**Example**: `0x0000`\n**Effect**: Sets the halted flag to true, stopping further instruction execution\n\n### 0x1 - LOAD_IMMEDIATE\n**Description**: Load an immediate 8-bit value into a register\n**Format**: `0x1[REG][VAL_HIGH][VAL_LOW]`\n**Parameters**:\n- REG: Target register (0-F)\n- VAL_HIGH: High nibble of the 8-bit value\n- VAL_LOW: Low nibble of the 8-bit value\n**Example**: `0x12AB` loads 0xAB into register 2\n**Effect**: `REG[REG] = (VAL_HIGH \u003c\u003c 4) | VAL_LOW`\n\n### 0x3 - DUMP\n**Description**: Store a register value to memory\n**Format**: `0x3[REG][ADDR_HIGH][ADDR_LOW]`\n**Parameters**:\n- REG: Source register (0-F)\n- ADDR_HIGH: High nibble of memory address\n- ADDR_LOW: Low nibble of memory address\n**Example**: `0x31AB` stores register 1 to memory address 0xAB\n**Effect**: `MEM[ADDR] = REG[REG]` (16-bit value stored as 2 bytes)\n\n### 0x4 - ADD\n**Description**: Add two register values and store result in accumulator\n**Format**: `0x4[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: First operand register (0-F)\n- REG2: Second operand register (0-F)\n- UNUSED: Ignored\n**Example**: `0x4120` adds register 1 and register 2\n**Effect**: `ACCUM = REG[REG1] + REG[REG2]`\n\n### 0x5 - SUB\n**Description**: Subtract second register from first register, store result in accumulator\n**Format**: `0x5[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: Minuend register (0-F)\n- REG2: Subtrahend register (0-F)\n- UNUSED: Ignored\n**Example**: `0x5120` subtracts register 2 from register 1\n**Effect**: `ACCUM = REG[REG1] - REG[REG2]`\n\n### 0x6 - MULT\n**Description**: Multiply two register values and store result in accumulator\n**Format**: `0x6[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: First operand register (0-F)\n- REG2: Second operand register (0-F)\n- UNUSED: Ignored\n**Example**: `0x6120` multiplies register 1 and register 2\n**Effect**: `ACCUM = REG[REG1] * REG[REG2]`\n\n### 0x7 - DIV\n**Description**: Divide first register by second register, store result in accumulator\n**Format**: `0x7[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: Dividend register (0-F)\n- REG2: Divisor register (0-F)\n- UNUSED: Ignored\n**Example**: `0x7120` divides register 1 by register 2\n**Effect**: `ACCUM = REG[REG1] / REG[REG2]`\n**Note**: Division by zero will cause a panic\n\n### 0x8 - AND\n**Description**: Perform bitwise AND on two register values, store result in accumulator\n**Format**: `0x8[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: First operand register (0-F)\n- REG2: Second operand register (0-F)\n- UNUSED: Ignored\n**Example**: `0x8120` performs AND on register 1 and register 2\n**Effect**: `ACCUM = REG[REG1] \u0026 REG[REG2]`\n\n### 0x9 - OR\n**Description**: Perform bitwise OR on two register values, store result in accumulator\n**Format**: `0x9[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: First operand register (0-F)\n- REG2: Second operand register (0-F)\n- UNUSED: Ignored\n**Example**: `0x9120` performs OR on register 1 and register 2\n**Effect**: `ACCUM = REG[REG1] | REG[REG2]`\n\n### 0xA - NOT\n**Description**: Perform bitwise NOT on a register value, store result in accumulator\n**Format**: `0xA[REG][UNUSED][UNUSED]`\n**Parameters**:\n- REG: Source register (0-F)\n- UNUSED: Ignored\n**Example**: `0xA100` performs NOT on register 1\n**Effect**: `ACCUM = !REG[REG]`\n\n### 0xB - XOR\n**Description**: Perform bitwise XOR on two register values, store result in accumulator\n**Format**: `0xB[REG1][REG2][UNUSED]`\n**Parameters**:\n- REG1: First operand register (0-F)\n- REG2: Second operand register (0-F)\n- UNUSED: Ignored\n**Example**: `0xB120` performs XOR on register 1 and register 2\n**Effect**: `ACCUM = REG[REG1] ^ REG[REG2]`\n\n### 0xC - LSHIFT\n**Description**: Left shift a register value by specified bits, store result in accumulator\n**Format**: `0xC[REG][BITS][UNUSED]`\n**Parameters**:\n- REG: Source register (0-F)\n- BITS: Number of bits to shift (0-F)\n- UNUSED: Ignored\n**Example**: `0xC130` left shifts register 1 by 3 bits\n**Effect**: `ACCUM = REG[REG] \u003c\u003c BITS`\n\n### 0xD - RSHIFT\n**Description**: Right shift a register value by specified bits, store result in accumulator\n**Format**: `0xD[REG][BITS][UNUSED]`\n**Parameters**:\n- REG: Source register (0-F)\n- BITS: Number of bits to shift (0-F)\n- UNUSED: Ignored\n**Example**: `0xD130` right shifts register 1 by 3 bits\n**Effect**: `ACCUM = REG[REG] \u003e\u003e BITS`\n\n### 0xE - PUSH\n**Description**: Push a register value onto the stack\n**Format**: `0xE[REG][UNUSED][UNUSED]`\n**Parameters**:\n- REG: Source register (0-F)\n- UNUSED: Ignored\n**Example**: `0xE100` pushes register 1 onto the stack\n**Effect**: Stack pointer decreases by 2, register value stored at new stack position\n\n### 0xF - POP\n**Description**: Pop a value from the stack into a register\n**Format**: `0xF[REG][UNUSED][UNUSED]`\n**Parameters**:\n- REG: Target register (0-F)\n- UNUSED: Ignored\n**Example**: `0xF100` pops stack value into register 1\n**Effect**: Value loaded from stack into register, stack pointer increases by 2\n\n### 0x10 - DUMP_ACCUM\n**Description**: Store accumulator value to memory\n**Format**: `0x10[UNUSED][ADDR_HIGH][ADDR_LOW]`\n**Parameters**:\n- UNUSED: Ignored\n- ADDR_HIGH: High nibble of memory address\n- ADDR_LOW: Low nibble of memory address\n**Example**: `0x10AB` stores accumulator to memory address 0xAB\n**Effect**: `MEM[ADDR] = ACCUM` (16-bit value stored as 2 bytes)\n\n### 0x11 - PUSH_ACCUM\n**Description**: Push accumulator value onto the stack\n**Format**: `0x1100`\n**Example**: `0x1100` pushes accumulator onto the stack\n**Effect**: Stack pointer decreases by 2, accumulator value stored at new stack position","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrorcodezero%2Fmpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferrorcodezero%2Fmpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrorcodezero%2Fmpc/lists"}