Final 2026 s3 Archi Correction en
Final 2026 s3 Archi Correction en
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.
$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.
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
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.
Be careful. The GetEnd subroutine must contain 12 lines of instructions at the most.
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.
Exercise 1
Instruction Memory Register
A0 = $00005004
Example $005000 54 AF 00 40 E7 21 48 C0
A1 = $0000500C
Exercise 2
Size Result
Operation N Z V C
(bits) (hexadecimal)
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
subq.l #1,a0
rts
move.b (a0)+,d0
subq.l #1,a0
move.l (a7)+,d0
rts
jsr GetStart
move.l a0,d0
jsr GetEnd
suba.l d0,a0
move.l a0,d0
move.l (a7)+,a0
rts