2

I am adding ax and bx. So if MSB of the result is 1 then the sign flag=1 or else sign flag=0. Am I right? If I'm right why sign flag=0 is showing in output? Shouldn't it be SF=1? If I am wrong please correct me. I am confused

mov ax,20h
mov bx,80h
add ax,bx
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Tapu Das
  • 391
  • 2
  • 17

1 Answers1

2

So if MSB of the result is 1 then the sign flag=1 or else sign flag=0. Am i right?

You're right about the sign flag reflecting the most significant bit of the result, but in your addition add ax, bxyou're adding 2 words and that's what makes all the difference.

Consider adding bytes:

mov     al, 20h
mov     bl, 80h
add     al, bl     ; -> AL = 20h + 80h = A0h

The result in AL has the most significant bit (bit 7) set and so the SF=1

Consider adding words:

mov     ax, 0020h
mov     bx, 0080h
add     ax, bx     ; -> AX = 0020h + 0080h = 00A0h

The result in AX has the most significant bit (bit 15) cleared and so the SF=0

Tip

It might help to write hexadecimal numbers with as much digits as the register involved can hold.
Write mov ax, 0020h instead of mov ax, 20h.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76