0% found this document useful (0 votes)
12 views23 pages

Understanding Assembly Language Basics

Assembly language (AL) is a low-level programming language specific to computer architectures, requiring an assembler to convert it into machine code. Assemblers can be one-pass or two-pass, and common examples include MASM and NASM. The document also covers instruction set architecture (ISA), particularly x86, its historical development, and comparisons with other ISAs like ARM.

Uploaded by

jamiunk1555
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views23 pages

Understanding Assembly Language Basics

Assembly language (AL) is a low-level programming language specific to computer architectures, requiring an assembler to convert it into machine code. Assemblers can be one-pass or two-pass, and common examples include MASM and NASM. The document also covers instruction set architecture (ISA), particularly x86, its historical development, and comparisons with other ISAs like ARM.

Uploaded by

jamiunk1555
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assembly Language

Programming
TEE 4..
General Introduction
Assembly Language Introduction
What is Assembly
• Assembly language (AL) is a low-level programming language for a
computer or other programmable device
• AL is specific to a particular computer architecture in contrast to most
high-level programming languages, which are generally portable
across multiple systems.
• It means a program written for a machine running on an Intel
processor might not work with a machine running on an ARM or MIPS
processor. Hence, different processors understands different
assembly language instructions
• Assembly language is converted into executable machine code
(binary: 0s and 1s) by a utility program referred to as an assembler
like NASM, MASM, etc.
The Assembler
• The Assembler is a Software that converts an assembly language code
to machine code.
• It takes basic Computer commands and converts them into Binary
Code that Computer’s Processor can use to perform its Basic
Operations. These instructions are assembler language or assembly
language.
• While a compiler converts the high-level language to machine
language, an assembler converts assembly language to machine
language.
Types of Assembler
Assemblers are classified into two types based on the number of phases used to
convert to machine code, assemblers have two types:
1. One-Pass Assembler
2. Two-pass Assembler
One-Pass Assembler: A single-pass assembler scans a program one time and
makes an equivalent binary program. The entire assembly language program is
translated to its equivalent machine language program at once.
Two-Pass/Multi-Pass Assembler: the assembly language program has to be
scanned twice or multiple times to translate it completely to the equivalent machine
language program.
These assemblers first process the assembly code and store values in the opcode
table and symbol table. And then in the second step, they generate the machine
code using these tables.
Common Assemblers
1. MASM – Microsoft Macro Assember
2. NASM – Netwide Assembler
3. GAS – GNU Assembler
4. FASM – Flat Assembler
Instruction Set Architecture
X86 ISA
Instruction Set Architecture (ISA)
• Definition: An ISA refers to the basic set of commands and instructions that
a microprocessor understands and can carry out. It is an abstract model of
a processor.
• ISA interface tells the computer hardware what to do in response to a
software command. ISA contains the binary/machine codes for all possible
workings of the hardware.
• The assembly language mnemonics used to communicate with a processor
depends on the ISA upon which that processor is built. For instance, the
instruction MOV R0, R2 works for an ARM-based processor but not an Intel
processor.
• Similarly, the instruction MOV EAX, ECX can be understood by an intel
processor but not an ARM processor. However, this instruction, which is
part of x86 ISA, can be understood both by Intel and AMD processors.
ISA Classification
• An ISA may be classified in a number of ways. A common classification is by
architectural complexity. By this mode of classification we have the:
1. Complex instruction set computer (CISC) which has many specialized
instructions, some of which may only be rarely used in practical programs
2. Reduced instruction set computer (RISC) which simplifies the processor by
efficiently implementing only the instructions that are frequently used in
programs
Other classes of instruction set architectures are:
1. Minimal Instruction Set Computer (MISC)
2. Very Long Instruction Word (VLIW)
3. Explicitly Parallel Instruction Computing (EPIC)
4. One Instruction Set Computer (OISC)
x86 ISA - Historical Development
• x86 is a family of instruction set architectures initially developed by Intel
based on the Intel 8086 microprocessor and its 8088 variant.
• The x86 ISA evolution began with an 8-bit 8080 processor developed by
Intel in 1974.
• In 1978, the 16-bit 8086 microprocessor was introduced as an extension of
the intel 8-bit 8080 microprocessor
• Since then several successors to Intel’s 8086 processor have been released
with the names 80186, 80286, 80386 and 80486. Note, these processor
releases end with 86 in their naming and thus the term x86 came into
existence.
• 80386 is Intel’s first 32-bit type processor which was released in 1985 and
continued with processors such as the Intel Pentium, Intel Pentium 4, Intel
Pentium Core Duo and so on. The Advanced Micro Devices’ (AMD’s) Athlon
is also based on the x86 ISA.
X86 ISA – Historical Development
• Intel and AMD are different processor manufacturing companies but they
both make use of the x86 ISA .
• 1985 – Intel Corporation founded the x86 ISA. It is a 32 bit ISA, it is faster
that the existing 16bit ISA. The extension for x86 32-bit ISA was the Intel
i386
• 1991 AMD got license from Intel to produce x86 based CPUs.
• 2003- AMD built on the x86 32-bit ISA to develop the world’s first 64-bit
x86 based CPU called AMD Opteron. It uses the AMD64 extension to
convert intel’s i386 32-bit instructions into x86 64-bit instructions.
• Intel got license from AMD to use her AMD64 extension to build x86 64-bit
CPUs
• From 2006 till date, both Intel and AMD are working on x86_64 with the
64-bit AMD64 package/extension.
x86 Processors – Use Cases
• x86 processors are ubiquitous in both stationary and portable
personal computers and are also used in midrange computers,
workstations, servers, and most new supercomputer clusters.
• Several software including operating systems like Microsoft Windows,
Android-x86, Firefox OS and Chrome OS are designed to run on x86-
based processors/hardware.
ISAs Available in the CPU Market
• Intel x86 – Developed by Intel
• ARM – Developed by ARM Corporation
• RISC-V – Developed by a Russian Company
• IBM PowerPC – Developed by IBM
• ORACLE SPARC – Developed by ORACLE

• Intel x86 is popular as it is used in most consumer grade computers. It is


structured on the CISC ISA
• ARM is also popular as it is used in mobile phones. Developed using the
RISC ISA structure
Assignment
• Distinguish between the x86 and ARM instruction set architecture,
highlighting the differences in their basic structure, development and
use cases. (5mks)
General Computer
Architecture
Computer Architecture

Fig. 1.0: General Computer Architecture


The CPU
• Control Unit: Responsible for decoding the instructions and
controlling how data moves around the computer system
• ALU: Carries out calculations and logic decisions as required by the
program instruction
• Bus: Wires or lines that carry data around the computer
• Registers are memory locations with specific purposes within the CPU
and can be accessed quickly since they are built into the CPU.
Registers hold instructions and data the computer is using at any
given moment.
Arithmetic Logic Unit (ALU)
The ALU performs arithmetic operations, such as:
• add, subtract, multiply, and divide in fixed-point, decimal, and
floating-point number representations;
• increment and decrement;
• logical operations, such as AND, OR, NOT, exclusive-OR, exclusive-
NOR;
• shifting operations, such as shift right algebraic (SRA), shift right
logical (SRL), shift left algebraic (SLA), and shift left logical (SLL);
and
• rotate operations, such as rotate right and rotate left
Memory
• In general, memory is an aggregate of switches that retain a pattern
long enough for that pattern to be read and understood by a person
or a mechanism.
• Memory consists of containers for alterable patterns that retain an
entered pattern until someone or something alters the pattern. These
patterns are achieved using the combination of binary state 0 and 1
Cache
• Cache is a small amount of very fast memory built into the CPU
• It is used to store instructions or data that are either frequently used
or about to be used
Clock Speed
• The clock inside the CPU ticks at a regular speed. The CPU can process
one instruction per clock tick.
• Example at
• Tick 1 – fetch instruction from memory (RAM) to Register in CPU
• Tick 2 – the Control Unit Decodes the instruction to determine how it is
executed
• Tick 3 – The ALU executes the instruction as specified by the control unit
• The higher the clock speed, the faster the CPU as it can do more in a
shorter period of time.
Memory Heirarchy

CPU
Register

Internal CPU Cache Increasing


order of
Increasing
Memory
order of
External Cache Capacity
speed

RAM

Hard Disk
Register - Types

• Accumulator: Store the result of calculations made by the ALU


• Program Counter: Keeps track of the memory location for the next
instruction to be executed. The program counter passes this next
instruction address to the memory address register
• Memory Data Register (MDR): used to store any data or instruction
fetched from memory or any data that is to be transferred to, and
stored in memory.
• Current Instruction Register (CIR): Register that stores the most
recently fetched instruction while it is waiting to be decoded and
executed
Quiz
• What is an Assembler?
• What is Assembly Language?
• What are Mnemonics?
• What are the types of assembler?
• Mention any 3 common Assemblers
• What is the difference between assembler and compiler?

You might also like