Input for this program will be a from a text file containing a valid ACSL Assembly Language program. Each line will contain one command. All labels will be single characters, and there will be 5 PRINT statements in the program. The data for the READ statements will follow the END statement, and the data file will have a maximum of 50 lines. Output to the screen, each PRINT statement in the program, labeled numerically, with the current value of the listed LOC. Let the user input the file name from the keyboard. If coding in C++, use the string class. Refer to the sample output below.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
C++
Write a program to compile and output ACSL Assembly Language programs. The ACSL Assembly
Language was introduced earlier in the semester with the Chapter 4 material. With this compiler only the
commands listed in the chart below will be used. Execution starts at the first line of the program and
continues sequentially, except for "branch" instructions, until the "end" instruction is encountered. The result
of each operation is stored in a special word of memory, called the "accumulator" (ACC). Each line of an
ACSL Assembly Language program has 3 components: a label (usually optional), an opcode (always
required), and a loc field (nearly always required):
The label, if present, is an alphanumeric character string beginning in the first column. A label
must begin with an alphabetic character (A through Z, or a through z), and labels are case-sensitive. The
label field is required for the DC opcode; it is optional for all other opcodes.
●
●
Valid opcodes are listed in the chart below; they are uppercase and case sensitive. Opcodes are
reserved words of the language and may not be used as a label.
The loc field is either a reference to a label (e.g., "ADD A") or immediate data (e.g., "LOAD
=123"). Only those opcodes with an asterisk in the following chart are allowed to use the immediate data
format of the loc field. The loc field is required for all opcodes, except for the END opcode. It is prohibited on
the END opcode.
OPCODE
*LOAD
STORE
*ADD
*SUB
*MULT
*DIV
BE
BG
BL
BU
END
READ
PRINT
DC
ACTION
Contents of LOC are placed in the ACC. LOC is unchanged.
Contents of ACC are placed in the LOC. ACC is unchanged.
Contents of LOC are added to the contents of the ACC. The sum
is stored in the ACC. LOC is unchanged. Addition is modulo
1,000,000.
Contents of LOC are subtracted from the contents of the ACC.
The difference is stored in the ACC. LOC is unchanged.
Subtraction is modulo 1,000,000.
The contents of LOC are multiplied by the contents of the ACC.
The product is stored in the ACC. LOC is unchanged.
Multiplication is modulo 1,000,000.
Contents of LOC are divided into the contents of the ACC. The
signed integer part of the quotient is stored in the ACC. LOC
is unchanged.
Branch to instruction labeled with LOC if ACC = 0.
Branch to instruction labeled with LOC if ACC > 0.
Branch to instruction labeled with LOC if ACC < 0.
Branch unconditionally to instruction labeled with LOC.
Program terminates. LOC field is ignored.
Read a signed integer (modulo 1,000,000) into LOC.
Print the contents of LOC.
The value of the memory word defined by the LABEL field is
defined to contain the specified constant. The LABEL field is
mandatory for this opcode. The ACC is not modified.
Transcribed Image Text:Write a program to compile and output ACSL Assembly Language programs. The ACSL Assembly Language was introduced earlier in the semester with the Chapter 4 material. With this compiler only the commands listed in the chart below will be used. Execution starts at the first line of the program and continues sequentially, except for "branch" instructions, until the "end" instruction is encountered. The result of each operation is stored in a special word of memory, called the "accumulator" (ACC). Each line of an ACSL Assembly Language program has 3 components: a label (usually optional), an opcode (always required), and a loc field (nearly always required): The label, if present, is an alphanumeric character string beginning in the first column. A label must begin with an alphabetic character (A through Z, or a through z), and labels are case-sensitive. The label field is required for the DC opcode; it is optional for all other opcodes. ● ● Valid opcodes are listed in the chart below; they are uppercase and case sensitive. Opcodes are reserved words of the language and may not be used as a label. The loc field is either a reference to a label (e.g., "ADD A") or immediate data (e.g., "LOAD =123"). Only those opcodes with an asterisk in the following chart are allowed to use the immediate data format of the loc field. The loc field is required for all opcodes, except for the END opcode. It is prohibited on the END opcode. OPCODE *LOAD STORE *ADD *SUB *MULT *DIV BE BG BL BU END READ PRINT DC ACTION Contents of LOC are placed in the ACC. LOC is unchanged. Contents of ACC are placed in the LOC. ACC is unchanged. Contents of LOC are added to the contents of the ACC. The sum is stored in the ACC. LOC is unchanged. Addition is modulo 1,000,000. Contents of LOC are subtracted from the contents of the ACC. The difference is stored in the ACC. LOC is unchanged. Subtraction is modulo 1,000,000. The contents of LOC are multiplied by the contents of the ACC. The product is stored in the ACC. LOC is unchanged. Multiplication is modulo 1,000,000. Contents of LOC are divided into the contents of the ACC. The signed integer part of the quotient is stored in the ACC. LOC is unchanged. Branch to instruction labeled with LOC if ACC = 0. Branch to instruction labeled with LOC if ACC > 0. Branch to instruction labeled with LOC if ACC < 0. Branch unconditionally to instruction labeled with LOC. Program terminates. LOC field is ignored. Read a signed integer (modulo 1,000,000) into LOC. Print the contents of LOC. The value of the memory word defined by the LABEL field is defined to contain the specified constant. The LABEL field is mandatory for this opcode. The ACC is not modified.
Input for this program will be a from a text file containing a valid ACSL Assembly Language program.
Each line will contain one command. All labels will be single characters, and there will be 5 PRINT
statements in the program. The data for the READ statements will follow the END statement, and the data file
will have a maximum of 50 lines. Output to the screen, each PRINT statement in the program, labeled
numerically, with the current value of the listed LOC. Let the user input the file name from the keyboard. If
coding in C++, use the string class. Refer to the sample output below.
Sample File:
A
D
NO
23
DC
1
READ B
READ C
PRINT C
LOAD =1
MULT
с
BE
D
STORE A
PRINT A
DIV B
BL
D
STORE C
PRINT C
SUB
BG
A
D
STORE B
PRINT B
ADD
A
STORE A
PRINT A
END
Sample Run:
Enter file name: assemb.txt
1. 3
2. 3
3. 1
4. -2
5. 1
Transcribed Image Text:Input for this program will be a from a text file containing a valid ACSL Assembly Language program. Each line will contain one command. All labels will be single characters, and there will be 5 PRINT statements in the program. The data for the READ statements will follow the END statement, and the data file will have a maximum of 50 lines. Output to the screen, each PRINT statement in the program, labeled numerically, with the current value of the listed LOC. Let the user input the file name from the keyboard. If coding in C++, use the string class. Refer to the sample output below. Sample File: A D NO 23 DC 1 READ B READ C PRINT C LOAD =1 MULT с BE D STORE A PRINT A DIV B BL D STORE C PRINT C SUB BG A D STORE B PRINT B ADD A STORE A PRINT A END Sample Run: Enter file name: assemb.txt 1. 3 2. 3 3. 1 4. -2 5. 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education