profkelly wrote:

BGT Brances if N and V are equal and Z=0.

If the numbers are the same then Z=1.

For all other cases:

Comparing a larger number to a smaller number when both are the same sign will result in N=0, V=0.

Comparing a positive number to a negative number will result in N=1, V=1

**Code:**

; Compare 127 to 100

move.b #127,d0 ; larger positive

sub.b #100,d0 ; minus smaller positive, N=0, V=0, Z=0

; Compare 100 to 127

move.b #100,d0 ; smaller positive

sub.b #127,d0 ; minus larger positive, N=1, V=0, Z=0

; Compare -100 to -127

move.b #-100,d0 ; larger negative

sub.b #-127,d0 ; minus smaller negative, N=0, V=0, Z=0

; Compare -127 to -100

move.b #-127,d0 ; smaller negative

sub.b #-100,d0 ; minus larger negative, N=1, V=0, Z=0

; Compare -100 to 100

move.b #-100,d0 ; smaller negative

sub.b #100,d0 ; minus larger positive, N=0, V=1, Z=0

; Compare 100 to -100

move.b #100,d0 ; larger positive

sub.b #-100,d0 ; minus smaller negative, N=1, V=1, Z=0

Thanks for answering my question. I don't understand two things.

**Code:**

; Compare -100 to 100

move.b #-100,d0 ; smaller negative

sub.b #100,d0 ; minus larger positive, N=0, V=1, Z=0[/quote]

Why N=0 and V=1? Why isn't N=1? -100 - 100 is -200 which is a negative number.

**Code:**

; Compare 100 to -100

move.b #100,d0 ; larger positive

sub.b #-100,d0 ; minus smaller negative, N=1, V=1, Z=0

I don't understand why N=1 and V=1? 100-[-100]=200 which is positive.

I did run everything through the simulator and you are correct. But I am working everything out on my own on paper and these two things aren't clear to me.