{"id":30815426,"url":"https://github.com/apebl/mips-asm-examples","last_synced_at":"2025-10-09T02:07:00.636Z","repository":{"id":133134015,"uuid":"368950237","full_name":"apebl/mips-asm-examples","owner":"apebl","description":"MIPS assembly language examples","archived":false,"fork":false,"pushed_at":"2021-05-19T17:35:18.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T08:22:26.533Z","etag":null,"topics":["assignment","mars-mips","mips","mips-assembly"],"latest_commit_sha":null,"homepage":"","language":"Assembly","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/apebl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2021-05-19T17:30:40.000Z","updated_at":"2025-03-05T02:41:28.000Z","dependencies_parsed_at":"2024-08-10T09:29:49.356Z","dependency_job_id":null,"html_url":"https://github.com/apebl/mips-asm-examples","commit_stats":null,"previous_names":["apebl/mips-asm-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/apebl/mips-asm-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apebl%2Fmips-asm-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apebl%2Fmips-asm-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apebl%2Fmips-asm-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apebl%2Fmips-asm-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apebl","download_url":"https://codeload.github.com/apebl/mips-asm-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apebl%2Fmips-asm-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000772,"owners_count":26082906,"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-09T02:00:07.460Z","response_time":59,"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":["assignment","mars-mips","mips","mips-assembly"],"created_at":"2025-09-06T08:13:22.964Z","updated_at":"2025-10-09T02:07:00.607Z","avatar_url":"https://github.com/apebl.png","language":"Assembly","readme":"# MIPS Assembly Language Examples\n\nFiles:\n\n- `macros.asm`: Common macros (MARS macros)\n- `sle.asm`: Solve systems of linear equations (Ax = b)\n- `mult-table.asm`: Print out multiplication tables from 2 to 9\n- `ary-stack.asm`: Implement a stack using an array\n- `qsort.asm` Implement quick sort algorithm\n\nUse MARS MIPS simulator to run the codes.\n\n## `sle.asm`\n\n\u003e Solve systems of linear equations (Ax = b) (A: 5x5, x: 5x1)\n\nEach matrix is assumed to be supplied in column-major order.\n\n![Row- and column-major order](assets/row-and-column-major-order.png)\n\nMatrix:\n\n```\n| 7 1 7 9 3 |   | 4 |   | ? |\n| 8 8 6 5 6 |   | 2 |   | ? |\n| 4 1 3 7 8 | x | 6 | = | ? |\n| 8 8 0 4 5 |   | 6 |   | ? |\n| 4 4 2 1 7 |   | 5 |   | ? |\n```\n\nIn memory:\n\n```asm\n# Matrix A\nmat_A: .word 7 8 4 8 4\n             1 8 1 8 4\n             7 6 3 0 2\n             9 5 7 4 1\n             3 6 8 5 7\n\n# Matrix x\nmat_x: .word 4 2 6 6 5\n\n# Result matrix\nmat_b: .word 0 0 0 0 0\n```\n\nResult:\n\n```\nResult:\n  | 141 |\n  | 144 |\n  | 118 |\n  | 97 |\n  | 77 |\n```\n\n## `mult-table.asm`\n\n\u003e Print out multiplication tables from 2 to 9\n\nResult:\n\n```\n2 times table:\n - 2x1 = 2\n - 2x2 = 4\n - 2x3 = 6\n - 2x4 = 8\n - 2x5 = 10\n - 2x6 = 12\n - 2x7 = 14\n - 2x8 = 16\n - 2x9 = 18\n3 times table:\n - 3x1 = 3\n - 3x2 = 6\n - 3x3 = 9\n - 3x4 = 12\n - 3x5 = 15\n - 3x6 = 18\n - 3x7 = 21\n - 3x8 = 24\n - 3x9 = 27\n...\n```\n\n## `ary-stack.asm`\n\n\u003e Implement Stack using an array (stack capacity: 10)\n\nPush/pop:\n\n```\n:: Usage:\n::  - Input a zero or positive number =\u003e push\n::  - Input a negative number =\u003e pop\n\u003e Input: 1\n:: Stack: (size: 1) [ 1 ]\n\u003e Input: 2\n:: Stack: (size: 2) [ 1 2 ]\n\u003e Input: 99\n:: Stack: (size: 3) [ 1 2 99 ]\n\u003e Input: -1\n:: Popped item: 99\n:: Stack: (size: 2) [ 1 2 ]\n\u003e Input: -1\n:: Popped item: 2\n:: Stack: (size: 1) [ 1 ]\n\u003e Input: 77\n:: Stack: (size: 2) [ 1 77 ]\n\u003e Input:\n```\n\nStack capacity exceeded:\n\n```\n:: Usage:\n::  - Input a zero or positive number =\u003e push\n::  - Input a negative number =\u003e pop\n\u003e Input: 1\n:: Stack: (size: 1) [ 1 ]\n\u003e Input: 2\n:: Stack: (size: 2) [ 1 2 ]\n\u003e Input: 3\n:: Stack: (size: 3) [ 1 2 3 ]\n  ...\n\u003e Input: 9\n:: Stack: (size: 9) [ 1 2 3 4 5 6 7 8 9 ]\n\u003e Input: 10\n:: Stack: (size: 10) [ 1 2 3 4 5 6 7 8 9 10 ]\n\u003e Input: 11\n:: WARN: Stack capacity exceeded! Your input has been discarded\n:: Stack: (size: 10) [ 1 2 3 4 5 6 7 8 9 10 ]\n\u003e Input:\n```\n\nStack is empty:\n\n```\n:: Usage:\n::  - Input a zero or positive number =\u003e push\n::  - Input a negative number =\u003e pop\n\u003e Input: -1\n:: WARN: Stack is empty!\n:: Stack: (size: 0) [ ]\n\u003e Input:\n```\n\n## `qsort.asm`\n\n\u003e Implement quick sort algorithm\n\nThe array is stored in the stack and its capacity is increased if needed. Check `resize_array()` macro.\n\nC language version of the `sort` function:\n\n```c\nvoid sort (int *arr, int low, int high) {\n    if (low \u003e= high) return;\n    int pivot = partition(arr, low, high);\n    sort(arr, low, pivot - 1);\n    sort(arr, pivot + 1, high);\n}\n```\n\nResult:\n\n```\n\u003e Input: 1\n:: Array: (size: 1) [ 1 ]\n\u003e Input: 2\n:: Array: (size: 2) [ 2 1 ]\n\u003e Input: 3\n:: Array: (size: 3) [ 3 2 1 ]\n\u003e Input: 4\n:: Array: (size: 4) [ 4 3 2 1 ]\n\u003e Input: 99\n:: Array: (size: 5) [ 99 4 3 2 1 ]\n\u003e Input: 0\n:: Array: (size: 6) [ 99 4 3 2 1 0 ]\n\u003e Input: -1\n:: Array: (size: 7) [ 99 4 3 2 1 0 -1 ]\n\u003e Input: 124\n:: Array: (size: 8) [ 124 99 4 3 2 1 0 -1 ]\n\u003e Input: 5\n:: Array: (size: 9) [ 124 99 5 4 3 2 1 0 -1 ]\n\u003e Input: -5\n:: Array: (size: 10) [ 124 99 5 4 3 2 1 0 -1 -5 ]\n\u003e Input: -3\n:: Array: (size: 11) [ 124 99 5 4 3 2 1 0 -1 -3 -5 ]\n\u003e Input:\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapebl%2Fmips-asm-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapebl%2Fmips-asm-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapebl%2Fmips-asm-examples/lists"}