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

  Research report on software design

Write a Research Report on software design and answer diffrent type of questions related to design. Report contain diffrent basic questions related to software design.

  A case study in c to java conversion and extensibility

A Case Study in C to Java Conversion and Extensibility

  Create a structural model

Structural modeling is a different view of the same system that you analyzed from a functional perspective. This model shows how data is organized within the system.

  Write an report on a significant software security

Write an report on a significant software security

  Development of a small software system

Analysis, design and development of a small software system.

  Systems analysis and design requirements

Systems Analysis and Design requirements

  Create a complete limited entry decision table

Create a complete limited entry decision table

  Explain flow boundaries map

Explain flow boundaries map the dfd into a software architecture using transform mapping.

  Frame diagrams

Prepare a frame diagram for the software systems.

  Identified systems and elements of the sap system

Identify computing devices, which could be used to support Your Improved Process

  Design a wireframe prototype

Design a wireframe prototype to meet the needs of the personas and requirements.

  Explain the characteristics of visual studio 2005

Explain the characteristics of Visual Studio 2005.

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