{"id":13783112,"url":"https://github.com/megabytefisher/MAI","last_synced_at":"2025-05-11T17:31:05.912Z","repository":{"id":27747250,"uuid":"31235175","full_name":"megabytefisher/MAI","owner":"megabytefisher","description":"MAI - MIPS Assembly Interpreter","archived":false,"fork":false,"pushed_at":"2015-04-27T16:19:31.000Z","size":269,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T18:18:16.471Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/megabytefisher.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}},"created_at":"2015-02-23T23:14:55.000Z","updated_at":"2022-06-14T19:18:35.000Z","dependencies_parsed_at":"2022-09-03T05:10:59.853Z","dependency_job_id":null,"html_url":"https://github.com/megabytefisher/MAI","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megabytefisher%2FMAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megabytefisher%2FMAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megabytefisher%2FMAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megabytefisher%2FMAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megabytefisher","download_url":"https://codeload.github.com/megabytefisher/MAI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253604549,"owners_count":21934882,"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":[],"created_at":"2024-08-03T18:01:53.290Z","updated_at":"2025-05-11T17:31:05.624Z","avatar_url":"https://github.com/megabytefisher.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"#MAI\n\nTeam members:\nKevin Fisher\nNathaniel Warren III\nEdward Prins III\nMiguel Betances Lee\nDereje Arega\n\nResearch Problem\n\n\nFor our research project, we have decided to write a MIPS interpreter in C.\n\nSimilar to the Python interpreter, it will allow a user to run it and enter MIPS assembly instructions line by line, displaying which registers/values change as a result of each line. We believe this would be very useful for students learning about assembly language, because it would allow them to test fragments of programs easily and quickly, rather than having to create a full MIPS program in an IDE/simulator like MARS.\n\nIn addition to the live interpreter mode, users will be able to load and run a MIPS file, just like in MARS. A small goal that we have is running MIPS programs faster than MARS can. We believe this will be easy given that MARS has a huge overhead (the Java runtime). Our program will be a faster C program with no such limitation.\n\nWe plan to implement pseudo-opcodes like in MIPS (such as mov and li).\n\nTechnical Approach\n\n\nMAI will be implemented in C. We will use only the standard C library, meaning it will run on all platforms without modification.\n\nMAI will have two modes of operation -- live interpreter and input file mode. In live interpreter mode, users enter assembly instructions on a line by line basis. In input file mode, MAI will read a file and run it, similar to MARS.\n\nMAI differs from MARS in that it is not an assembler. While MARS translates the assembly code into machine code and simulates that, MAI will instead parse the text and execute C functions based on that.\n\nWe will create a small C function for every emulated MIPS instruction. Each of these functions will take two parameters, a struct containing the current MIPS state, and a string for parsing the parameters of the MIPS instruction.\n\nIt will contain a dictionary structure that resolves a string representation of an instruction (such as add) into a corresponding C function. Since MIPS is a reduced instruction set architecture, it will not be hard to implement all instructions, as opposed to something like x86.\n\nThe basic loop for the interpreter mode will be as follows:\nRead a line from console\nResolve the opcode name (add, sub, etc…) into a corresponding C function\nCall the function with the string containing the instruction operands\nThe function will parse the substring, using another standard function to translate register names into int pointers, and act upon those.\nAny user input error will simply write a description of the problem to console and have no other effect\nDisplay any changed registers’ values\nRepeat\n\nThe file input mode will be very similar, except that it reads each line from the file in and substitutes that for user input.\n\nFor testing opcode emulation correctness, we will run small portions of MIPS assembly in our interpreter and verify the resulting MIPS register state is as we expect. We can also compare results against running the same programs in MARS.\n\nFor testing speed, we will time programs that run in MARS and in MAI.\n\nWe will use github to collaborate at: https://github.com/megabytefisher/MAI\n\nMilestones\n\n\nA basic system for reading user input and parsing strings from MIPS opcodes into our own C emulation functions\nImplementation of a majority of the standard MIPS instruction set.\nAbility to input .data sections (like .data text : word 5)\nImplementation of MARS pseudo-instructions\nAbility to read MIPS programs from file and run them.\nOptimization/Speed ups\n\nReferences\n\n\nSince we are only using the standard C library, our main reference will be websites that describe the C language and stdlib. Such as cplusplus.com\n\nAnother reference we will need is descriptions of the MIPS instruction set and syscalls, such as:\nhttp://courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html\nhttp://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html\n\nProjected Example\n\n\n\nWelcome to the MIPS Live Interpreter\nEnter an opcode to execute:\n\u003e\u003e addi $a0, $zero, 5\nModified registers:\n$a0 : 5\n\u003e\u003e add $a0, $a0, $a0\nModified registers:\n$a0 : 10\n\u003e\u003e li $v0, 1\nModified registers:\n$v0 : 1\n\u003e\u003e syscall\n10\n\u003e\u003e .data\ntestValue: .word 15\n.text\n\u003e\u003e li $v0, 10\nModified registers:\n$v0 : 10\n\u003e\u003e syscall\n(exits program)\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegabytefisher%2FMAI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegabytefisher%2FMAI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegabytefisher%2FMAI/lists"}