Previous
Previous Product Image

Easy Notes Of Microprocessor unit-3 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.
Next

Easy Notes Of Microprocessor unit-5 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.
Next Product Image

Easy Notes Of Microprocessor unit-4 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.

Unit – IV Assembly Language Programming
4.1 Models of 8086 assembly language program
4.2 Programming using assembler: Arithmetic operations on hexadecimal and BCD numbers
Sum of series Smallest and largest numbers from array Sorting numbers in ascending and
descending order Check whether given number is odd or even Check whether given number is
positive or negative Block transfer String operations – Length, Reverse, Compare,
Concatenation, Copy Count numbers of ‘l’ and ‘0’ in 16 bit number

Hurry Up!
Add to Wishlist
Add to Wishlist

Description

4.1 Models of 8086 Assembly Language Program 💾

The 8086 uses a segmented memory architecture, dividing memory into logical segments (Code, Data, Stack, Extra). Memory Models define the maximum allowed size for the Code and Data segments and are crucial for the linker and assembler to manage memory references. The .MODEL directive is used to specify the model.

Model Code Size Data Size Pointer Size Key Feature
TINY $\leq 64 \text{KB}$ $\leq 64 \text{KB}$ Near Both code and data share a single segment (produces a .COM file).
SMALL $\leq 64 \text{KB}$ $\leq 64 \text{KB}$ Near Code and data are in separate segments but are small.
COMPACT $\leq 64 \text{KB}$ $> 64 \text{KB}$ Near Code, Far Data Larger data, but single code segment.
MEDIUM $> 64 \text{KB}$ $\leq 64 \text{KB}$ Far Code, Near Data Larger code, but single data segment.
LARGE $> 64 \text{KB}$ $> 64 \text{KB}$ Far Multiple code and data segments, no single data array $> 64 \text{KB}$.
HUGE $> 64 \text{KB}$ $> 64 \text{KB}$ Far Similar to Large, but allows single data array $> 64 \text{KB}$.

4.2 Programming Using Assembler 🔢

This section covers essential algorithms and data manipulation techniques in 8086 assembly:

Arithmetic Operations

  • Hexadecimal Operations: Standard instructions like ADD, SUB, MUL, DIV, INC, and DEC are inherently performed on binary data, which directly represents hexadecimal values.

  • BCD Operations (Binary Coded Decimal): Special instructions are used to adjust the accumulator (AL or AX) after arithmetic operations to ensure the result is a valid BCD number.

    • DAA (Decimal Adjust After Addition): Corrects the result in AL after an ADD or ADC instruction.

    • DAS (Decimal Adjust After Subtraction): Corrects the result in AL after a SUB or SBB instruction.

  • Sum of Series: Typically involves setting up a loop using the LOOP instruction and using a register like CX as a counter and AX or DX:AX as an accumulator.

Array & Sorting

  • Smallest and Largest Numbers (Array): Involves using a loop to iterate through the array, using instructions like MOV and CMP (Compare) to compare the current element with the currently stored minimum/maximum value. Jump instructions (JL – Jump Less, JG – Jump Greater) are used to update the min/max register.

  • Sorting Numbers: Implemented using nested loops (like Bubble Sort or Insertion Sort). This requires using CMP and XCHG (Exchange) instructions to compare adjacent elements and swap them based on the desired order (ascending/descending).

Number Properties (Check)

  • Odd or Even: Determined by checking the Least Significant Bit (LSB).

    • Use the TEST instruction with a bitmask of 0001h (e.g., TEST AL, 01H). If the Zero Flag (ZF) is set (result is zero), the number is even (LSB is 0). If $\text{ZF}=0$, the number is odd (LSB is 1).

    • Alternatively, using ROR (Rotate Right) can shift the LSB into the Carry Flag (CF). If $\text{CF}=1$, it’s odd.

  • Positive or Negative: Determined by checking the Most Significant Bit (MSB), which is the Sign Bit in two’s complement representation.

    • For 8-bit numbers, this is Bit 7. For 16-bit, it’s Bit 15.

    • Check the Sign Flag (SF) after any arithmetic/logical operation. If $\text{SF}=1$, the number is negative. If $\text{SF}=0$ (and $\text{ZF}=0$), the number is positive.

Data Transfer & String Operations

  • Block Transfer: Moving a block of data from one memory location (Source Segment:Offset $\rightarrow$ DS:SI) to another (Extra Segment:Offset $\rightarrow$ ES:DI). This is efficiently done using the REP MOVSB (Repeat Move String Byte) or REP MOVSW (Repeat Move String Word) instructions. CX holds the count.

  • String Operations: The 8086 has dedicated string instructions that automatically increment/decrement the index registers (SI/DI) based on the Direction Flag (DF):

    • Length: Iterating (using SCASB – Scan String Byte) until a delimiter (e.g., $ or 00H) is found, and then calculating the distance from the start address.

    • Reverse/Copy: Using MOVSB or STOSB (Store String Byte) in a loop, often by initializing DI to the end of the destination and setting the DF flag (STD for decrement) to copy backward.

    • Compare: Using REPZ CMPSB (Repeat while Zero/Equal Compare String Byte). This compares the strings at $\text{DS}:\text{SI}$ and $\text{ES}:\text{DI}$ and sets flags based on the result.

    • Concatenation: Copying the first string, then copying the second string to the memory location immediately following the end of the first string.

  • Count ‘1’s and ‘0’s (16-bit number): This is achieved using Bit Manipulation instructions:

    • Use a loop that iterates 16 times (or the bit size).

    • Inside the loop, use the RCL (Rotate through Carry Left) or RCR (Rotate through Carry Right) instruction to move the MSB or LSB into the Carry Flag ($\text{CF}$).

    • Check the $\text{CF}$: if $\text{CF}=1$, increment the ‘1’ counter; otherwise, increment the ‘0’ counter.

Reviews

There are no reviews yet.

Be the first to review “Easy Notes Of Microprocessor unit-4 @Computer Diploma”

Your email address will not be published. Required fields are marked *

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping