Cie AS Computing
Dear A2 students,
It is indeed a great privilege for me to welcome all of you to this A2 computing class, which stared June 2012. I wish you have all had a great experience in you AS level computing where you had learned programming and theory in your own way. From my side, I have always seen you all as students who have good knowledge in programming. However, coming to the theory, I am sorry to say that you have not met my requirements, most of the time you answers have deviated from the examiners requirement and as such, you have lost marks heavily in theory. Now, please dont take the same experience and attitude with you in your A2 computing course, you may sure end up landing no where. So, right from the beginning, inculcate the habit of reading more into the subject thought and sure reading alone would provoke you to bring dozens of questions to classroom discussions. I dont want the classroom to be an passive teaching place or an active learning place, I want the classroom to be a flipped classroom. That is where the students experience are discussed in the classroom and the problems are solved. This alone can get you a A grade. For this, you need to have your reading habit to go on and on on a daily basis until the end of the A2 course. Hope all of you would take this A2 course very serious and fill in your intellectual void with my words of wisdom taken from the CIE oven and served to you hot.
All the best,
Keep moving,
Dr.Ravi
Tags:
May/June 2003
1. (a) Because intepreter reads the code line by line and errors are detected as it runs. For a loop that will need to be executed 2000 times, it will take a very long time to finish. By using a compiler, it will read all the codes in one go and informs the user at the end of the compiling process. This way, users won't have to correct the error every time it's detected, instead, they will get all the errors at the end of the compiling process and correct it all directly.
(b) During lexical analysis, the user uses the source program as input. It turns the high-level language (HLL) code into a stream of tokens for the next stage of compilation. A token replaces a group of characters in the code. For example, PRINT function could be replaced by the token 011110100011110. Single characters that have their own meaning will be replaced by their ASCII value.
When going through a variable, it will need to store additional information about it and this is done by creating symbol table. This table is used throughout the compilation process to build up the information of the identifier names used in the source program. So, when a variable such as, MyName, is met for the first time, it will be stored on the table.
The lexical analyser will also output some error and diagnostic message. For example, it can report error such as a keyword which is not entered properly. If PINT is entered instead of PRINT, the error may be found because there is no token which can replace it.
3 (a) Explain why an interpreter would be preferred to a compiler as a translator when writing a high level language program.
answer : - an interprter would scan error line by line during writing of the source code of a program. Errors would be detected immidiately, and programmer would able to rectify the errors at the moment before continue to write new line of code.
- compiler will scan the whole source code and generate error report at the end of the process, programmer need to fin locations of errors and rectify it. This process is especially tedious to do when the source code is complex and long.
-In intrepreter programmer can attempt to run the program at any time , including before all code has been written, this helpful for a programmer to check whether the segment of code is working, before continuing writing new segment.
-debugging is generally easier and faster using an intrepreter as error message is generated as soon as error encoutered.
-each instructions is executed before next instructions is identified hence a complex high language program can be develop on a system which lacked power and memory needed for compilation.
(b) describe process of syntax analysis
answer : - refer to dain answer. :)
Work out the infix equivalents of these reverse Polish expressions:
x y + z + c d + -
ans: ( ( ( x + y ) + z ) - ( c + d ) )
Work out the reverse Polish equivalent of the given infix expression:
( a + b ) / ( c - d )
Solution:
ab+cd-/
No. 9 May/June 2011
by : amir asyraf
work out the reverse polish notation ( postfix ) equivalents of these inflix expressions
A) ( a + b ) - ( c + d ) ----------> a b + c d + -
B) X * Y Z --------------> X Y Z - *
May/June 2011. P31
(a) Explain the need for reverse Polish notation
Reverse Polish expressions can be processed directly from left to right
It is free of ambiguities and does not require brackets and it also does not require use of rules of precedence.
(b) File has been uploaded by Faiz
ab + cde -*-
Exercise Chapter 3.
Explain and mention the uses of each register to complete a task
- Program Counter (Sequence Control Register) contains the address of the next instruction to be carried out and controls the sequence of instructions.
- Current Instruction Register holds the instruction while it is being executed and contains both function and address/operand.
- Memory Address Register act to hold the address of the data that is next to be used.
- Memory Data Register store contents of any address that has been accessed in here first before being used, it may be an instruction or a piece of data. It also acts as a buffer between memory and CPU
- Accumulator stores results of calculations and does the arithmetic. All input to and output from processor pass through the accumulator
Explain the fetch decode execute cycle
- Address in the program counter(PC) in loaded into the memory address register(MAR)
- The value of PC in incremented by 1
- Instructions in the memory address given by the MAR is loaded into the memory data register(MDR)
- Instructions that is now in the MDR is loaded into the current instruction register(CIR)
- If the instruction is a jump instruction then the address part of the instruction will be loaded into the PC and reset by going to step 1
- If not, execute the instruction
- Reset by going to step 1
How do you explain the fetch decode execute cycle using the pseudocode algorithm
What is paraller processor, array processor and maths co-processor
- Parallel processor is many processors working together on the same program at the same time.
- Array processor has a number of Arithmetic Logic Units(ALU) that allows all the elements of an array to be processed at the same time.
- Maths co-processor is especially designed to carry out floating point calculation very quickly thus making performance faster.
© 2025 Created by Ravichandran.
Powered by