Monday, April 15, 2013

How does Assembly Code run on a microprocessor?


every program that is run on a computer is being executed inside the processor
The microprocessor or Central Processing Unit (CPU) is the heart of the computer
it is the piece of hardware that carries out the tasks or instructions sent to it by the user or operating system

 A program is a set of instructions that are written in a higher-level language, like C/C++ and Java, and translated to a lower-level language by the compiler to assembly and then object or machine code, 1’s and 0’s
 assembler and compiler maps the human readable instructions to machine code, in order to be read by the computer.

 the only language the computer hardware, including the processor, understands is Machine Language

 To code in machine language directly would be problematic and very confusing, so programmers invented a lower-level language called assembly language. Assembly language is just machine language translated to a human readable format that is standardized.

 Just like English there are many different types of assembly languages and each one is specific to the processor it is running on

 The simplest and widely used assembly language is MIPS.
 The MIPS architecture uses only three formats to organize its 128 different types of instructions.
 In a 32-bit architecture each instruction is 32 bits wide and the first six bits (opcode) represent the instruction the processor needs to execute.


 There are three stages in the cycle of the programs execution: Fetch, Decode, and Execute

 The first stage, Fetch, fetches the current instruction from the memory and stores it into the PC or program counter.
 In the decode stage, the instruction is decoded so the processor knows what to do
 The last stage, execute, executes the current decoded instruction.

 This cycle then repeats after PC is incremented by 4, to load the next instruction.
 Once all instructions are done executing the program is done executing.

 http://www.personal.psu.edu/scb5156/assignment5.html

No comments:

Post a Comment