Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CO5570 Anonymous Questions and Answers Page (2021, 15-34) XML CO5570 Anonymous Questions and Answers This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers. We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course. Question 34: Submission reference: IN2080 Excuse me sir David, in the '.code' part, what if I had an opcode without an operand, what would the error be? Answer 34: 'If there are either too few or too many operands for an instruction then the error message would be: Incorrect number of operands for ABCD' Question 33: Submission reference: IN2079 Excuse me sir, in the RAM declarations, if one of my RAM declarations was an opcode like LOAD, would it count as an illegal character or an illegal opcode? Answer 33: You could output an 'Illegal label' error message but I won't test your code with any examples. Question 32: Submission reference: IN2078 Excuse me sir, is the Shack language so strict that additional space in the end of the line is considered an illegal character? Answer 32: No. Question 31: Submission reference: IN2077 Excuse me sir David, in the RAM declaration part, after the '.dec', I want you to clarify what type of characters can be used to name the RAM declarations other than the Upper and Lower case letters. Answer 31: 'They consist of 1 or more alphabetic, numeric and underscore characters starting with an alphabetic character.' So the following are all legal: a, a1, a_1, aa1_bb12___0 Question 30: Submission reference: IN2073 hello david, I don't know if it's already answered or it's on the brief somewhere, but might I ask what happens if we have a shack code with no ".dec" and ".code" but have declared RAM Labels and Instructions? Do we just write an error message for each line since it's invalid to have declared labels and instructions without ".dec" and ".code"? sorry if the questions seems stupid. I just need confirmation Answer 30: The .dec section is optional. If there is no .code then any instructions would in error and the first would produce an error message. It an attempt is made to use undeclared RAM labels in the instructions then that would be an error. Keywords: assign3 Question 29: Submission reference: IN2060 Ass4 '::=' and ':=' sorry i think i have miss understand with these two in this programmer we using ':=' Answer 29: Boaz programs use := as the assignment symbol The grammar notation uses ::= as the symbol to separate the name of a non-terminal symbol (on the lhs) from its definition (on the rhs). Question 28: Submission reference: IN2024 Hello David hope you are doing well, I wanted to ask, when we output the hack contents to the corresponding shack contents, can we simply print out the content using system out or should we actually translate the shack contents into a txt file with the corresponding hack? Thanks, Merry Christmas and a happy new year. Answer 28: I am doing well, thanks. The brief says: The assembler must write the translated Hack version to a file whose name has the same prefix as the Shack source file but a `.asm' suffix. The file written to must be in the same directory/folder as the Shack source file. Theoretically, you could achieve that using System.out as long as the assemble script redirects standard output to a '.asm' file of the correct name. For instance: outfile=`basename $1 .shk`.asm java -cp . assembler.Main $* > $outfile However, it would be better to have your Java code open the output file of the correct name and write the Hack output there. Question 27: Submission reference: IN1998 In the book, multiple command types (A_COMMAND, C_COMMAND, L_COMMAND) are specified. I understand that the book's assembler different, however would a similar structure for command typing be required for our assembler? Answer 27: You might find it useful to define a type to represent the set of opcodes. Question 26: Submission reference: IN1993 Are there any more examples of test Shack code that we could use as a way to verify fully if our code is correct? No worries if not, I will just make my own up in that case. Answer 26: No, I don't have any more pre-prepared but it should be relatively easy for you to just put together multiple variations on the examples given in the brief as, aside from the label definitions, each instruction line is independent of all the others. Question 25: Submission reference: IN1987 Hi David I was just wondering if the formatting of our error messages matters for this assignment. For example if I used the error message "# is an illegal character" instead of " illegal character: #" would this get marked down? Thank you :) Answer 25: You should stick to the exact error messages in the brief to be on the safe side, even though more informative messages would be preferable if this were a real assembler. Question 24: Submission reference: IN1963 Hi David, I know the book does not exactly line up with the assignment but do we still need 4 files(Parser, Code, SymbolTable, Main) like the proposed software design is in the book? Answer 24: Is this for assignment 3 or 4? For assignment 4 there is no code to be generated. For assignment 3 you have a free choice over how you structure your program but those 4 classes are a reasonable fit for the tasks because you have to parse/analyse each line of the Shack input and generate equivalent Hack code for it. You will also need a symbol table to record the ROM and RAM labels that are defined. Question 23: Submission reference: IN1962 Apologies for the late timing however I have been stuck on how to start assignment 3 is there any information that could be provided to have a general concept on how to go approach it? Answer 23: Not really anything other than is in the course material, assignment brief and answers to questions on here. Question 22: Submission reference: IN1961 Is there a submission link live yet? Answer 22: There is now! Sorry for the delay and thanks for the prompt. Question 21: Submission reference: IN1959 if I want to use ram addresses to store data such as R1, R2 etc would I need to declare these in the .dec for shack to consider this correct? i.e would ADDD R1 give me an error of RAM label R1 has not been declared? Answer 21: That is a good point that you raise and the definition of Shack should have taken the pre-defined Hack symbols into account. I won't test your assemblers with pre-defined Hack symbols so feel free to ignore the special significance those would have. Question 20: Submission reference: IN1952 In the brief it says " If an illegal character is found on an input line then no further processing of the line should be undertaken." Does checking the rest of the line for illegal characters count as processing, to say do we write every illegal character in the line or only report the first? Answer 20: Yes, checking the rest of the line would count as further processing. Question 19: Submission reference: IN1948 Hi David, About instruction labels such as loop: and start:. would they be translated to (loop) and (start) respectively in hack? Answer 19: Yes, that is correct. Question 18: Submission reference: IN1942 So do I use (label) for ROM label definitions? Also when RAM labels are declared they are at the top of the .asm file as: @ramlabel1 @ramlabel2 should they be changed to: (ramlabel1) (ramlabel2) as well? Thanks Answer 18: RAM labels are not explicitly declared in Hack. They are declared by usage, so no translation of the .code section is required. Question 17: Submission reference: IN1933 In the brief labels translate to @label, but in hack labels are defined as (label)? Answer 17: The @ symbol is used when the value of a label is to be loaded into the A register in Hack but label definitions in Shack are converted into the parenthesised version in Hack. Question 16: Submission reference: IN1891 If I have the line: LOAD D 1whatever should I print: illegal operand: 1whatever or illegal character: 1 Answer 16: I would go with illegal operand. Question 15: Submission reference: IN1886 I notice in the brief I can use labels like sum and #sum. Since #sum couldn't be defined as a RAM or ROM label, does that mean the label referenced by #sum is just 'sum' whether it be RAM or ROM? Answer 15: The # character indicates that it is a value operand rather than an addr operand. The # is not part of the label. This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Last modified Thu Feb 10 09:13:46 2022 This document is maintained by David Barnes, to whom any comments and corrections should be addressed.