{"id":22965093,"url":"https://github.com/aayush-bhargav/mips_assembler","last_synced_at":"2026-05-18T02:31:18.489Z","repository":{"id":235209304,"uuid":"790292015","full_name":"Aayush-Bhargav/MIPS_Assembler","owner":"Aayush-Bhargav","description":"This repository consists of an ASM code to implement bubble sort in MIPS architecture. It also contains a python assembler designed to run the ASM code.","archived":false,"fork":false,"pushed_at":"2024-04-22T16:16:26.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T11:34:38.096Z","etag":null,"topics":["asm","assembly-code","assembly-language","mips-assembly","python","sorting"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Aayush-Bhargav.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-04-22T16:03:09.000Z","updated_at":"2024-07-26T08:02:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"e68f8a81-40e8-466a-8a65-7d3263fb4f67","html_url":"https://github.com/Aayush-Bhargav/MIPS_Assembler","commit_stats":null,"previous_names":["aayush-bhargav/mips_assembler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aayush-Bhargav/MIPS_Assembler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aayush-Bhargav%2FMIPS_Assembler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aayush-Bhargav%2FMIPS_Assembler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aayush-Bhargav%2FMIPS_Assembler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aayush-Bhargav%2FMIPS_Assembler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aayush-Bhargav","download_url":"https://codeload.github.com/Aayush-Bhargav/MIPS_Assembler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aayush-Bhargav%2FMIPS_Assembler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33162602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"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":["asm","assembly-code","assembly-language","mips-assembly","python","sorting"],"created_at":"2024-12-14T20:13:33.484Z","updated_at":"2026-05-18T02:31:18.473Z","avatar_url":"https://github.com/Aayush-Bhargav.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MIPS_Assembler\nThis repository consists of an ASM code to implement bubble sort in MIPS architecture. It also contains a python assembler designed to run the ASM code.\n\n1) Implementation of Sorting algorithm using MIPS(template.asm)\n \n  We implemented the bubble sort algorithm to sort the numbers in increasing order.We\nstored the variables 'n','n-1','i'(control variable for outer for loop) in different\ntemporary registers. When 'n'=1,there's no need to enter the loop . So we jump to the\nlabel 'skiploop'. In the outer for loop , we store the starting address of input\nvalues,output values and control variable for inner for loop(j) in other temporary\nregisters. In the inner for loop, we compare two adjacent elements. If the element at\nindex a\u003eelement at index b(and a\u003cb),then we swap the elements by calling the label\n'swap' and then continue. At the end of each iteration of outer for loop,the largest\nelement will occupy the last position . Then we write this element to the (starting\naddress of output values+4*(n-i-1)).(So if n=4 and i=0 then at the end of the first\niteration of the outer for loop, we write the element at a[n-i-1] to address=base output\naddress+4*(n-1))\nThis part where we write to the output addresses is done in the label 'innerloopdone'\nsignyfying it is called after each iteration of the outer loop. We continue this process\ntill i becomes n-1 and once i=n-1 , we go to 'done' block where we write the smallest\nelement in the array to the base output address. After this,the numbers entered are\nsorted in ascending order as proven by the output as well.\n\n2) Assembler.py\n\n  The python program Assembler.py creates an assembler for the template.asm\ncode. An assembler converts assembly level code into machine level code. First\nwe define few dictionaries which gives us the mapping between instructions\nand opcodes, registers and numbers, labels and immediates. Then we write a\nfunction called Convert_to_Binary() which takes a string input of a decimal\nnumber and gives us its binary equivalent output. The binary string length can\nbe 5 or 16 depending on the parameter. We handle the negative number case by\nusing the 2's complement representation. Conditional statements are used to\ncheck if a number is positive or negative. The two's complement is calculated in\nthe function. Finally we use nested if-else statement to check the type of\ninstruction and calculate its corresponding machine code. The machine code is\nrepresented using a string called 'output'. We use the split() function to make the\nfile-input simpler. Output for each instruction is calculated based on its type ie\nR,I,J type instructions. We use a for-loop to loop through the template.asm code\nand print the corresponding hexadecimal PC value and the output. In the end\nthe PC is incremented by four.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faayush-bhargav%2Fmips_assembler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faayush-bhargav%2Fmips_assembler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faayush-bhargav%2Fmips_assembler/lists"}