S
S
sddvxd2017-06-16 11:15:19
assembler
sddvxd, 2017-06-16 11:15:19

How does a processor work with memory?

Good afternoon. I'll ask a number of questions here:
1) Why are pointers and multilevel pointers needed
2) What is an offset
3) How does a computer remember register values ​​if registers are constantly updating values ​​due to other programs

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2017-06-16
@sddvxd

1. For indirect addressing. We do not just refer to the 325th cell, but carry out the calculation, get 325 and refer to the cell with this number. If they received 456, they would turn to the 456th.
This gives a bunch of interesting data structures, and the simplest of them is an array.
A multilevel pointer is already a higher-level matter. So far, I just called a pointer an address in memory. But, excuse me, one-byte integers, two-byte integers, fractional, arrays, strings, other pointers are stored in memory - in general, the concept of “data type” appears at a higher level. And there are pointers to an integer, to a fraction - and to a pointer!
2. The difference between some address and the start of a data structure. For example, we have such a data structure (for simplicity, without alignment).
a : word
b : dword
c : byte
Then field c is at offset 2+4 = 6, and if the head of the structure is at address 124, then field c will be at address 124+6=130.
Also in standard mode, the 8086 - a 16-bit processor with 1 megabyte of addressable memory - had a tricky addressing system called "segment:offset", and the address was calculated using the formula segment 16 + offset. At the same time, it was customary to assume that the segment is unshakable, and we moved along the data structure (which could not exceed 64K), changing the offset.
3. So-called. "context switch" - the OS kernel simply saves registers in memory. A very long task, by the way.

A
Andrey Burov, 2017-06-16
@BuriK666

All answers in this book www.ozon.ru/context/detail/id/20032936

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question