August 2000
SW204 : SOFTWARE AND
FILE DESIGN

QUESTION 3

Total Marks: 15 Marks

Click here to access other questions

SUGGESTED SOLUTIONS
Solutions and allocated marks are indicated in green.
Return to
Question 3

(a) Describe the three objectives of translation. [3]
To convert a high level language into machine language (1 mark), to
identify any source code errors (1 mark), and to produce compact and
efficient object code (1 mark). [3 marks]


(b) What are the three tasks involved in lexical analysis? [3]
Changing source code into a form that is independent of the input device (1 mark), standardising formats (1 mark), and converting reserved words and composite symbols into tokens (1 mark). [3 marks]


(c) Give two reasons why programs that are converted into machine language by
translators cannot be executed directly. [2]
One mark should be awarded for each named reason (up to a maximum of two marks). The reasons are as follows:
- The program may call subroutines that were not converted to machine language at the same time as the current program and, as such, their addresses are unknown.
- The program may be a subprogram and may require a calling program
to work.
- The program may not be placed in memory at the starting address
assumed by the translator. [2 marks]


(d) (i) Describe the term compile-and-go loader. [2]
A compile-and-go loader involves translators running in one part of memory and the translated machine instructions and data are assembled and placed directly into their assigned memory locations (1 mark). When the program assembly is completed, the loader transfers to the starting instruction of the newly translated
program (1 mark). [2 marks]

(ii) List two disadvantages of compile-and-go loaders [2]
One mark should be awarded for each named disadvantage (up to a maximum of two marks). Examples include the following:
- The portion of memory occupied by the translator is wasted because the object code cannot use that much of memory.
- The program must be translated each time it is run.
- It is difficult to handle multiple segments, especially if different source codes are in different languages.
- It is difficult to produce orderly modular programs.
Other correct answers should also receive credit. [2 marks]


(e) (i) How do absolute loaders differ from compile-and-go loaders? [1]
Absolute loaders differ from compile-and-go loaders in that object
code is not stored directly in memory. [1 mark]

(ii) List two disadvantages of absolute loaders. [2]
One mark should be awarded for each named disadvantage (up to
a maximum of two marks). Examples include the following:
- The programmer must specify to the assembler the address at which the program is to be loaded.
- If there are many subroutines, the programmer must remember the address of each and use that absolute address explicitly in other subroutines to perform subroutine linkage.
- If the program size increases, necessary adjustments must be made to all subroutines that access it.
Other correct answers should also receive credit. [2 marks]