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 (April 26, 2025) 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 - April 26, 2025, 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 April 26, 2025,<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 April 26, 2025]. 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 April 26, 2025. 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: April 26, 2025]

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.

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

STM1001: Assignment 3 for Science/Health Stream Students

STM1001: Assignment 3 Science/Health Stream Students Only Academic Integrity Information In submitting your work, you are consenting that it may be copied and transmitted by the University for the detection of plagiarism. If you are unsure of your academic integrity responsibilities, please check the information provided in the Assessment Overview

Read More »

ACCG1000 Accounting for Decision Making Xero Assignment

1ACCG1000Accounting for Decision MakingXero AssignmentInformation packSession 2 2024Due Date: Friday 18th October 2024 at 11.55pm2Xero AssignmentIntroductionThe Xero assignment is designed to provide introductory accounting students with an overview of the Xero Accounting Software by completing a one-month accounting cycle for a fictional business. This is an online assignment worth 20%

Read More »

WRIT1001 Assessment Notification 2

6Final Essay: Rhetorical analysisDue: Friday 18 October 2024 at 23:59 (Sydney time)Length: 1500 words, worth 40% of the overall grade for the unitSubmit: as a Word document or PDF, via Canvas AssignmentMain question:● Present a scholarly essay that analyses the rhetoric used in arguments about thecontentious topic you have been

Read More »

WRIT1000 Assessment Four

Title: Self-ReflectionDue: Friday October 18 by 11:59PM.Length: 500 words (+/- 10%)Weight: 10% of the total gradeFormat: Times New Roman, double-spaced, 12pt. Your project should have the title“WRIT1000 Assessment Four – Self Reflection for xxxxxxx” where “xxxxxxxx” is yourstudent number. Please only submit Word documents (.doc or .docx). Turnitin doesnot recognise

Read More »

Written Assessment – Psychosocial Research Perspectives

Written Assessment – Psychosocial Research Perspectives TRIGGER WARNING: This is a case study of a real person. Katherine Knight was the first woman in Australia to receive a life sentence without parole after she decapitated and cooked her lover. If you think that you will have problems reading about this

Read More »

RES800 Assessment 1 – Research Question and Literature Review

Subject Title Business Research Subject Code RES800 Assessment Title Assessment 1 – Research Question and Literature Review Learning Outcome/s     Utilise critical thinking to analyse managerial problems and formulate relevant research questions and a research design   Apply research theories and methodologies to assist in developing a business research

Read More »

Assessment Task 2 Health advocacy and communication plan

Assessment Task 2 Health advocacy and communication plan Rationale and multimedia plan presentation Submission requirements Due date and time:         Rationale: 8pm AEST Monday 23 September 2024 (Week 11) Multimedia plan presentation: 8pm AEST Monday 30 September 2024 (Study Period) % of final grade:         50% of overall grade Word limit: Time

Read More »

MLI500 Leadership and innovation Assessment 1

Subject Title Leadership and innovation Subject Code MLI500 Assessment Assessment 1: Leadership development plan Individual/Group Individual Length 1500 words Learning Outcomes LO1 Examine the role of leaders in fostering creativity and innovation LO5 Reflect on and take responsibility for their own learning and leadership development processes Submission   Weighting 30%

Read More »

FPC006 Taxation for Financial Planning

Assignment 2 Instructions Assignment marks: 95 | Referencing and presentation: 5 Total marks: 100 Total word limit: 3,000 words Weighting: 40% Download and use the Assignment 2 Answer Template provided in KapLearn to complete your assignment. Your assignment should be loaded into KapLearn by 11.30 pm AEST/AEDT on the wdue

Read More »

TCHR5001 Assessment Brief 1

TCHR5001 Assessment Brief 1 Assessment Details Item Assessment 1: Pitch your pedagogy Type Digital Presentation (Recorded) Due Monday, 16th September 2024, 11:59 pm AEST (start of Week 4) Group type Individual Length 10 minutes (equivalent to 1500 words) Weight 50% Gen AI use Permitted, restrictions apply Aligned ULOS ULO1, ULO2,

Read More »

HSH725 Assessment Task 2

turquoise By changing the Heading 3 above with the following teal, turquoise, orange or pink you can change the colour theme of your CloudFirst CloudDeakin template page. When this page is published the Heading 3 above will be removed, but it will still be here in edit mode if you wish to change the colour theme.

Read More »

Evidence in Health Assessment 2: Evidence Selection

Evidence in Health Assessment 2: Evidence Selection Student name:                                                                    Student ID: Section 1: PICO and search strategy Evidence Question: Insert evidence question from chosen scenario here including all key PICO terms.       PICO Search Terms                                                                                                                                                                                                          Complete the following table.   Subject headings Keywords Synonyms Population  

Read More »

Assessment 1 – Lesson Plan and annotation

ASSESSMENT TASK INFORMATION: XNB390 Assessment 1 – Lesson Plan and annotation This document provides you with information about the requirements for your assessment. Detailed instructions and resources are included for completing the task. The Criterion Reference Assessment (CRA) Marking Matrix that XNB390 markers will use to grade the assessment task

Read More »

XNB390 Task 1 – Professional Lesson Plan

XNB390 Template for Task 1 – Professional Lesson Plan CONTEXT FOR LESSON: SOCIAL JUSTICE CONSIDERATIONS: Equity Diversity Supportive Environment UNIT TITLE:    TERM WEEK DAY TIME 1   5           YEAR/CLASS STUDENT NUMBERS/CONTEXT LOCATION LESSON DURATION         28 Children (chl): 16 boys; 12

Read More »

A2 Critical Review Assignment

YouthSolutions Summary The summary should summarise the key points of the critical review. It should state the aims/purpose of the program and give an overview of the program or strategy you have chosen. This should be 200 words – included in the word count. Critical analysis and evaluation Your critical

Read More »

PUN364 – Workplace activity Assignment

Assessment 1 – DetailsOverviewFor those of you attending the on-campus workshop, you will prepare a report on the simulated simulated inspection below. For those of you who are not attending, you will be required to carry out your own food business inspection under the supervision of a suitably qualified Environmental

Read More »

FPC006 Taxation for Financial Planning

Assignment 1 Instructions Assignment marks: 95 | Referencing and presentation: 5 Total marks: 100 Total word limit: 3,600 words Weighting: 40% Download and use the Assignment 1 Answer Template provided in KapLearn to complete your assignment. Your assignment should be loaded into KapLearn by 11.30 pm AEST/AEDT on the due

Read More »

Mental health Nursing assignment

Due Aug 31 This is based on a Mental health Nursing assignment Used Microsoft word The family genogram is a useful tool for the assessment of individuals, couples, and families.  It can yield significant data and lead to important, new patient understandings and insights as multigenerational patterns take shape and

Read More »

Assessment 2: Research and Policy Review

Length: 2000 words +/- 10% (excluding references)For this assessment, you must choose eight sources (academic readings and policy documents) as the basis of your Research and Policy Review. You must choose your set of sources from the ‘REFERENCES MENU’ on the moodle site, noting the minimum number of sources required

Read More »

HSN702 – Lifespan Nutrition

Assessment Task: 2 Assignment title: Population Nutrition Report and Reflection Assignment task type: Written report, reflection, and short oral presentation Task details The primary focus of this assignment is on population nutrition. Nutritionists play an important role in promoting population health through optimal nutritional intake. You will be asked to

Read More »

Written Assessment 1: Case Study

Billy a 32-year-old male was admitted to the intensive care unit (ICU) with a suspected overdose of tricyclic antidepressants. He is obese (weight 160kg, height 172cm) and has a history of depression and chronic back pain for which he takes oxycodone. On admission to the emergency department, Paramedics were maintaining

Read More »

Assessment Task 8 – Plan and prepare to assess competence

Assessment Task 8 – Plan and prepare to assess competence Assessment Task 8 consists of the following sections: Section 1:      Short answer questions Section 2:      Analyse an assessment tool Section 3:      Determine reasonable adjustment and customisation of assessment process Section 4:      Develop an assessment plan Student Instructions To complete this

Read More »

Nutrition Reviews Assignment 2 – Part A and Part B

This assignment provides you with the opportunity to determine an important research question that is crucial to address based on your reading of one of the two systematic reviews below (Part A). You will then develop a research proposal outlining the study design and methodology needed to answer that question

Read More »

NUR332 – TASK 3 – WRITTEN ASSIGNMENT

NUR332 – TASK 3 – WRITTEN ASSIGNMENT for S2 2024. DESCRIPTION (For this Task 3, the word ‘Indigenous Australians’, refers to the Aboriginal and Torres Strait Islander Peoples of Australia) NUR332 Task 3 – Written Assignment – Due – WEEK 12 – via CANVAS on Wednesday, Midday (1200hrs) 16/10/2024. The

Read More »

NUR100 Task 3 – Case study

NUR100 Task 3 – Case study To identify a key child health issue and discuss this issue in the Australian context. You will demonstrate understanding of contemporary families in Australia. You will discuss the role of the family and reflect on how the family can influence the overall health outcomes

Read More »

NUR 100 Task 2 Health Promotion Poster

NUR 100 Task 2 Health Promotion Poster The weighting for this assessment is 40%. Task instructions You are not permitted to use generative AI tools in this task. Use of AI in this task constitutes student misconduct and is considered contract cheating. This assessment requires you to develop scholarship and

Read More »

BMS 291 Pathophysiology and Pharmacology CASE STUDY

BMS 291 Pathophysiology and Pharmacology CASE STUDY Assessment No: 1 Weighting: 40% Due date Part A: midnight Friday 2nd August 2024 Due date Part B: midnight Sunday 29th September 2024 General information In this assessment, you will develop your skills for analysing, integrating and presenting information for effective evidence-based communication.

Read More »

Can't Find Your Assignment?

Open chat
1
Free Assistance
Universal Assignment
Hello 👋
How can we help you?