Linux – How an application executes from a computer architecture perspective

How an application executes from a computer architecture perspective… here is a solution to the problem.

How an application executes from a computer architecture perspective

Dear Community Members,
I’m studying a computer architecture class on coursera.org, which comes up with the idea of converting an application to execute instructions on a microprocessor. Extending this idea, I wonder how simple applications such as word processors or emacs perform.

I mean what happens when you start the app, start typing, delete a word or line, save, and exit the app.

Is it possible to see which instructions were executed when the program starts, in typing mode, etc. How do I see the execution of each instruction, its operands, memory, and cache access?

If the issue looks incomplete, add the missing parts to make it more interesting.

Thanks

Solution

We think of the action as “move the cursor by one letter”, “scroll to the next line”, or “enter the letter ‘a'”. Computers are much simpler. It works in a purely mathematical form and calls to load and store data in registers or memory. So “moving the cursor” is really a very, long chain :

  • Get the memory/registration location X
  • Add some value to it to update the original location
  • Repeat….
  • Now that all the parameters are ready, call the system call to update the screen

A simple thing to do is to see how to convert C code to ASM and then to machine language. Keep in mind that even the assembly is higher than the 0s and 1s that actually drive the machine.

Translate the following into whatever ASM they use inside the class:

int result = 1;
int i;

for (i = 100; i > 0; i++)
{
    result *= i;
}

printf("%d\n", result);

Yes, this is stupid code. But look at the amount of code it takes to recreate it in ASM. Now, trace the machine code definition for that ASM and convert the ASM to binaries. This can quickly become monotonous. However, once you understand how it works, you’ll understand how VMWare works and how each computing device works.

Related Problems and Solutions