Programming Languages & Translators (AQA GCSE Computer Science)

Exam Questions

21 mins9 questions
11 mark

The three examples of code shown in Figure 4 are all equivalent to one another.

Figure 4

Example 1

Example 2

Example 3

a ← 4
b ← 3
IF a = b THEN
c ← a + b
ENDIF

MOV R0, #4
MOV R1, #3
CMP R0, R1
BNE end
ADD R2, R0, R1
end:
HLT

1001 0000 0100 0000
1001 0001 0011 0000
0100 0000 0001 0000
1010 0101 0000 0000
1100 0010 0000 0001
1111 0000 0000 0000

Identify one choice to show the statement that is true about Figure 4

  • None of the examples of code is in a low-level language.

  • Only one of the examples of code is in a low-level language

  • Only two of the examples of code are in low-level languages

  • All three of the examples of code are in low-level languages

Did this page help you?

2a2 marks

Figure 4 shows three programs (A, B, C) that add two numbers and output the result. The programs are written in different programming languages.

Figure 4

A

B

C

x = 14
y = 3
z = x + y
OUTPUT(z)

LDR R0, #14
LDR R1, #3
ADD R2, R0, R1
STR R2, 63
OUT R2

0000 00001110
0001 00000011
0110 00010000
1010 10111111
1110 00000000

Identify the type of programming language used for each program shown in Figure 4 by writing A, B or C in the correct row of Table 2.

You must only use each letter once.

Table 2

A, B or C

Assembly language

High-level language

Machine code

2b1 mark

Identify one choice to show which statement is true about program translators.

  • A compiler translates all the original program code before execution

  • Compiled code still needs the original program code to execute

  • Compiled code executes more slowly than code that is being interpreted.

  • Interpreters generate machine code directly.

Did this page help you?

32 marks

Programming languages can be classified as low-level or high-level.

Identify two choices to show the statements that are true about code written using a low-level language instead of a high-level language.

  • The code more closely resembles English.

  • The code is easier to write

  • The code is not translated using a compiler.

  • The code is quicker to write

  • The code can directly manipulate computer registers.

  • The code never needs to be translated before being executed.

Did this page help you?

41 mark

Assemblers and interpreters are two types of program translator.

State the purpose of an assembler.

Did this page help you?

51 mark

The following are three types of program translator:

A Assembler
B Compiler
C Interpreter

Write the label (A–C) for the type of translator next to the description

Description

Label (A–C)

Converts a low-level language designed to be human-readable into machine code

Reads a high-level program line-by-line and calls corresponding subroutines.

Takes the entire high-level program as input and produces machine code.

Did this page help you?

1a4 marks

Explain why a developer, who is good at both low-level and high-level programming, would normally use high-level languages when writing programs.

1b2 marks

The three examples of code shown in Figure 4 are all equivalent to one another.

Figure 4

Example 1

Example 2

Example 3

a ← 4
b ← 3
IF a = b THEN
c ← a + b
ENDIF

MOV R0, #4
MOV R1, #3
CMP R0, R1
BNE end
ADD R2, R0, R1
end:
HLT

1001 0000 0100 0000
1001 0001 0011 0000
0100 0000 0001 0000
1010 0101 0000 0000
1100 0010 0000 0001
1111 0000 0000 0000

Statements A and B refer to two different types of program translator.

Statement A: This type of translator can convert a high-level language program into machine code. The source code is analysed fully during the translation process. The result of this translation can be saved, meaning the translation process does not need to be repeated.

Statement B: This type of translator was used to convert the code in Example 2 to the code in Example 3 in Figure 4.

State the type of program translators referred to in statements A and B.

Did this page help you?

21 mark

State one advantage of writing programs in assembly language instead of a high-level language.

Did this page help you?

32 marks

State two advantages of programming using a high-level language compared with programming using a low-level language.

Did this page help you?

14 marks

Explain how an interpreter works.

Did this page help you?