日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

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

CS 2210編程代寫、Java程序語言代做

時間:2023-11-27  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



CS 2210 Programming Project (Part IV)
Code Generation
This project is intended to give you experience in writing a code generator as well as bring together
the various issues of code generation discussed in the text and in class.
Due date
The assignment is due December 9th, 2023, 11:59pm. This is the hard deadline and no extensions will be given for this project.
Project Summary
Your task is to write a code generator, the final phase of your compiler. It produces (target)
assembly code for the MIPS R2000 architecture. It takes as input the augmented AST and symbol
table produced by the previous phases of your compiler. The generated code will be executed using
SPIM S20, a simulator for the MIPS R2000.
Code generation will consist of assigning memory addresses for each variable used in the MINIJAVA program and translating subtrees of the AST (intermediate language representation) into
sequences of assembly instructions that perform the same task.
Code Generation
This is the only phase of your compiler which is machine dependent. Examples of assembly code
programs will be provided on the class webpage.
The important/interesting issues in generating code for MINI-JAVA are discussed in the following paragraphs. Please refer to chapter 7, 8 and class notes for further details on these issues,
You can make the following assumptions to simplify the project.
ˆ Code is generated for the intermediate instructions on a statement-by-statement basis without
taking into account the context of an intermediate instruction
ˆ code is generated for the intermediate instructions in the order that they occur within the
intermediate instruction sequence.
ˆ You may take advantage of any special instruction of the machine when choosing target
instructions for a given intermediate instruction.
ˆ You do not have to any fancy register allocation or optimization on your target code.
1
Computing Memory Addresses
Since address information has not been computed and entered into the symbol table by earlier
phases, the first task of the code generator is to compute the offsets of each variable name (both
global and local); that is, the address of each local data object and formal parameter within the
activation record for the block in which they are declared. This can be done by initializing a
variable offset at the start of each declaration section, and as each declaration is processed, the
current value of offset is entered as an attribute of that symbol, and offset is then incremented
by the total width of that data object (depending on its type).
The program execution begins with a method called main() being called. Since the language
has no way to initiate classes, all classes are instantiated when program execution begins. Thus,
all storage for all classes is allocated globally. The offsets of variables within classes should be
computed and stored as an attribute of the variable name, typically relative to the start of the class
or can just be relative to the start of the global storage.
For simplicity, declarations within a method donot contain any objects whose types are classes.
That is, local variables can only be of integer type or integer array type.
Call-by-value parameters will have a width dependent on the type of the parameter (remember
we are using only integer parameters), whereas call-by-reference parameters will have a width
equal to ONE word to store an address. The total activation record size of each method should be
computed at this time and entered in the symbol table as an attribute of the method name.
The machine architecture must be take into account when computing these widths, that is,
an integer in the MIPS processor is 4 bytes. Offsets of locals can be implemented as a negative
offset from the frame pointer while offsets of parameters can be positive from the frame pointer.
Thus, the computation of offsets of arguments and local variables can be done independently. This
information will be used upon every reference to the data object in addition to being used in the
allocation of storage for activation records.
Handling Structure Data Types
Storage for an array is allocated as a consecutive block of memory. Access to individual elements
of an array is handled by generating an address calculation using the base address of the array,
the index of the desired element, and the size of the elements. You are free to choose the layout of
elements of an array in your implementation (e.g., row major or column major order).
Simple Control Flow
Code for simple control statements, namely conditional and loops in MINI-JAVA, can be generated
according to the semantics of conventional programming languages using the compare and branch
instructions of the assembly language. Unique target labels will also have to be generated.
Method Invocation, Prologues, and Epilogues
Recursion in MINI-JAVA prevents the use of a static storage allocation strategy. However, the
language has no features that prevent the deallocation of activation records in a last-in-first-out
manner. That is, activation records containing data local to an execution of a method, actual
parameters, saved machine status, and other information needed to manage the activation of the
2
method can be stored on a run-time stack. The MIPS assembly language provides the subroutine
call mechanisms to manipulate the run-time user stack.
An activation record for a method is pushed onto the stack upon a call to that method, while
the activation record for the method is popped from the stack when execution of the method is
finished and control is to be returned to the caller. As MINI-JAVA does not allow dynamic classes
and arrays, the sizes of all activation records are known at compile time.
Method calls result in the generation of a calling sequence. Upon a call, an activation record for
the callee must be set up and control must be transferred to the callee after saving the appropriate
information in the activation record. For each method, the generated code sequence will consist of
a prologue, the code for the statements of the method, and the epilogue. Typically, the prologue
saves the registers upon a method call and allocates space on the stack for local variables, whereas
the epilogue consists of restoring the saved machine status and returning control to the point in the
caller immediately after the point of call. The handout on the MIPS assembly language explains
the instructions used to implement these actions.
Parameter passing
In order to correctly handle the formal parameters within the body of the callee, the symbol table
entry for each formal parameter must include an attribute that indicates the parameter passing
mode, that is, by-value or by-reference. Remember that we do not pass arrays as parameters. On
a method invocation, call-by-value parameters are handled by allocating the local store for the size
of the object in the activation record of the callee and then evaluating the actual parameter and
initializing the local store within the callee with the value of the actual parameter. All accesses to
that formal parameter will change the value in the local space, with no effect on the caller. On a
return, no values are copied back to the caller.
Call-by-reference parameters are handled by allocating local space in the callee’s activation
record for the address of the actual parameter and then copying the address of the actual parameter
into that local space. All accesses to that formal parameter during execution of the callee are indirect
accesses through this address, having a direct effect on the caller. On return, no action is taken
other than reclaiming the space.
Note that MIPS has a convention that the first 4 arguments of a method call are passed in
register $a0-$a3. You have the option to follow this convention.
Register Usage
In the MIPS processor, certain registers are typically reserved for special purposes. You should
abide by these conventions.
Possible Functions
You may want to write the following functions to help in the code generation.
1. emit call(func name, num arg)/*emit a call instruction; func name: function id lexeme pointer;
num arg: number of arguments */
2. emit label(l num)/*emit a definition of a label; l num: label number; example: L=102, code
generated = “L 102” */
3
3. emit goto(operator, l num) /*emit unconditional and conditional jump instructions; operator:
an operator in the branch-jump group; l num: label number */
4. emit data(name, type, size) /* emit one data line, which is used for STATIC allocation;
name: data object id lexeme pointer; type: type width; size: number of elements of above type
*/
5. emit str(name, str) /* emit a string constant definition line; name: pointer to the name
lexeme; str: pointer to the str */
6. emit most(operator, type, num op, op1, op2, op3) /* emit most of the instructions; operator:
one of the instructions in the general group; type: data type; num op: number of operators 1,
2 and/or 3; op1...3: operands, op2 and op3 can be omitted depending on num op */
Run-time Error Detection
You do not need to generate any run-time checks. Thus you can assume that array bounds are
within range and scalars are within range.
Testing your code
The code generated is MIPS assembly code and should follow the descriptions specified in the
handout SPIM S20. Samples will be put on the class webpage.
You can run the generated assembly code on the simulator and check the results. However, the
correct output does not guarantee that your code is completely correct. You should examine your
generated code carefully.
proj4> codeGen < sample1.java
proj4> spim -asm -file code.s
... ...
or
proj4> spim
(spim) load “code.s”
(spim) step
[0x00400000] 0x8fa40000 lw $4,0($29)
(spim) run
... ...
Assignment submission
Please submit your project in Canvas before the due time. The submission should be a compressed
file that contains your project source code and readme file (if any).
請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:代寫CSC3100 Data Structures
  • 下一篇:CSCC43代做、R設計編程代寫
  • 無相關信息
    合肥生活資訊

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

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

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

    日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

      <em id="rw4ev"></em>

        <tr id="rw4ev"></tr>

        <nav id="rw4ev"></nav>
        <strike id="rw4ev"><pre id="rw4ev"></pre></strike>
        欧美中文在线观看国产| 欧美一激情一区二区三区| **性色生活片久久毛片| 国内外成人免费激情在线视频网站| 影音先锋国产精品| 国产精品视频网| 久久疯狂做爰流白浆xx| 亚洲午夜精品一区二区| 亚洲精华国产欧美| 国模套图日韩精品一区二区| 久久国产天堂福利天堂| 欧美精品v国产精品v日韩精品| 亚洲精品资源| 午夜精品视频在线观看| 国产精品毛片a∨一区二区三区| 日韩一级欧洲| 久久综合给合久久狠狠狠97色69| 欧美专区在线播放| 亚洲国产天堂网精品网站| 亚洲人人精品| 中文在线资源观看视频网站免费不卡| 国产亚洲欧美另类中文| 老司机凹凸av亚洲导航| 久久视频在线看| 亚洲人成亚洲人成在线观看图片| 欧美在线网站| 欧美成人dvd在线视频| 黑人巨大精品欧美黑白配亚洲| 麻豆成人综合网| 欧美精品三级| 久久噜噜噜精品国产亚洲综合| 久久九九99| 亚洲日本中文字幕免费在线不卡| 亚洲毛片在线免费观看| 亚洲福利视频一区| 国产精品人人做人人爽人人添| 乱码第一页成人| 欧美视频在线观看免费网址| 久久蜜桃精品| 夜色激情一区二区| 亚洲欧美国产日韩天堂区| 午夜亚洲性色福利视频| 久久国产精品一区二区| 欧美激情亚洲一区| 国产精品爱啪在线线免费观看| 国产午夜精品在线| 欧美专区日韩专区| 国产免费一区二区三区香蕉精| 欧美专区18| 国产日韩欧美精品| 夜夜嗨av一区二区三区网站四季av| 亚洲欧美日本伦理| 另类亚洲自拍| 一本一本久久a久久精品综合麻豆| 午夜精品久久久久久久99樱桃| 亚洲狼人精品一区二区三区| 欧美中文字幕精品| 欧美午夜精品伦理| 国产一区二区三区无遮挡| 在线视频亚洲欧美| 性欧美videos另类喷潮| 亚洲福利视频专区| 国产精品日韩在线播放| 午夜性色一区二区三区免费视频| 一本久久a久久精品亚洲| 欧美大尺度在线观看| 欧美视频免费在线| 国产欧美日韩免费看aⅴ视频| 国产精品久久久久9999高清| 欧美成人a视频| 欧美怡红院视频一区二区三区| 欧美日韩免费一区二区三区| 久久影视精品| 国产在线精品一区二区中文| 黄网站色欧美视频| 亚洲国产精品成人综合| 午夜精品久久久久99热蜜桃导演| 欧美新色视频| 久久精品免费看| 欧美日韩国产首页在线观看| 女人香蕉久久**毛片精品| 99国产精品视频免费观看一公开| 欧美中文字幕在线播放| 欧美伊久线香蕉线新在线| 国产一区日韩二区欧美三区| 亚洲第一区在线观看| 亚洲男女毛片无遮挡| 亚洲精品乱码久久久久久黑人| 欧美一区二区三区视频在线观看| 国产欧美一区二区三区国产幕精品| 欧美激情视频一区二区三区免费| 亚洲精品自在久久| 国产伦精品一区| 欧美 日韩 国产一区二区在线视频| 一区二区激情小说| 亚洲三级色网| 亚洲欧美日韩一区在线观看| 国产日产欧产精品推荐色| 狠狠色香婷婷久久亚洲精品| 亚洲激情电影在线| 狠狠色丁香婷婷综合久久片| 一区免费视频| 欧美三区视频| 国产欧美精品日韩精品| 欧美亚洲在线视频| 欧美电影免费观看高清完整版| 欧美一区二区三区视频| 亚洲一区二区av电影| 久久精品人人做人人爽| 亚洲国产高清视频| 亚洲精品乱码久久久久久按摩观| 欧美一区二区精品| 欧美日本三级| 亚洲一区在线观看视频| 黄色一区二区在线观看| 午夜精品视频在线| 1000部国产精品成人观看| 亚洲欧美日韩中文视频| 国产日韩精品综合网站| 国产日韩欧美黄色| 亚洲国产老妈| 国产乱肥老妇国产一区二| 久久精品亚洲热| 美脚丝袜一区二区三区在线观看| 一本色道久久综合亚洲精品按摩| 亚洲视频网站在线观看| 免费在线看成人av| 一区二区成人精品| 性8sex亚洲区入口| 国内外成人在线视频| 久久精品国内一区二区三区| 亚洲午夜久久久| 国产精品美女久久久久久久| 99re热这里只有精品视频| 一二美女精品欧洲| 野花国产精品入口| 亚洲欧美日韩在线| 国产一区二区精品在线观看| 亚洲精品一区二区网址| 国产亚洲美州欧州综合国| 国产精品九九久久久久久久| 亚洲午夜在线| 亚洲午夜激情免费视频| 免费亚洲电影| 狠狠爱成人网| 嫩模写真一区二区三区三州| 亚洲国产精品国自产拍av秋霞| 欧美中文字幕视频在线观看| 亚洲激情不卡| 亚洲男人影院| 国产一区二区三区视频在线观看| 夜夜爽www精品| 禁断一区二区三区在线| 日韩视频免费在线| 欧美精品色一区二区三区| 午夜视频精品| 亚洲欧洲三级| 一区二区三区国产精华| 国产精品影片在线观看| 亚洲国产成人av| 国产精品v欧美精品∨日韩| 美女露胸一区二区三区| 免费亚洲电影| 夜夜狂射影院欧美极品|