Electronic – How to access more than 15 addresses of data from the 8 bit incomplete computer

eepromramregister

Last year I started researching upon how computers work, so I started making one, at least on paper last month, but I ran into a serious problem that isn't getting a satisfying answer from any article or past question.

If I have an 8 bit memory, and according to some good reliable sources like Ben Eater and crash course computer science, half of the byte in memory is the opcode and the other half is the address which means 4 bit or 15 opcodes which is enough, but just 15 addresses which I think is not sufficient to cover a 32 kB EEPROM, so I wonder how am I supposed to get more than 15 addresses accessed from the computer or the instructions itself? Let's say I have an opcode 0101, and I want to refer that to the address 16, I can't because the highest I can go is 01011111, which is just doing something to highest of 15 addresses but if this is the reality, a 64 bit device should only be able to use 4 GB of RAM, but there are 16 GB also, so how can I fix this problem?

If I have a look at a MOS6502 Microprocessor, it has 16 address pins, so does it mean that it is a 16bit address register and that it is designed for working with a 64kb memory and is that why Ben Eater in his EEPROM video turned the EEPROM off using the Chip enable whenever the processor fetches beyond the 32kb range of the EEPROM.

Best Answer

the half of the byte in memory is the opcode and other half is the address

Well, that's one way of doing it, but there are lots of ways of doing it.

Instructions don't have to contain the address. Instructions containing the address or operand is usually known as "immediate" mode, but there are various other addressing modes. You could have those four bits tell you which register contains the address to use, and the registers can be longer.

The 6502 has a number of different addressing modes that use its 8-bit registers, its 16-bit program counter, and immediate addresses.

Instructions don't have to be one byte (or word) long. It's certainly easier to do it this way, but you can have multi-byte instructions. X86 is notorious for this; instructions can be anything from one byte long to fifteen if you add enough prefixes and modifiers.

As you can see from the 6502 modes page, there is a "load immediate" mode which has a one byte instruction followed by two bytes defining the address to load from.

(I strongly suggest finding some good non-video sources to learn from, such as "NAND to Tetris")