Cpu Assembler In Python

Fetch the next instruction in the program.

Decode the instruction 2) to determine which operation to perform.

Execute the instruction (perform the operation).

10111000 10011110 00011010 11011100 and so forth. ..

Execute the instruction (perform the operation).

From Machine Language to Assembly Language

Computers can only execute programs that are written in machine language. As previously mentioned, a program can have thousands or even millions of binary instructions, and writing such a program would be very tedious and time consuming. Programming in machine language would also be veiy difficult because putting a 0 or a 1 in the wrong place will cause an error,

Although a computer's CPU only understands machine language, it is impractical for people to write programs in machine language. For this reason, assembly language was created in the early days of computing2 as an alternative to machine language. Instead of using binary numbers for instructions, assembly language uses short words that are known as mnemonics. For example, in assembly language, the mnemonic add typically means to add numbers, mul typically means to multiply numbers, and mov typically means to move a value to a location in memory. When a programmer uses assembly language to write a program, he or she can write short mnemonics instead of binary numbers.

NOTE: There are many different versions of assembly language. It was mentioned earlier that each brand of CPU has its own machine language instruction set. Each brand of CPU typically has its own assembly language as well.

Assembly language programs cannot be executed by the CPU, however. The CPU only understands machine language, so a special program known as an assembler is used to translate an assembly language program to a machine language program. This process is shown in Figure 1-18. The machine language program that is created by the assembler can then be executed by the CPU.

Figure 1-18 An assembler translates an assembly language program to a machine language program

Assembly language program

Machine language program

Assembly language program

Was this article helpful?

0 0

Post a comment