AS computing

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   

Views: 390

Reply to This

Replies to This Discussion

Dear Students, to get more detailed idea of scheduling concepts and its types, I wish you watch this video.

Dr.Ravi

Dear students, I want Dain, who missed his class on RPN to translate this video and explain in the class to all of us.

Oct/Nov 2006


a) Explain the purpose of the code generation phase of compilation, including the principle of optimization.

   

 - it produces the object code

- when a variable is encountered during code generation  the address of the variable is computed and stored in the          symbol table.

-compiler can produce machine code that is required by the computer by directly translating from the tokens to the binary code using look-up tables

-Code optimization is where codes executes as quickly as possible and least amount of codes is produced.

b) Explain purpose of linkers and loaders.

- A loader loads all the modules into memory and sorts out difficulties such as changes of address or the variables.

- A linker links the modules together by making sure that references from one module to another are correct.

Oct/Nov 2007

7. How a variable in a high level language program is dealt with by a compiler:

   -Lexical analysis stage:

    -When a variable is met for the first time, the variable's name is noted in a symbol table.

    -The lexical analyser has rules for valid variable names, such as having fewer than 64 characters and not starting with a digit character

   -Syntax analysis stage:

    -Any details found regarding the variable is put into the symbol table

    -Most languages require the programmer to declare all variables and data types before they are used

    -At this stage the compiler verifies that all variables and constants have been properly declared and used in the correct syntax

   -Code generation stage:

    -When a variable is encountered, the address of the variable is computed and stored in the symbol table so that it can be referred to

  

May/June 2004

4. Describe what happens during the syntax analysis stage of compilation. [5]


Answer:

-Starts with the output produced from the lexical analysis stage.

-The code is parsed to ensure that it is gramatically correct.

-The code is checked against the rules defined by the Backus-Naur Form(BNF) notation.

-The code is also compared to a syntax diagram to ensure there are no syntax errors.

-Through this, invalid identifier names can be found. ie. PINT may have been read as a variable during the lexical analysis stage.

-Semantic checks are then carried out to check on the meaning of the statements to ensure that they make sense. ie. label checks and dec;aration checks.

May/June 2011. P31

 

2. (a) Explain the relationship between assembly languages and machine code.[2 marks]

-One to one relationship 

-Mnemonics are used to represent operation codes

-Labels are used to represent memory addresses

-machine code exist in form of binary codes 

-assembly code cannot be executed // machine code can be executed

-machine code and assembly language are both low level languages,they are machine specific

 

(b) Describe how an assembler produces machine code from assembly language.[2 marks]

-Labels are added to a symbol table

-Labels are later looked up to determine the actual address using assembler which

allocate addresses to labels

-Mnemonic looked up in opcode table to find operation code

-Macro instructions used to stand for groups of instructions

 

11. (a)  Describe the differences between interpretation and compilation of a high-level

language program. [3 marks]

-Interpreter translates one instruction, runs it before going on to the next //

Compiler translates all the instructions before run.

-Compiler creates object code/executable file // Interpreter does not

-Compiler makes debugging process more difficult as one error can produce many false errors //Interpreter makes for easier debugging as each line of code is analysed and checked before being executed.

-Compiled programs will execute faster // interpreted code will execute slower

-Interpreter must be present to run the program // compiler not needed at runtime

-Interpreter will translate code in loops more than once // Compiler only once

-once compiled no further translation needed // every program execution requires

interpreter

May/June 2011 P33

2 a). i) Linkers - Linkers is a software required to link program blocks which are stored in non-continuous areas of memory.       

                        This software is used to combine already compiled procedures and produce an executable file.

       ii) Loaders - Loader is a program that does the task of loading the jobs and adjusting the addresses. It copies object code into primary memory ready for execution.

11. a) Interpreter translates one instruction, runs it before going on to the next while compiler translates all the instructions before run.Next, compiler creates object code, interpreter does not.

The interpreter will translate code in loops more than once whereas compiler only once.
The interpreter makes for easier debugging while compiler allows faster execution translated code
The interpreter must be present to run the program but compiler not needed at runtime

Difference between Compilers and Interpreters:

1) Compiler scans the whole code then translate while interpreters translate sentence by sentence , and if there is an error, interpretation will stop

2) Compilers get rid of the source code while translating it into object code while interpreter keeps the source code throughout the translation

3) Compiled codes run more quickly since no translation is required, but for interpreter to run the code, the intepreter program must be present.

Two Phases Carried out before Code Generation:

1) Lexical Analysis

2) Syntax Analysis

Code Generation Phase:

Creates object code, equivalent to high level language

Optimization is used to reduce length of codes

Remove repeating codes and remove other errors 

Reply to Discussion

RSS

© 2025   Created by Ravichandran.   Powered by

Report an Issue  |  Terms of Service