Jump to content

How does software "work"?


Recommended Posts

A while back I asked a question on how to make your own code in this forum. After lengthy conversations I came to the conclusion that it was not wise to bother trying. Now I pose this question as follow up. When computers were first invented how exactly did they manage to code them. I ask this because when I asked the question of making your own code I was given answers that seemed that they all required a base code to work with in the first place. Then the question is raised assuming that this is the case, how was that code formed. I'm asking fundamentally how software works and went from a circuit into something you can code with using a screen. 

Edited by Cheif Operations Director
Link to comment
Share on other sites

You should start with studying the history of computer development.  That should answer the first part of your question.  For the second;  You need to understand how a processor (CPU) works, and how code is used to interface and govern the control of a processor's actions.  In a nutshell, a processor is a machine which has various functions that have controls attached to them... and code is used to manipulate those controls to activate/deactivate those functions.  At its lowest level, the bridge between code and electronics, is its pre-defined binary language.  Higher-level languages are the bridge for humans to easily understand and write/create instructions which ultimately are converted into binary for the CPU to understand.  I'd suggest you hit up a library at this point and start with some research on the topics, which I think will be more rewarding than just searching the web.  However, you'll find some basic information at the links I've posted below.

How a CPU works.

How coding works.

Good luck on your quest.

Link to comment
Share on other sites

Just now, LordFerret said:

You should start with studying the history of computer development.  That should answer the first part of your question.  For the second;  You need to understand how a processor (CPU) works, and how code is used to interface and govern the control of a processor's actions.  In a nutshell, a processor is a machine which has various functions that have controls attached to them... and code is used to manipulate those controls to activate/deactivate those functions.  At its lowest level, the bridge between code and electronics, is its pre-defined binary language.  Higher-level languages are the bridge for humans to easily understand and write/create instructions which ultimately are converted into binary for the CPU to understand.  I'd suggest you hit up a library at this point and start with some research on the topics, which I think will be more rewarding than just searching the web.  However, you'll find some basic information at the links I've posted below.



How a CPU works.

How coding works.

Good luck on your quest.

I will most likely do just that, as a follow up how does this binary and code system become into being in the first place. How can you make a computer take a voltage amount and convert it into a number? By this I mean what allows the computer to actually read a voltage and output a number.

Link to comment
Share on other sites

4 minutes ago, Cheif Operations Director said:

I will most likely do just that, as a follow up how does this binary and code system become into being in the first place. How can you make a computer take a voltage amount and convert it into a number? By this I mean what allows the computer to actually read a voltage and output a number.

It's like this marble machine:

Not exactly the same, but the marbles are kind of like electrical inputs. The machine doesn't count, so much as display what has happened to it in a way that can be read by humans or other machines. 

I don't know where binary came from, but all the first computers were mechanical.

Link to comment
Share on other sites

2 minutes ago, Mad Rocket Scientist said:

I don't know where binary came from, but all the first computers were mechanical.

The binary system has been a thing for literally thousands of years.
https://en.wikipedia.org/wiki/Binary_number

If you search the web for first computer you'll get a lot of different answers.  I'll tell you to consider the Abacus.

Link to comment
Share on other sites

11 minutes ago, Mad Rocket Scientist said:

It's like this marble machine:

Not exactly the same, but the marbles are kind of like electrical inputs. The machine doesn't count, so much as display what has happened to it in a way that can be read by humans or other machines. 

I don't know where binary came from, but all the first computers were mechanical.



An Interesting video, how does the computer "display" the 0 or 1 for the binary as it has no underlying code to identify it as an on or off. I mean I can see it turning on a LED and perhaps those LEDs form the shape 0 or 1 but how can you interact with that in any meaningful way without underlying code. If their is underlying code is it mechanical?

2nd Thing

Is the number

001100, assuming 0 means off and 1 equals are saying

2 offs

2 ons

2 offs?

Edited by Cheif Operations Director
Link to comment
Share on other sites

58 minutes ago, Cheif Operations Director said:

I watched the video, I understood most of what it was saying but again I'm left with this point how does the "Arithmetic Logic Unit" take the initial inputs and convert them into software.

The ALU gets its inputs from and sends its outputs to "registers", special storage locations inside the CPU. Where a typical PC now has billions of bytes in RAM, usually you only have 8 or 16 registers (each holding 8 bytes in a modern CPU, fewer in older CPUs).

To really "get" the details of this, you can try writing programs in assembly language. This requires you to specify each instruction that the CPU is to execute. For example, you might tell it to load a value from a memory location into a particular register, then another location into some other register, then add the values in those registers and put the result into a different register, then transfer the value from that register into a third memory location.

3 hours ago, Cheif Operations Director said:

When computers were first invented how exactly did they manage to code them.

In the 1940s, you would flip physical switches to set instruction bits to 1 or 0, and when the program was ready you would turn the computer on and it would execute them.

Later you would punch holes in paper tape. Even later the paper tape was replaced by cards.

Here's some discussion of a simulator of a first generation computer system:

Card based systems looked and worked like this:

 

Edited by HebaruSan
Link to comment
Share on other sites

Transistor has 3 legs (collector-emitter-base or source-drain-base), i.e. input-output-key.
When you apply some voltage to the "key" leg, the "input-output" path gets conducting, and another current (the one you want to treat as a signal) flows from "input" to "output". The transistor is "opened".
When no voltage on the "key" leg, the resistance of the "input"-"output" path grows, no current is flowing through the signal path.  The transistor is "closed".

So, connecting transistors with their legs (output of the previous one attached to the key of the next one) you can manage the signal path, and change current state of your circuit parts.
A chip is just a myriad of transistors in a single hull.

0/1 signals are different values of electric current flowing through the local part of the computer circuit.

Say, (all values are fictitious) "-0.27 +/- 0.05 V" means logical "0", while "-0.84 +/- 0.07 V" means logical "1".
(Other values mean that your circuit is damaged).

Applying the electric current to your transistor scheme (usually inside chips), you get those "0" and "1" voltage values in required places of your circuits.
These voltages in turn open/close electric circuits applying voltage to the "key" legs of next transistors, and so on. 

The very first transistors you mechanically open/close with keyboard/mouse keys.
The very last transistors apply/not apply voltage to your screen pixels.

Edited by kerbiloid
Link to comment
Share on other sites

On 2/21/2019 at 1:44 AM, kerbiloid said:

Transistor has 3 legs (collector-emitter-base or source-drain-base), i.e. input-output-key.
When you apply some voltage to the "key" leg, the "input-output" path gets conducting, and another current (the one you want to treat as a signal) flows fro "input" to "output". The transistor is "opened".
When no voltage on the "key" leg, the resistance of the "input"-"output" path grows, no current flows.  The transistor is "closed".

So, connecting transistors with their legs you can manage the signal path, and change current state of your circuit parts.
A chip is just a myriad of transistors in a single hull.

0/1 signals are different values of electric current flowing through the local part of the computer circuit. 



Say, (all values are fictitious) "-0.27 +/- 0.05 V" means logical "0", while "-0.84 +/- 0.07 V" means logical "1".
(Other values mean that your circuit is damaged).



Applying the electric current to your transistor scheme (usually inside chips), you get those "0" and "1" voltage values in required places of your circuits.
 These voltages in turn open/close electric circuits applying voltage to the "key" legs of next transistors, and so on. 

 

how do you set these values, you used "-0.84+/-0.07 V" 

second: Is this is diagram of a transistor something like this

                     

 

 

                          transistor        stuff             /                           wire

                           |                                     |                                      |

                           |                                      |                                     |

               Wire going up                Output steady                   completion of circuit

                                                             voltage if 

                                                                 on

Edited by Gargamel
Large Blank Space Removed
Link to comment
Share on other sites

6 minutes ago, Cheif Operations Director said:

how do you set these values, you used "-0.84+/-0.07 V" 

Resistors define the electric properties of your circuit, including voltages.
Exact values are defined by the transistors/chips available on the market.

(I can see just a large blank post)

Transistors are connected like this.

sc_darlington_pair.gif

So, you can see the "output" (the arrow) of the previous attached to the "key" of the next.

Managing the very first "key", you are changing the very last "output".
In a real scheme there are multiple "firsts" and "lasts" interconnected with each other through many intermediate ones.

Edited by kerbiloid
Link to comment
Share on other sites

4 minutes ago, kerbiloid said:

Resistors define the electric properties of your circuit, including voltages.
Exact values are defined by the transistors/chips available on the market.



(I can see just a large blank post)

Transistors are connected like this.



sc_darlington_pair.gif

So, you can see "output" (the arrow) of the previous attached to the "key" of the next.

Interesting, is it possible to set up a system where any electrical input would be counted as 1 and no value would be counted as 0

wait

Edited by Cheif Operations Director
Link to comment
Share on other sites

for example no electrical input whatsoever is 0 and 1 volt is 1 and volts in the binary for 2 etc

1 minute ago, kerbiloid said:

A simple wire.

Why did I not see that, ha!

Ok that makes more sense, more proceeding onward to the overarching question how is the electrical inpute made into an interactable value

Link to comment
Share on other sites

6 minutes ago, Cheif Operations Director said:

for example no electrical input whatsoever is 0 and 1 volt is 1 and volts in the binary for 2 etc

It's the simplest possible, but practically inapplicable. The simplest Morse made of a key and a lamp.

In a real scheme you anyway have to deal with not an exact voltage value (say, 0 V), but with a range (say, "0 +/- 0.8 V"), so it's much more stable to have two non-zero voltages for 0 and 1.

You can use three different voltage values and make a ternary CPU, but the more states - the more problems with their distinguishing and treating.
So, 2 voltage values and a binary system are the most useful.

Edited by kerbiloid
Link to comment
Share on other sites

14 minutes ago, kerbiloid said:

Resistors define the electric properties of your circuit, including voltages.
Exact values are defined by the transistors/chips available on the market.

(I can see just a large blank post)

Transistors are connected like this.

sc_darlington_pair.gif

So, you can see the "output" (the arrow) of the previous attached to the "key" of the next.

Managing the very first "key", you are changing the very last "output".
In a real scheme there are multiple "firsts" and "lasts" interconnected with each other through many intermediate ones.

 

err my post was deleted

As to my overarching question how do these electrical charges become digitized into 0 and 1 and how can you interact with these 0 and 1s

Link to comment
Share on other sites

7 minutes ago, Cheif Operations Director said:

As to my overarching question how do these electrical charges become digitized into 0 and 1 and how can you interact with these 0 and 1s

Transistor is opened - 1, transistor is closed - 0.
So, the voltage gets "-0.27... V" or "-0.84... V" on the corresponding resistor.

Some transistors (RAM) keep their state while the power is on. They change it only when CPU commands to the adapter to switch some RAM transistor state.
Others (in the processors) are changing their states many times per second, depending on the current commands.

There is no "solid" "1"/"0", there are only voltages with some accuracy.

Edited by kerbiloid
Link to comment
Share on other sites

Just now, kerbiloid said:

Transistor is opened - 1, transistor is closed - 0.

Some transistors (RAM) keep their state while the power is on. They change it only when CPU commands to the adapter to switch some RAM transistor state.
Others (in the processors) are changing their states many times per second, depending on the current commands.

I understand, what I saying (satirically) is why not A and Z, What im fundemtally trying to understand is how the input becomes the actual value, furthur more how that value can then be coded to do something for example say if this = 1 then do that

Link to comment
Share on other sites

The CPU has (simplifying) 64 "outputs" per register.
Any high-level program when compiled is a set of binary instructions to what voltage level put these outputs.

So, CPU reads the sequence of these primitive commands (lower than assembler level, the machine codes) and changes the output voltages into correspnding states.

Edited by kerbiloid
Link to comment
Share on other sites

Perhaps it would help if you realize that a transistor based computer is very similar to the above posted marble machine. There are switched and latches and different paths the current can take depending on previous state of the transistors and the new inputs. Transistors are pretty similar to dumb mechanical switches (well, apart from being much faster and the ability to not fully open or close, but that is not relevant for this topic).

Additionally, it would probably be easier to wrap your head around the early electromechanical computers which had actual physical switches and relays.

The fundamental functional block of a computer is something called half adder - a device that adds two bits. Take a look at this half adder made with relays to have a better idea of how it works:

relay-Half-adder.jpg

A computer is made from many blocks like this and similar.

Every input into a computer eventually is broken down and turned into a series of bits that go into many of these devices to be calculated and spat out as sum or carry. Those are further processed to get the human readable output.

Link to comment
Share on other sites

3 hours ago, Cheif Operations Director said:

.... how is the electrical inpute made into an interactable value

 

Maybe it helps if you see a computer as a pyramid of abstractions, each one using the functionality of the lower levels and combining them to do something more complex and at the same time hiding its own functionality completely through an interface.

On the lowest level you have the hardware, currents representing 0s and 1s, memory units, registers, etc. That is the hardware. Some basic routines are hardwired and can be called from the layer above. It also offers interfaces to basic protocols to transport bits from a to b.

On the next level you have routines to control the flow of data, to address directly physical units (a drive, a network port, ...), but also in prep for the next layer, to address logical entities, like a packet of data. They run on the hardware through an interface of basic routines they can call.

(leaving the official path here)

A control program uses these routines to provide abstract management of processes, memory, i/o access, user rights, processor time, schedules, etc. It contains specialized routines to close the interfaces between user and hardware like a graphics card or a drive unit. So it is possible for a programmer to write programs that run on several graphics cards without actually caring about how they work. The abstraction layer (lets call it kernel) offers an interface in his direction that connects to specialized routines in the other one. Sometimes a programmer interacts with this level when writing very basic routines

Above the management program sits the application layer. APIs as well belong to this layer. These are libraries that offer prefab routines for a purpose to a programmer, to integrate in his own programs. The application layer in itself can get rather complex with many layers of abstractions. For example a game, written in a high level language that runs on an application called runtime environment and using several levels of "middleware" like a game "engine" and scripting. Compiler, terminals, everything we do, be it gamer or programmer, uses this layer and its interface to the management layer, which uses the protocols of the lower level, which uses the currents and hardware units of the base level.

Hope that wasn't totally nonsense :-)

 

tl:dr: Complexity is all about abstraction and interfaces to work with. Each higher level widens the functionality of the lower levels by adding data structures and algorithms. In the end it is 0s and 1s that are combined by small wires to represent values.

----------------

An "official" example of such a pyramid of abstractions is the

https://en.wikipedia.org/wiki/OSI_model

 

Edited by Green Baron
Link to comment
Share on other sites

I think you are trying to understand too many levels at once. No-one can understand directly how voltages in a transistor become KSP. instead you need to break it down into lots of steps. Each step involves adding together large numbers of the previous step.

The full steps to forming a chain of understanding would include

  1. Understanding how voltages in transistors act as switches.
  2. Understanding how to build the basic logic (and, or, nand, nor, not) gates from transistors.
  3. Understanding how to build basic cpu components like the adder above out of logic gates.
  4. Understanding how to implement simple machine code instuctions like load, store, add etc from the cpu components.
  5. Understanding how to build simple programs out of machine code instructions
  6. understanding how to convert programs written in more advanced languages (c, c# etc) into machine code instructions
  7. Understanding how to create the desired program in an advanced language

As a programmer I have a pretty good knowledge of step 7 but a much more basic understanding of all the other steps.

As for your more specific question of how you display an answer to the user you could probably imagine a system where a series of lights turned on and of to show the binary value of the result.

The next step in computer evolution would be something like an old fashioned seven segment display. There to control just the top segment you are going to need several logic gates, it needs to be lit for any digit except 4 and 1.

Trying to explain how the result of a calculation is displayed on a modern digital monitor in terms of electrical currents is just the wrong question to ask. It crosses too many levels of the model and any full answer is going to have to be a very long book.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...