A-level题目:为何从HLL代码转二进制仅认定Compiler为正确翻译器?
Total := 60 + 10; a Compiler (Not an Interpreter) in A-level Questions? Great question—this is a classic point of confusion in A-level computing, so let’s break down the reasoning clearly based on how these translators are defined in exam contexts:
First, let’s recap the core differences between compilers and interpreters as taught in A-level courses:
- Compiler: Translates an entire (or complete section of) high-level language (HLL) program into fully formed assembly or machine code in one batch process. The resulting target code is a standalone output that can be stored and executed later without needing the original HLL code or the translator itself.
- Interpreter: Executes HLL code line-by-line, translating each instruction just before it runs. It doesn’t generate a persistent, complete set of assembly or machine code as a separate product—there’s no reusable output file, just immediate execution.
Now look at the example given:
We have a full, corresponding set of assembly code (LD #60 ADD #10 ST Total) and binary machine code (00101000 00111100 00111000 00001010 01100000 00101001) for the HLL line Total := 60 + 10;. This is a clear sign that the translator produced a complete, static target code output—not just executing the instruction on the fly.
An interpreter would never generate these full assembly/binary code blocks. Instead, it would read the line, calculate 60 + 10, store the result in Total, and move on—no permanent assembly or machine code would be created as part of the process.
In A-level assessments, this distinction is strict: if a translator produces a complete, reusable target code (like the assembly/binary here), it’s categorized as a compiler. Interpreters only handle execution without generating such outputs, so they don’t fit this scenario.
内容的提问来源于stack exchange,提问作者user9156598

