researchurn.blog Open in urlscan Pro
2a02:4780:24:fc30:5b27:d14b:3913:bd6b  Public Scan

URL: https://researchurn.blog/cpsc-323-csu-symbol-table-handling-and-generating-an-assembly-code-for-rat20su/
Submission: On December 01 via api from US — Scanned from NL

Form analysis 0 forms found in the DOM

Text Content

 * Home
 * About us
 * Blog
 * Contact us
 * Log In
 * Order Now

Select Page
 * Home
 * About us
 * Blog
 * Contact us
 * Log In
 * Order Now


CPSC 323 CSU SYMBOL TABLE HANDLING AND GENERATING AN ASSEMBLY CODE FOR RAT20SU

by ella | Sep 15, 2023 | Programming



by ella | Sep 15, 2023 | Programming


CPSC 323 CSU SYMBOL TABLE HANDLING AND GENERATING AN ASSEMBLY CODE FOR RAT20SU




DESCRIPTION

Some Semantics:

Consider that “true” has an integer value of 1 and “false” has an integer value
of 0. No arithmetic operations are allowed for booleans. The types must match
for arithmetic operations (no conversions)

Part 1) Symbol table Handling:

Every identifier declared in the program should be placed in a symbol table and
accessed by the symbol table handling procedures.

a) Each entry in the symbol table should hold the lexeme, and a “memory address”
where an identifier is placed within the symbol table. For example, define a
global integer variable called “Memory_address” and set initially 5000 and
increment it by one when a new identifier is declared and placed into the table.

b) You need to write a procedure that will check to see if a particular
identifier is already in the table, a procedure that will insert into the table
and a procedure that will printout all identifiers in the table. If an
identifier is used without declaring it, then the parser should provide an error
message. Also, if an identifier is already in the table and wants to declare it
for the second time, then the parser should provide an error message. Also, you
should check the type match.

Part 2) Generating the assembly code:

Add code (See the partial solution) to your parser that will produce the
assembly code instructions. The instructions should be kept in an array and at
the end, the content of the array is printed out to produce the listing of
assembly code. Your array should hold at least 300 assembly instructions. The
instruction starts from 1.

The listing should include an array index for each entry so that it serves as
label

to jump to. The compiler should also produce a listing of all the identifiers.

Our target machine is a virtual machine based on a stack with the following
instructions

I1. PUSHI {Integer Value} Pushes the {Integer Value} onto the Top of the Stack
(TOS)

I2. PUSHM {ML – Memory Location} Pushes the value stored at {ML} onto TOS

I3. POPM {ML} Pops the value from the top of the stack and stores it at {ML}

I4. STDOUT Pops the value from TOS and outputs it to the standard output

I5. STDIN Get the value from the standard input and place in onto the TOS

I6. ADD Pop the first two items from stack and push the sum onto the TOS

I7. SUB Pop the first two items from stack and push the difference onto the TOS

( Second item – First item)

I8. MUL Pop the first two items from stack and push the product onto the TOS

I9. DIV Pop the first two items from stack and push the result onto the TOS

( Second item / First item and ignore the remainder)

I10. GRT Pops two items from the stack and pushes 1 onto TOS if second item is

larger otherwise push 0

I11. LES Pops two items from the stack and pushes 1 onto TOS if the second item
is

smaller than first item otherwise push 0

I12. EQU Pops two items from the stack and pushes 1 onto TOS if they are equal

otherwise push 0

I13. JUMPZ {IL – Instruction Location} Pop the stack and if the value is 0 then
jump to {IL}

I14. JUMP {IL} Unconditionally jump to {IL}

I15. LABEL Empty Instruction; Provides the instruction location to jump to.

A Sample Source Code

$$

[* declarations *]

integer i

integer max;

integer sum;

sum = 0;

i = 1;

get ( max);

while (i < max) {

sum = sum + i;

i = i + 1;

}

sum = sum + max;

put (sum);

$$

One Possible Assembly Code Listing

1 PUSHI 0

2 POPM 5002

3 PUSHI 1

4 POPM 5000

5 STDIN

6 POPM 5001

7 LABEL

8 PUSHM 5000

9 PUSHM 5001

10 LES

11 JUMPZ 21

12 PUSHM 5002

13 PUSHM 5000

14 ADD

15 POPM 5002

17 PUSHM 5000

17 PUSHI 1

18 ADD

19 POPM 5000

20 JUMP 7

21 PUSHM 5002

22 PUSHM 5001

23 ADD

24 POPM 5002

25 PUSHM 5002

24 STDOUT

Symbol Table

Identifier Memory Location Type

i 5000 integer

max 5001 integer

sum 5002 integer

NOTE:

– DO NOT CREATE YOUR OWN ASSEMBLY INSTRUCTIONS.

USE ONLY PROVIDED INSTRUCTIONS.

– Turn in your document according to the instructions given in the project
outline.



ORDER A SIMILAR ASSIGNMENT, AND HAVE WRITERS FROM OUR TEAM OF EXPERTS WRITE IT
FOR YOU, GUARANTEEING YOU AN A






 * Ch9- Sales and Distribution (SD) using SAP



ORDER A SIMILAR ASSIGNMENT, AND HAVE WRITERS FROM OUR TEAM OF EXPERTS WRITE IT
FOR YOU, GUARANTEEING YOU AN A






Categories Select Category >Applied Sciences homework help >Architecture and
Design homework help >Biology homework help >Business & Finance homework help
>Chemistry homework help >Computer Science homework help >Education homework
help >Engineering homework help >English homework help >Geography homework help
>Government homework help >History homework help >Human Resource Management
homework help >Information Systems homework help >Law homework help >Literature
homework help >Mathematics homework help >Nursing homework help >Physics
homework help >Political Science homework help >Psychology homework help
>Reading homework help >Science homework help >Social Science homework help 2
and 3 more times. Can you find periodic courses of lengths 3 20uM Dye solution
according to Steven Ryfle Accounting and more recently by the Warsaw Gay
Movement. Little Mermaids The common modern perception of the mermaid Art Art &
Design Article Writing Biology burned Business Business & Finance Chemistry City
University of Hong Kong compose a 300–500-word essay on 1 specific topic from
Module/Week 2’s Reading & Study material on Design in the Middle Ages to the
Renaissance (CHs 4-6 comprehensive Computer Science credibility statement DePaul
University Economics Engineering English Environmental Science for those you
care about and for the world?You can use real-life examples (either your own
life experiences Foreign Languages Health & Medical History HR Management hsm
460 Humanities Information Systems Law Literature Management Marketing Math
Mathematics Maths Music Nursing Other PA. B. Grenoble Philosophy please complete
the Project Reflection Political Science Programming Psychology Science Social
Science Uncategorized University of Illinois at Chicago using different and
additional resources Writing


WE ARE IN THE KNOW



Follow us on social media and get the latest updates on essay writing.


COMPANY

 * Home
 * About us
 * Contact us
 * Our blog


QUICK LINKS

 * Order Now
 * Manage Orders
 * Create account
 * Recent posts


CONTACT US

 * info@researchurn.blog
 * +1 (510) 514-0763


WE ACCEPT

platinumressays.com. All rights reserved.