CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler

1.  Objectives

This project is designed to help students to understand the RISC architecture (MIPS) and its instruction set and assembly. Students will gain programming experience in C.

2.  Goals

Your team (2 persons) will build an MIPS assembler for a subset of MIPS instructions in C. This assembler will read a simple MIPS program and generate an MIPS machine code output file. Due dates for Project 1 is November 3.

3.  Specifications

  • Input

Your assembler will read and parse the contents of a simple MIPS program (program.asm). Each line of the program contains an MIPS instruction or a directive. A label will appear on a line by itself. Operands are comma-separated. No line is blank. No comment is allowed. There will be no white spaces between operands. All lines will begin with a tab except labels. Only decimal numbers are allowed. Lines containing instructions have the following format:

<tab>instruction<tab>comma- separated-operands

Lines containing directives have the following format:

<tab>directive[<tab>comma-separated-operand]

Lines containing labels have the following format: label:

The supported instructions are as follows. You may wish to consult additional MIPS references or the textbook to know the details of the instructions.

InstructionNameSyntaxSemantic
ADDAdditionadd $1,$2,$3$1 = $2 + $3
SUBSubtractsub $1,$2,$3$1 = $2 – $3
SLLShift left logicalsll $1,$2,5$1 = $2 << 5
SRLShift right logicalsrl $1,$2,5$1 = $2 >> 5
SLTSet less thanslt $1,$2,$3If $2<$3, $1=1; otherwise, $1=0
ADDIAddition immediateaddi $1,$2,45$1 = $2 + 45
LUILoad upper immediatelui $1,45Upper 16-bit of $1 = 45 (Lower 16-bit of $1 is set to 0)
ORIOr immediateori $1,$2,45$1 = $2 | 45 (bitwise OR)
LWLoad wordlw $1,100($2)$1 = Memory[$2+100]
SWStore wordsw $1,100($2)Memory[$2+100] = $1
BEQBranch on equalbeq $1,$2,LabelIf $1=$2, jump to Label
BNEBranch on not equalbne $1,$2,LabelIf $1≠$2, jump to Label
JJumpj LabelJump to Label
LA *Load addressla $1,Labellui $1, upper 16-bit of Label ori $1, $1, lower 16-bit of Label
  • LA is a pseudo-instruction. It is used to load the memory location (Label, 32 bits) into the destination register. The assembler replaces it with two instruction sequence, lui followed by ori.

The supported directives are as follows.

DirectiveNameSyntaxSemantic
.dataData segment.data (no operand)Data section in memory; it begins at 0 (0x0000 0000) by default
.textText segment.text (no operand)Program section in memory; it begins at 512 (0x0000 0200) by default
.space nAllocation of n words of memory.space 10Allocation of 10 words (40 bytes) of memory
.word wAllocation of a word and initialized to w. word 16Allocation of   a   word   (4   bytes)   and initialized to 16 (0x0001 0000).
  • The program may contain data section only or text section only. If both exist, the data section proceeds the text section.

The registers are denoted as $0, $1, $2, etc. instead of “$s0” or “r1”. $0 always takes the value of 0 and is not changeable.

3.2  Output

The assembler generates an output file (program.out) of size 1KB consisting of 512B of data segment (begins at 0x0000) and 512B of text segment (begins at 0x0200). Since each data and instruction is 4B long, there will be at maximum 128 word data and at maximum 128 instruction words. This file is a binary file. Do not try to open this file as it causes an error. The assembler does not detect syntax errors and assumes the assembly input is correctly formed. We assume big-endian.

For a sample assembly input file (test.asm):

.data print_data:

.word 0 add_result:

.word                        0 load_data:

.word    1

.word    2

.text

start:

la$1,load_data
lw$4,0($1)
lw$5,4($1)
add$4,$4,$5

la         $1,add_result

sw        $4,0 ($1)

Then, the contents of the output file (test.out) will be as follows. Again, this is a binary file and can only be seen with a special tool.

  • In Linux, you will have to use the command line command “od -Ax -t x4” (octal dump). To see the text segment (offset 0x0200), please use the command “od -Ax -t x4 -j512”.
  • In Windows, you can use “format-hex.” Click the Start menu button and type “powershell” (without the quotation marks). In the “Windows PowerShell” window, please use the command line command “format-hex”.
  • You can also view it online: https://hexed.it/

00000000 00000000 00000001 00000002

00000000 00000000 00000000 00000000

……………

3c010000 34210008 8c240000 8c250004

00852020 3c010000 34210004 ac240000

……………

Note that the file begins with the data segment (512 bytes) followed by the text segment. “3c010000 34210008” denotes the assembled output for the LA instruction (LUI and ORI). “8c240000” denotes the LW instruction. And so on.

Encoding of MIPS instructions is as follow. You may wish to consult additional MIPS references or the textbook to know the details of the instructions.

Instruc- tionSyntaxMIPS instruction encoding (32 bits)
(R-type)Opcode(6)Rs(5)Rt(5)Rd(5)Shamt(5)Func(6)
ADDadd $1,$2,$3000000   N/A100000
SUBsub $1,$2,$3000000   N/A100010
SLL *sll $1,$2,5000000N/A   000000
SRL **srl $1,$2,5000000N/A   000010
SLTslt $1,$2,$3000000    101010
(I-type)Opcode(6)Rs(5)Rt(5)Immediate (16)
ADDIaddi $1,$2,45001000   
LUIlui $1,45001111N/A  
ORIori $1,$2,45001101   
LWlw $1,100($2)100011   
SWsw $1,100($2)101011   
BEQbeq $1,$2,Label000100   
BNEbne $1,$2,Label000101   
(J-type)Opcode(6)Offset(26)
Jj Label000010 

Please note the use of labels in the branch (beq and bne) instructions. You will need to compute the appropriate immediate fields for the machine code based on the following relationship.

Addr(Label) = Addr(inst_after_branch) + immediate(16 bits)*4

First, the immediate field represents the distance, in instructions rather than in bytes, between the branching instruction and the destination instruction. This explains *4 at the end of the relationship. Second, typically PC-relative addressing is relative to PC+4, not PC. That is, it is relative to the next instruction, not the current instruction. This explains “Addr(inst_after_branch)” in the relationship.

The targaddr field of the jump instruction will be defined using pseudo-direct addressing where the address of the destination is defined as

Addr(Label) = Addr(inst_after_jump)[31-28] || immediate(26 bits) || 00

where Addr(inst_after_jump)[31-28] is the 4 most significant bits of PC+4, and || denotes concatenation.

3.3  Useful standard C library functions for this project

(ref: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rtref/stalib.htm)

You may want to use file-related C functions such as fopen(), fclose(), and fwrite() and string- related C functions such as strncmp(), strtok(), and atoi(). Please make yourself familiar with those functions first.

You may find another string-related C functions fgets() to be particularly useful for this assignment. The fgets function reads n characters from stream and writes them to the str buffer. On success, the function returns the same str parameter. If the end-of-file is encountered, a null pointer is returned. The following example shows the usage of fgets() function:

#include int main () { FILE *fp; char str[60]; /* opening file for reading */ fp = fopen(“file.txt” , “r”); if(fp == NULL) { perror(“Error opening file”); return(-1); } if( fgets (str, 60, fp)!=NULL ) { /* writing content to stdout */ puts(str); } fclose(fp); return(0); }

The sscanf function would be also useful. It scans the str buffer to try to match the format specifiers in the format string. Additional pointer arguments may be supplied to indicate variables that should be filled with elements found in the str buffer. The following example shows the usage of sscanf() function:

The fwrite function writes a raw data to a file. On success, the function returns the count of the number of items successfully written to the file. On error, it returns a number less than the specified number of items to be written. The following example shows the usage of fwrite() function:

#include int main () {

FILE *fp;

int year;

fp = fopen( “file.txt” , “w” );

if (fwrite(&year , size(int), 1, fp )!=1) {

perror(“Error writing file”);

return(-1); }

fclose(fp);

return(0); } 

You may also want to make use of some bitwise operators (&, |, <>) or the union construct to manage the instruction fields easily. Also, watch out for signed-ness.

3.4  Testing

A few sample test assembly files will also be provided about a week before the project is due. Make use of the sample executable to help verify your output.

You can test your design using your own programs. The quality of your assembler will be determined by how much and how varied the tests are. For example, testing if the assembler works for BNE for both the equal and not equal cases, and forward and backward branching, and all combinations of these, would get a better grade than just testing for one case of BNE.

To confirm your assembler generates the correct machine code, you can get some help from Internet, e.g., https://www.csfieldguide.org.nz/en/interactives/mips-assembler/ or https://alanhogan.com/asu/assembler.php. Just type your assembly program such as “add $s1, $s2,

$s3”, it will output machine code for you. (Note that this assembler recognizes $s1, $s2, etc. but does not recognize $1, $2, etc.)

4.  Submission and Grading

Each group submits via Blackboard the source code: assembler.c.

At the top of the source code, please list CLEARLY all the instructions and directives your program cannot handle and all known issues with your program (those that are not implemented, those that are implemented but not work correctly, etc.).

You must submit before 11:59 PM on November 3 to get full credit. Late submissions will be accepted for 10% off per day up to three additional days. Automatic plagiarism detection software will be used on all submissions. Any cases detected will result in a grade of 0, reduction of the overall grade by one letter grade, and a report will be sent to Academic Affairs.

Order Now

Get expert help for Computer Architecture and many more. 24X7 help, plag-free solution. Order online now!

Universal Assignment (May 14, 2026) CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler. Retrieved from https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/.
"CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler." Universal Assignment - May 14, 2026, https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/
Universal Assignment November 4, 2022 CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler., viewed May 14, 2026,<https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/>
Universal Assignment - CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler. [Internet]. [Accessed May 14, 2026]. Available from: https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/
"CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler." Universal Assignment - Accessed May 14, 2026. https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/
"CIS 600 Computer Architecture, Fall 2022 Project 1 – MIPS Assembler." Universal Assignment [Online]. Available: https://universalassignment.com/cis-600-computer-architecture-fall-2022-project-1-mips-assembler/. [Accessed: May 14, 2026]

Please note along with our service, we will provide you with the following deliverables:

Please do not hesitate to put forward any queries regarding the service provision.

We look forward to having you on board with us.

Categories

Get 90%* Discount on Assignment Help

Most Frequent Questions & Answers

Universal Assignment Services is the best place to get help in your all kind of assignment help. We have 172+ experts available, who can help you to get HD+ grades. We also provide Free Plag report, Free Revisions,Best Price in the industry guaranteed.

We provide all kinds of assignmednt help, Report writing, Essay Writing, Dissertations, Thesis writing, Research Proposal, Research Report, Home work help, Question Answers help, Case studies, mathematical and Statistical tasks, Website development, Android application, Resume/CV writing, SOP(Statement of Purpose) Writing, Blog/Article, Poster making and so on.

We are available round the clock, 24X7, 365 days. You can appach us to our Whatsapp number +1 (613)778 8542 or email to info@universalassignment.com . We provide Free revision policy, if you need and revisions to be done on the task, we will do the same for you as soon as possible.

We provide services mainly to all major institutes and Universities in Australia, Canada, China, Malaysia, India, South Africa, New Zealand, Singapore, the United Arab Emirates, the United Kingdom, and the United States.

We provide lucrative discounts from 28% to 70% as per the wordcount, Technicality, Deadline and the number of your previous assignments done with us.

After your assignment request our team will check and update you the best suitable service for you alongwith the charges for the task. After confirmation and payment team will start the work and provide the task as per the deadline.

Yes, we will provide Plagirism free task and a free turnitin report along with the task without any extra cost.

No, if the main requirement is same, you don’t have to pay any additional amount. But it there is a additional requirement, then you have to pay the balance amount in order to get the revised solution.

The Fees are as minimum as $10 per page(1 page=250 words) and in case of a big task, we provide huge discounts.

We accept all the major Credit and Debit Cards for the payment. We do accept Paypal also.

Popular Assignments

Assessment 1

Helpful Tools for ReflectionDuring the reflective journal process, you may wish to use these helpful templates and decision wheel tools to consolidate thoughts and ideas.Regardless of which framework is chosen, all areas of reflection are to be attempted to complete the full reflective cycle. It is important that any template,

Read More »

Professional Nursing Assignment Help for Students: Achieve Academic Excellence with Expert Support

Introduction Nursing is a demanding field that combines theoretical knowledge with practical skills. Students pursuing nursing courses often face challenges in completing assignments that require accuracy, critical thinking, and real-world application. This is where nursing assignment help becomes an essential academic support system. With increasing academic pressure and clinical responsibilities,

Read More »

Economics Assignment Help: A Complete Guide for Students

Introduction Economics is a fundamental subject that helps students understand how markets, governments, and individuals make decisions regarding resources. While it is highly relevant in today’s world, many students find economics assignments challenging due to complex theories, graphs, and data analysis. This is where economics assignment help becomes extremely useful.

Read More »

Law Assignment Help: A Complete Guide for Students

Introduction Law is a complex and intellectually demanding field that requires critical thinking, analytical skills, and a deep understanding of legal principles. Students pursuing law often face challenges in completing assignments due to extensive research requirements and intricate case analysis. This is where law assignment help becomes highly beneficial. With

Read More »

Nursing Assignment Help: A Complete Guide for Students

Introduction Nursing is a highly respected and demanding field that requires a strong understanding of medical concepts, patient care, and clinical practices. Students pursuing nursing often face intense academic pressure due to complex assignments, practical responsibilities, and tight deadlines. This is where nursing assignment help becomes essential. With expert assistance,

Read More »

Finance Assignment Help: A Complete Guide for Students

Introduction Finance is a core subject in business and management studies, covering areas like investment analysis, financial management, and risk assessment. While it offers excellent career opportunities, many students find finance assignments challenging due to complex calculations and analytical concepts. This is where finance assignment help becomes essential. With expert

Read More »

Computer Science Assignment Help: A Complete Guide for Students

Introduction Computer Science is one of the most popular and dynamic fields of study, offering vast career opportunities in software development, data analysis, cybersecurity, and more. However, students often face difficulties in completing assignments due to the technical complexity and time constraints. This is where computer science assignment help becomes

Read More »

Digital Marketing Assignment Help: A Complete Guide for Students

Introduction Digital marketing has become a vital part of modern business strategies, making it a popular subject among students worldwide. From social media campaigns to search engine optimization, the field is dynamic and constantly evolving. However, completing assignments in this subject can be challenging due to its practical and analytical

Read More »

Cloud Computing Assignment Help: A Complete Guide for Students

Introduction Cloud computing has become a fundamental part of modern technology, powering everything from mobile apps to enterprise systems. As universities increasingly include this subject in their curriculum, students often find it challenging to keep up with assignments and projects. This is where cloud computing assignment help becomes essential. With

Read More »

Blockchain Assignment Help: A Complete Guide for Students

Introduction Blockchain technology has rapidly gained popularity across industries such as finance, healthcare, and supply chain management. As a result, it has become an important subject in academic programs worldwide. However, students often struggle with its technical concepts and practical applications. This is where blockchain assignment help becomes highly valuable.

Read More »

Data Science Assignment Help: A Complete Guide for Students

Introduction Data Science has become one of the most in-demand fields in today’s digital era, combining statistics, programming, and analytical thinking. However, many students find it difficult to keep up with the complexity of assignments and projects in this subject. This is where data science assignment help plays a crucial

Read More »

Artificial Intelligence Assignment Help: A Complete Guide for Students

Introduction Artificial Intelligence (AI) is transforming industries across the globe, making it one of the most sought-after academic subjects today. However, mastering AI concepts and completing assignments can be challenging for many students. This is where artificial intelligence assignment help becomes essential. With expert guidance, students can better understand complex

Read More »

Assignment Writing Services: A Complete Guide for Students

Introduction Assignments are a crucial part of academic life, helping students develop knowledge, research skills, and critical thinking. However, managing multiple assignments along with exams and personal responsibilities can be overwhelming. This is where assignment writing services become highly beneficial. These services provide expert assistance, helping students complete their assignments

Read More »

Blockchain Assignment Help: A Complete Guide for Students

Introduction Blockchain technology has emerged as one of the most revolutionary innovations in recent years. From cryptocurrencies to secure data management, blockchain is transforming industries like finance, healthcare, and supply chain. Students studying blockchain often face challenges due to its technical concepts and real-world applications. This is where blockchain assignment

Read More »

Assignment Writing Services: A Complete Guide for Students

Introduction Assignments are a crucial part of academic life, helping students develop knowledge, research skills, and critical thinking. However, managing multiple assignments along with exams and personal responsibilities can be overwhelming. This is where assignment writing services become highly beneficial. These services provide expert assistance, helping students complete their assignments

Read More »

Academic Writing Services: A Complete Guide for Students

Introduction Academic writing is a fundamental part of education, requiring students to produce essays, research papers, case studies, and dissertations. It demands strong writing skills, proper structure, and in-depth research. However, many students struggle with academic writing due to time constraints and lack of expertise. This is where academic writing

Read More »

Online Homework Help Services: A Complete Guide for Students

Introduction Homework is an essential part of a student’s learning process, helping reinforce classroom knowledge and improve understanding. However, with increasing academic pressure and multiple responsibilities, students often struggle to complete their homework on time. This is where online homework help services become highly beneficial. They provide expert guidance, save

Read More »

Thesis Writing Help: A Complete Guide for Students

Introduction A thesis is one of the most important academic documents a student will write during their educational journey. It requires in-depth research, critical analysis, and a clear presentation of ideas. However, many students find thesis writing overwhelming due to its complexity and time-consuming nature. This is where thesis writing

Read More »

Essay Writing Help: A Complete Guide for Students

Introduction Essay writing is a fundamental part of academic life, helping students express their ideas, analyze topics, and develop critical thinking skills. Whether it’s argumentative, descriptive, or analytical, writing a high-quality essay requires proper structure, research, and clarity. However, many students struggle with essay writing due to time constraints and

Read More »

Content Writing Assignment Help: A Complete Guide for Students

Introduction Content writing has become a crucial skill in the digital era, playing a key role in blogging, marketing, and online communication. From academic essays to website content, strong writing skills are essential for students across all fields. However, many students struggle with structuring content, maintaining clarity, and optimizing for

Read More »

Digital Marketing Assignment Help: A Complete Guide for Students

Introduction Digital marketing has become one of the most important skills in today’s online-driven world. From social media marketing to search engine optimization (SEO), businesses rely heavily on digital strategies to reach their audience. Students studying digital marketing often face challenges in understanding strategies, tools, and real-world applications. This is

Read More »

Can't Find Your Assignment?