0
0
Compiler Designknowledge~30 mins

Target machine model in Compiler Design - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding the Target Machine Model
📖 Scenario: You are learning about how compilers translate programs into instructions that a computer can understand. To do this, the compiler uses a target machine model which describes the computer's features.Imagine you are designing a simple description of a computer's capabilities so a compiler can generate the right instructions.
🎯 Goal: Create a simple description of a target machine model using a dictionary. Then add configuration details, write the main logic to summarize the model, and finally complete the description with a summary statement.
📋 What You'll Learn
Create a dictionary called target_machine with keys: 'registers', 'memory_size', and 'instruction_set' with exact values
Add a variable called max_registers set to 8
Write code to create a list called supported_instructions containing only instructions with names longer than 3 characters
Add a final summary string called summary describing the target machine model
💡 Why This Matters
🌍 Real World
Compilers need to know the target machine's features to generate correct machine code that runs efficiently on that computer.
💼 Career
Understanding target machine models is important for compiler developers, systems programmers, and anyone working on low-level software optimization.
Progress0 / 4 steps
1
Create the target machine dictionary
Create a dictionary called target_machine with these exact entries: 'registers': 16, 'memory_size': 65536, and 'instruction_set': ['LOAD', 'STORE', 'ADD', 'SUB', 'JMP'].
Compiler Design
Need a hint?

Use curly braces {} to create a dictionary. Keys are strings and values are numbers or lists.

2
Add max_registers configuration
Add a variable called max_registers and set it to 8.
Compiler Design
Need a hint?

Just write max_registers = 8 on a new line.

3
Filter supported instructions
Create a list called supported_instructions that contains only the instructions from target_machine['instruction_set'] whose names have more than 3 characters.
Compiler Design
Need a hint?

Use a list comprehension to filter instructions by length.

4
Add summary description
Add a string variable called summary that describes the target machine model as: 'Target machine has 16 registers, 65536 memory size, and supports 2 instructions longer than 3 characters.'
Compiler Design
Need a hint?

Write the exact string inside single quotes and assign it to summary.