About the addressing method.

Asked 1 years ago, Updated 1 years ago, 84 views

About the addressing method.

Direct Addressing Method
INDEX ADDRESSING SYSTEM
Base addressing method
Relative Addressing Method
Indirect Addressing Method
Register Addressing Method
Immediate Addressing Method

I understand the difference between these seven.
But what exactly is it used for?
I don't understand the historical background of why this difference in thought was born.
I think it's probably about OS design thinking...

algorithm assembly-language

2022-09-30 19:18

3 Answers

In the past, the program was placed in a fixed position in memory, and the address indicating where the data and instructions were located was fixed.Then, all addressing was "direct (absolute)" and it was fine.The programmer knows the address where the program is loaded and directly specifies instructions such as "Where to fly."

However, it has become common practice to load various programs into memory, to place them in places other than memory to make up for the lack of memory, and to change the loading location every time to prevent unauthorized access to them.Then, the actual address will not be known until the program is running.

In that case,

  • Address ** from where you are
  • Address ** off the starting point
  • Because I put the address in the variable

I think that's why various addressing methods have been created.

As for Wikipedia, you may want to read instructions such as location-independent code and relocatable binary.


2022-09-30 19:18

Chicken comes first or egg comes first, but
·Design CPU addressing to make it easier for the compiler to create
·Design the compiler to fit the addressing of the existing CPU
That's right.
The OS doesn't really matter. So we're going to build the OS to fit the CPU.Yes)

Assume 32-bit
C/C++ will provide examples of code and instructions with a temporary CPU (assuming x86, SH, RX, etc.) for explanation

Direct Addressing Global static variables are placed at static addresses.

int global_scoped_static_variable;
void some_func(){
  global_scoped_static_variable=1;
}

Direct addressing instructions can be generated for this substitution
MOV.L#1, @_global_scoped_static_variable

Immediate Addressing
int*p=&global_scoped_static_variable for the same source code. MOV.L#_global_scoped_static_variable, R3

Register Dressing If ++*p; follows the previous source code,
INC.L@R3
Alternatively, function calls through function pointers are JSR@R3 and so on.

Base addressing, base + index addressing
Used to handle array variables.
array[NN]; if array[x]=2; is present for interray[NN); Base address = array
Index = x
Multiplication factor = 4
This allows MOV.L [EBX+EAX*4], 2.

Others omitted (homework)

The smaller the number of instruction words, the faster the program is.
Addressing modes and compilers have been designed to do so.
It's almost finished, so the addressing mode doesn't seem to change much in the future.


2022-09-30 19:18

Classification of assembly language instructions.
For example, a microcomputer datasheet has an instruction table.So I write the program while checking the addressing mode.

I made it possible to express it succinctly so as not to increase the amount and complexity of the instructions.Without this function, it would be almost the same size as writing a program in machine language.Because the assembler extends within the functionality of the CPU, it has the advantage of not having to understand complex processing descriptions, detailed architectures close to hardware, or duplicate code.That's why the number of execution states is different, especially in microcomputers, even though the outgoing hydrologes are managed by the same clock.

While addressing modes in the OS, page management Physical Addressing Mode and Virtual Addressing Mode refer to physical and virtual address spaces.Moreover, it is a minor expression.If you are studying at the same time, be careful not to confuse them.


2022-09-30 19:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.