Register content and Flag status after Instructions

Basically, you are given a set of instructions and the initial content of the registers and flags of 8085 microprocessor. You have to find the content of the registers and flag status after each instruction.

Initially,

Below is the set of the instructions:



SUB A
MOV B, A
DCR B
INR B
SUI 01H
HLT 


Assumption:
Each instruction will use the result of the previous instruction for registers. Following is the description of each instruction with register content and flag status:

  • Instruction-1:
    SUB A instruction will subtract the content of the accumulator itself. It is used to clear the content of the accumulator. After this operation the content of the registers and flags will be like figure given below.

  • Instruction-2:
    MOV B, A will copy the content from source register (A) to the destination register (B). Since it is the Data Transfer instruction so it will not affect any flag. After this operation the content of the registers and flags will be like figure given below.

  • Instruction-3:
    DCR B will decrease the content of the register B by 1. DCR operation doesn’t affect Carry flag(CY).

    B-00H 0 0 0 0  0 0 0 0 

    For DCR B takes the 2’s complement of the 01H, 2’s Complement of 01H:

     0 0 0 0  0 0 0 1
     1 1 1 1  1 1 1 0  (1's complement)
                  + 1
    ------------------
     1 1 1 1  1 1 1 1 
    ------------------ 
    
    +(00)  0 0 0 0  0 0 0 0 
    -----------------------
           1 1 1 1  1 1 1 1   
    ----------------------  

    (FFH) this will be the content of the B. So after this operation the content of the registers and flag will be like figure given below.

  • Instruction-4:
    INR B will increase the content of the register B by 1. INR operation doesn’t affect Carry flag(CY).


    B(FFH)     
            1 1 1 1  1 1 1 1 
    +(01)   0 0 0 0  0 0 0 1 
           ------------------
    CY=1    0 0 0 0  0 0 0 0  
           ------------------ 

    (0 0 0 0 0 0 0 0) will be the content of the register B. So after this operation the content of the registers and flag will be like figure given below.

  • Instruction-5:
    SUI 01H will subtract 01H from the content of the accumulator and store the result in the accumulator.

    A-00H  0 0 0 0  0 0 0 0 

    For SUI 01H takes the 2’s complement of the 01H, 2’s Complement of 01H:

           0 0 0 0  0 0 0 1
           1 1 1 1  1 1 1 0  (1's complement)
                        + 1
          ------------------
           1 1 1 1  1 1 1 1 
          ------------------ 
    +(00)  0 0 0 0  0 0 0 0   (Content of the accumulator)
        -----------------------
           1 1 1 1  1 1 1 1   

    (FFH) this will store in the Accumulator. After this operation the content of the registers and flag will be like figure given below.

    HLT will terminate the execution of program.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.