r/computerscience • • 2h ago

Help how do computers access more data then their processors have physical address space

ive been googling and can't figure this out

so like Disks, Drives, ect,

for example, 32 bit x86 systems don't even have enough address space to read 1 miniCD. Which can take up too, if I did my math right, 44 bits worth of addresses,

but I know they, in fact did, same with hard drives.

I know older systems (Like early Nintendo consoles) used bank switching, is it a similar concept?

10 Upvotes

14 comments sorted by

3

u/dariusbiggs 1h ago

just because you only have a 32 bit CPU doesn't mean you can't work on 64 bit numbers, just split the big thing into the upper and lower parts and do the math on those.

Which then gives you the concepts of pagination or blocks/sectors. Page 0 (we start at 0) gets the first 232 bits of data, page 1 gets the next 232, etc. Or with blocks you can say, this thing is divided into blocks of 4096 bits (212), and we can have 232 of them. That gives us those 44bits. Increase the size of the blocks and you can store more at the expense of reading more data in latger chunks.

There are a myriad of ways to solve that problem, it's not a complicated one.

In the low level Assembly language for example you have CPU registers called AH, and AL, (8 bits each) which make up the high bits, and low bits respectively of AX (16 bits), which represents the lower half of EAX (32 bits), which is the lower half of RAX (64 bits).

That is one way the systems evolved from 8 to 16 to 32 to 64 bits.

1

u/0boy0girl 1h ago

this is the answer I was looking for thank you sm

8

u/tcpukl 2h ago

It's just loading different days into ram off disk as it's needed. You can't see it all at once. Your Kindle doesn't load the entire book into ram. It's as you open pages.

1

u/khedoros 1h ago

"Primary storage" is storage directly accessible by the CPU. That's often data like firmware ROM, the main system memory, memory-mapped hardware registers, etc. That's all the stuff that has to have a place in the computer's memory map, and it's the category where bank-switching can be useful (like for the systems in the 80s with a 16-bit address space, but ROMs that could need more bits to address).

"Secondary storage" isn't directly accessible to the CPU; the addresses of a block device like a hard drive or optical drive aren't mapped into the CPU's address space. In a PC, a drive controller's registers are exposed to the CPU via either port-mapped or memory-mapped I/O, and there's a protocol for sending commands to the drive controller to read/write chunks of data from specific blocks on the storage device itself and get them into CPU-accessible memory. There are different generations of interface protocols, and different protocols used for different device types, so exact details vary.

1

u/0boy0girl 1h ago

okay thank you this is very helpful with my understanding, ive rencent wanted to know how computers work on a hardware level, the most accessible path is nes and gameboy homebrew, but those are very different to PCs or even later consoles, so I'm very lost trying to make the transition

1

u/khedoros 28m ago

In a sense, the NES has a comparable situation. The CPU and PPU have separate memory maps. The CPU's is 16 bits, RAM taking up some of the lower area, game ROM mapped to the top half, and a bunch of control registers in between. The PPU's is 14 bits, and isn't mapped into the CPU's address space at all.

So, you read/write data from/to the PPU through some registers (which are mapped into the CPU's address space), setting a PPU address, then reading/writing the data that's stored in the PPU's RAM/ROM.

1

u/0boy0girl 18m ago

never thought about that, thanks for pointing that out!

3

u/four_reeds 2h ago

The processors have a catch system (actually, usually more than two layers of cache) into which instructions are data are read. You are correct that it is rare that entire programs can fit in the cache(s) so the first chunk gets read in and operations begin. Eventually, most of the stuff in the cache is read or operated on and a new stuff gets loaded in and processing resumes.

That is s is an oversimplification. A lot of things are happening in modern processors sometimes in sequence, sometimes in parallel. Then there are other layers of complexity when you think about process scheduling, preemption and resuming.

2

u/jmtd CS BSc 2001-04, PhD 2017- 1h ago

  32 bit x86 systems don't even have enough address space to read 1 miniCD

32 bits is enough to address 4GiB. For larger, look up PAE

1

u/TheologyFan 2h ago

Drives are already slow, no reason why you can’t use 2 32 addresses to select where you want to read from

1

u/somewhereAtC 1h ago

Working with limited memory has been a research topic since computers began. You might find the writings of Knuth interesting, where he describes algorithms to sort dozens of megabytes of data using 3 or 4 tape drives, on a CPU having only a few kilobytes RAM.

1

u/zeekar 1h ago

Processor address lines only matter for accessing RAM, which is a relatively small amount of memory that only remembers stuff while the computer is turned on. The actual code that is running at any time has to live in RAM, but other than that it's up to the program what to keep there. When computers need data from the outside world, they fetch it a little at a time and copy it into RAM, which is the only place they can do anything with it.

Modern computers have other processors besides the CPU just for input/output, so the CPU doesn't even have to do the copying part. It just issues a request that says something like "Hey, I need this sector from the disk drive", and then the disk controller copies the data from that sector into a buffer in RAM.

1

u/claytonkb 1h ago

I'm going to over-simplify a bit, but here's the basic answer to your questions...

x86 is a von Neumann architecture: it consists of CPU, memory and I/O. Memory refers to the high-speed memory, such as DDR5 memory (also, RAM or DRAM). There are other memories on your motherboard besides the main memory, but we'll keep it simple here. The hard-disk or any other similar device, is called storage or mass-storage.

While both memory and storage do essentially the same thing (storing data), there are three important differences: 1) RAM is volatile (the stored bytes disappear when the RAM chips lose power) whereas a hard-disk / flash-USB / etc. is not, and 2) RAM is fast while the hard-drive is very slow (hundreds or thousands of times worse latency, and many times lower bandwidth) and 3) RAM is not nearly as dense as a mass-storage device (1TB of RAM takes up a lot of physical space, whereas a 10TB hard-drive is much smaller and denser).

The CPU accesses RAM directly -- the motherboard design ensures that there is a minimum-latency, high-bandwidth connection between CPU and RAM in order to utilize the RAM to its maximum. Storage devices, however, are not accessed directly by the CPU. Instead, the CPU issues I/O requests to the chipset. The I/O request is something like, "Please read X bytes of data from the bus device with bus-address Y according to instructions Z." The chipset is essentially the bus master of the main bus of the motherboard (along with a bunch of other roles it performs). Note: on SoC, the chipset is electrically integrated, but still logically separate. The CPU sends an I/O packet to the chipset which routes the packet to the correct device on the main bus, in this case, a hard-disk.

The hard-disk expects to receive command packets with a certain format, and the OS or installed drivers know how to format those packets. Once a command packet is sent to the hard-drive, its onboard controller processes the packet and responds accordingly. If the packet is a read-command, the controller will read the appropriate section of the disk and reply to the chipset with the requested data from the disk. If it is a write-command, the controller will receive the data from the chipset and write it to disk.

PS: This is a very generic description of a generic computing architecture, I am not giving a spec-accurate description of x86-based PC architecture which would take us down a bunch of historical rabbit trails...

1

u/rupertavery64 54m ago edited 49m ago

In the case of disk storage, data isn't accessed through the address bus. The drive is an I/O device that is located at a memory address, but the data is accessed using commands and through logical block addressing.

So the device controller finds the data and sends it over in chunks. For SSDs it would probably look like bank switching. For hard disks, the LBA is translated into cylinders heads and sectors.