TutorChase logo
Login
AQA A-Level Computer Science

16.3.4 Addressing Modes

Addressing modes determine how the processor interprets the data (operands) used in instructions. They are crucial in understanding how programs interact with memory and registers to perform tasks.

Immediate addressing

Immediate addressing is one of the simplest and fastest addressing modes. In this mode, the operand is specified directly within the instruction itself. This means the instruction doesn’t refer to a memory location or register to retrieve the data. Instead, the processor uses the value provided in the instruction immediately during execution.

How it works

When an instruction uses immediate addressing, it embeds the actual data as part of the instruction. During the fetch-execute cycle, the processor does not need to perform any additional memory accesses to retrieve the operand because the value is already available.

For example, the instruction:

nginx

LOAD #15

means "load the value 15 directly into the specified register."

The # symbol is commonly used in many assembly languages to indicate immediate data, although this varies between instruction set architectures.

Characteristics of immediate addressing

  • The operand is not a reference to a memory location or register; it is the actual value.

Take your grades to the next level!

UPGRADING TO PREMIUM UNLOCKS
AI Tutor
AI-powered study assistant
instant feedback and guidance
Predicted Papers
Examiner-style predicted papers
based on recent exam trends
Practice Questions
All exam practice questions
by topic for each subject
Study Notes
All detailed revision notes
written by expert teachers
Cheat Sheets
Quick revision summaries
perfect for last-minute review
Past Papers
Complete collection
of practice and past exam papers
Email
Password
Confirm Password
Already have an account?

Practice Questions

FAQ

Immediate addressing is more efficient because it requires fewer processor cycles to complete an instruction. In immediate addressing, the operand (actual data) is embedded directly within the instruction itself. This means the processor retrieves both the operation (opcode) and the data in a single step during the fetch stage of the fetch-decode-execute cycle. There is no need for an additional memory access, which saves time and reduces complexity. In contrast, direct addressing involves a second step: the instruction contains a memory address, so the processor must perform an extra memory fetch to retrieve the actual data stored at that address. Memory access is typically slower than accessing data already within the instruction register. This added step introduces latency and increases the number of processor cycles required to complete the operation. Therefore, immediate addressing speeds up program execution, particularly for simple operations involving constants or fixed values that don’t require memory lookup.

Yes, both immediate and direct addressing can be used within the same assembly program, and doing so is often necessary for efficiency and functionality. Immediate addressing is typically used when working with constant values that are known at the time of writing the program. For example, setting an initial value such as a loop counter to 0 or incrementing a register by a fixed value like 1 would use immediate addressing. This is because it avoids additional memory accesses and simplifies the instruction. On the other hand, direct addressing is used when the program needs to work with variable data that resides in memory. This includes reading input values, accessing data arrays, or storing results after calculations. Using direct addressing allows the program to dynamically retrieve or store information during execution. Combining both modes gives the programmer greater control and flexibility, allowing constants to be embedded while still handling dynamic, changing data stored externally in memory.

The choice of addressing mode can significantly impact the overall size of compiled machine code, especially in systems with limited memory. Instructions using immediate addressing tend to be more compact because they include the actual data value within the instruction itself. These instructions don’t require any additional references or lookups, which helps reduce code length. However, the size of the immediate value is limited by the number of bits available in the operand section of the instruction. If larger values are needed, special handling may be required, such as using multiple instructions. In contrast, direct addressing requires the instruction to contain a full memory address, which can be longer, especially on systems with large address spaces. This can make the compiled code longer, particularly if many such references are needed. While direct addressing offers more flexibility, it comes at the cost of slightly larger and more complex machine code. Efficient use of addressing modes helps balance speed, memory usage, and code size.

A compiler or assembler might choose direct addressing over immediate addressing when the value to be used is not known at compile time or is expected to change during execution. Immediate addressing requires the operand to be a constant, which is only suitable for values that remain fixed throughout the program’s execution. In contrast, direct addressing allows access to values stored in memory, which can be updated dynamically as the program runs. For instance, when dealing with user inputs, sensor readings, or values that are calculated and stored during runtime, direct addressing is essential. Additionally, variables in high-level languages often map to memory locations, and accessing these through direct addressing maintains this one-to-one correspondence. Compilers are also designed to optimise for reusability and flexibility, and direct addressing allows for more generic instructions that adapt to changing memory contents, especially in loops, conditionals, or functions that manipulate external data structures such as arrays or records.

Yes, direct addressing comes with certain limitations and risks that aren’t present in immediate addressing. Since direct addressing involves referencing specific memory locations, any error in the memory address can lead to unintended behaviour, such as accessing the wrong data or overwriting critical memory. These issues can cause data corruption, logical errors, or crashes, especially in low-level systems without memory protection. Direct addressing also introduces dependencies on the structure and stability of memory allocation. If data in memory shifts due to other processes or operations (e.g. dynamic memory allocation or stack operations), the original address may no longer point to the correct data. In contrast, immediate addressing is inherently safer because the value is fixed and embedded within the instruction, eliminating the risk of accidental misaddressing. Furthermore, direct addressing is slower, as it involves extra memory access. Programmers must be cautious with memory management when using direct addressing to avoid such issues, particularly in complex or multi-threaded systems.

Hire a tutor

Please fill out the form and we'll find a tutor for you.

1/2
Your details
Alternatively contact us via
WhatsApp, Phone Call, or Email