Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please explain the answers to all your questions. Thank you! 1. What will be the

ID: 3568385 • Letter: P

Question

Please explain the answers to all your questions. Thank you!

1. What will be the value of BX after the following instructions execute?

mov bx, 0FFFFh

and bx, 6Bh

3. What will be the value of BX after the following instructions execute?

mov bx, 0649Bh

or bx, 3Ah

5. What will be the value of EBX after the following instructions execute?

                mov ebx, 0AFAF649Bh

                or ebx, 3A219604h

7. In the following instruction sequence, show the resulting value of AL where indicated, in binary:

                mov al, 01101111b

                and al, 00101101b                            ; a.

                mov al, 6Dh

                and al, 4Ah                                          ; b.

                mov al, 00001111b

                or al, 61h                                              ; c.

                mov al, 94h

                xor al, 37h                                           ; d.

9. In the following instruction sequence, show the values of the Carry, Zero, and Sign flags where indicated:

                mov al, 00001111b

                test al, 00000010b                            ; a. CF =               ZF =                        SF =

               

mov al, 00000110b

cmp al, 00000101b                           ; b. CF =               ZF =                        SF =

mov al, 00000101b

cmp al, 00000111b                           ; c. CF =                ZF =                        SF =

11. How are JA and JNBE affected by the Zero and Carry flags?

13. What will be the final value in EDX after this code executes?

                mov edx, 1

                mov eax, 7FFFh

                cmp eax, 8000h

                jb L1

                mov edx, 0

15. (True/False): The following code will jump to the label named Target.

                mov eax, -30

                cmp eax, -50

                jg Target

17. What will be the value of RBX after the following instructions execute?

                mov rbx, 0FFFFFFFFFFFFFFFFh

                and rbx, 80h

19. What will be the value of RBX after the following instructions execute?

                mov rbx, 0FFFFFFFFFFFFFFFFh

                and rbx, 80808080h

Explanation / Answer

1.

mov bx,0FFFFh AND bx,6Bh

The binary equivalent of 0FFFFh is (0000 1111 1111 1111 1111)

The binary equivalent of 6Bh is (0000 0000 0000 0110 1011)

Perform the AND operation of the two and the result is as follows:

(0000 1111 1111 1111 1111)AND(0000 0000 0000 0110 1011)=(0000 0000 0000 0110 1011)=(6B)h

Thus, the value of BX after the execution of the instruction is 6Bh.

3.

mov bx, 0649Bh OR bx, 3Ah

The binary equivalent of 0649Bh is (0000 0110 0100 1001 1011)

The binary equivalent of 3Ah is (0000 0000 0000 0011 1010)

The OR operation is performed and the result is as follows:

(0000 0110 0100 1001 1011)OR(0000 0000 0000 0011 1010)=(0000 0110 0100 1011 1011)=(064BB)h

Thus, the value of BX after the execution of the instruction is 064BBh.

5.

mov ebx,0AFAF649Bh OR ebx,3A219604h

The binary equivalent of 0AFAF649Bh is (0000 1010 1111 1010 1111 0110 0100 1001 1011)

The binary equivalent of 3A219604 is (0000 0011 1010 0010 0001 1001 0110 0000 0100)

The OR operation is performed and the result is as follows: OR

Thus, the value of EBX after the execution of the instruction is 0BFAFF69Fh

7.

Here, the value of AL at the position a can be obtained by doing the operation: 01101111 AND 00101101 which is (0010 1101) in binary form.

Similarly, the value of AL at the position b is obtained as follows:

The decimal equivalent of 6Dh is (0110 1101)

The decimal equivalent of 4Ah is (0100 1010)

The AND operation is performed and the result is as follows:

(0110 1101) AND (0100 1010) = (0100 1000) in binary format.

The value of AL at the position c is obtained as follows:

The binary equivalent of 61h is (0110 0001) and one operand is given as (0000 1111) so the result is: (0000 1111) OR (0110 0001) = (0110 1111) in binary format.

The value of AL at the position d can be obtained as follows:

The binary equivalent of 94h is (1001 0100)

The binary equivalent of 37h is (0011 0111)

The value is obtained by doing the XOR operation as follows: (1001 0100) XOR (0011 0111) in binary format.

9.

The value of carry, zero and sign flags are calculated as follows:

           (0000 1111) AND (0000 0010) = (0000 0010)

           The flags are affected in the following ways:

           CF=0 (this is because it is a logical operation and not an arithmetic operation)

           ZF=0 (the result is non-zero in this case)

           SF=0(the most significant bit is off)

The flags are affected in the following ways:

     CF=0(there is no carry or borrow)

     ZF=0(the result is non-zero)

     SF=0(the most significant digit is off)

The flags are affected as follows:

    CF=1(there is borrow in MSB)

    ZF=0(the result non-zero)

    SF=1 (The result is negative so MSB is on)

11.

The carry flag is cleared when jump occurs. The zero flag, ZF is cleared when the jump takes place. For example, Consider the first operand as op1 and second operand as op2. When the comparison is done in both the operands then the following cases occur:

If(op1>op2)

13.

EDX is initialized to 1, jb is an unsigned operation and 7555h is below 8000h, so here jump will be taken, skip the instruction mov edx,0. The final value in EDX will be 1.

15.

The following code will jump to the label named TARGET so the statement is True because the signed representation of -30 and -50 is compared.

17.

The value of RBX after the execution of the instruction is as follows:

(0FFFFFFFFFFFFFFFF) AND (00000000000000080) = (00000000000000080) = (80) h

19.

The value of RBX after the execution of the instruction is as follows:

(0FFFFFFFFFFFFFFFF) AND (00000000080808080) = (00000000080808080) = (80808080) h