edited by
3,811 views
0 votes
0 votes

Consider the following $\textsf{x}86$ – assembly language instructions:

MOV AL, 153
NEG AL

The contents of the destination register $AL$ (in $8$-bit binary notation), th status of Carry Flag $(CF)$ and Sign Flag $(SF)$ after the execution of above instructions, are

  1. $AL=0110 \: 0110; \: CF=0; \: SF=0$
  2. $AL=0110 \: 0111; \: CF=0; \: SF=1$
  3. $AL=0110 \: 0110; \: CF=1; \: SF=1$
  4. $AL=0110 \: 0111; \: CF=1; \: SF=0$
edited by

4 Answers

2 votes
2 votes
The NEG instruction negates a value by finding 2's complement of its single operand.
153 = 1 0 0 1 1 0 0 1,
its 2's compliment is 0 1 1 0 0 1 1 1
when negating Sign Flag(SF) will have 1 and Carry Flag(CF) is 0 because no carry is there.
So, AL = 0 1 1 0 0 1 1 1, CF = 0 and SF = 1
0 votes
0 votes

NEG instruction actually negates a number by calculating it's 2's complement form i.e it subtracts the operand(or,number) from (0's)

$153=99H=1001\ 1001 \\ \therefore AL=2's\ complement\ of\ 1001\ 1001 =0000\ 0000-1001\ 1001=0110\ 0111\\ As\ there\ is\ a\ borrow\ operation\ CY=1.$

So,(1) is the ans

0 votes
0 votes
153 = 1001 1001
NEG(1001 1001) = 1's complement of(1001 1001) = 0110 0110
MOV AL 153
AL = 1001 1001
NEG AL
AL = 0110 0101
MSB is 0. Hence SF=0
By default CF=0 and it will not change with above operations (MOV, NEG)
So, option (A) is the correct answer.
0 votes
0 votes

I think options were shuffled so everyone’s marking different option in different timeline.

Correct Answer – 

AL = 0110 0111 (2’s Complement of 1001 1001)

CF = 0 (NEG sets the carry flag to 1, unless initial value of the byte, word, or long is 0)

SF = 0 

 

Ref:

https://docs.oracle.com/cd/E19455-01/806-3773/instructionset-31/index.html#:~:text=Description,word%2C%20or%20long%20is%200

https://www.ibm.com/docs/it/aix/7.2?topic=set-neg-negate-instruction

Related questions

3 votes
3 votes
4 answers
1
go_editor asked Aug 9, 2016
8,644 views
What will be the output at $\text{PORT1 }$if the following program is executed?MVI B, 82H MOV A, B MOV C, A MVI D, 37H OUT PORT1 HLT$37H$$82H$$B9H$$00H$
2 votes
2 votes
1 answer
2
0 votes
0 votes
4 answers
4
Pooja Khatri asked Jul 13, 2018
2,538 views
Match the items in $\textbf{List-I}$ and $\textbf{List-II}$ :$\begin{array}{clcl} {} & {\textbf{List-I}} & {} & {\textbf{List-II}} \\ \text{(a)} & \text{interrupts whi...