Untitled
State the name of an identifier for a variable that is used to store a single character Choice State the name of an identifier for a user-defined subroutine that has one parameter ResetSourceCode State the name of an identifier for a user-defined subroutine that returns an integer ConvertToDecimal State the name of an identifier for a user-defined procedure DisplayMenu A constant is used to hold the maximum memory. State one advantage of using named constants for constant values So that it is more understandable as it is more descriptive and to easily change it if the program's requirements change. Explain what is meant by exception handling and how exception handling could be used in the EditSourceCode subroutine. Exception handling is the process of triggering an "except" block of code in the scenario that the "try" block produces an error. Used in EditSourceCode to ensure that the LineNumber entered is an integer A structured programming approach has been used in the production of the Skeleton Program. Explain what is meant by a structured programming approach. A programming approach that relies on 5 basic structures to develop a program: assignment, sequence, selection, iteration and subroutines. There is a variable called NumberOfLines in the subroutine Assemble . There is also a different variable called NumberOfLines in the subroutine DisplayCode. Explain why these two different variables can have the same identifier. Because they are local variables and are only visible within the subroutine Several subroutines use a variable NumberOfLines. It could have been declared as a global variable instead of locally in each subroutine. Why is it good practice to use local variables? - saves memory as it is only assigned when the subroutine it is in is called - allows for easier debugging and maintenance 1 / 4 State the name of an identifier for: 1) An array 2) A dictionary 3) A local variable used to store a string value 1) SourceCode 2) SymbolTable 3) FileName Explain how data is shared between the separate subroutines Each function returns a value so that when it is called, the value returned can be used by other subroutines Explain what will happen if the number of lines supplied in the data file is greater than the number of index positions in SourceCode array. Error code 2 is printed. It would also produce an error as Memory only goes up to 20 SourceCode is an array but a list could have been used. Describe two differences between arrays and lists and give an advantage of using an Array over a List? - Arrays stores one data type - Lists can store more than one data type - Arrays save more memory This question refers to the subroutine UpdateSymbolTablel. Give an example of why error code 3 would be displayed and explain how the code will detect the error caused by the text file Error code 3 is displayed when the same label is used more than once As labels are stored in SymbolTable, the code checks if the label has already been stored in SymbolTable State the identifier for a user defined subroutine that uses nested indefinite iteration EditSourceCode State the identifier for a data structure that stores values of more than one data type AssemblerInstruction State the identifier for a data structure that stores only one data type SourceCode What is the purpose of a hierarchy chart? To represent the structure of a program and to aid with decomposition of a problem What does each box in a hierarchy chart represent? A subroutine 2 / 4 State the most appropriate data type to use for whole numbers Integer The Skeleton Program uses the data structure SourceCode. State what the first element of this data structure, SourceCode[0], is used for To store the number of lines Explain what is meant by decomposition Breaking down a problem into smaller sub-problems in which each sub-problem can be solved individually and may be broken down further Explain the differences between definite and indefinite iteration Definite - when the number of times its going to loop is specified (for loops) Indefinite - when it loops until a condition is met (while loops) State the identifier of a subroutine in the Skeleton Program that contains definite iteration. ResetSourceCode State the identifier of a subroutine in the Skeleton Program that contains indefinite iteration GetMenuOption What is a subroutine? Named "out of line" block of code that may be executed (called) by simply writing its name in a program statement The use of subroutines promotes code re-use. Describe with references to subroutine(s) in the skeleton program, an example of how a subroutine has been re-used DisplayStack is called every time an item is added to the stack Describe am advantage of re-using subroutines - saves time as code doesnt have to be written - saves memory as there is less duplicated code Why is a for loop used with the sourcecode index 0 and not a while loop - because of the number of lines are known and so it loops for a specific number of times, definite iteration 3 / 4 BinaryString is stored as a string but only contains integers, why is this? Because the leading zeros would not be shown if it was represented as an integer Explain Error Code 1 The file does not exist Explain Error Code 2 The loaded file cannot be read correctly Explain Error Code 3 Label is already in SymbolTable Explain Error Code 4 If a colon doesn't follow the label Explain Error code 5 if the opcode is not recognised Explain Error Code 6 Operand isn't an integer or a valid label Explain Error Code 7 The number of lines of code is empty or trying to display source code before file is loaded Explain error code 8 The number of lines of code is empty or trying to edit source code before file is loaded explain error code 9 The number of lines of code is empty of trying to assemble source code before file is loaded explain error code 10 operand value is 0 or pass one is uncuccessful explain error code 11 opcode is "err" or pass two is unsuccessful What does the term instantiation mean? Creating an instance of a class (object) When would the operandstring and operandvalue be the same thing within an object When the operand is an integer and not a label. If it was a label, operandvalue would be the linenumber What does operandvalue store for each object Value if operand is integer, line number if operand is a label When will it start as Jump1 If no start is present of if the start label is in the first line Currently a number in the ACC which is a negative overflow does not produce a runtime error, why not? Because the negative flag is tripped and setflags is written so that only one flag can be tripped at a time