国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看

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

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




 

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

    合肥圖文信息
    流體仿真外包多少錢_專業CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務 管路流場仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務 管路
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真技術服務
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲勞振動
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲
    流體cfd仿真分析服務 7類仿真分析代做服務40個行業
    流體cfd仿真分析服務 7類仿真分析代做服務4
    超全面的拼多多電商運營技巧,多多開團助手,多多出評軟件徽y1698861
    超全面的拼多多電商運營技巧,多多開團助手
    CAE有限元仿真分析團隊,2026仿真代做咨詢服務平臺
    CAE有限元仿真分析團隊,2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗證碼 豆包網頁版入口 破天一劍 目錄網 排行網

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

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

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    日韩精品一区二区三区四区五区| 欧美日产一区二区三区在线观看| 日本在线观看一区二区| 国产裸体写真av一区二区| 久久精品午夜一区二区福利| 亚洲最新免费视频| 国产有码在线一区二区视频| 国产福利一区视频| 欧美一区二区三区在线免费观看| 国内精品视频一区| 精品国内亚洲在观看18黄 | 国精产品一区一区三区有限在线 | 精品一区二区三区无码视频| 国产成人鲁鲁免费视频a| 日韩免费不卡av| 久久精品人成| 欧美在线3区| 国产精品无码av在线播放| 欧美亚洲一级片| zzjj国产精品一区二区| 日本黄网站免费| 久久久免费av| 热久久这里只有精品| 日韩亚洲成人av在线| 欧洲精品久久| 国产精品视频不卡| 美日韩精品免费| 欧美精品在线免费观看| 国产精品永久免费视频| 亚洲综合自拍一区| 国产成人永久免费视频| 欧美在线视频观看| 国产精品福利网站| 国产伦精品一区二区三区照片91| 欧美日韩福利视频| 国产精品小说在线| 亚洲精品免费在线视频| 7777精品久久久久久| 日韩欧美不卡在线| 久久精品福利视频| 国产日韩欧美自拍| 亚洲欧洲一区二区| 国产成人福利视频| 精品免费一区二区三区蜜桃| 美女黄色丝袜一区| 久色视频在线播放| 欧美日韩国产高清视频| 欧美激情视频给我| 久久久在线视频| 欧美最大成人综合网| 国产精品视频免费在线观看| 国产日韩欧美一区二区| 亚洲wwwav| 日韩中文字幕在线播放| 国模极品一区二区三区| 亚洲.欧美.日本.国产综合在线| 九一免费在线观看| 蜜桃麻豆www久久国产精品| 一区二区三区一级片| 国产福利视频在线播放| 国内精品视频在线| 亚洲国产精品www| 久久久国产精品x99av| 国产乱码精品一区二区三区日韩精品 | 国产精品午夜一区二区欲梦| 欧美一区二区三区艳史| 国产精品视频白浆免费视频| 波多野结衣综合网| 欧美在线观看黄| 中文字幕中文字幕在线中一区高清| 久久久久久美女| 国产精品一区二区电影| 日产中文字幕在线精品一区| 国产精品久久久久久久电影 | 欧美亚洲精品日韩| 在线播放豆国产99亚洲| 久久久黄色av| 91高清视频免费| 美女主播视频一区| 日本高清视频精品| 亚洲综合第一页| 国产精品免费看久久久香蕉| 国产精品18久久久久久首页狼| 欧美不卡1区2区3区| 日韩在线国产| 蜜臀久久99精品久久久无需会员 | 欧洲精品在线一区| 亚洲欧美日韩精品综合在线观看 | 精品国产一区av| 国产精品一区二区三区四区五区| 日韩欧美一区二区三区四区| 久久久久国产精品免费网站| 久久精品最新地址| 久久美女福利视频| 91美女片黄在线观看游戏| 国产视频一区二区三区四区| 欧美视频在线观看网站| 涩涩日韩在线| 亚洲欧美影院| 中文字幕欧美日韩一区二区三区| 国产精品污www一区二区三区| 国产精品9999| 国产精品亚洲天堂| 国产在线精品二区| 欧美不卡福利| 日本一区免费看| 亚洲精品中文综合第一页| 欧美精品免费看| 国产精品裸体瑜伽视频| 日韩在线中文视频| 国产h视频在线播放| 成人av网站观看| 国产欧美精品在线播放| 黄色网zhan| 欧美不卡1区2区3区| 欧美亚洲免费高清在线观看| 欧美一区二区激情| 性高湖久久久久久久久aaaaa| 亚洲美女搞黄| 亚洲精品国产一区| 一区二区三区视频| 欧美激情网站在线观看| 欧美另类99xxxxx| 欧美成人一二三| 欧美另类69精品久久久久9999| 国产精品久久成人免费观看| 久久久精品在线| 国产精品入口免费| 国产精品偷伦免费视频观看的| 日韩亚洲精品视频| 国产精品视频99| 国产精品乱码一区二区三区| 国产精品免费视频一区二区| 国产精品久久久久高潮| 国产精品后入内射日本在线观看| 久久视频精品在线| 国产精品久久久久一区二区| 国产精品户外野外| 一区二区视频在线播放| 亚洲精品一区国产精品| 色播五月综合| 热re99久久精品国产99热| 欧美亚洲日本网站| 精品少妇一区二区三区在线| 国产一区二区视频在线免费观看| 国产日韩精品推荐| 成人av色在线观看| 久久精品一二三区| 国产精品无码一区二区在线| 久久伊人免费视频| 久久91精品国产91久久久| 亚洲影视九九影院在线观看| 日韩高清国产一区在线观看| 欧美亚洲另类在线| 国产毛片视频网站| 国产精品999| 久久9精品区-无套内射无码| 国产精品女视频| 中文字幕免费在线不卡| 色噜噜狠狠一区二区三区| 欧美激情国产精品日韩| 国产日韩中文在线| 91国语精品自产拍在线观看性色| 日韩在线一区二区三区免费视频| 国产精品视频专区| 国产精品成人aaaaa网站| 亚洲影影院av| 欧美人成在线观看| 国产伦精品一区二区三区免| 久久香蕉综合色| 国产精品美女久久久久久免费| 一区二区三区日韩视频| 日韩亚洲欧美精品| 国产精品一区二区欧美黑人喷潮水| 国产成人综合精品| 精品中文字幕在线2019| 日韩亚洲一区在线播放| 国产日韩视频在线观看| 久久手机视频| 久久中文字幕一区| 无码无遮挡又大又爽又黄的视频| 国模精品一区二区三区| 91精品国产电影| 国产精品第一视频| 日本精品一区| 成人免费aaa| 国产精品久久久久久久电影| 午夜精品一区二区在线观看| 欧美精品久久| 久久免费视频观看| 欧美激情中文字幕乱码免费| 日韩经典在线视频| 成人精品水蜜桃| 国产精品久久一区| 日本不卡久久| 国产精品亚洲一区| 国产精品久久波多野结衣| 日本三级中国三级99人妇网站| 国产在线精品一区二区三区》| 久久av一区二区三区漫画|