Page 1 of 1

Solve using C++ programming language with a screenshot to show the same sample run attached below. Write a program to co

Posted: Sat May 14, 2022 8:16 pm
by answerhappygod
Solve using C++ programming language with a screenshot to show
the same sample run attached below.
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 ACTION
*LOAD Contents of LOC are placed in the ACC. LOC is
unchanged.
STORE Contents of ACC are placed in the LOC. ACC is
unchanged.
*ADD 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.
*SUB 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.
*MULT 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.
*DIV 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.
BE Branch to instruction labeled with LOC if ACC = 0.
BG Branch to instruction labeled with LOC if ACC > 0.
BL Branch to instruction labeled with LOC if ACC < 0.
BU Branch unconditionally to instruction labeled with LOC.
END Program terminates. LOC field is ignored.
READ Read a signed integer (modulo 1,000,000) into LOC.
PRINT Print the contents of LOC.
DC 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 DC 1
READ B
READ C
PRINT C
LOAD =1
MULT C
BE D
STORE A
PRINT A
DIV B
BL D
STORE C
PRINT C
SUB A
BG D
STORE B
PRINT B
ADD A
STORE A
PRINT A
D END
2 3