Live data from Hacker News

I'm 17 and wrote this guide on how CPUs run programs

github.com

261–270 of 327 posts

Re: I'm 17 and wrote this guide on how CPUs run programs

#261
post #79

Earlier quoted context omitted.

I only browsed this but it seems like a pretty cool primer. Loving the style as well. It's also a very good idea to write these types of resources when you teach yourself something new because it clarifies your thought process and helps you identify parts that are still unclear even though you initially thought you understadn them etc. I also liked this at the end: """ I talked to GPT-3.5 and GPT-4 a decent amount wh…

I'm glad you enjoyed it! > It's also a very good idea to write these types of resources when you teach yourself something new because it clarifies your thought process and helps you identify parts that are still unclear even though you initially thought you understadn them etc. I found this to be very much the case. As I wrote the article, I discovered so many things that I didn't properly understand. It partially to…

The most important reason to write this while learning is that you only once have the questions of someone who doesn't know the topic. As soon as you learn it, you forget what it was like to not know it. Fron that point on, you've always known it.

That's why writing down all your questions while learning is extremely important for then teaching.

Re: I'm 17 and wrote this guide on how CPUs run programs

#262
"After executing an instruction, the pointer moves forward to immediately after the instruction in RAM so that it now points to the next instruction.'

What is a pointer? How does it "move" inside the computer? This is low level stuff, but still probably somewhat mysterious to the layman.

Never mind the obscurity of the word "syntax".

Re: I'm 17 and wrote this guide on how CPUs run programs

#263
:x86:

Apart from the drawing boards at Intel when the 80286 was designed, can anyone find any evidence or have first-hand experience that rings 1 and 2 were ever used in any specific commercial purpose? (I haven't heard or seen of it.) 286 protected mode was generally a flop (outside of OS/2), while 386 protected mode was significantly better. The LDTR (-> LDT) and hardware task switching (reloading TR) aren't typically used. GDTR (-> GDT), TR (->TSS) and IDTR (->IDT) setup are essential.

The TSS includes where to find the 6-7 stacks, and for a permissions mask for port I/O.

Double fault handler (in the IDT -> INT 8) is typically what leads to a colorful screen of death. When the double fault handler fails (or the IDT or was overwritten), a triple fault happens and the CPU halts or the virtual machine does it own impression of a colorful screen of death without (usually) actually killing the host machine.

An invalid opcode handler permits handling CPU-unknown opcodes in the OS such as using emulation or other hardware.

Note that generally most PCs prior to UEFI/EFI booted in real mode with 1 core running, so writing a parallel and concurrent OS typically involves setting up protected mode structures, switching to protected mode, and then talking to the APIC for every other core.

Resources:

https://sandpile.org

http://ref.x86asm.net/geek64.html

https://cdrdv2.intel.com/v1/dl/getContent/671200

https://www.intel.com/content/www/us/en/docs/intrinsics-guid...

https://www.amd.com/en/support/tech-docs/amd64-architecture-...

SVGA/VGA/EGA

https://wiki.osdev.org/Expanded_Main_Page

http://www.osdever.net/FreeVGA/home.htm

https://archive.org/details/gpbb20/

https://archive.org/details/programmersguidetotheegavgaandsu...

System management

https://wiki.osdev.org/Symmetric_Multiprocessing

https://pdos.csail.mit.edu/6.828/2018/readings/i386/s09_08.h... https://ctyme.com/rbrown.htm

https://wiki.osdev.org/UEFI

USB

https://beyondlogic.org/usbnutshell/usb1.shtml

Emulators

https://www.qemu.org (qemu-system-x86_64 or qemu-system-i386 for very retro)

You'll usually want to create an ELF32x64 binary kernel image that's a bit of real mode, ia32 and then switches to 64-bit registers mostly (ia32e [amd64/x86_64]).

Re: I'm 17 and wrote this guide on how CPUs run programs

#264

Hi! I'm Lexi, I wrote this article/mini-book. There's a classic question of "what happens when you load a website?", but I've always been more interested in "what happens when you run a program?". About 3 months ago, I was really annoyed at myself for not knowing how to answer that question so I decided to teach myself. I taught myself everything else I know in programming, so this should be easy, right? NOPE! Appare…

I browsed through it shortly but it is impressive. When it comes to existing resources, the boring university classes can actually be navigated online. For this topic CS-152 from Berkeley could be a nice followup (https://inst.eecs.berkeley.edu/~cs152/sp23/) and there's a CPU design project in CS-61C that should cover everything you learned if you want to apply the knowledge to a concrete design.

Re: I'm 17 and wrote this guide on how CPUs run programs

#265

OP, don't excuse your work by prefixing it with your age. Your write-up is better than most people will ever do. Nice work!

Very unlikely anyone would care about this ChatGPT-level summary of how a CPU works if the author didn't mention they were 17.

[deleted]

Re: I'm 17 and wrote this guide on how CPUs run programs

#266
post #188

Earlier quoted context omitted.

I'm glad you enjoyed it! > It's also a very good idea to write these types of resources when you teach yourself something new because it clarifies your thought process and helps you identify parts that are still unclear even though you initially thought you understadn them etc. I found this to be very much the case. As I wrote the article, I discovered so many things that I didn't properly understand. It partially to…

Excellent work. I have run across so many resources where it is clear that they author was both a learner and had little interest in going back to improve their work for clarity and accuracy. Your work is clearly several leaps beyond that. It is clear and the portions I have read are accurate. It leaves me wanting to go back to read more and I am confident you won't disappoint. Thank you for your contributions and I…

Submit this with any College applications and for any computer work while in school.

Re: I'm 17 and wrote this guide on how CPUs run programs

#267

Hi! I'm Lexi, I wrote this article/mini-book. There's a classic question of "what happens when you load a website?", but I've always been more interested in "what happens when you run a program?". About 3 months ago, I was really annoyed at myself for not knowing how to answer that question so I decided to teach myself. I taught myself everything else I know in programming, so this should be easy, right? NOPE! Appare…

Lexi, this is amazing! I am 33 and I still don't know ANYTHING about how a CPU runs a program.

Appreciate you injecting your own style into the writing. After a decade in the industry I'm sick of soulless reference materials.

Re: I'm 17 and wrote this guide on how CPUs run programs

#268

Hi! I'm Lexi, I wrote this article/mini-book. There's a classic question of "what happens when you load a website?", but I've always been more interested in "what happens when you run a program?". About 3 months ago, I was really annoyed at myself for not knowing how to answer that question so I decided to teach myself. I taught myself everything else I know in programming, so this should be easy, right? NOPE! Appare…

Having read the first couple of pages, my only feedback is a strong suggestion to drop the cutesy language. >The central processing unit (CPU) of a computer is in charge of all computation. It’s the big cheese. The shazam alakablam. It starts chugging as soon as you start your computer, executing instruction after instruction after instruction. Given the context, that would read much better as: >The central processin…

Drop this! (farts in your general direction)

Re: I'm 17 and wrote this guide on how CPUs run programs

#269

Great effort, but really still needs a bunch of work. In some places the sentences just don't make sense. I think in terms of CPU, a good starting point is the Von Neumann architecture which most computers are designed around. The current description of CPUs mix things up with OS concepts. You may want to look into things like memory management units ( MMU ) that builds on the basic Von Neumann architecture to provid…

I haven't read all of the article yet, but CPU modes are very clearly mentioned?
Post reply on HN