TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What happens when a CPU starts

452 pointsby nowandlaterover 2 years ago

24 comments

billtiover 2 years ago
Amongst the first sentences...<p>&gt; 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.<p>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, &quot;I know, I&#x27;ll get a Raspberry Pi! That way even if I brick it I didn&#x27;t waste too much money&quot;.<p>Turns out the Raspberry Pi (and I&#x27;m guessing many other systems) are pretty confusing to understand at boot time. For one, it&#x27;s the GPU that actually does the initial boot process, and much of that is hard to find good info on. (<a href="https:&#x2F;&#x2F;raspberrypi.stackexchange.com&#x2F;questions&#x2F;14862&#x2F;why-does-the-raspberry-pis-gpu-control-the-first-stages-of-the-boot-process" rel="nofollow">https:&#x2F;&#x2F;raspberrypi.stackexchange.com&#x2F;questions&#x2F;14862&#x2F;why-do...</a>)<p>I spent many many hours reading various specs &amp; docs and watching tons of low-level YouTube videos. Compared to software development higher up the stack (my usual area), I found the material surprisingly sparse and poor for the most part. (Maybe that&#x27;s reflective of the size of the audience and the value in producing it).
评论 #34334002 未加载
评论 #34334273 未加载
评论 #34334434 未加载
评论 #34334233 未加载
评论 #34334011 未加载
评论 #34337973 未加载
评论 #34336349 未加载
评论 #34344591 未加载
评论 #34335057 未加载
评论 #34336209 未加载
评论 #34339756 未加载
评论 #34335903 未加载
评论 #34344395 未加载
评论 #34349896 未加载
评论 #34335622 未加载
评论 #34349887 未加载
评论 #34334527 未加载
评论 #34334739 未加载
评论 #34335104 未加载
评论 #34336443 未加载
santadakotaover 2 years ago
Ben Eater&#x27;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.<p>6502 playlist: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=LnzuMJLZRdU&amp;list=PLowKtXNTBypFbtuVMUVXNR0z1mu7dp7eH">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=LnzuMJLZRdU&amp;list=PLowKtXNTBy...</a><p>8-bit build playlist: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HyznrdDSSGM&amp;list=PLowKtXNTBypGqImE405J2565dvjafglHU">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HyznrdDSSGM&amp;list=PLowKtXNTBy...</a><p>He also sells kits if one is interested in playing along.
评论 #34335897 未加载
评论 #34336854 未加载
kensover 2 years ago
If anyone is interested in what happens with an older CPU, I&#x27;ve written up how the IBM 1401 from 1959 starts up: <a href="https:&#x2F;&#x2F;www.righto.com&#x2F;2021&#x2F;02&#x2F;an-ibm-1401-mainframe-computer-at.html" rel="nofollow">https:&#x2F;&#x2F;www.righto.com&#x2F;2021&#x2F;02&#x2F;an-ibm-1401-mainframe-compute...</a><p>Among other things, since it uses magnetic core memory, you can run the program that was loaded when you shut it off.
评论 #34335306 未加载
saagarjhaover 2 years ago
&gt; The Z80&#x27;s system, although simpler, creates a &quot;hole&quot; in the memory, because the bottom of the memory space is used by ROM and therefore you cannot use the beginning of the memory space for normal RAM work.<p>Gameboy actually does a funny thing where the boot ROM gets mapped at the bottom of the address space, and then it writes to a MMIO address to unmap the ROM overlay and restore the first 256 bytes of the cartridge there instead. It’s quite amusing!<p>&gt; On some computer platforms, the instruction pointer is called the &quot;program counter&quot;, inexplicably abbreviated &quot;PG&quot;<p>Typo, maybe? Typically it’s called “pc”.
评论 #34343445 未加载
als0over 2 years ago
&gt; Regardless of where the CPU begins getting its instructions, the beginning point should always be somewhere in a ROM chip. The computer needs startup instructions to perform basic hardware checking and preparation, and these are contained in a ROM chip on the motherboard called the BIOS. This is where any computer begins executing its code when it is turned on.<p>I can&#x27;t see any date on this, but this is a bit antiquated. For security and reliability, modern CPUs have an on-chip ROM, which is executed first. That on-chip ROM will tend do basic things like check clock, power, memory etc. Once that&#x27;s complete it will then securely load firmware from the motherboard flash. Even modern cheapo microcontrollers are shipping with on-chip ROM these days.
pclmulqdqover 2 years ago
&quot;It starts at 0 and executes instructions&quot; is a funny, but mostly true way to express this. Some people are shocked that no magic happens before the instructions start.
评论 #34334369 未加载
评论 #34334080 未加载
评论 #34334025 未加载
评论 #34334122 未加载
评论 #34334426 未加载
评论 #34335086 未加载
hackanover 2 years ago
Is it me or the article seems incomplete? It kinda finishes for me after:<p>&gt; The following are the memory ranges you get with a 2-to-4 converter on an 8-bit address bus:<p>And that&#x27;s it. It looks truncated, or incomplete :thinking:
评论 #34334655 未加载
squokkoover 2 years ago
Now there&#x27;s a domain I haven&#x27;t seen in a very long time.
评论 #34337937 未加载
broastover 2 years ago
Amazing to see that tripod sites are still around.
评论 #34334195 未加载
评论 #34335833 未加载
评论 #34334585 未加载
Rimintilover 2 years ago
&gt; The memory chips respond by sending the contents of the selected memory cell over the data bus to the CPU.<p>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)?
评论 #34334390 未加载
评论 #34334465 未加载
评论 #34334346 未加载
评论 #34343988 未加载
评论 #34334687 未加载
评论 #34334644 未加载
评论 #34336385 未加载
atomjamesover 2 years ago
the nand2tetris course is a nice primer for understanding this kind of stuff:<p>nand2tetris.org&#x2F;
ruslanover 2 years ago
Starting procedure on MOS6502 is not that simple as it is told in the article. It spends some 7 clocks on doing internal initialization and only then fetches address of first jump from reset vector (0xFFFC&#x2F;0xFFFD). I find Ben Eater&#x27;s series on building simple 8-bit breadboard computer using 6502 CPU very educating and entertaining.<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HyznrdDSSGM">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HyznrdDSSGM</a>
tim_huttonover 2 years ago
One route to understanding how CPUs work is to explore the computers that have been made in cellular automata. Golly (<a href="https:&#x2F;&#x2F;golly.sourceforge.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;golly.sourceforge.net&#x2F;</a>) has several, including one by John von Neumann, one by Edgar Codd and another by John Devore. The advantage of course is that the physics is trivial and you can see everything that happens and step backwards and forwards.<p>Example:<p><a href="https:&#x2F;&#x2F;timhutton.github.io&#x2F;2010&#x2F;03&#x2F;10&#x2F;30984.html" rel="nofollow">https:&#x2F;&#x2F;timhutton.github.io&#x2F;2010&#x2F;03&#x2F;10&#x2F;30984.html</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;GollyGang&#x2F;ruletablerepository&#x2F;wiki&#x2F;CoddsDesign">https:&#x2F;&#x2F;github.com&#x2F;GollyGang&#x2F;ruletablerepository&#x2F;wiki&#x2F;CoddsD...</a>
sanatgersappaover 2 years ago
Honestly, I had no idea tripod was still around.
fzliuover 2 years ago
&gt; This is because when the power supply is first powering up, even if it only takes a second or two, the CPU has already received &quot;dirty&quot; power, because the power supply was building up a steady stream of electricity. Digital logic chips like CPUs require precise voltages, and they get confused if they receive something outside their intended voltage range.<p>This is only partially true. When digital chips boot up, gate outputs are in an indeterminate state. The reset sets them to know initial (and valid) values&#x2F;bits.
评论 #34335111 未加载
storklatheover 2 years ago
Could anybody clarify for me the purpose of the NOP opcode that the article refers to? I would think that something like a &quot;do nothing&quot; instruction would want to be optimized away as much as possible, but maybe there&#x27;s some hidden facet of the instruction protocol I&#x27;m not familiar with that necessitates it?
评论 #34340409 未加载
migaover 2 years ago
It describes old 8-bit machines. New machines start by executing instructions firmware ROM or in cache memory before RAM is tested and initialized.<p>Additionally the reset registers differ by the platform. (Some platforms expect software to initialize and reset some registers.)
snvzzover 2 years ago
A tangent, but I thought worth mentioning:<p>If you like this sort of plain text technical document, you might enjoy browsing the net with Gopher.<p>I recommend Gopherus[0] as a modern implementation that&#x27;s cross-platform.<p>0. <a href="https:&#x2F;&#x2F;gopherus.sourceforge.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gopherus.sourceforge.net&#x2F;</a>
fennecfoxyover 2 years ago
I think this is traditional for this topic: <a href="https:&#x2F;&#x2F;nandgame.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nandgame.com&#x2F;</a><p>Say goodbye to a couple hours!
charcircuitover 2 years ago
I thought it started by executing microcode from ROM.
评论 #34335129 未加载
评论 #34335328 未加载
DotaFanover 2 years ago
Last week I&#x27;ve tried to understand how Chip8 worked, and it did help me understand this article a bit more.
dirtyidover 2 years ago
Somewhere out there is a company specializing in selling tripods patiently waiting for the domain to free up.
Wolfenstein98kover 2 years ago
What a delightful article to read. Thanks for sharing!
bandramiover 2 years ago
Tripod still exists?