Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

CIS 480/580 Computer Architecture, Spring 2021 Project 1 & 2 – MIPS Assembler

Rating
-
Sold
-
Pages
6
Uploaded on
10-04-2023
Written in
2022/2023

CIS 480/580 Computer Architecture, Spring 2021 Project 1 & 2 – MIPS Assembler 1. Objectives This project is designed to help students to understand the RISC architecture (MIPS) and its instruction set and assembly. 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. 3. Specification Project 2 is the extension of Project 1 by including branch and jump instructions. Note that the shaded parts in this document are Project 2 requirements. Due dates for Project 1 and 2 is March 12 and March 26, respectively. While there are no language requirements, I will be grading your programs using Linux, so make sure your program can easily be compiled and run in a Linux environment. C and Java should work without issue, C# should be fine as long as you don’t use any GUI components. 3.1 Input Your assembler will read and parse the contents of a simple MIPS program (). Each line of the program contains an MIPS instruction or a directive. No line is blank. A label will not appear on a line by itself. Operands are comma-separated. There will be no white spaces between operands. No line will begin with white spaces. Lines containing instructions have the following format: [label:]tabinstructiontaboperands Lines containing directives have the following format: [label:]tabdirective[taboperand] The supported instructions are as follows. You may wish to consult additional MIPS references or the textbook to know the details of the instructions. Instruction Name Syntax Semantic ADD Addition add $1,$2,$3 $1 = $2 + $3 SUB Subtract sub $1,$2,$3 $1 = $2 - $3 SLL Shift left logical sll $1,$2,5 $1 = $2 5 SRL Shift right logical srl $1,$2,5 $1 = $2 5

Show more Read less
Institution
Course

Content preview

CIS 480/580 Computer Architecture, Spring 2021
Project 1 & 2 – MIPS Assembler
1. Objectives

This project is designed to help students to understand the RISC architecture (MIPS) and its
instruction set and assembly.


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.


3. Specification

Project 2 is the extension of Project 1 by including branch and jump instructions. Note that the
shaded parts in this document are Project 2 requirements. Due dates for Project 1 and 2 is March
12 and March 26, respectively.

While there are no language requirements, I will be grading your
programs using Linux, so make sure your program can easily be
compiled and run in a Linux environment. C and Java should work
without issue, C# should be fine as long as you don’t use any GUI
components.
3.1 Input

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

[label:]<tab>instruction<tab>operands

Lines containing directives have the following format:
[label:]<tab>directive[<tab>operand]

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

Instruction Name Syntax Semantic
ADD Addition add $1,$2,$3 $1 = $2 + $3
SUB Subtract sub $1,$2,$3 $1 = $2 - $3
SLL Shift left logical sll $1,$2,5 $1 = $2 << 5
SRL Shift right logical srl $1,$2,5 $1 = $2 >> 5



This study source was downloaded by 100000850872992 from CourseHero.com on 04-10-2023 12:40:07 GMT -05:00


https://www.coursehero.com/file/91299083/20221S-project1-2-1-1doc/

, SLT Set less than slt $1,$2,$3 If $2<$3, $1=1; otherwise, $1=0
ADDI Addition immediate addi $1,$2,45 $1 = $2 + 45
LUI Load upper immediate lui $1,0xA5A5 ** Upper 16-bit of $1 = 0xA5A5
(Lower 16-bit of $1 is set to 0)
ORI Or immediate ori $1,$2,0xB6B6 $1 = $2 | 0x0000 B6B6 (bitwise OR)
LW Load word lw $1,100($2) $1 = Memory[$2+100]
SW Store word sw $1,100($2) Memory[$2+100] = $1
BEQ Branch on equal beq $1,$2,Label If $1=$2, jump to Label
BNE Branch on not equal bne $1,$2,Label If $1≠$2, jump to Label
J Jump j Label Jump to Label
LA * Load address la $1,Label lui $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.
** This is just an example. We only allows decimal numbers in the assembly
program.

The supported directives are as follows.

Directive Name Syntax Semantic
.text Text segment .text Program section in memory;
(no operand) it begins at 0x0000 0200 by default
.data Data segment .data Data section in memory;
(no operand) it begins at 0x0000 0000 by default
.space n Allocation of n bytes .space 10 Allocation of 10 bytes of memory
of memory
.word w Allocation of a word . word 16 Allocation of a word (4 bytes or 32 bits)
and initialized to w and initialized to 16 (0x0001 0000).

The registers are denoted as $0, $1, $2, etc. instead of “$s0” or “r1”.


3.2 Output

The assembler generates an output file (program-name.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 can be considered a binary executable 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



This study source was downloaded by 100000850872992 from CourseHero.com on 04-10-2023 12:40:07 GMT -05:00


https://www.coursehero.com/file/91299083/20221S-project1-2-1-1doc/

Written for

Course

Document information

Uploaded on
April 10, 2023
Number of pages
6
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsConnoisseur Self
Follow You need to be logged in order to follow users or courses
Sold
587
Member since
3 year
Number of followers
344
Documents
1492
Last sold
1 week ago

4.2

68 reviews

5
40
4
11
3
13
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions