Академический Документы
Профессиональный Документы
Культура Документы
Assembly Language
Outline
I. Introduction to Assembly Language
II. Data Representation
III. Boolean Expressions
Introduction to Assembly
Language
What is Assembly Language?
• Assembly language is a low-level programming language for a computer or other
programmable device specific to a particular computer architecture.
• It bears the closest resemblance to native machine language.
• Assembly language is converted into executable machine code by a utility program
referred to as an assembler like NASM, MASM, FASM, etc.
• A linker is a utility program that combines individual files created by an
assembler into a single executable program.
• A related utility, called a debugger lets a user step through a program while its
running and examine registers and memory.
Relation of Assembly Language to
Machine Language
• Machine language is a numeric language specifically understood by a
computer’s processor (CPU).
• Assembly language consists of statements written with short mnemonics
such as ADD, MOV, SUB, and CALL.
• Assembly language has a one-to-one relationship with machine
language.
• Each assembly language instruction corresponds to a single
machine-language instruction.
Relation of Assembly Language to
Machine Language
Relation of Assembly Language to
High-Level Languages
• High-level languages such as Python, C++, and Java have a one-to-many
relationship with assembly language and machine language while each
assembly language statement corresponds to a single machine instruction.
• A single statement in C++ expands into multiple assembly language or
machine instructions.
Relation of Assembly Language to
High-Level Languages
• When adding 1 to 1, the result is 10 binary. The extra digit generates a carry
to the next-highest bit position.
Binary Addition
Binary Addition
Example 2:
What is the sum of each pair of binary integers?
a) 10101111 + 11011011
b) 10010111 + 11111111
c) 01110101 + 10101100
Integer Storage Sizes
• The basic storage unit for all data in a computer is a byte, containing 8 bits.
• Other storage sizes are:
• Word (2 bytes)
• Doubleword (4 bytes)
• Quadword (8 bytes)
• Double Quadword (16 bytes)
Integer Storage Sizes
• A number of large measurements are • One terabyte (1 TB) is equal to 240,
used when referring to both memory or 10244 , or 1,099,511,627,776
and disk space: bytes.
• One kilobyte (1 KB) is equal to 210, • One petabyte is equal to 250 bytes.
or 1024 bytes.
• One exabyte is equal to 260 bytes.
• One megabyte (1 MB) is equal to • One zettabyte is equal to 270 bytes.
220 , or 1,048,576 bytes.
• One gigabyte (1 GB) is equal to 230 ,
• One yottabyte is equal to 280 bytes.
or 10243 , or 1,073,741,824 bytes.
Ranges and Sizes of Unsigned Integer Types
The Hexadecimal Number System
• Hexadecimal digits offer a convenient way to represent binary (especially
large) data.
• Each digit in a hexadecimal integer represents four binary bits, and two
hexadecimal digits together represent a byte.
• A single hexadecimal digit represents decimal 0 to 15, so letters A to F
represent decimal values in the range 10 through 15.
The Hexadecimal Number System
The Hexadecimal Number System
• Converting the binary number 0001 0110 1010 0111 1001 0100 to
hexadecimal:
The Hexadecimal Number System
Example 3:
What is the hexadecimal representation of each of the following binary
numbers?
a) 00110101110110102
b) 11001110101000112
c) 11111110110110112
The Hexadecimal Number System
Example 4:
What is the binary representation of each of the following hexadecimal
numbers?
a) 0126F9D416
b) 6ACDFA9516
c) F69BDC2A16
Converting Unsigned Hexadecimal
to Decimal
• In hexadecimal, each digit position represents a power of 16.
• The following formula calculates a hexadecimal integer's decimal value:
𝑑𝑒𝑐 = 𝐷𝑛−1 × 16𝑛−1 + 𝐷𝑛−2 × 16𝑛−2 + ⋯ + 𝐷1 × 161 + 𝐷0 × 160
• For example, 123416 is equal to:
1 × 163 + 2 × 162 + 3 × 161 + 4 × 160 = 466010
• Similarly, 3BA416 is equal to:
3 × 163 + 11 × 162 + 10 × 161 + 4 × 160 = 15,26810
Converting Unsigned Hexadecimal
to Decimal
Powers of 16 in Decimal
Converting Unsigned Hexadecimal
to Decimal
Example 6:
What is the unsigned decimal representation of each of the following
hexadecimal integers?
a) 6216
b) 4B316
c) 29F16
Converting Unsigned Decimal to
Hexadecimal
• To convert an unsigned decimal integer to hexadecimal, repeatedly divide
the decimal value by 16 and retain each remainder as a hexadecimal digit.