You are on page 1of 13

Machine & Assembly

Language
Group 2.2
What is Machine Language?
Machine language, also known as machine code, is a low-level
programming language that is directly understood and executed
by a computer’s central processing unit (CPU). It consists of
binary code, which is a series of 0s and 1s, representing specific
instructions and data for the computer’s hardware.
Machine language instructions typically include:

1. Opcode: A binary code that specifies the operation to be


performed, such as addition, subtraction, or data transfer.

2. Operand(s): Data or memory addresses on which the


operation is to be performed.
Here’s a simple example of machine language
code for a hypothetical CPU:
01010110 00011001 00100100
In this example, the first group of 8 digits (01010110) might
represent an opcode for “addition,” the second group
(00011001) could be an operand specifying a memory address
or a register where data is stored, and the third group
(00100100) could represent another memory address or data to
be added.
CPU Architecture
Each CPU architecture has its own specific machine language
instruction set, making it unique. Programmers rarely write code
directly in machine language because it’s extremely low-level
and hard to understand. Instead, higher-level programming
languages like C++, Python, or Java are used, and compilers or
assemblers translate those higher-level languages into machine
code for the computer to execute.
What is an Assembly Language?
Assembly language is a low-level programming language that
provides a human-readable representation (mnemonic codes) of
a computer’s machine code instructions. Each assembly
language instruction typically corresponds directly to one
machine code instruction. It’s used to write programs that
interact closely with a computer’s hardware.
What is an Assembly Language?
Assembly language is a low-level programming language that
provides a human-readable representation (mnemonic codes) of
a computer’s machine code instructions. Each assembly
language instruction typically corresponds directly to one
machine code instruction. It’s used to write programs that
interact closely with a computer’s hardware.
Here's a simple explanation and example:
Example assembly code :
MOV AX, 5 – Move the value 5 into the AX register

ADD BX, AX – Add the value in AX to the value BX

JMP LOOP_START – Jump to the label LOOP_START


In this example:
MOV is the mnemonic for “move,” which copies the value 5
into the AX register.
ADD is the mnemonic for “add,” which adds the value in the
AX register to the value in the BX register.
• JMP is the mnemonic for “jump,” which transfers program
control to the LOOP_START label.
Comparison:
Machine Language (Binary):
01011000 10010010 00100101

Equivalent Assembly Language (Mnemonics):


ADD R1, R2, #37
Assembly language is specific to a particular CPU architecture,
and each architecture has its own set of mnemonics and syntax
rules. Programmers use assembly language when they need fine-
grained control over hardware and performance optimization.
Assembly code is typically written in a text file and assembled
into machine code using an assembler before it can be executed
by the computer.

You might also like