r/AskComputerScience • u/10011011011001 • Apr 08 '21
I have three questions regarding computers: 1. How do 8-bit computers have more than 256 bytes of RAM, 2. How does an 8-bit computer display pixel on a monitor, and another question about operand/op-code logistics
Hello Everyone, I am learning about computers and have a few questions about 8-bit computers (inspired by learning about the Commodore's).
Question 1:
How does an 8-bit computer have more than 256 bytes of RAM? because 8 bits can only have 256 combinations, the memory addresses must only have around 256 bytes, considering that 8-bit computers can only have 256 possible memory addresses for each byte of RAM.
If this isn't true, how does it really work, and if it is true, how do/did 8-bit computers get around that? (such as the commodore 64 having 64kB of RAM, and 20kB of ROM).
Question 2:
How do computers (focusing on 8 bit, but all computers) display pixels on a screen. After watching some videos and reading some books, I learned that the computer outputs the letter or number to the display, but how does that monitor know where to go, how big, and how far apart each character is? Is it the monitor doing the work or the computer, and if it is the monitor how does the monitor deal with different clock speeds?
Question 3:
I learned that computer instructions are split up in two ways:
in an 8 bit computer, the first four bits are op-codes, which get passed through a decoder, and the last four bits are the operand, (eg: STORE | 14 == 1010 | 1110)
(according to another video I found) all 8 bits are the op-code, then the next instruction to pass through is the operand, (eg: STORE | 10110100 then 14 | {0010}1110)
^ that storing the number as an integer
The first one I understand, but the latter I do not. How does the computer remember that the next byte is meant to be an operand instead of an instruction, or an instruction instead of an operand?
7
Apr 08 '21
The memory addressing is pretty straight forward. The Commodore 64 use 16-bit memory addresses. It just had to read two separate bytes.
5
u/jhaluska Apr 09 '21 edited Apr 09 '21
For Question 1.
8 bit didn't always mean 8 bits of address space. It often meant the width of the ALU / internal wiring. They usually got around the address limitation with bank switching.
Say they could they could address say 24 bits, but it might have to set up the address 8 bits at a time. So you to set up an address might require 3 instructions. Then you might only write 8 bits to the address.
For Question 2.
The video card often would read and display the same memory over and over again. So if you just wrote to the memory it would show on the screen. They either had a text mode or a graphic mode, but the concept was the same. In early computers Text mode was used because text required much less memory to display than a full graphics mode. Memory used to be EXPENSIVE.
For Question 3.
For it to remember where it is in an instruction, it has a complicated state machine made up of logic gates.
You sound like you'd probably love Ben Eater's series. Just keep in mind there are more than one way to do things in 8 bit computers!
2
u/AxelTheRabbit Apr 08 '21
interesting topic, I don't know the answers but I can tell you about the question 2, there is a graphic driver that handles that, it's a combination of hardware and software, nowadays there are several layers I don't know back then, no obviously the monitor doesn't do any work, it displays whatever input is given.
I'm not sure what you mean with the 3rd question but obviously it depends on the architecture and cpu.
the answer to the first question is here: https://electronics.stackexchange.com/questions/57950/how-can-8-bit-processor-support-more-than-256-bytes-of-ram
1
u/Steve132 Apr 09 '21
For the 8 bit architectures I am familiar with, the memory address in load/store operations is provided as a combination of two registers which forms a 16 bit address space.
I'm pretty sure this is how it works on both z80 and avr
1
u/Steve132 Apr 09 '21
To answer your third question: the encoding differs per processor type. But in avr it's 16 bits per instruction with different meanings for the bits.
To answer your second question: it depends a LOT on hardware. Lots of 8 bit computers don't have displays at all they just connect input and output over some kind of serial interface. But for a 2d display, there's typically a big 2d array of memory called vram which can be written to by the device. Then, a piece of dedicated hardware reads the vram really fast and converts it into a signal that the display device can understand as pixel colors.
For something like a NES, the main vram on the device has 16 kits of space. The NES has a hardware module which can scan that memory and output the appropriate signal for NTSC television signals to represent a digital image in memory.
So the CPU writes some data to the vram, and the scanline chip reads the vram and outputs a TV signal.
Something similar happens on a modern computer architecturally. The cpu tells the GPU complicated instructions to to write pixels to the GPU vram, and the GPU vram gets encoded as an HDMI signal and sent out on the wire by hardware in the GPU
1
u/Bottled_Void Apr 09 '21
Pages.
Write to VRAM. It all equates to pixels in a certain resolution.
When it reads the op code, it knows how many bytes follow that are data. So it just reads them and increments thr PC.
1
23
u/thegreatunclean Apr 08 '21 •
You assume "8-bit" means the computer cannot have hardware capable of handling larger bitwidths; this is incorrect. Just because the native operating size (the "word" size) is 8 bits does not mean the address bus must also be 8 bits. Many 8-bit architectures have a 16-bit address bus.
By giving up the ability to hold a complete memory address in a single general-purpose register. Usually some kind of architectural feature is added to mitigate this, such as a special-purpose register wide enough to hold the address and special instructions to access memory using it.
Most techniques boil down to having a framebuffer: a special piece of hardware that looks like normal memory, but can be read out by special hardware that takes the image data and gets it to the screen. How that hardware works depends heavily on what kind of screen you have.
The screen/monitor and the special hardware mentioned above have to share some common protocol or understanding of how the image data is to be sent. For pixel data it's something of the form "I'm going to send you X numbers per microsecond" and the display knows to interpret those as packed red-green-blue intensity values with some metadata about timing.
It's baked into the architecture design. The CPU sees the opcode byte, decodes it, and knows that opcodes of that specific form have a second byte of data following them so it loads that as well.
What happens if you branch into the middle of a multi-byte instruction? At best the CPU notices the data byte doesn't decode to any valid instruction and faults, at worst the CPU does something unpredictable if that data byte does happen to match some unknown instruction.