+ 2

Software to hardware?

Like many people I’ve been learning software and the ins and outs but I have never found out how software(code) gets onto a hard drive, cpu, etc in my device. Could someone please explain this for me? it doesn’t have to be too in depth but pls be thorough .

23rd Jun 2022, 5:04 AM
Allister G
Allister G - avatar
3 Answers
+ 1
So, imagine you write a Program in C++, when you compile the program the program first gets translated into machine code. In the linking stage the compiler/linker defines the entry point for the program and and makes it into a format that the OS can load and understand. For Linux this is the ELF format, for Windows the PE format. Now the first step is done and you have an executable binary program. Now when you start the program the operating system loads the entire program into ram and transfers execution to the entry point of the program. From here the CPU loads instruction by instruction. There is a lot happening in the CPU, you should check out an CPU architecture course for that. But on the lowest level you know that machine code is a mapping from asm code to numbers. And the CPU only understands these numbers, because these can be translated to other number systems like binary. And numbers in binary like "00001011"(11 in decimal) can be represented by power signals (low power=0, high power=1)
12th Jul 2022, 5:28 AM
Erarnitox
Erarnitox - avatar
+ 1
Now transistors can be used to model simple logical gates usings flipflops etc. most imortantly NAND or NOR (these can be used to model represent any other). The CPU now has many of these Logical gates to 1. Decode the operation to be executed 2. load the arguments 3. Execute the selected instruction. By using constructions like a flipflop, values can be saved in registers on the CPU. from there they can be written the same way, by sending electronic signals to RAM. If you want to save the data ypu calculated for longer when power is off you can mechanically write this data to a HDD, which uses magnetism to remember data: positive=1, negative=0. using a small amount of power these bits can be flipped / written. This is still pretty shallow, so if you really want to in depth take a look into asm, CPU architecture, Operating systems, van Neuman architecture... probably electrical engineering (how transistors work, how flipflops work, how to build logical gates)
12th Jul 2022, 5:38 AM
Erarnitox
Erarnitox - avatar
+ 1
Also probably number systems, especially binary and hexadecimal and how they are used to encode everything. How text is encoded (ASCII / Unicode), how floating point numbers are encoded (IEEE Standard). Negative numbers using the twoth complement. There is simply a lot... i might get back to this and give a more detailed/structured overview. Unfortunately I'm slightly rusty in some of these thungs myself right now and could use a refresher. edit: ofc. you would also want to look into compilers and linkers as they carry a lot of weight in making high level languages understandable for the OS/computer in general
12th Jul 2022, 5:43 AM
Erarnitox
Erarnitox - avatar