Building an assembly language interpreter

Assignment Help Software Engineering
Reference no: EM131963562

This project is about building an Assembly Language Interpreter (ALI) for a Simple Assembly Language (SAL) in C++11. Fortunately for you SAL has the same limited set of instructions, described below, as Project 2 in this semester. SAL programs are executed on a virtual (emulated) machine con- sisting of a memory, which stores program code and program data, an accumulator register, an additional register and a Program Counter (PC), which keeps track of the instruction being currently executed. For the C++ version ALI does not include a graphical user interface. Instead ALI reads a SAL program from a file and executes the program either one line at a time (in debug mode) or all the way to completion (normal run mode). ALI interacts with a user through the following command line:

1. r - This command reads a SAL program from a file named input.sal. The file should be in the same directory as your executable ALI file. You may assume that the input program is syntactally correct. The program is stored in internal ALI memory and displayed on the user's console.

2. d - Execute the program in debug mode. This command causes one line of code to be executed. The PC, registers, bits and the state of memory are updated as a result of the execution. The value of the registers, the PC, the bits and the content of memory after the instruction is executed are diplayed on the user's screen.

3. r - Run the program to completion. This command causes the execution of program starting from the current PC instruction until the halt instruction is found or the program reaches its last instruction. The content of the registers, PC, bits and memory are displayed on the user's console.

4. s - Save the program state. This command causes the content of memory, the bits and the registers to be saved to a file named output.txt.

5. q - Quits the ALI.

The computer hardware uses 32-bit words and consists of the following components:

1. Memory. A 32-bit, word-addressable memory (RAM) for data, holding 256 words. Words are addressed by their location, starting from location 0 all the way up to location 255. Each location may either hold a signed integer in 2's complement notation or a SAL instruction.

2. Accumulator. A 32-bit register. It is also known as Register A or A for short.

3. Additional register. A 32-bit register also known as Register B or B for short.

4. Program counter (PC). An 8-bit program counter (PC). The PC holds the address (number in program memory) of the next instruction to be executed. Before the program starts execution, the PC holds the value 0. It is subsequently updated as each instruction is executed.

5. A zero-result bit. This bit is set if the last ADD instruction produced a zero result. This bit is cleared if the last ADD instruction produced a result different from zero. The initial value is zero. The bit is changed only after ADD instructions are executed.

6. An overflow bit. This bit is set whenever an ADD instruction produces an overflow (i.e., a result that cannot be stored in 2's complement notation with 32 bits). It is cleared if the ADD instruction did not produce an overflow. The initial value is zero.

The registers are used to hold data in arithmetic operations (i.e., additions). The program counter holds the index value (starting at 0) of the next instruction to be executed. SAL has the instruction set shown in Table 1.

DEC symbol

Declares a symbolic variable consisting of a single letter (e.g., X ). The

variable is stored at the memory location of this instruction.

LDA symbol

Loads byte at data memory address of symbol into the accumulator.

LDB symbol

Loads byte at data memory address symbol into B.

LDI value

Loads the integer value into the accumulator register. The value could be negative

but must be in the range of 32-bit 2's complement numbers.

ST symbol

Stores content of accumulator into data memory at address of symbol.

XCH

Exchanges the content of registers A and B.

JMP number

Transfers control to instruction at address number in program memory.

JZS number

Transfers control to instruction at address number if the zero-result bit is set.

JVS number

Transfers control to instruction at address number if the overflow bit is set.

ADD

Adds the content of registers A and B. The sum is stored

in A. The overflow and zero-result bits are set or cleared as needed.

HLT

Terminates program execution.

Table 1: Instruction set of SAL.

You may assume that SAL programs are entered correctly by users of ALI. (You are not required to perform error diagnosis or correction). Information in data memory and the registers should be displayed in decimal format. Program source code should be displayed in symbolic (i.e., textual) format. Finally, you must use inheritance in your implementation. One good place for inheritance is to define an abstract superclass for SAL instructions with concrete subclasses for each particular instruction. Beware of infinite loops in SAL.

Extra credit. If you implement correctly the Command pattern from the Gang-of-Four book, you will receive a 20% increase on your project grade, up to 20 extra points.

You must work alone on this project. Save all your code in a collection of header and code files and submit a zip archive with a (short) readme file containing instructions on how to use your ALI. The archive should also contain a sample input.sal file. Submit the archive by clicking on the link provided with this assignment. Your code should compile under the GNU C++11 or the CLANG C++11 compiler. No late submissions will be accepted.

Reference no: EM131963562

Questions Cloud

What stands in the way of this idea being achievable : What could lead to Greenleaf's theology of institutions becoming a viable model for making societal change?
Calculate the aud required to purchase autonz : Calculate the AUD re¬quired to purchase AutoNZ under the three scenarios, assuming that the bid-ask spread in 1 month's time is still 0.0010.
Briefly discuss details of data analysis : Describe the characteristics of the group or groups. How appropriate is the group to address the research question(s)
What is the optimal cover charge that agnieszka : If Agnieszka is a profit maximizing monopolist and knows the demand curve of each customer, what is the optimal cover charge that Agnieszka should charge
Building an assembly language interpreter : This project is about building an Assembly Language Interpreter - which stores program code and program data, an accumulator register, an additional register
Katrien profit-maximising price pm and quantity qm : If she charges the same price to all customers, what are Katrien's profit-maximising price PM and quantity QM?
Nothing without an accompanying facebook : In today's market, a business is nothing without an accompanying Facebook, Twitter, and Instagram account - right? Consider how you, as an employee
How to search an array for a specified value : Prepare a flowchart, and provide the corresponding pseudocode to show how to search an array for a specified value using the sequential search algorithm.
How will increasing taxes on the rich boost the economy : How will increasing taxes on the rich boost the economy? Does an increase in taxes for the rich benefit the poor or does it hurt the poor?

Reviews

Write a Review

Software Engineering Questions & Answers

  Create erd using entities and attributes for driver-s log

Create a detailed ERD using the Entities and Attributes for Driver's Log document found on the Huffman Trucking Intranet site.

  Software engineer working as a performance engineer

Prepare and submit a paper dealing with a topic from your current course that could be applied to your workplace. The paper should be a minimum of 750 words (about 3 double-spaced pages) and contain a minimum of two (2) outside references from peer-r..

  Er model for large organization has several parking lots

Construct ER model for each of the given descriptions: A large organization has many parking lots, which are used by staff.

  Diversity of approaches to software construction

Analyze each reason listed above as a reason for a diversity of approaches to software construction and modeling, and give your opinion on whether or not each reason is valid.

  What is the process of software design

What is the process of software design. What tools are used in software design.

  Program for alpha testing

At this point, you want to put together the work that has been completed to deliver a working program for alpha testing. You will combine the elements you have written to this point and deliver a working solution

  What is the fundamental reason

What is the fundamental reason that software cannot be considered to be engineered? (a) It is designed by humans and therefore flawed

  Implement the login function

Module 1: Implement the buttons' function to call each method according to its name. Module 2: Implement the Login Function

  Debugging the existing software to find causes of problems

The existing software has a number of bugs filed against it. How will you go about debugging the existing software to find the causes of these problems and testing your fixes to see if they really fix the problems

  Number of block to fetch record-single level primary index

Assume one file has r =1000000 records. Each record takes R = 100 bytes, of which 10 bytes are for the key of the record. What is the least number of block accesses to fetch a record by using single level primary index?

  Explain the significance of information package diagrams

Analyze the purpose of requirements gathering and justify its role in any development process. Explain three differences between building an operational system and a data warehouse. Explain the significance of information package diagrams.

  Process of modeling using entity-relationship diagrams

Process of starting with world objects and modeling by using entity-relationship diagrams is referred to as top-down process.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd