I know this is an incredibly vague question, and this may not be a very good question for programmers, since it is really hardware related, but I assume that the assembly / machine code comes in a game that is suitable for this site.
So I'm wondering: Imagine a 6502 processor. It has several registers, a set of instructions, and access to a specific amount of memory. Then imagine that you have an arbitrary resolution LCD screen. How is what shown on this screen determined? How is it determined which pixels, in which position is given what color? Is a screen always displayed, for example, a pixel with a value in the battery 6502 and with the position x stored in the register x, and the y-position stored in y? Or is this interpreted differently on each machine?
Someone wrote a JavaScript 6502 emulator, and the device displays a pixel with its value in some memory position, starting at $ 200. For example:
LDA #$08 STA $200
will display a pinkish pixel at x: 0, y: 0.
LDA #$01 STA $205
will display a white pixel at position x: 5, y: 0.
However, if you look at NES, it has a dedicated PPU that displays specific pixels with a specific value in a specific area on the screen.
So how does it work? Is it interpreted differently by each machine (e.g. Apple II, C64, NES), or is there some sort of sequence of how it is interpreted?
In fact, what happens if a program compiled for Apple II somehow runs on C64? The machine should be able to read the instructions, right?