SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
Overview Write a Python script that reads lines of MIPS assembly code from a file (with specific
formatting constraints, detailed below) and writes the corresponding MIPS machine code for those
instructions to an output file. The input file should be passed as a command line argument to the
Python script using Python argparse. Input File Format The input file may contain instructions in
the following types: - R type-add, sub, sll, srl, slt - I-Type-addi, beq, bne, lw, sw - J type: Not
needed in this project!Formatting Constraints The input file contains a single instruction per line,
with the opcode in lowercase characters followed by whitespace (a single space character, or any
combination of whitespace characters, or tabs), followed by the arguments. The arguments are
separated by commas without any whitespace between them. The registers are specified using
either a dollar sign followed by a number between 0 and 31 (e.g. $3) or using a dollar sign
followed by an alias (e.g. $v1). The immediate values are in decimal form only. The immediate
values may be negative so make sure to convert them to two's complement. The end of a line is
denoted with a Unixstyle line ending (n) and any further leading or trailing whitespace from each
line should be ignored. If an invalid input line (not conforming to the formatting constraints and/or
instruction not in this assignment) is encountered, append !!! Invalid Input !!! n to the output file
exactly as it is written, with no leading or trailing spaces, close the output file, and terminate
program execution gracefully. See the Output Format below for specific instructions.Output File
Format The output from the program should be written to the file out_code.txt. The program should
create this file if it does not yet exist, and overwrite if it does already exist. Each line of the output
file should contain 32 characters, each of which is an ASCII 0 or an ASCII 1, followed at the end
by a newline character (n). The output for each line specifies the 32-bit MIPS machine code for the
corresponding MIPS instruction line in the input file, beginning with the most significant bit.
Remember that in the event of invalid input, the error message !!! Invalid Input !!! n should be
written to out_code.txt before gracefully closing the file and exiting the program.Requirements 1.
The code must use Python argparse to input the text file. 2. The code must include a succinct
description of the converter at the top of the file using triple quotes. Put appropriate code
comments to promote readability. 3. The code must be modular using two or more functions.
Sample Inputs and Outputs To develop and troubleshoot the MIPS to machine language
converter, use the following MIPS codes and their corresponding outputs. The TA will use these to
verify your code.

Más contenido relacionado

Similar a Overview Write a Python script that reads lines of MIPS asse.pdf

what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compileradilmehmood93
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMaheshPandit16
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programmingMithun DSouza
 
CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfomarionmatzmcwill497
 
Write a LEX program that does the following1. Reads a C++ pro.docx
Write a LEX program that does the following1. Reads a C++ pro.docxWrite a LEX program that does the following1. Reads a C++ pro.docx
Write a LEX program that does the following1. Reads a C++ pro.docxlatriced9tl
 
Python workshop
Python workshopPython workshop
Python workshopJibin Sabu
 
SPL 3 | Introduction to C programming
SPL 3 | Introduction to C programmingSPL 3 | Introduction to C programming
SPL 3 | Introduction to C programmingMohammad Imam Hossain
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# programMAHESHV559910
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
 
C++
C++C++
C++k v
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler languageAshok Raj
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptxEdFeranil
 
Finish the 2 TODO in the ASM Language A palindrome is a w.pdf
Finish the 2 TODO in the ASM Language A palindrome is a w.pdfFinish the 2 TODO in the ASM Language A palindrome is a w.pdf
Finish the 2 TODO in the ASM Language A palindrome is a w.pdfablazeaepl
 

Similar a Overview Write a Python script that reads lines of MIPS asse.pdf (20)

Lecture 1
Lecture 1Lecture 1
Lecture 1
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
 
CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdf
 
Write a LEX program that does the following1. Reads a C++ pro.docx
Write a LEX program that does the following1. Reads a C++ pro.docxWrite a LEX program that does the following1. Reads a C++ pro.docx
Write a LEX program that does the following1. Reads a C++ pro.docx
 
Python workshop
Python workshopPython workshop
Python workshop
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
SPL 3 | Introduction to C programming
SPL 3 | Introduction to C programmingSPL 3 | Introduction to C programming
SPL 3 | Introduction to C programming
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
C++
C++C++
C++
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler language
 
C Theory
C TheoryC Theory
C Theory
 
C Lang notes.ppt
C Lang notes.pptC Lang notes.ppt
C Lang notes.ppt
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptx
 
Finish the 2 TODO in the ASM Language A palindrome is a w.pdf
Finish the 2 TODO in the ASM Language A palindrome is a w.pdfFinish the 2 TODO in the ASM Language A palindrome is a w.pdf
Finish the 2 TODO in the ASM Language A palindrome is a w.pdf
 
Python Glimpse
Python  Glimpse Python  Glimpse
Python Glimpse
 

Más de syedabdul78662

Oxidase neg Indole neg VP pos Citrate pos Motile.pdf
Oxidase  neg Indole  neg VP  pos Citrate  pos Motile.pdfOxidase  neg Indole  neg VP  pos Citrate  pos Motile.pdf
Oxidase neg Indole neg VP pos Citrate pos Motile.pdfsyedabdul78662
 
Other map symbols on topographic maps Occasionally you will.pdf
Other map symbols on topographic maps Occasionally you will.pdfOther map symbols on topographic maps Occasionally you will.pdf
Other map symbols on topographic maps Occasionally you will.pdfsyedabdul78662
 
Osprey Corporation stock is owned by Pedro and Pittro who a.pdf
Osprey Corporation stock is owned by Pedro and Pittro who a.pdfOsprey Corporation stock is owned by Pedro and Pittro who a.pdf
Osprey Corporation stock is owned by Pedro and Pittro who a.pdfsyedabdul78662
 
ourism is extremely important to the economy of Florida Hot.pdf
ourism is extremely important to the economy of Florida Hot.pdfourism is extremely important to the economy of Florida Hot.pdf
ourism is extremely important to the economy of Florida Hot.pdfsyedabdul78662
 
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdf
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdfOrvilie borrowed 25000 from his friend Wilbur Orvile sign.pdf
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdfsyedabdul78662
 
Our story begins at the Pearson Cooking Academy where many n.pdf
Our story begins at the Pearson Cooking Academy where many n.pdfOur story begins at the Pearson Cooking Academy where many n.pdf
Our story begins at the Pearson Cooking Academy where many n.pdfsyedabdul78662
 
Owen is a medical researcher who will receive bonus pay base.pdf
Owen is a medical researcher who will receive bonus pay base.pdfOwen is a medical researcher who will receive bonus pay base.pdf
Owen is a medical researcher who will receive bonus pay base.pdfsyedabdul78662
 
Oriole Company had the following assets on January 1 2025 .pdf
Oriole Company had the following assets on January 1 2025 .pdfOriole Company had the following assets on January 1 2025 .pdf
Oriole Company had the following assets on January 1 2025 .pdfsyedabdul78662
 
Organizational context The organizational context for this .pdf
Organizational context  The organizational context for this .pdfOrganizational context  The organizational context for this .pdf
Organizational context The organizational context for this .pdfsyedabdul78662
 
Overtime Hours Worked A random sample of 12 registered nurse.pdf
Overtime Hours Worked A random sample of 12 registered nurse.pdfOvertime Hours Worked A random sample of 12 registered nurse.pdf
Overtime Hours Worked A random sample of 12 registered nurse.pdfsyedabdul78662
 
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdf
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdfOrganizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdf
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdfsyedabdul78662
 
Over the next decades sea level will rise at a constant ra.pdf
Over the next decades sea level will rise at a constant ra.pdfOver the next decades sea level will rise at a constant ra.pdf
Over the next decades sea level will rise at a constant ra.pdfsyedabdul78662
 
Over the years technology has changed rapidly and made our .pdf
Over the years technology has changed rapidly and made our .pdfOver the years technology has changed rapidly and made our .pdf
Over the years technology has changed rapidly and made our .pdfsyedabdul78662
 
Over the past two decades local governments have increasing.pdf
Over the past two decades local governments have increasing.pdfOver the past two decades local governments have increasing.pdf
Over the past two decades local governments have increasing.pdfsyedabdul78662
 
Over the past 1015 years the ways that insurance companies.pdf
Over the past 1015 years the ways that insurance companies.pdfOver the past 1015 years the ways that insurance companies.pdf
Over the past 1015 years the ways that insurance companies.pdfsyedabdul78662
 
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdf
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdfPart 1 Create a 4 to 5page BCC Enterprise Information Secu.pdf
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdfsyedabdul78662
 
Part 1 Find a Canadian companyorganization Canadian mea.pdf
Part 1 Find a Canadian companyorganization Canadian mea.pdfPart 1 Find a Canadian companyorganization Canadian mea.pdf
Part 1 Find a Canadian companyorganization Canadian mea.pdfsyedabdul78662
 
Part 1 LinkedList Create a file named LinkedListpy I.pdf
Part 1  LinkedList  Create a file named LinkedListpy  I.pdfPart 1  LinkedList  Create a file named LinkedListpy  I.pdf
Part 1 LinkedList Create a file named LinkedListpy I.pdfsyedabdul78662
 
Part 1 The company has three branches two in Europe and o.pdf
Part 1   The company has three branches two in Europe and o.pdfPart 1   The company has three branches two in Europe and o.pdf
Part 1 The company has three branches two in Europe and o.pdfsyedabdul78662
 
Para reducir la desigualdad y la pobreza en una economa el.pdf
Para reducir la desigualdad y la pobreza en una economa el.pdfPara reducir la desigualdad y la pobreza en una economa el.pdf
Para reducir la desigualdad y la pobreza en una economa el.pdfsyedabdul78662
 

Más de syedabdul78662 (20)

Oxidase neg Indole neg VP pos Citrate pos Motile.pdf
Oxidase  neg Indole  neg VP  pos Citrate  pos Motile.pdfOxidase  neg Indole  neg VP  pos Citrate  pos Motile.pdf
Oxidase neg Indole neg VP pos Citrate pos Motile.pdf
 
Other map symbols on topographic maps Occasionally you will.pdf
Other map symbols on topographic maps Occasionally you will.pdfOther map symbols on topographic maps Occasionally you will.pdf
Other map symbols on topographic maps Occasionally you will.pdf
 
Osprey Corporation stock is owned by Pedro and Pittro who a.pdf
Osprey Corporation stock is owned by Pedro and Pittro who a.pdfOsprey Corporation stock is owned by Pedro and Pittro who a.pdf
Osprey Corporation stock is owned by Pedro and Pittro who a.pdf
 
ourism is extremely important to the economy of Florida Hot.pdf
ourism is extremely important to the economy of Florida Hot.pdfourism is extremely important to the economy of Florida Hot.pdf
ourism is extremely important to the economy of Florida Hot.pdf
 
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdf
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdfOrvilie borrowed 25000 from his friend Wilbur Orvile sign.pdf
Orvilie borrowed 25000 from his friend Wilbur Orvile sign.pdf
 
Our story begins at the Pearson Cooking Academy where many n.pdf
Our story begins at the Pearson Cooking Academy where many n.pdfOur story begins at the Pearson Cooking Academy where many n.pdf
Our story begins at the Pearson Cooking Academy where many n.pdf
 
Owen is a medical researcher who will receive bonus pay base.pdf
Owen is a medical researcher who will receive bonus pay base.pdfOwen is a medical researcher who will receive bonus pay base.pdf
Owen is a medical researcher who will receive bonus pay base.pdf
 
Oriole Company had the following assets on January 1 2025 .pdf
Oriole Company had the following assets on January 1 2025 .pdfOriole Company had the following assets on January 1 2025 .pdf
Oriole Company had the following assets on January 1 2025 .pdf
 
Organizational context The organizational context for this .pdf
Organizational context  The organizational context for this .pdfOrganizational context  The organizational context for this .pdf
Organizational context The organizational context for this .pdf
 
Overtime Hours Worked A random sample of 12 registered nurse.pdf
Overtime Hours Worked A random sample of 12 registered nurse.pdfOvertime Hours Worked A random sample of 12 registered nurse.pdf
Overtime Hours Worked A random sample of 12 registered nurse.pdf
 
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdf
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdfOrganizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdf
Organizasyon Teorisi gnmz Organizasyonlarnn anlalmasnda .pdf
 
Over the next decades sea level will rise at a constant ra.pdf
Over the next decades sea level will rise at a constant ra.pdfOver the next decades sea level will rise at a constant ra.pdf
Over the next decades sea level will rise at a constant ra.pdf
 
Over the years technology has changed rapidly and made our .pdf
Over the years technology has changed rapidly and made our .pdfOver the years technology has changed rapidly and made our .pdf
Over the years technology has changed rapidly and made our .pdf
 
Over the past two decades local governments have increasing.pdf
Over the past two decades local governments have increasing.pdfOver the past two decades local governments have increasing.pdf
Over the past two decades local governments have increasing.pdf
 
Over the past 1015 years the ways that insurance companies.pdf
Over the past 1015 years the ways that insurance companies.pdfOver the past 1015 years the ways that insurance companies.pdf
Over the past 1015 years the ways that insurance companies.pdf
 
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdf
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdfPart 1 Create a 4 to 5page BCC Enterprise Information Secu.pdf
Part 1 Create a 4 to 5page BCC Enterprise Information Secu.pdf
 
Part 1 Find a Canadian companyorganization Canadian mea.pdf
Part 1 Find a Canadian companyorganization Canadian mea.pdfPart 1 Find a Canadian companyorganization Canadian mea.pdf
Part 1 Find a Canadian companyorganization Canadian mea.pdf
 
Part 1 LinkedList Create a file named LinkedListpy I.pdf
Part 1  LinkedList  Create a file named LinkedListpy  I.pdfPart 1  LinkedList  Create a file named LinkedListpy  I.pdf
Part 1 LinkedList Create a file named LinkedListpy I.pdf
 
Part 1 The company has three branches two in Europe and o.pdf
Part 1   The company has three branches two in Europe and o.pdfPart 1   The company has three branches two in Europe and o.pdf
Part 1 The company has three branches two in Europe and o.pdf
 
Para reducir la desigualdad y la pobreza en una economa el.pdf
Para reducir la desigualdad y la pobreza en una economa el.pdfPara reducir la desigualdad y la pobreza en una economa el.pdf
Para reducir la desigualdad y la pobreza en una economa el.pdf
 

Último

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 

Último (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

Overview Write a Python script that reads lines of MIPS asse.pdf

  • 1. Overview Write a Python script that reads lines of MIPS assembly code from a file (with specific formatting constraints, detailed below) and writes the corresponding MIPS machine code for those instructions to an output file. The input file should be passed as a command line argument to the Python script using Python argparse. Input File Format The input file may contain instructions in the following types: - R type-add, sub, sll, srl, slt - I-Type-addi, beq, bne, lw, sw - J type: Not needed in this project!Formatting Constraints The input file contains a single instruction per line, with the opcode in lowercase characters followed by whitespace (a single space character, or any combination of whitespace characters, or tabs), followed by the arguments. The arguments are separated by commas without any whitespace between them. The registers are specified using either a dollar sign followed by a number between 0 and 31 (e.g. $3) or using a dollar sign followed by an alias (e.g. $v1). The immediate values are in decimal form only. The immediate values may be negative so make sure to convert them to two's complement. The end of a line is denoted with a Unixstyle line ending (n) and any further leading or trailing whitespace from each line should be ignored. If an invalid input line (not conforming to the formatting constraints and/or instruction not in this assignment) is encountered, append !!! Invalid Input !!! n to the output file exactly as it is written, with no leading or trailing spaces, close the output file, and terminate program execution gracefully. See the Output Format below for specific instructions.Output File Format The output from the program should be written to the file out_code.txt. The program should create this file if it does not yet exist, and overwrite if it does already exist. Each line of the output file should contain 32 characters, each of which is an ASCII 0 or an ASCII 1, followed at the end by a newline character (n). The output for each line specifies the 32-bit MIPS machine code for the corresponding MIPS instruction line in the input file, beginning with the most significant bit. Remember that in the event of invalid input, the error message !!! Invalid Input !!! n should be written to out_code.txt before gracefully closing the file and exiting the program.Requirements 1. The code must use Python argparse to input the text file. 2. The code must include a succinct description of the converter at the top of the file using triple quotes. Put appropriate code comments to promote readability. 3. The code must be modular using two or more functions. Sample Inputs and Outputs To develop and troubleshoot the MIPS to machine language converter, use the following MIPS codes and their corresponding outputs. The TA will use these to verify your code.