Assembler

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Assembler

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does an assembler translate?
A Assembly language into machine code
B Machine code into assembly language
2. Which statement about an assembler is correct?
A Its output is a high-level language program
B Its output is machine code the CPU can run
3. Which language is the INPUT to an assembler?
A Assembly language
B Python
4. Which translator would you use for a program written in assembly language?
A A compiler
B An assembler
5. How does an assembler treat each mnemonic such as ADD or LDA?
A It becomes one machine code instruction
B It becomes many lines of high-level code

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1assembler Aassembly language -> assembler -> machine code
2LDA 5 BAn assembler translates assembly language, not a high-level language. Translating high-level code is the job of a compiler or interpreter.
3An assembler takes assembly language as input and gives machine code as output Cassembler output: 10110000 01100001
4Machine code produced by the assembler can be run directly by the CPU DOne assembly mnemonic line that the assembler turns into one machine code instruction
5An assembler translates a high-level language program into machine code EA translator that converts an assembly language program into machine code
6One assembly mnemonic is turned into many machine code instructions by the assembler FEach mnemonic becomes exactly one machine code instruction, so it is a one-to-one translation, not one-to-many.

Definitions

assembler

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
assembly language -> _________ -> machine code
2.
assembly language -> assembler -> ____________
3.
LDA #5 ___ #3 ; add 3 to the accumulator STA 20
4.
high-level code -> ________ -> machine code
5.
Each mnemonic becomes ___ machine code instruction

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A input = assembly program
B translator = interpreter
C output = machine code
D CPU runs the output
Question 2
A source: assembly language
B translator: assembler
C output: high-level code
D run by: CPU
Question 3
A LDA 20
B STO 21
C HLT
D # 1 mnemonic = 3 instructions
Question 4
A source = assembly_file
B mc = assembler(source)
C cpu.run(source)
Question 5
A Assembler input:
B high-level language program
C Assembler output:
D machine code program

Answer Key

Assembler
Section A: Quick Questions
Q1
A — Assembly language into machine code
Q2
B — Its output is machine code the CPU can run
Q3
A — Assembly language
Q4
B — An assembler
Q5
A — It becomes one machine code instruction
Section B: Match the Pairs
Q1
assembler → A translator that converts an assembly language program into machine code
Q2
LDA 5 → One assembly mnemonic line that the assembler turns into one machine code instruction
Q3
An assembler takes assembly language as input and gives machine code as output → assembly language -> assembler -> machine code
Q4
Machine code produced by the assembler can be run directly by the CPU → assembler output: 10110000 01100001
Q5
An assembler translates a high-level language program into machine code → An assembler translates assembly language, not a high-level language. Translating high-level code is the job of a compiler or interpreter.
Q6
One assembly mnemonic is turned into many machine code instructions by the assembler → Each mnemonic becomes exactly one machine code instruction, so it is a one-to-one translation, not one-to-many.
Section C: Definitions
Q1
assembler — A translator that converts an assembly language program into machine code, so the CPU can run it. Each mnemonic becomes one machine code instruction.
Section D: Fill in the Blanks
Q1
assembly language -> assembler -> machine code
Q2
assembly language -> assembler -> machine code
Q3
LDA #5 ADD #3 ; add 3 to the accumulator STA 20
Q4
high-level code -> compiler -> machine code
Q5
Each mnemonic becomes one machine code instruction
Section E: Spot the Error
Q1
B — The translator that converts an assembly language program into machine code is an assembler, not an interpreter. It should be translator = assembler.
Q2
C — An assembler outputs machine code, not high-level code. The line should be output: machine code.
Q3
D — Each assembly mnemonic is translated into exactly one machine code instruction. It should be 1 mnemonic = 1 instruction.
Q4
C — The CPU can only run machine code. It must run the assembler's output, so the line should be cpu.run(mc), not the assembly source.
Q5
B — The input to an assembler is an assembly language program, not a high-level language program. Line 2 should be assembly language program.