Live data from Hacker News

What happens when a CPU starts

lateblt.tripod.com

31–40 of 133 posts

Re: What happens when a CPU starts

#31
post #8

Is it me or the article seems incomplete? It kinda finishes for me after: > The following are the memory ranges you get with a 2-to-4 converter on an 8-bit address bus: And that's it. It looks truncated, or incomplete :thinking:

I see this at the end:

  The following are the memory ranges you get with a 2-to-4 converter on an 8-bit address bus:

  00: 00h to 3Fh
  01: 40h to 7Fh
  10: 80h to BFh
  11: C0h to FFh

Re: What happens when a CPU starts

#32
post #5
post #3

Amongst the first sentences... > It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins. I thought that too. Last year I spent a while getting as low-level as I could and trying to understand how to write a boot loader, a kernel, learn about clocks and pins and interrupts, etc. I thought, "I know, I'll get a Raspberry Pi! Th…

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

> But they run no OS, your program runs directly on the hardware

How is threading/time scheduling/interrupt handling/context switching usually done?

Re: What happens when a CPU starts

#33

> The memory chips respond by sending the contents of the selected memory cell over the data bus to the CPU. What does that ROM memory cell _physically look like_? How do we physically manipulate it to contain a 1 or a 0 (absence of something)?

A peer mentioned different types of memory and flip flops. I’d search for JK flip flop or D flip flop/latch for conceptual pointers. Those can be used to build up register files. The logic gates used to build flip flops/latches use things like NMOS/CMOS/PMOS - different kind of metal oxide seniconductor logic based on substrate. The differing behavior affects how you arrange circuits (voltage source, ground, etc) to provide desired logic from inputs (keywords: pull down/pull up network). Once you have logic and memory, you can build control units and things like arithmetic logic (look up von Neumann/Harvard architecture).

I’m not an expert in modern hardware, but these are the basic principles I recollect. Happy to be corrected if this answer is dated :)

Re: What happens when a CPU starts

#34
Ben Eater's fantastic video series on building a breadboard 6502 based computer and an 8-bit breadboard computer from scratch might be appreciated in this thread.

6502 playlist: https://www.youtube.com/watch?v=LnzuMJLZRdU&list=PLowKtXNTBy...

8-bit build playlist: https://www.youtube.com/watch?v=HyznrdDSSGM&list=PLowKtXNTBy...

He also sells kits if one is interested in playing along.

Re: What happens when a CPU starts

#35
post #5

Earlier quoted context omitted.

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

> But they run no OS, your program runs directly on the hardware How is threading/time scheduling/interrupt handling/context switching usually done?

I'm still digging in to the details so I can't answer perfectly. But as far as I can tell. There is no threading or processes, it's more like a microcontroller. I don't think there are any interrupts for things like inputs, you have a main loop and you are expected to poll the inputs frequently. I suspect there are timers which can interrupt like you'd get on a microcontroller though I haven't tried this yet.

Re: What happens when a CPU starts

#36
post #3

Amongst the first sentences... > It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins. I thought that too. Last year I spent a while getting as low-level as I could and trying to understand how to write a boot loader, a kernel, learn about clocks and pins and interrupts, etc. I thought, "I know, I'll get a Raspberry Pi! Th…

RPi's unfortunately have lousy documentation for the low level stuff.

Just about anything else (including dodgy Chinese substitutes) is better, sadly.

Re: What happens when a CPU starts

#37
post #5
post #3

Amongst the first sentences... > It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins. I thought that too. Last year I spent a while getting as low-level as I could and trying to understand how to write a boot loader, a kernel, learn about clocks and pins and interrupts, etc. I thought, "I know, I'll get a Raspberry Pi! Th…

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

writing programs for old game consoles,

Oh yeah, like the Intellivision.

particularly the Nintendo DS.

Oh come on, the DS ain't that old.

Re: What happens when a CPU starts

#38

> The memory chips respond by sending the contents of the selected memory cell over the data bus to the CPU. What does that ROM memory cell _physically look like_? How do we physically manipulate it to contain a 1 or a 0 (absence of something)?

my understanding is that there is a thin trace (a fuse) at each cell. in order to program it, the address lines are manipulated to select the word, and a programming voltage is applied (for some reason I remember 18v, but it really could be anything), that draws a large current across the fused and blows it. on a die, you wouldn't go through that trouble, you would just directly synthesize the zeros and ones. but we…

Many modern microcontrollers have programmable fuses for security reasons.

Re: What happens when a CPU starts

#39
post #37
post #5

Earlier quoted context omitted.

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

writing programs for old game consoles, Oh yeah, like the Intellivision. particularly the Nintendo DS. Oh come on, the DS ain't that old.

20 years next year.

Re: What happens when a CPU starts

#40
post #5

Earlier quoted context omitted.

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

> But they run no OS, your program runs directly on the hardware How is threading/time scheduling/interrupt handling/context switching usually done?

I dunno about the DS, which doesn't really qualify as that old to me; it's got a pretty decent sized rom for when you don't have a cartridge in, and I'd guess the SDK gives you something approaching an OS, maybe even with a threading library.

But on real old hardware, you're not going to run threads or a scheduler, you're going to run one iteration of your game loop, then wait for a sign that it's time to do your graphics work (after VBlank, during the screen scan on Atari 2600, mostly during VBlank on more generous platforms). If the platform doesn't have many interrupts, it probably has a fixed address for the interrupt vectors and your rom would cover that address/those addresses; and there's probably a fixed address that execution starts at too or it's one of the elements of the interrupt vector table.

Context switching isn't really that hard anyway --- call into (or get interrupted into) a routine that saves registers to the stack, then saves the stack pointer for the current task, restores the pointer for another task, pops the registers from the stack and returns.

There's not usually any sort of memory protection between tasks in a game, but it's assumed you kmow what you're doing.

Post reply on HN