Register content and Flag status after Instructions - GeeksforGeeks

25 Oct, 2018
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.
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.
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.
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.
microprocessor
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Direct Access Media (DMA) Controller in Computer Architecture
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Architecture of 8085 microprocessor
Pin diagram of 8086 microprocessor
I2C Communication Protocol
Memory mapped I/O and Isolated I/O
Difference between Hardwired and Micro-programmed Control Unit | Set 2
Computer Architecture | Flynn's taxonomy
Computer Organization | Different Instruction Cycles
Introduction of Control Unit and its Design