a level (a2) 9608 computer science - students resource
TRANSCRIPT
A LEVEL (A2) 9608
Computer Science Paper 4
TOPICAL WORKBOOK
WITH MARK SCHEME
JUNE 2015 – NOVEMBER 2019
Reviewed By:
FAWAD KHAN
___________________________________________________________________________________________________
___________________________________________________________________________________________________
Topic: Introduction___________________________________________________________________________________________________
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
3 Computer Science Paper 4 Topical
Computer Science Topical Paper 4 Content
Introduction Syllabus Update……………………………………………………………………………… 3 Content………………………………………………………………………………………….. 4 Preface………………………………………………………………………………………..….5 About the author…………………………………………………………………………….6 Acknowledgment ……………………………………………………………………………7
Topic 1 Abstraction and Recursion…………………………………………………………….. 7 Mark Scheme…………………………………………………………………………….… 14
Topic 2 Classes, Inheritance, Containment ………..………………………………...…. 18 Mark Scheme……………………………………………………………………………….. 94
Topic 3 Linked List, Queue, Stack, Binary Tree, Hash Table…………………….. 168 Mark Scheme…………………………………………………………………………….. 225
Topic 4 Algorithms Binary Search, Insertion Sort, Bubble Sort……………….. 254 Mark Scheme…………………………………………………………………………….. 268
Topic 5 Assembly Language …..……………………………………………………………... 274 Mark Scheme…………………………………………………………………………….. 299
Topic 6 Procedural Programming (AS)…..…………………………………….…………. 309 Mark Scheme…………………………………………………………………………….. 315
Topic 7 Declarative Programming…………………………………………………………… 321 Mark Scheme…………………………………………………………………………….. 340 Topic 8 State Transition Diagram………………………………………………….………… 346 Mark Scheme…………………………………………………………………………….. 355
Topic 9 Decision Table……………………………………………………………………………. 360 Mark Scheme…………………………………………………………………………….. 369
Topic 10 Jackson Structure …………………………………………………………………….… 376 Mark Scheme…………………………………………………………………………….. 382
Topic 11 File Processing……………………………………………………………………………. 386 Mark Scheme…………………………………………………………………………….. 388
Topic 12 Exception Handling…………………………………………………………………..… 391 Mark Scheme…………………………………………………………………………….. 396
Topic 13 Software Engineering ………………………………………………………………… 397 Mark Scheme…………………………………………………………………………….. 414
1
A recursively defined procedure X is defined below:
PROCEDURE X(BYVALUE n : INTEGER) IF (n = 0) OR (n = 1) THEN OUTPUT n ELSE CALL X(n DIV 2) OUTPUT (n MOD 2) ENDIF ENDPROCEDURE
(a) Explain what is meant by recursively defined.
...................................................................................................................................................
.............................................................................................................................................. [1]
(b) Explain how a stack is used during the execution of a recursive procedure.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(c) Dry run the procedure X by completing the trace table for the procedure call:
CALL X(40)
Call number
n (n = 0) OR (n = 1) n DIV 2 n MOD 2
1 40 FALSE 20
2
3
4
5
6
OUTPUT ............................................................................................................................... [6]
9608/43/M/J/15 Q6
Topic 1 Abstraction and Recursion
Topic 1: Abstraction & Recursion___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
7
___________________________________________________________________________________________________
(d) State the process that is carried out by procedure X.
...................................................................................................................................................
.............................................................................................................................................. [1]
(e) Write program code for procedure X.
Programming language .............................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
Topic 1: Abstraction & Recursion___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
8
___________________________________________________________________________________________________
2 NameList is a 1D array that stores a sorted list of names. A programmer declares the array in pseudocode as follows:
NameList : Array[0 : 100] OF STRING
The programmer wants to search the list using a binary search algorithm.
The programmer decides to write the search algorithm as a recursive function. The function, Find, takes three parameters:
• Name, the string to be searched for• Start, the index of the first item in the list to be searched• Finish, the index of the last item in the list to be searched
The function will return the position of the name in the list, or −1 if the name is not found.
Complete the pseudocode for the recursive function.
FUNCTION Find(BYVALUE Name : STRING, BYVALUE Start : INTEGER, BYVALUE Finish : INTEGER) RETURNS INTEGER
// base case
IF .............................................................................................................................................
THEN
RETURN −1
ELSE
Middle ..................................................................................................................
IF ................................................................................................................................
THEN
RETURN ...........................................................................................................
ELSE // general case
IF SearchItem > .........................................................................................
THEN
.............................................................................................................
ELSE
.............................................................................................................
ENDIF
ENDIF
ENDIF
ENDFUNCTION
9608/41/M/J/17 Q3
Topic 1: Abstraction & Recursion___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
9
___________________________________________________________________________________________________
3 The recursive algorithm for the Calculate() function is defined as follows:
01 FUNCTION Calculate(BYVALUE Number : INTEGER) RETURNS INTEGER
02 IF Number = 0
03 THEN
04 Calculate −10
05 ELSE
06 Calculate Number * Calculate(Number − 1)
07 ENDIF
08 ENDFUNCTION
(a) (i) State what is meant by a recursive algorithm.
...........................................................................................................................................
...................................................................................................................................... [1]
(ii) State the line number in Calculate() where the recursive call takes place.
...................................................................................................................................... [1]
9608/41/O/N/18 Q4
Topic 1: Abstraction & Recursion___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
10
___________________________________________________________________________________________________
A procedure that calls itself // is defined in terms of itself [1]
(b) Before procedure call is executed current state of the registers/local variables is saved onto
the stack When returning from a procedure call the registers/local variables are re-instated [2]
(c)
Call number n (n=0) OR (n=1) n DIV 2 n MOD 2
1 40 FALSE 20 0
2 20 FALSE 10 0
3 10 FALSE 5 0
4 5 FALSE 2 1
5 2 FALSE 1 0
6 1 TRUE
1 mark 1 mark 1 mark
OUTPUT 101000 – 1 mark for each pair of bits. [6] (d) Conversion of denary number into binary [1] (e) (i) Example Pascal
Procedure X(n: INTEGER) BEGIN IF (n = 0) OR (n = 1) THEN Write(n) ELSE BEGIN X(n DIV 2); Write(n MOD 2); END; END; Example Python def X(n): if (n == 0) or (n == 1): print(n, end="") else: X(n // 2) print(n % 2, end="")
Mark as follows: Procedure heading & ending Boolean expression correctly grouped statements within ELSE recursive call Using DIV and MOD correctly [5]
1 (a)
Topic 1: Mark Scheme___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
14
___________________________________________________________________________________________________
1
A payroll program is to be written using an object-oriented programming language. An Employeeclass is designed. Two subclasses have been identified:
• HourlyPaidEmployee who is paid a monthly wage calculated from their hourly rate of pay and the number of hours worked during the month
• SalariedEmployee who is paid a monthly wage which is one 12th of their annual salary
(a) Draw an inheritance diagram for these classes.
[3]
•••
•••
(b) The design for the Employee class consists of: • properties
• EmployeeName• EmployeeID• AmountPaidThisMonth
• methods• SetEmployeeName• SetEmployeeID •
CalculatePay
Write program code for the class definition of the superclass Employee.
Programming language .............................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
9608/42/M/J/15 Q4
Topic 2 Classes, Inheritance, Containment
Topic 2: Classes, Inheritance, Containment___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
18
___________________________________________________________________________________________________
(c) (i) State the properties and/or methods required for the subclass HourlyPaidEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [4]
(ii) State the properties and/or methods required for the subclass SalariedEmployee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [2]
(d) Name the feature of object-oriented program design that allows the method CalculatePay to be declared in the superclass Employee.
...................................................................................................................................................
.............................................................................................................................................. [1]
Topic 2: Classes, Inheritance, Containment___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
19
___________________________________________________________________________________________________
2
A sports club stores data about its members. A program is to be written using an object-oriented programming language.
A Member class is designed. Two subclasses have been identified: • FullMember • JuniorMember
(a) Draw an inheritance diagram for these classes.
[3]
(b) The design for the Member class consists of
• properties •• MemberName •• MemberID •• SubscriptionPaid
• methods •• SetMemberName •• SetMemberID •• SetSubscriptionPaid
9608/43/M/J/15 Q4
Topic 2: Classes, Inheritance, Containment___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
20
___________________________________________________________________________________________________
Write program code for the class definition of the superclass Member.
Programming language ....................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..................................................................................................................................................... [5]
(c) Additionally a DateOfBirth property is required for the JuniorMember class.
(i) Write program code for the class definition for the subclass JuniorMember.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
(ii) Write program code to create a new instance of JuniorMember. Use identifier NewMember with the following data:
name Ahmed with member ID 12347, born on 12/11/2001, who has paid his subscription.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
Topic 2: Classes, Inheritance, Containment___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
21
___________________________________________________________________________________________________
[3]
1 (a)
(b) Example Pascal Type Employee = CLASS PUBLIC procedure SetEmployeeName Procedure SetEmployeeID Procedure CalculatePay PRIVATE EmployeeName : STRING EmployeeID : STRING AmountPaidThisMonth : Currency END;
Mark as follows: Class header (1 mark) PUBLIC and PRIVATE used correctly (1 mark)
EmployeeName + EmployeeID (1 mark)
AmountPaidThisMonth (1 mark)
Methods x 3 (1 mark) Example VB Class Employee Private EmployeeName As String Private EmployeeID As String Private AmountPaidThisMonth As Decimal Public Sub SetEmployeeName() End Sub Public Sub SetEmployeeID() End Sub Public Sub CalculatePay() End Sub
Example Python Class Employee(): def __init__(self): self.__EmployeeName = "" self.__EmployeeID = "" self.__AmountPaidThisMonth = 0 def SetEmployeeName(self, Name): self.__EmployeeName = Name def SetEmployeeID(self, ID): self.__EmployeeID = ID def SetAmountPaidThisMonth(self, Paid):
self.__AmountPaidThisMonth = Paid [max 5]
Topic 2: Mark Scheme___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
94
___________________________________________________________________________________________________
1
A queue Abstract Data Type (ADT) has these associated operations:
• create queue • add item to queue • remove item from queue
The queue ADT is to be implemented as a linked list of nodes.
Each node consists of data and a pointer to the next node.
(a) The following operations are carried out:
CreateQueue AddName("Ali") AddName("Jack") AddName("Ben") AddName("Ahmed") RemoveName AddName("Jatinder") RemoveName
Add appropriate labels to the diagram to show the final state of the queue. Use the space on the left as a workspace. Show your final answer in the node shapes on the right:
[3]
9608/42/M/J/15 Q6
Topic 3: Linked List, Queue, Stack, Binary Tree, Hash Table
Topic 3: Linked List, Queue, etc...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
168
___________________________________________________________________________________________________
2
A stack Abstract Data Type (ADT) has these associated operations:
• create stack • add item to stack (push) • remove item from stack (pop)
The stack ADT is to be implemented as a linked list of nodes.
Each node consists of data and a pointer to the next node.
(a) There is one pointer: the top of stack pointer, which points to the last item added to the stack. Draw a diagram to show the final state of the stack after the following operations are carried
out.
CreateStack Push("Ali") Push("Jack") Pop Push("Ben") Push("Ahmed") Pop Push("Jatinder")
Add appropriate labels to the diagram to show the final state of the stack. Use the space on the left as a workspace. Show your final answer in the node shapes on the right:
[3]
9608/43/M/J/15 Q5
Topic 3: Linked List, Queue, etc...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
172
___________________________________________________________________________________________________
3
A binary tree Abstract Data Type (ADT) has these associated operations:
• create the tree (CreateTree) • add an item to tree (Add) • output items in ascending order (TraverseTree)
(a) Show the final state of the binary tree after the following operations are carried out.
CreateTreeAdd("Dodi")Add("Farai")Add("Elli")Add("George")Add("Ben")Add("Celine")Add("Ali")
[4]
9608/41/O/N/15 Q4
Topic 3: Linked List, Queue, etc...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
176
___________________________________________________________________________________________________
Head Ben
Ahmed
Tail Jatinder 0
1 mark for Head and Tail pointers 1 mark for 3 correct items – linked as shown 1 mark for correct order with null pointer in last nod [3]
(b) (i)
Queue
HeadPointer Name Pointer
0 [1] 2
[2] 3
TailPointer [3] 4
0 [4] 5
[5] 6
FreePointer [6] 7
1 [7] 8
[8] 9
[9] 10
[10] 0
Mark as follows: HeadPointer =0 & TailPointer = 0
FreePointer assigned a value
Pointers[1] to [9] links the nodes together
Pointer[10] = 'Null' [4]
1 (a)
Topic 3: Mark Scheme___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
225
___________________________________________________________________________________________________
1
Data is stored in the array NameList[1:10]. This data is to be sorted.
(a) (i) Complete the pseudocode algorithm for an insertion sort.
FOR ThisPointer ← 2 TO .................................................
// use a temporary variable to store item which is to
// be inserted into its correct location
Temp ← NameList[ThisPointer]
Pointer ← ThisPointer – 1
WHILE (NameList[Pointer] > Temp) AND .................................................
// move list item to next location
NameList[....................................] ← NameList[....................................]
Pointer ← .................................................
ENDWHILE
// insert value of Temp in correct location
NameList[....................................] ← .................................................
ENDFOR [7]
(ii) A special case is when NameList is already in order. The algorithm in part (a)(i) is applied to this special case.
Explain how many iterations are carried out for each of the loops.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...................................................................................................................................... [3]
9608/42/M/J/15 Q5
Topic 4: Algorithms Binary Search, Insertion Sort, Bubble Sort
Topic 4: Algorithms Binary Search...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
254
___________________________________________________________________________________________________
2 NameList is a 1D array that stores a sorted list of names. A programmer declares the array in pseudocode as follows:
NameList : Array[0 : 100] OF STRING
The programmer wants to search the list using a binary search algorithm.
The programmer decides to write the search algorithm as a recursive function. The function, Find, takes three parameters:
• Name, the string to be searched for• Start, the index of the first item in the list to be searched• Finish, the index of the last item in the list to be searched
The function will return the position of the name in the list, or −1 if the name is not found.
Complete the pseudocode for the recursive function.
FUNCTION Find(BYVALUE Name : STRING, BYVALUE Start : INTEGER, BYVALUE Finish : INTEGER) RETURNS INTEGER
// base case
IF .............................................................................................................................................
THEN
RETURN −1
ELSE
Middle ..................................................................................................................
IF ................................................................................................................................
THEN
RETURN ...........................................................................................................
ELSE // general case
IF SearchItem > .........................................................................................
THEN
.............................................................................................................
ELSE
.............................................................................................................
ENDIF ENDIF
ENDIF
ENDFUNCTION [7]
9608/41/M/J/17 Q3
Topic 4: Algorithms Binary Search...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
257
___________________________________________________________________________________________________
3 The array Numbers[0 : Max] stores numbers. An insertion sort can be used to sort these numbers into ascending order.
Complete the following pseudocode for the insertion sort algorithm.
FOR Pointer 1 TO (Max - 1)
ItemToInsert .......................................................................................
CurrentItem ........................................................................................
WHILE (CurrentItem > 0) AND (Numbers[CurrentItem – 1] > ItemToInsert)
Numbers[........................................................] Numbers[CurrentItem - 1]
CurrentItem CurrentItem – 1
ENDWHILE
Numbers[CurrentItem] ...........................................................................
ENDFOR [4]
(b) Identify two features of the array Numbers that would have an impact on the performance of this insertion sort algorithm.
1 ................................................................................................................................................
2 ................................................................................................................................................ [2]
(a) 9608/42/O/N/17 Q4
Topic 4: Algorithms Binary Search...___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
258
___________________________________________________________________________________________________
(i) FOR ThisPointer � 2 TO 10 // use a temporary variable to store item which is to
// be inserted into its correct location
Temp � NameList[ThisPointer]
Pointer � ThisPointer – 1
WHILE (NameList[Pointer] > Temp) AND (Pointer > 0)
// move list item to next location
NameList[Pointer + 1] � NameList[Pointer]
Pointer � Pointer - 1
ENDWHILE
// insert value of Temp in correct location
NameList[Pointer + 1] Temp�
ENDFOR
1 mark for each gap filled correctly [7] (ii) The outer loop (FOR loop) is executed 9 times (1 mark)
it is not dependant on the dataset (1 mark)
The Inner loop (WHILE loop) is not entered (1 mark) as the condition is already false at the first encounter (1 mark) [max 3]
(b) (i) outer loop is executed 9 times (1 mark) inner loop is executed 9 times (for each iteration of the outer loop) (1 mark) not dependant on the dataset (1 mark) [max 2]
(ii) NumberOfItems � 10
REPEAT
NoMoreSwaps � TRUE
FOR Pointer � 1 TO NumberOfItems – 1 IF NameList[Pointer] > NameList[Pointer + 1] THEN
NoMoreSwaps � FALSE
Temp � NameList[Pointer]
NameList[Pointer] � NameList[Pointer + 1]
NameList[Pointer + 1] � Temp ENDIF ENDFOR
NumberOfItems � NumberOfItems - 1 UNTIL NoMoreSwaps = TRUE
Mark as follows:
• change outer loop to a REPEAT/WHILE loop (1 mark)
• FOR loop has variable used for final value (1 mark)
• Initialise Boolean variable to TRUE (1 mark)
• set Boolean variable to FALSE in correct place (1 mark)
• number of items to consider on each pass decrements (1 mark)
•
Correct stopping condition for REPEAT loop (1 mark) [max 5]
1 (a)
Topic 4: Mark Scheme___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
268
___________________________________________________________________________________________________
1
The table shows assembly language instructions for a processor which has one general purpose register – the Accumulator (ACC).
InstructionExplanation
Op Code Operand
LDM #n Immediate addressing. Load the number n to ACC
LDD <address> Direct addressing. Load the contents of the given address to ACC
STO <address> Store the contents of ACC at the given address
ADD <address> Add the contents of the given address to the ACC
INC <register> Add 1 to the contents of the register
CMP <address> Compare the contents of ACC with the contents of <address>
JPN <address> Following a compare instruction, jump to <address> if the compare was False
END Return control to the operating system
(a) (i) Dry-run this assembly language program using the trace table.
500 LDD 512
501 ADD 509
502 STO 512
503 LDD 511
504 INC ACC
505 STO 511
506 CMP 510
507 JPN 500
508 END
509 7
510 3
511 0
512 0
9608/42/O/N/15 Q5
Topic 5 Assembly Language
Topic 5: Assembly Language___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
274
___________________________________________________________________________________________________
2 The following table shows part of the instruction set for a processor which has one general purpose register, the Accumulator (ACC), and an index register (IX).
Instruction
ExplanationOp code Operand
LDM #n Immediate addressing. Load the number n to ACC.
LDD <address> Direct addressing. Load the contents of the given address to ACC.
LDX <address>Indexed addressing. Form the address from <address> + the contents of the index register. Copy the contents of this calculated address to ACC.
LDR #n Immediate addressing. Load the number n into IX.
STO <address> Store the contents of ACC at the given address.
INC <register> Add 1 to the contents of the register (ACC or IX).
DEC <register> Subtract 1 from the contents of the register (ACC or IX).
CMP <address> Compare the contents of ACC with the contents of <address>.
CMP #n Compare the contents of ACC with number n.
JPE <address> Following a compare instruction, jump to <address> if the compare was True.
JPN <address> Following a compare instruction, jump to <address> if the compare was False.
OUT Output to the screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.
A programmer is writing a program that outputs a string, first in its original order and then in reverse order.
The program will use locations starting at address NAME to store the characters in the string. The location with address MAX stores the number of characters that make up the string.
The programmer has started to write the program in the table opposite. The Comment column contains descriptions for the missing program instructions.
Complete the program using op codes from the given instruction set.
9608/41/O/N/16 Q3
Topic 5: Assembly Language___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
276
___________________________________________________________________________________________________
The numerical difference between the ASCII code of an upper case letter and the ASCII code of its lower case equivalent is 32 denary (3210).
For example, 'F' has ASCII code 70 and 'f' has ASCII code 102.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
The bit patterns differ only at bit number 5. This bit is 1 if the letter is lower case and 0 if the letter is upper case.
9608/42/O/N/16 Q3 3(a)
(i) A program needs a mask to ensure that a letter is in upper case.
Write the binary pattern of the mask in the space provided in the table below.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
Mask
Give the bit-wise operation that needs to be performed using the mask and the ASCII code.
.......................................................................................................................................[2]
(ii) A program needs a mask to ensure that a letter is in lower case.
Write the binary pattern of the mask in the space provided in the table below.
Bit number
7 6 5 4 3 2 1 0
ASCII code ASCII code in binary
70 0 1 0 0 0 1 1 0
102 0 1 1 0 0 1 1 0
Mask
Give the bit-wise operation that needs to be performed using the mask and the ASCII code.
.......................................................................................................................................[2]
Topic 5: Assembly Language___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
278
___________________________________________________________________________________________________
(i)
Memory Address
Accumulator 509 510 511 512
0 7 3 0 0
7 7
0
1 1
7
14 14
1
2 2
14
21 21
2
3 3
3 marks 1 mark 1 mark
If values changed in column 509 or 510 don’t give marks for 511/512 [5]
(ii) stores the counter value for ….// acts as a control variable/counter How many times the loop has been performed // control the loop
Ignore re-stating the steps [2]
(b) LDM #12 (must be instruction before storage)STO 509 (must be final instruction)
1 mark for each instruction [2]
1 (a)
Topic 5: Mark Scheme ___________________________________________________________________________________________________Computer Science Paper 4 Topical
By: ALI AKRAM Airport Road | Bahria Town | Johar Town
299
___________________________________________________________________________________________________