edited by
6,169 views
2 votes
2 votes

Consider the following program fragment in assembly language:

        mov ax, 0h
        mov cx, 0A h
do loop:
        dec ax
        loop doloop

What is the value of $ax$ and $cx$ registers after the completion of the doloop ?

  1. $ax= FFF5 \: h$ and $cx=0 \:h$
  2. $ax= FFF6 \: h$ and $cx=0 \: h$
  3. $ax= FFF7 \: h$ and $cx=0A \:h$
  4. $ax=FFF5 \: h$ and $cx=0A \: h$
edited by

2 Answers

4 votes
4 votes
cx is counter register;
so loop will execute until cx!=0 ;
content of cx= 0Ah
A=10 in hex;
statement doloop:
                     dec ax;  decrement value of ax cx times
                    loop doloop;
simply add ( ax + ( -cx ) )
=>  0000 0000 0000 0000 + ( 2's compliment of cx = 1111 1111 1111 0110)
=> 1111 1111 1111 0110= FFF6, cx =0000h
3 votes
3 votes

Answer is B.

In 8086, dec instruction is to decrement.

loop instruction decrements the value of cx register by 1 until it becomes 0h.

(ax = 0h or we can say 0000h. I am taking two hexadecimal digits from LSB to simplify calculations. ax = 00h)

Answer:

Related questions

1 votes
1 votes
0 answers
2
1 votes
1 votes
1 answer
3
Arjun asked Nov 5, 2017
1,724 views
In the architecture of $8085$ microprocessor match the following :$\begin{array}{clcl} \text{(a)} & \text{Processing unit} & \text{(i)} & \text{Interrupt} \\ \text{(b)}...
3 votes
3 votes
2 answers
4
Arjun asked Nov 5, 2017
1,709 views
In $8085$ microprocessor which of the following flag(s) is (are) affected by an arithmetic operation?AC flag onlyCY flag OnlyZ flag OnlyAC, CY, Z flags