I know this is an incredibly vague question, and it might not be a good question for programmers, since this is really a hardware related thing, but I guess some assembly/machinecode comes into play which would be appropriate for this site.
So what I'm wondering is; imagine the 6502 processor. It has some registers, an instruction set, and access to a certain amount of memory. Then imagine that you have some LCD screen with an arbitrary resolution. How is it determined what is shown on this screen? How is it determined which pixels at which position is given what color? Does the screen always display, for instance, a pixel with the value in the accumulator of the 6502, and with x position stored in register x, and y position stored in y? Or is it interpreted differently by every machine?
Someone wrote a JavaScript 6502 emulator, and the device displays a pixel with its value at some memory position starting with $200. So for instance:
LDA #$08
STA $200
would display a pinkish pixel at position x:0, y:0.
LDA #$01
STA $205
would display a white pixel at position x:5, y:0.
If you look at the NES, however, it has a dedicated PPU which displays certain pixels with a certain value at a certain area on the screen.
So how does it work? Is it interpreted differently by every machine (i.e. Apple II, C64, NES), or is there some kind of consistency of how it is interpreted?
As a matter of fact, what would happen if a program compiled for an Apple II was somehow executed on a C64? The machine should be able to read the instructions, right?