91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

CS4121代做、代寫C++語言編程
CS4121代做、代寫C++語言編程

時間:2025-06-06  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



CS4121 Cminus Expression Evaluation Compiler Project

Due Date: Tuesday, June. 3, 2025 at11:59 am

Purpose

The purpose of this project is to gain experience in giving meaning to a programming language by generating

Mips assembly for a subset of Cminus. Specifically, you will be generating assembly for integer I/O operations,

integer arithmetic and logical expressions and assignment statements.

Project Summary

In this project, you will add actions to a parser provided by me. You must add code to do the following:

1. Assign space for global and local integer variables declared in a Cminus program.

2. Generate assembly pseudo-ops for string constants used in a Cminus program.

3. Generate assembly to print string constants.

4. Generate assembly to print integers.

5. Generate assembly to read integers.

6. Generate assembly to compute integer expressions.

7. Generate assembly to compute logic expressions.

8. Generate assembly to assign values to integer variables.

Prologue and Epilogue Code

Since you are converting a Cminus program to Mips assembly, you must begin each assembly file with any

data declarations and a declaration of where themainprogram begins. This is done with the following code:

.data

.newl: .asciiz "\n"

.text

.globl main

main: nop

This code declares a data section with a string.newlthat is just the newline character, followed by a text

section (instructions) containing a declaration of the main routine. Each Mips assembly file should begin

with this sequence. Any space that you allocate for strings or floating-point constants in the static data area

may be allocated with directives after the   .data   directive and before the   .text   directive.

Assigning Variable Space

Memory for global variables declared in a Cminus program will be address as an offset off of$gp. The

register$gppoints to the middle of a 64K region in the static data area. You may address this area as a

positive or negative offset off of$gp. I will guarantee that you will need no more than 64K of space in the

static data area for any input program for any of the projects in this class.

Memory for local variables is allocated on the stack. Each integer requires four bytes of space. Local space

is allocated by adjusting the stack pointer the requisite number of bytes. Since stacks grow in the negative

direction in memory, space is allocated by subtracting from the stack pointer. The Cminus declarations

1

int i,j,k;

require 12 bytes of space. That space is allocated on the stack with the instructions

sw $fp, ($sp)

move $fp, $sp

sub $sp, $sp, 12

which should be placedimmediatelyfollowing the prologue code. The first instruction stores the old frame

pointer. The second sets the new frame pointer,$fp, and the third instruction allocates the space for the 3

variables.

String Constants

A Cminus program may use string constants in write statements. These constants are declared in the data

section using the.asciizpseudo-op. For the Cminus statement,

write(  Hello  );

The following declaration must be added to the data section of the assembly file:

.string0: .asciiz "Hello"

The label.string0is implementation dependent. You may name your string constants however you wish.

Printing Strings

Printing strings requires using a system call. The system call service for printing strings is 4. Since a

character string is stored in memory, you must pass the address of the string to the system call in register

$a0. As an example, the code to implement thewritestatement in the previous section would be:

la $a0, .string0

li $v0, 4

syscall

Note that you will need to additionally print the newline character when printing any data.

Printing Integers

Printing integers is similar to printing strings except that the actual integer is passed to the system call

rather than an address and the system call service is 1. As an example, to implement the statement:

write(7);

the following Mips assembly would need to be generated:

li $a0, 7

li $v0, 1

syscall

Reading Integers

To read an integer, the system call service is 5. The read value is returned in register$v0. Thus, to read an

integer, the following instructions are needed:

li $v0, 5

syscall

2

Accessing Variables

You may access local variables by loading them from an offset of the frame pointer ($fp). As an example,

assuming that the variableais assigned the second 4 bytes of local space. The following code might be

generated to accessa:

sub $s0, $fp, 4

lw $s1, 0($s0)

Loading a global variable is similar except that we use$gpinstead of$fp. Ifais a global variable that is

store 8 bytes (in the positive direction) off of$gp, the following code might be generated to access it:

add $s0, $gp, 8

lw $s1, 0($s0)

Integer Arithmetic Expressions

In Mips assembly, all operations are done on registers. The best way to generate code is to store all interme-

diate values in Mips registers. Using the registers$s0, ..., $s7,$t0, ..., $t9should be sufficient. You

should not need any other temporary registers. For an operation, the operands should all be put into regis-

ters, a result register should be allocated, the operations should be performed and then the input registers

should be released to be reused later. As an example, the statement

write(a+b);

might result in the code (ifais the first declared variable andbis the second)

lw $s1, 0($fp)

sub $s0, $fp, 4

lw $s2, 0($s0)

add $s3, $s1, $s2

move $a0, $s3

li $v0, 1

syscall

Logic Expressions

Logic expressions are similar to arithmetic expressions. For the mips, the value forfalseis 0 and the value

fortrueis 1.

Storing Integer Variables

To store a value in a variable, first compute the address and then store the value into that location. For

example, the statement

a = 5;

could be implemented with

li $s0, 5

sub $s1, $fp, 4

sw $s0, 0($s1)

3

Exiting the Program

Theexitstatement in Cminus can be implemented in Mips assembly as follows:

li $v0, 10

syscall

These instructions call the system routine that exits a program. Everymainroutine in a Cminus program

will end in anexitstatement.

Requirements

Write all of your code in C or C++ . It will be tested on a CS machine and MUST work there. You will

receive no special consideration for programs which   work   elsewhere, but not on a CS machine.

Input.The fileCminusProject2.tgzcontains the parser need to begin this project. You will need to

modifiy the actions in the project fileparser/CminusParser.yto do this project. Currently, the actions

just emit the rules that are reduced. Sample input for this project is provided in the project directoryinput.

To run your compiler, use the command

cmc .cm

To execute the resulting assembly file, use the Mars simulator(http://courses.missouristate.edu/KenVollmar/mars/).

Submission.Your code should be well-documented. You will submit all of your files, by tarring up your

project directory using the command

tar -czf CminusProject2.tgz CminusProject2

Submit the fileCminusProject2.tgzvia the CS4121 Canvas page. Make sure you do a   make clean   of your

directory before executing the tar command. This will remove all of the   .o   files and make your tar file much

smaller.

Data Structures and DocumentationI have provided several C data structures for those who will

be programming in C. There are doubly linked list, symbol table and string manipulation routines in the

workspace directoryCminusProject2/util. The HTML Doxygen documentation for the provided code

is inCminusProject1/Documentation/html/index.html. You may ask me any questions regarding these

routines. You will not likely need any of these structures now, but you may want to familiarize yourself with

them. For those coding in C++, you may use STL.

codegen directoryI have created the codegen directory where the codegen.*, reg.* and other files are

store. You will add fuctions to generate instructions for different productions in parser and these functions

are in codegen.c. In addition, the register allocation management untily implimenation files are reg.c and

reg.h, which makes you use registers simple. Before generatging the compiler, you need issue make command

under the codegen direcetory.

Makefile StructureThe Makefiles for the project are set up to automatically generate make dependences.

In a particular directory (e.g.,parser), you may add new files for compilation by adding the source file name

to theSRCSvariable declaration on the first line of that directory  sMakefile. For example, to add the file

newfile.cto be compiled in theparserdirectory, change the first line ofparser/Makefilefrom

SRCS = CminusScanner.c CminusParser.c

4

to

SRCS = CminusScanner.c CminusParser.c newfile.c

Nothing else needs to be done. Do not add source files to the root directoryCminusProject2as the make

files assume there are no source files in that directory.

If you would like to add your own subdirectory (e.g.,newdir) toCminusProject2, then change the line

DIRS = parser util

inCminusProject1/Makefileto

DIRS = parser util newdir

and the line

LIBS = parser/libparser-g.a util/libutil-g.a

inCminusProject1/Makefileto

LIBS = parser/libparser-g.a util/libutil-g.a newdir/libnewdir-g.a

Then, copyutil/Makefiletonewdir/Makefile. Finally, change theSRCSdeclaration innewdir/Makefile

to contain only the source files in that directory and change the line

請加QQ:99515681  郵箱:99515681@qq.com   WX:codinghelp




 

掃一掃在手機打開當前頁
  • 上一篇:欣欣花客服電話官方教你一招成功上岸!
  • 下一篇:關于花生米強制下款-如何聯系客服解決問題
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務-企業/產品研發/客戶要求/設計優化
    有限元分析 CAE仿真分析服務-企業/產品研發
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
  • 短信驗證碼 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区
    国内精品久久久久久久97牛牛 | 亚洲免费高清| 国产一区日韩欧美| 91影院在线免费观看| 国产精品1区2区| 国产在线视频一区二区三区| 青青草91视频| 亚洲午夜精品网| 综合婷婷亚洲小说| 亚洲欧美日韩一区二区三区在线观看| 亚洲精品一区二区三区影院| 日韩中文字幕av电影| 亚洲女与黑人做爰| 亚洲第一久久影院| 日日摸夜夜添夜夜添亚洲女人| 亚洲大尺度视频在线观看| 亚洲成人精品一区二区| 亚洲美女精品一区| √…a在线天堂一区| 一区二区日韩电影| 婷婷激情综合网| 精品中文av资源站在线观看| 国产精品66部| 国产在线成人| aa国产精品| 中日韩视频在线观看| 色偷偷88欧美精品久久久| 日韩欧美一级在线播放| 国产精品三级久久久久三级| 亚洲高清不卡在线观看| 国产精品一区二区久久不卡| 欧美激情视频一区二区三区在线播放 | 国产激情一区二区三区桃花岛亚洲| 成人av免费观看| 美女久久网站| 欧美一区二区三区影视| 国产精品国产自产拍高清av| 亚洲综合免费观看高清完整版| 国产一区999| 亚洲精品在线二区| 欧美色国产精品| 亚洲精品伦理在线| 国产成人一区二区精品非洲| 国产区日韩欧美| 日韩精品一区二区三区在线观看| 亚洲人成网站在线| a亚洲天堂av| 久久青草久久| 国产精品美女一区二区在线观看| 日韩综合在线视频| 亚洲小说区图片区| 26uuu成人网一区二区三区| 亚洲电影视频在线| 欧美jizzhd精品欧美喷水| 欧美色视频在线| 国产精品黄色在线观看| 99视频精品在线| 欧美成人a∨高清免费观看| 日韩国产欧美在线视频| 一本久久综合| 国产精品久久久久久福利一牛影视| 国产麻豆精品theporn| 91国产丝袜在线播放| 亚洲精品午夜久久久| 女女同性精品视频| 欧美成人欧美edvon| 在线不卡一区二区| 久久国产精品高清| 亚洲欧美电影一区二区| 极品日韩久久| 自拍偷拍欧美精品| 欧美午夜视频在线| 国产亚洲精品福利| 午夜精品剧场| 亚洲人妖av一区二区| 狠色狠色综合久久| 久久久久久久网| 国产精品一区二区在线观看不卡| 欧美亚洲高清一区二区三区不卡| 五月天国产精品| 7777精品伊人久久久大香线蕉的 | 91免费观看在线| 中文字幕一区三区| 亚洲在线视频| 免费人成在线不卡| 久久久久久一区二区| 亚洲一区二区三区三| 色综合av在线| 国产露脸91国语对白| 精品久久久久久最新网址| 91片黄在线观看| 17c精品麻豆一区二区免费| 日韩网站在线| 日韩国产一区二| 精品国产露脸精彩对白| 国内一区二区三区| 亚洲精品欧美综合四区| 色香蕉久久蜜桃| 91看片淫黄大片一级| 亚洲风情在线资源站| 欧美一级精品大片| 永久91嫩草亚洲精品人人| 亚洲精品自拍动漫在线| 欧美视频一区二区| 国产一区二区三区电影在线观看| 欧美精品一区二区蜜臀亚洲| 国产精品亚洲综合久久| 成人一级片网址| 亚洲精品中文字幕在线观看| 欧美日韩精品欧美日韩精品一综合| 91免费精品国自产拍在线不卡| 亚洲国产精品一区二区久久 | 在线一区亚洲| 大胆欧美人体老妇| 日韩和的一区二区| 亚洲精品一区二区三区四区高清| 欧美视频一区二区三区| 久久精品道一区二区三区| 亚洲丰满在线| 亚洲二区免费| 欧美一区二区三区在| 国产精品毛片一区二区三区| 欧美精品一区二区三区在线看午夜| 国产一区二区三区四区五区入口 | 成人午夜视频福利| 国产老妇另类xxxxx| 国产中文一区二区三区| 极品少妇xxxx精品少妇偷拍| 精品无码三级在线观看视频| 免费精品视频最新在线| 蜜桃av一区二区三区电影| 免费看欧美女人艹b| 毛片av中文字幕一区二区| 国产资源在线一区| 国产专区欧美精品| 国产99精品视频| 午夜精品视频| 亚洲精一区二区三区| 欧美亚洲网站| 在线观看免费亚洲| 日韩一区二区免费在线观看| 精品国产一区二区国模嫣然| 国产日韩三级在线| 亚洲一区二区在线观看视频| 日韩和欧美的一区| 国产高清无密码一区二区三区| 成人国产在线观看| 亚洲免费播放| 欧美美女直播网站| 国产精品福利在线播放| 亚洲成人av免费| 国产一区二区日韩精品| 99re这里只有精品视频首页| 欧美午夜精品| 久久一区激情| 国产日产欧美一区| 日韩影院在线观看| av不卡免费在线观看| 六月天综合网| 国产欧美在线观看一区| 日韩精品亚洲专区| 99久久99久久精品免费看蜜桃| 一本综合精品| 日韩视频一区二区在线观看| 亚洲天堂网中文字| 成人性色生活片| 麻豆成人精品| 国产欧美久久久精品影院| 久久国产剧场电影| 亚洲美女一区| 精品精品欲导航| 麻豆91在线播放| 一本久道久久综合狠狠爱| 欧美mv日韩mv国产网站app| 水蜜桃久久夜色精品一区的特点| 91色综合久久久久婷婷| 欧美日韩一区二区三区视频| 亚洲欧美日韩国产手机在线| 国产999精品久久久久久| 色婷婷精品久久二区二区蜜臀av| 中文字幕国产一区二区| 国产激情一区二区三区四区| 亚洲男女自偷自拍| 亚洲人成精品久久久久久| 97成人超碰视| 精品国产精品一区二区夜夜嗨| 精品在线视频一区| 欧美在线一二三| 国产精品制服诱惑| 亚洲欧美综合另类在线卡通| 91网页版在线| 久久欧美中文字幕| 国产1区2区3区精品美女| 欧美日韩在线直播| 久久99精品久久久| 欧美一区二区三区免费大片| 国产成人亚洲综合a∨婷婷图片| 欧美日韩国产一区| 国产风韵犹存在线视精品| 欧美日韩黄色一区二区|