All Exams Test series for 1 year @ ₹349 only
Question

What is the value in AL and CF after the following instruction in 8086 is executed?
MOV AL, 8EH
MOV CL, 02H
SAR AL, CL

The correct answer is
AL-11100011, CF=1

Understanding the 8086 Assembly Instructions

This solution explains the result of executing a sequence of 8086 assembly instructions, focusing on the final values of the $AL$ register and the Carry Flag ($CF$).

Initial State: MOV Instructions

The process begins with two $MOV$ instructions:

  1. $MOV AL, 8EH$: This instruction loads the hexadecimal value $8EH$ into the $AL$ register. In binary representation, $8EH$ is $10001110$.
    • So, after this instruction: $AL$ = $10001110$.
  2. $MOV CL, 02H$: This instruction loads the hexadecimal value $02H$ (which is decimal $2$) into the $CL$ register. The $CL$ register typically holds the count for shift or rotate operations.
    • So, after this instruction: $CL$ = $00000010$.

Executing the SAR Instruction

The core of the question lies in the $SAR AL, CL$ instruction. $SAR$ stands for Arithmetic Shift Right.

  • Operation: This instruction shifts the bits in the destination operand ($AL$) to the right by the number of positions specified in the source operand ($CL$).
  • Key Feature: Arithmetic Shift Right preserves the sign of the number. The value of the Most Significant Bit (MSB) is copied into the Carry Flag ($CF$) and also fills the vacated MSB position(s) on the left.
  • Shift Count: The $CL$ register contains $2$, meaning the bits in $AL$ will be shifted right $2$ times.

Step-by-Step Shift Execution:

Initial value of $AL$ is $10001110$. The MSB is $1$. The initial value of $CF$ is irrelevant before the first shift.

Shift 1:

  • The MSB of $AL$ ($1$) is shifted into the $CF$ flag. $CF$ becomes $1$.
  • All bits in $AL$ shift one position to the right.
  • The vacated MSB position is filled with the original MSB ($1$).
  • The Least Significant Bit (LSB) ($0$) is discarded.
  • $AL$ becomes $11000111$.

Shift 2:

  • The MSB of the current $AL$ ($1$) is shifted into the $CF$ flag. $CF$ remains $1$.
  • All bits in $AL$ shift one position to the right.
  • The vacated MSB position is filled with the original MSB ($1$).
  • The LSB ($1$) is discarded.
  • $AL$ becomes $11100011$.

Final State

After executing $SAR AL, CL$ with $CL$ = $2$:

  • The final value of the $AL$ register is $11100011$.
  • The final value of the Carry Flag ($CF$) is $1$.

Therefore, the final state is $AL$ = $11100011$ and $CF$ = $1$. This matches the first option.

Was this answer helpful?

Important Questions from Microprocessors

  1. What is the content in R1, after the following instructions are executed?
    CLR C
    MOV A,#4CH
    SUBB A,#6EH
    JNC NEXT
    CPL A
    INC A
    NEXT: MOV R1, A
  2. When TMOD is 10 H, the timer will operate as ____________.
  3. The Assembler directive in 8086 which is used to tell the assembler that the names or labels following the directive are in some other assembly module is, ____________.
  4. The magnetic vector potential of an electromagnetic system is given by $  \vec{A}=(y \cos ax)  \vec{a_x} + (y+e^x)   \vec{a_z}$. The magnitude of the magnetic flux density at the origin is

  5. The location of flags in 8086 flag register in ascending order is
    A. CY
    B. T
    C. D
    D. Z
    E. O
    Choose the correct answer from the options given below:

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App