📚 AS CAIE Computer Science: Mock Unit Test Analysis | AS CAIE 计算机:单元测试模拟卷解析
This article provides a thorough walkthrough of a mock unit test designed for the AS Cambridge International (CAIE) Computer Science syllabus. The questions cover core topics such as data representation, computer architecture, networking, logic, and databases. Each question is presented with a detailed explanation in both English and Chinese to support bilingual learners and help them master key concepts for the exam.
本文为 AS 剑桥国际(CAIE)计算机科学课程设计的一套单元测试模拟卷提供详细解析。题目涵盖数据表示、计算机体系结构、网络、逻辑和数据库等核心主题。每道题均配有中英文双语详解,助力双语学习者掌握考试重点。
1. Question 1: Binary to Hexadecimal Conversion | 第1题:二进制与十六进制转换
Question: Convert the binary number 11011010₂ into hexadecimal. Show your grouping method.
题目: 将二进制数 11011010₂ 转换为十六进制,并展示分组过程。
To convert binary to hexadecimal, group the binary digits into sets of four starting from the right. Add leading zeros if needed. The given binary number is 11011010. Group as 1101 1010. Convert each nibble: 1101₂ corresponds to D (decimal 13) and 1010₂ corresponds to A (decimal 10). Therefore, the hexadecimal equivalent is DA₁₆.
将二进制转换为十六进制,从右侧开始每四位一组,必要时在左侧补零。给定的二进制数为 11011010,分组为 1101 1010。转换每个半字节:1101₂ 对应 D(十进制 13),1010₂ 对应 A(十进制 10)。因此,十六进制结果为 DA₁₆。
| Binary (4-bit) | Hexadecimal |
|---|---|
| 1101 | D |
| 1010 | A |
This method is efficient because each hex digit exactly represents four bits, making it easy to read and debug memory dumps.
这种方法非常高效,因为每个十六进制数字正好表示四个二进制位,便于阅读和调试内存转储。
2. Question 2: Two’s Complement Addition and Overflow | 第2题:二进制补码加法与溢出检测
Question: Using 8-bit two’s complement, perform the addition 10001101 + 10010110. State whether overflow occurs and justify your answer.
题目: 使用8位补码计算 10001101 + 10010110。判断是否发生溢出并说明理由。
Both numbers are negative because their most significant bits (MSB) are 1. Add them as binary integers:
10001101 + 10010110 = 1 00100011 (9 bits)
In 8-bit arithmetic, we discard the carry out beyond the 8th bit, leaving 00100011 as the sum. Since the result’s MSB is 0, it is positive. Adding two negative numbers produced a positive result, which is impossible; therefore, overflow has occurred. We can also check the carry into the sign bit (8th bit) and the carry out: carry into sign bit = 1 (from bit 7), carry out = 1. Overflow = carry_in XOR carry_out = 1 XOR 1 = 0? Actually, the standard overflow flag is set when carry into sign bit differs from carry out. Here they are both 1, so no overflow by that rule? Let’s recalculate carefully. Adding 10001101 (-115) and 10010110 (-106): bitwise addition: bit 0: 1+0=1; bit 1: 0+1=1; bit 2: 1+1=0 carry 1; bit 3: 1+0+carry1=0 carry1; bit 4: 0+1+carry1=0 carry1; bit 5: 0+0+carry1=1; bit 6: 0+0=0; bit 7: 1+1=0 carry 1. So sum bits: 00100011, carry out of sign bit = 1, carry into sign bit (from bit 6 to bit 7) = 0? Bit 6 result was 0, no carry into bit 7 from bit6? Actually we need to examine carry from bit 6 addition: inputs to bit 6 are 0 and 0, plus carry from bit 5? Bit 5 produced a carry? Let’s recalc systematically:
10001101
10010110
bit 0: 1+0=1, no carry
bit 1: 0+1=1, carry 0
bit 2: 1+1=0, carry 1
bit 3: 1+0=1 + carry 1 = 0, carry 1
bit 4: 0+1=1 + carry 1 = 0, carry 1
bit 5: 0+0=0 + carry 1 = 1, carry 0
bit 6: 0+0=0 + carry 0 = 0, carry 0
bit 7: 1+1=0 + carry 0 = 0, carry 1
Thus carry into sign bit (from bit 6 to bit 7) = 0, carry out of sign bit = 1. Since 0 != 1, overflow occurred. This matches the sign observation. So overflow detected.
两个数都是负数,因为其最高有效位(MSB)为1。按二进制整数相加:
10001101 + 10010110 = 1 00100011(9位)
在8位运算中,丢弃超出第8位的进位,得到 00100011 作为和。结果的MSB为0,是正数。两个负数相加得到正数,这不可能;因此发生了溢出。通过进位规则验证:进入符号位的进位(从位6到位7)为0,符号位的进位输出为1,两者不同,所以溢出。答案:溢出发生。
3. Question 3: Floating-Point Binary Representation | 第3题:二进制浮点表示
Question: Represent the decimal number 5.75 in a normalised floating-point binary format with an 8-bit mantissa and a 4-bit exponent, both in two’s complement. The mantissa is assumed to have its binary point after the MSB (like 0.1… format).
题目: 用规范化浮点二进制格式表示十进制数 5.75,尾数8位,指数4位,均使用补码。假定尾数的小数点在最高有效位之后(即 0.1… 格式)。
First, convert 5.75 to binary: 5 = 101₂, 0.75 = 0.11₂, so 5.75 = 101.11₂. Normalise to the form 0.1xxx × 2ᵉ: shift the binary point three places left to get 0.10111 × 2³ (since 101.11 = 0.10111 × 2³). The mantissa becomes 01011100? We need 8-bit two’s complement mantissa: we start with 0.1011100 (8 bits after binary point? Actually, mantissa is stored as fixed point with point after sign bit. The normalised positive number has sign bit 0, then the binary digits. For 0.10111, we write the mantissa as 0.1011100, padding with zeros to make 8 bits: 0 1011100. In two’s complement, positive numbers are same as binary, so mantissa = 01011100. The exponent is 3 in decimal, so 4-bit two’s complement exponent: 3 = 0011₂. Thus the full representation: mantissa 01011100, exponent 0011. Combined: 01011100 0011.
首先,将5.75转换为二进制:5 = 101₂,0.75 = 0.11₂,故 5.75 = 101.11₂。规范化为 0.1xxx × 2ᵉ 形式:将小数点左移三位得 0.10111 × 2³。尾数需要8位补码:正数符号位为0,接着是1011100,补足8位为 01011100。指数为十进制3,用4位补码表示为 0011。因此浮点表示为:尾数 01011100,指数 0011。
4. Question 4: Von Neumann Architecture and Registers | 第4题:冯·诺依曼架构与寄存器
Question: Outline the roles of the Program Counter (PC), Memory Address Register (MAR), Memory Data Register (MDR), and Current Instruction Register (CIR) in the fetch-decode-execute cycle.
题目: 简述程序计数器(PC)、内存地址寄存器(MAR)、内存数据寄存器(MDR)和当前指令寄存器(CIR)在取指-译码-执行周期中的作用。
PC holds the address of the next instruction to be fetched. Its value is copied into MAR. MAR holds the address of the memory location that is to be read from or written to. The address is sent along the address bus. MDR holds the data that has been read from memory or is to be written to memory. It acts as a buffer between the CPU and memory. CIR holds the current instruction while it is being decoded and executed. Together these registers enable the processor to fetch instructions sequentially and execute them.
PC 保存下一条待取指令的地址,其值被复制到 MAR 中。MAR 存放将要读取或写入的内存地址,该地址通过地址总线发送。MDR 存放从内存读取或即将写入内存的数据,充当 CPU 与内存之间的缓冲器。CIR 保存在被译码和执行过程中的当前指令。这些寄存器协同工作,使处理器能够顺序取指并执行。
5. Question 5: Interrupt Handling Process | 第5题:中断处理过程
Question: Describe what happens inside the CPU when an interrupt signal is received during the fetch-decode-execute cycle.
题目: 描述在取指-译码-执行周期中收到中断信号时 CPU 内部发生的情况。
When an interrupt is received, the processor completes execution of the current instruction. It then checks the priority of the interrupt; if it can be serviced, the processor saves the contents of its registers (including PC and status register) onto the stack. The interrupt service routine (ISR) address is loaded into the PC. The ISR executes to handle the interrupt. Upon completion, the saved register values are restored from the stack, and the original program resumes from where it was interrupted.
当接收到中断时,处理器先完成当前指令的执行。然后检查中断优先级;如果可以响应,处理器将寄存器内容(包括 PC 和状态寄存器)保存到堆栈中。中断服务程序(ISR)的地址被装入 PC,ISR 执行以处理中断。完成后,从堆栈恢复保存的寄存器值,原程序从被中断处继续执行。
6. Question 6: Logic Gates and Truth Table | 第6题:逻辑门与真值表
Question: Construct the truth table for the Boolean expression Q = (A AND B) OR (NOT C). Include all possible input combinations.
题目: 构造布尔表达式 Q = (A ∧ B) ∨ (¬C) 的真值表,包含所有可能的输入组合。
There are three inputs, so 2³ = 8 rows. Let’s compute intermediate columns: A AND B, NOT C, then the final OR.
共有三个输入,因此有 2³ = 8 行。计算中间列:A ∧ B、¬C,然后进行或运算。
| A | B | C | A ∧ B | ¬C | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
The output Q is 1 in most cases; it only becomes 0 when both A AND B are false and C is true.
输出 Q 在大多数情况下为1;只有当 A ∧ B 为假且 C 为真时才为0。
7. Question 7: IP Addressing and Subnet Mask | 第7题:IP地址与子网掩码
Question: Given the IP address 192.168.10.65 and subnet mask 255.255.255.224, determine the network address, the first usable host address, and the broadcast address.
题目: 给定 IP 地址 192.168.10.65 和子网掩码 255.255.255.224,求网络地址、第一个可用主机地址和广播地址。
Subnet mask 255.255.255.224 in binary: 11111111.11111111.11111111.11100000. The last octet has 3 ones, so 2⁵ = 32 addresses per subnet (5 host bits). Network address = IP AND mask: 192.168.10.64 (since 65 AND 224 = 64). First usable host: 192.168.10.65. Broadcast address: 192.168.10.95 (64 + 31). Thus the subnet range is 192.168.10.64 – 192.168.10.95.
子网掩码 255.255.255.224 的二进制为 11111111.11111111.11111111.11100000。最后一个字节有3个1,因此每个子网有 2⁵ = 32 个地址(5个主机位)。网络地址 = IP AND 掩码:192.168.10.64(因为 65 AND 224 = 64)。第一个可用主机:192.168.10.65。广播地址:192.168.10.95(64+31)。因此子网范围为 192.168.10.64 – 192.168.10.95。
8. Question 8: SQL Query on a Student Table | 第8题:学生表的SQL查询
Question: A database contains a table Students with fields: StudentID, FirstName, LastName, Grade, TutorGroup. Write an SQL query to retrieve the first and last names of all students in TutorGroup ’12B’ who have a Grade higher than 80. Order the result by LastName ascending.
题目: 数据库包含表 Students,字段有:StudentID、FirstName、LastName、Grade、TutorGroup。编写 SQL 查询,检索 TutorGroup 为 ’12B’ 且 Grade 大于 80 的所有学生的 FirstName 和 LastName,结果按 LastName 升序排序。
SELECT FirstName, LastName FROM Students WHERE TutorGroup = '12B' AND Grade > 80 ORDER BY LastName ASC;
The SELECT clause specifies the columns to return. The WHERE clause filters rows based on the conditions. ORDER BY with ASC ensures alphabetical order by last name. This query yields the required list of high-performing students in that tutor group.
SELECT 子句指定要返回的列,WHERE 子句按条件过滤行,ORDER BY 加 ASC 确保按姓氏字母顺序升序排列。该查询返回该辅导组中表现优异的学生名单。
Published by TutorHao | AS Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply