Search code examples
linuxhardwarecpu-architecturemicroprocessors

how an application gets executed from computer architecture point of view


Dear Community members, I am going through computer architecture course at coursera.org The course presents the idea that an application translates into executing instructions on the microprocessor. Extending this idea, i want to know how an application such as word processor or as simple as emacs gets executed.

I mean what happens when you start the application, start to type, delete a word or a line, save and quit the application.

Is it possible to see what instructions get executed when the program is launched, in the typing mode, etc. How to see each instruction execution, its operands, memory and cache access?

If the question seems incomplete, please add the missing pieces to make it more interesting.

Thank you


Solution

  • We think of operations as "move the cursor one letter", "scroll to the next line", or "input the letter 'a'". The computer is MUCH simpler. It works in pure math and calls to load and store data in registers or memory. So "move the cursor" is really a long, long chain of:

    • get mem/reg location X
    • add some value to it, update original location
    • repeat....
    • now that all of the arguments are ready, invoke system call to update the screen

    A simple thing is to look at what it takes to convert from C language code into ASM then into machine speak. Remember, even assembly is higher level than the 0's and 1's that actual drive the machine.

    Translate the following into whatever ASM they are using for the class:

    int result = 1;
    int i;
    
    for (i = 100; i > 0; i++)
    {
        result *= i;
    }
    
    printf("%d\n", result);
    

    Yes this is silly code. But look at the amount of code needed just to recreate that in ASM. Now, track down the machine code definitions for that ASM and translate the ASM into the binary. This gets monotonous really quickly. But, once you understand how it works you understand how VMWare works and how every computing device works.