Come funziona un microprocessore? Scriviamo un simulatore da zero in C
C Programming - Video 30 Today we delve into the heart of how a computer works, and more specifically, a microprocessor. We won't do this by analyzing the physical hardware, but by approaching the problem from a software perspective: we'll implement a complete simulator of a hypothetical machine called a Simpletron in C. This exercise, taken from the book "C Programming - The C Language: Fundamentals and Programming Techniques," is essential for anyone who wants to understand what really happens "under the hood" when we execute code. The Simpletron is a decimal computer (not binary, for ease of instruction) that operates on signed integers and allows us to explore the core concepts of computer architecture without the complexity of modern assembler. 👉 The C programming book and more general programming techniques recommended in the video: https://amzn.to/3KKtrqc 👉 Slides for Patreon subscribers: / come-funziona-un-145608268 👉 Source code illustrated in the video for Patreon subscribers: / sorgente-in-c-145276083 In the video, we'll write the code to simulate: • Memory: A 100-word array to hold instructions and data (Von Neumann Architecture). • Registers: Accumulator, Instruction Counter, and Instruction Register. • The ALU and Control Unit: We'll implement the fetch-decode-execute cycle using C constructs like switches and pointers. • The Instruction Set Language (SML): We'll create an interpreter for I/O operations, arithmetic calculations, and conditional branching. We'll also see how to load a "program" from a text file, manage keyboard input/output, and debug memory using a hexadecimal dump (or, better yet, decimal in this case). This is an excellent project for honing your knowledge of pointers in C and understanding the sequential logic of a CPU. Topics covered in the video: 🔹 Internal structure of a CPU: ALU, Registers, and Bus (simulated). 🔹 The machine cycle: fetching, decoding, and execution. 🔹 Memory management and pointers in C. 🔹 Implementing an instruction set language (opcodes and operands). 🔹 Loading and parsing text files for program execution. If you like the video, support the channel with a like and a comment! The correct load_program function: void load_program(const char* const filename, int* const m) { char buffer[MAXLEN]; FILE* fp = fopen(filename, "r"); unsigned int add = 0; while (fgets(buffer, MAXLEN, fp) != NULL && add < MEM_SIZE) { sscanf(buffer, "%d", &m[add++]); } fclose(fp); } ---- Contribute to the growth of the channel with a like, a comment and by subscribing. If you'd like, you can also make a direct or indirect financial contribution: • Subscribe to the channel here on YouTube • Join the community on Patreon: patreon.com/Alexa_Academy • Amazon Affiliate Program: https://amzn.to/3SArxJc

Come funziona un Assemblatore? Creiamone uno da zero in C per il linguaggio SML

Quantum Computers, Explained with Animations

Demystifying std::memory_order - Timur Doumler - ADC 2025

HOW TRANSISTORS RUN CODE?

Creator of C++: Bell Labs, Negative Overhead Abstraction, Mistakes | Bjarne Stroustrup

Using Large Language Models | Build Your Own LLM Workshop #1

Tips for C Programming

The Engineering that Runs the Digital World 🛠️⚙️💻 How do CPUs Work?

Linus Torvalds: AI Is Changing Linux Fast

Turing Award Winner: Disagreeing with Google, Postgres, Future Problems | Mike Stonebraker

Every Level of Reverse Engineering Explained

The 7 Levels of How a CPU Works

Cos'è e come funziona il TRANSISTOR - Animazione 3D

Busy Beaver Turing Machines - Computerphile

Programming in Assembly without an Operating System

Digital Electronics - The First Video YOU Should Watch

VHDL per FPGA: Introduzione completa con esempi pratici | PLD 9

How I program C

How do computers read code?

