What are the steps taken by the CPU to sum 2 numbers(2+2) from the keyboard input to the display in the screen?
example: reading the ascii code .... convert the typed number to binary ... send to cpu .... printing on screen?
What are the steps taken by the CPU to sum 2 numbers(2+2) from the keyboard input to the display in the screen?
example: reading the ascii code .... convert the typed number to binary ... send to cpu .... printing on screen?
The "higher level" steps are as you've guessed: Get characters from keyboard, convert to integers, add the integers, convert the result back to characters, then display those characters.
The CPU does none of this itself.
The CPU executes tiny little instructions that each do a very simple (and very specific) thing. These instructions are the fundamental (lowest level) building blocks of software. Each of those high level steps represents many instructions.
For a detailed example; to get 1 character from the keyboard (using multiple assumptions about the computer's hardware and the OS being used and over-simplifying):
stdin.Note that all of the above can easily add up to thousands of tiny little instructions that are executed by the CPU; even though it's only a fraction (barely more than one of the "higher level steps" we started with) and even though I didn't provide any details of how the input buffer is displayed while it's being edited (font engine, text layout engine, 2D graphics renderer).
For all higher level steps (get 2 numbers from user, add them, then display the result) the total number of instructions that a CPU executes can be (literally) millions.
pushes, a call and a return.
– 8bittree
Jan 23 '17 at 15:06
1.234e4 and four, and/or Internationalisation (e.g. 1,234.0 vs. 1.234,0) instead of only thinking of the crude/minimal "joke code" from places like standard C library.
– Brendan
Jan 30 '17 at 03:05