0% found this document useful (0 votes)
10 views

Final 2026 s3 Archi Correction en

Uploaded by

louis.rodetv2.0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Final 2026 s3 Archi Correction en

Uploaded by

louis.rodetv2.0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Computer Architecture – EPITA – S3 – 2022/2023

Key to Final Exam S3


Computer Architecture
Duration: 1 hr 30 min
Write answers only on the answer sheet.
Do not use a pencil or red ink.

Exercise 1 (3 points)
Complete the table shown on the answer sheet. Write down the new values of the registers (except the
PC) and memory that are modified by the instructions. Use the hexadecimal representation. Memory
and registers are reset to their initial values for each instruction.

Initial values: D0 = $FFFF0005 A0 = $00005000 PC = $00006000


D1 = $FFFFFFE0 A1 = $00005008
D2 = $AAAA0018 A2 = $00005010

$005000 54 AF 18 B9 E7 21 48 C0
$005008 C9 10 11 C8 D4 36 1F 88
$005010 13 79 01 80 42 1A 2D 49

Exercise 2 (2 points)
Complete the table shown on the answer sheet. Give the result of the additions and the values of the N, Z,
V and C flags.

Exercise 3 (4 points)
Let us consider the following program. Complete the table shown on the answer sheet.

Main move.l #$ff,d7

next1 moveq.l #1,d1


cmpi.w #$fe,d7
ble next2
moveq.l #2,d1

next2 moveq.l #1,d2


cmpi.b #$fe,d7
ble next3
moveq.l #2,d2

next3 clr.l d3
move.l #518,d0
loop3 addq.l #1,d3
subq.b #2,d0
bne loop3

next4 clr.l d4
clr.l d0
loop4 addq.l #1,d4
dbra d0,loop4 ; DBRA = DBF

Key to Final Exam S3 1/8


Computer Architecture – EPITA – S3 – 2022/2023
Exercise 4 (11 points)
All the questions in this exercise are independent. Except for the output registers, none of the data or
address registers must be modified when the subroutine returns. A string of characters always ends
with a null character (the value zero). For the whole exercise, we assume that the strings of characters are
never empty (they contain at least one character different from the null character).

1. Write the GetStart subroutine that returns the address of the first occurrence of a character in a
string.
Input: A0.L points to a string of characters.
D0.B holds the ASCII code of a character. We call this character C and we assume that it is in
the string pointed to by A0.L.
Output: A0.L points to the first occurrence of C in the string.

Be careful. The GetStart subroutine must contain 4 lines of instructions at the most.

2. Write the GetEnd subroutine that returns the address located right after the last character in a se-
quence of identical characters. We consider that a sequence of identical characters can be made up of
either a single character or several identical characters.
Input: A0.L points to a non-null character in a string. We call this character C.
Output:
• If the character that follows C is different from C, then A0.L will point to the character that fol-
lows C.
• If there are several C characters in a row, then A0.L will point to the character that follows the
last C.

For instance, let us consider the following string: “Heeeellooooo Wooorld”


• If A0.L points to “H”, the returned address will be that of the first “e”.
• If A0.L points to the first “e”, the returned address will be that of the first “l”.
• If A0.L points to the first “l”, the returned address will be that of the first “o”.
• If A0.L points to the first “o”, the returned address will be that of the space character.
• If A0.L points to “r”, the returned address will be that of the last “l”.
• If A0.L points to “d”, the returned address will be that of the null character.

Be careful. The GetEnd subroutine must contain 12 lines of instructions at the most.

Key to Final Exam S3 2/8


Computer Architecture – EPITA – S3 – 2022/2023
3. By using the GetStart and GetEnd subroutines, write the SuccessiveCount subroutine that counts
the number of characters in a sequence of identical characters. Such a sequence is in a string. If sev-
eral sequences based on the same character are in the string, only the first sequence must be taken
into account.
Input: A0.L points to a string of characters.
D0.B holds the ASCII code of a character. We call this character C and we assume that it is in
the string pointed to by A0.L.
Output: D0.L holds the number of C characters in a row from the first C.

For instance, let us consider that A0.L points to the following string: “Heeeellooooo Wooorld”
• If D0.B holds “H”, the returned value will be 1.
• If D0.B holds “e”, the returned value will be 4.
• If D0.B holds “l”, the returned value will be 2.
• If D0.B holds “o”, the returned value will be 5.
• If D0.B holds “W”, the returned value will be 1.
• If D0.B holds “d”, the returned value will be 1.

Be careful. The SuccessiveCount subroutine must contain 12 lines of instructions at the most.

Key to Final Exam S3 3/8


Computer Architecture – EPITA – S3 – 2022/2023

Key to Final Exam S3 4/8


Computer Architecture – EPITA – S3 – 2022/2023

Key to Final Exam S3 – Appendices 5/8


Computer Architecture – EPITA – S3 – 2022/2023

Key to Final Exam S3 – Appendices 6/8


Computer Architecture – EPITA – S3 – 2022/2023

Last name: ............................................. First name: ........................................... Group: ............................


ANSWER SHEET TO BE HANDED IN

Exercise 1
Instruction Memory Register
A0 = $00005004
Example $005000 54 AF 00 40 E7 21 48 C0
A1 = $0000500C

Example $005008 C9 10 11 C8 D4 36 FF 88 No change

MOVE.L #2943,4(A0) $005000 54 AF 18 B9 00 00 0B 7F No change

MOVE.B $5011,34(A2,D1.L) $005010 13 79 79 80 42 1A 2D 49 No change

MOVE.W 18(A0),-24(A0,D2.W) $005000 01 80 18 B9 E7 21 48 C0 No change

Exercise 2
Size Result
Operation N Z V C
(bits) (hexadecimal)

$5D + $6F 8 $CC 1 0 1 0

$87654321 + $ABCDEF00 32 $33333221 0 0 1 1

Exercise 3
Values of registers after the execution of the program.
Use the 32-bit hexadecimal representation.

D1 = $00000002 D3 = $00000003

D2 = $00000002 D4 = $00000001

Key to Final Exam S3 – Answer Sheet 7/8


Computer Architecture – EPITA – S3 – 2022/2023
Exercise 4

GetStart cmp.b (a0)+,d0


bne GetStart

subq.l #1,a0
rts

GetEnd move.l d0,-(a7)

move.b (a0)+,d0

\loop cmp.b (a0)+,d0


beq \loop

subq.l #1,a0
move.l (a7)+,d0
rts

SuccessiveCount move.l a0,-(a7)

jsr GetStart
move.l a0,d0

jsr GetEnd
suba.l d0,a0
move.l a0,d0

move.l (a7)+,a0
rts

Key to Final Exam S3 – Answer Sheet 8/8

You might also like