0% found this document useful (0 votes)
5 views8 pages

Assembly Language Assignment 2

The document discusses various addressing modes in CPUs, particularly the 8086 microprocessor, explaining how operands are accessed through methods like immediate, register, direct, indirect, indexed, base indexed, and relative addressing. It also contrasts machine language and assembly language, highlighting their differences in representation, readability, execution, and debugging. Additionally, it covers microprocessor data representation methods, including integer and floating-point representations, character encoding, and hexadecimal shorthand.

Uploaded by

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

Assembly Language Assignment 2

The document discusses various addressing modes in CPUs, particularly the 8086 microprocessor, explaining how operands are accessed through methods like immediate, register, direct, indirect, indexed, base indexed, and relative addressing. It also contrasts machine language and assembly language, highlighting their differences in representation, readability, execution, and debugging. Additionally, it covers microprocessor data representation methods, including integer and floating-point representations, character encoding, and hexadecimal shorthand.

Uploaded by

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

1.

Addressing modes in a Central Processing Unit (CPU) define how machine instructions identify the
location of an operand (data) to be processed. The "effective address" (EA) is the actual memory
address where the operand resides.

Here is an explanation of the requested addressing modes, primarily based on the 8086
microprocessor architecture.

1. Immediate Addressing Mode

In this mode, the operand is explicitly included as part of the instruction itself. It is commonly used
to initialize registers with constant values.

How it works: Instruction = Opcode + Data.

Example: MOV AX, 0005H (Load the hexadecimal value 0005 into the AX register).

Advantages: Very fast; no memory access is required to fetch the data.

2. Register Addressing Mode

The operands are stored in CPU registers. The instruction specifies the registers, not memory
addresses.

How it works: Operand = Content of Register.

Example: MOV AX, BX (Copy the contents of register BX into register AX).

Advantages: Faster than memory addressing, as it reduces memory reads/writes.

3. Direct Addressing Mode (Absolute)

The instruction contains the exact memory address (displacement) of the operand. The CPU uses this
address directly to access data.

How it works: Effective Address (EA) = Address part of the instruction.

Example: MOV AX, [5000H] (Move the content of memory location 5000H into the AX register).

Usage: Implementing static variables.

4. Indirect Addressing Mode (Register Indirect)

The instruction contains a register that holds the memory address of the operand, rather than the
data itself. It acts like a pointer.

How it works: EA = Contents of Register (e.g., BX, SI, DI).

Instruction Example: MOV AX, [BX] (If BX contains 2000H, move the content of memory location
2000H into AX).

Usage: Passing arrays as parameters or implementing pointers.


5. Indexed Addressing Mode

The effective address is calculated by adding a constant value (displacement) to the contents of an
index register (usually SI or DI).

How it works: EA = Contents of Index Register + Displacement.

Example: MOV AX, [SI + 05H] (If SI is 1000H, the operand is at 1005H).

Usage: Accessing arrays or records.

6. Base Indexed Addressing Mode

The effective address is computed by summing the contents of a base register (BX or BP) and an
index register (SI or DI).

How it works: EA = Content of Base Register + Content of Index Register.

Example: MOV AX, [BX + SI] (Commonly used for 2D arrays).

Instruction Usage: Handling complex data structures and 2D array elements.

7. Relative Addressing Mode (PC Relative)

The effective address is calculated by adding a displacement (given in the instruction) to the current
value of the Program Counter (PC/IP).

How it works: EA = Current PC + Displacement.

Example: JMP LABEL or JNZ 05H (Jump 5 bytes relative to the current instruction).

Usage: Relocatable code and branching (if/else, loops).

2.

Machine language is the raw binary code that a computer's CPU executes directly, while assembly
language is a human-readable, symbolic representation of that machine code. Assembly language
acts as a bridge, making low-level programming easier for humans, but it must be translated into
machine code by a program called an assembler before it can run.

Key difference between Machine Language and Assembly Language


Representation: Consists of binary digits (0s and 1s), often represented in octal or hexadecimal for
human reference.

Uses symbolic instruction names called mnemonics (e.g., ADD, MOV, SUB) and symbolic labels for
memory addresses.

Readability : Extremely difficult for humans to read, write, or interpret due to its numeric nature.

Significantly easier for humans to read, write, and understand compared to machine code.

Execution : Executed directly by the CPU without the need for a translator. Execution is very fast.

Cannot be executed directly by the CPU; it must first be translated into machine code by
an assembler. Execution is comparatively slower due to the translation step.

Modification/Debugging : Extremely difficult to modify or debug due to its unreadable format and
high risk of errors.

Easier to modify and debug because the symbolic structure helps in identifying errors and
understanding program logic.

Abstraction Level : The lowest level of programming, directly tied to the hardware's instruction set.

A low-level language but offers a slight level of abstraction above machine code.

Portability :Not portable; specific to a particular CPU architecture and its instruction set.

Not portable across different CPU architectures; programs must be rewritten for different hardware.

2b.

Here are five advantages of assembly language:

Modification/Debugging : Programs written in assembly language are extremely fast because they
are close to the machine code the processor understands. This efficiency enables the creation of
high-performance, time-critical, and speed-optimized code.

Modification/Debugging : Assembly allows for highly compact code because there is no overhead
from high-level language runtime libraries or bloated code structures. It is ideal for systems with
constrained memory resources.

Direct Hardware Control: Assembly language provides direct access to hardware components, such
as CPU registers, memory locations, and input/output ports. This allows programmers to manipulate
specific hardware resources that are not easily accessible in higher-level languages.
Ideal for System-Level Programming: It is heavily used in developing low-level software, such as
operating system kernels, device drivers, and firmware. It is often the only way to write code that
interacts directly with specialized hardware.

Use of Mnemonics: Unlike machine code (which uses binary or hexadecimal), assembly language
uses mnemonic codes (e.g., ADD, SUB, MOV) that are much easier for humans to remember and
understand.

3.

A microprocessor is a silicon-integrated circuit acting as the CPU of a computer, containing the ALU,
control unit, and registers on a single chip. It fetches, decodes, and executes binary instructions to
process data, offering high speed, low power consumption, and versatility for computing tasks.
4.

Microprocessor data representation involves encoding numbers, text, and instructions into binary
(0s and 1s) for processing, primarily using 1-byte (8-bit) to 8-byte (64-bit) formats. Key methods
include unsigned/signed integers, floating-point numbers, Binary Coded Decimal (BCD), and
character encoding (ASCII/EBCDIC). Data is handled in registers, memory, and via hexadecimal
shorthand.

Here is a detailed breakdown of microprocessor data representation methods:

Binary System (Bits and Bytes): The foundation of digital computing. Data is represented as a
sequence of bits (binary digits 0 or 1), which correspond to electrical states (high/low voltage).
A Byte (8 bits) is the standard unit of data measurement, while a Word (16, 32, or 64 bits) represents
the typical size processed at once.

Integer Representation (Numerical Data):

Unsigned Integers: Used for non-negative numbers. All bits represent the magnitude. A 16-bit word
can represent 0 to 12¹⁶ -1(65,535).

Signed Integers (Sign-Magnitude): The Most Significant Bit (MSB) is the sign (0 for +& 1 for -) and
remaining bits are magnitude.

2's Complement: The standard for representing signed integers, allowing subtraction via addition.
Negative numbers are created by inverting the bits of the positive value and adding 1.

Floating-Point Representation (Real Numbers): Used for numbers with fractional parts or scientific
notation (e.g., IEEE 754 standard). The number is divided into a sign bit, exponent, and mantissa
(significand) to represent a wide range of values.

Character Representation (Text):

ASCII (American Standard Code for Information Interchange): A 7-bit or 8-bit code representing
128/256 characters (letters, numbers, punctuation, control codes).

EBCDIC (Extended Binary Coded Decimal Interchange Code): An 8-bit character encoding used
primarily on IBM mainframes.
Binary Coded Decimal (BCD): A method where each decimal digit (0−9) is encoded as a 4-bit binary
sequence (0000−1001). This is often used in calculators and financial applications to avoid rounding
errors found in floating-point math.

Hexadecimal Representation: A base-16 system (0−9, A_F) used by programmers as a concise,


readable shorthand for binary. One hexadecimal character represents four bits, making a 32-bit
address easily written in 8 hex characters.

Data Width/Model (32-bit vs 64-bit): Defines how many bits are processed in one cycle. 64-bit
processors handle larger integers and direct memory addressing (2⁶⁴ locations) compared to 32-bit
systems.

5.

Calculation Breakdown:

A = 10

D =13

4 2 10 13 (4 2 A D)

4×16³ = 4×4096=1638

2×16² = 2×256=512

10×16¹ = 10×16=160

13×16⁰ = 13×1=13

Total:

16384+512+160+13=17069 in decimal.
Calculation breakdown

A=10

E= 14

10 7 2 14 ( A 7 2 E)

10×16³= 10×4096= 40960.

7×16²= 7×256= 1792.

2×16¹= 2×16= 32.

14×16⁰= 14×1=14.

Total

40960+1792+32+14 = 42798

Divide by 8

42798/8 = 5349 R 6.

5349/8 =668 R 5.

668/8 =83 R 4.

83/8 =10 R 3.

10/8 =1 R 2.

1/8 =0 R 1.

Therefore(A72E) hexadecimal to octal = (123456)base 8

References

Matha Electronics - What is Assembly Language

Spiceworks - Assembly Language Working, Features, and Advantages

OpenWA Pressbooks - Fundamentals of Assembly Language


Kaduna polytechnic
Department of computer
engineering
College of industrial
engineering

Assignment on assembly
language.
CTE 241

COE/23/ND/0285

JOSEPH SAINOM HENRY

You might also like