if-else logic simplification

I have two registers as follow,

HL(consecutive), H holds 8-bit, L holds 8-bit so HL is 16-bit register pair
DE(consecutive), D holds 8-bit, E holds 8-bit so DE is 16-bit register pair

I'm not able to compare HL and DE directly like if(HL > DE). Instead I have to compare separately the registers as H, L, D, E. I construct if-else structure possibilities to know if(HL > DE).

1.

if (l < e)
   if(h > d)
      do what I want
... if not checking other possibilities 2, 3

2.

if (l > e)
   if(h > d)
      do what I want
... if not checking other possibilities 1, 3

3.

if (h > d)
     do what I want
... if not checking other possibilities 1, 2

I'm not sure whether I do rightly. However, if so, can be three of them simplified?

Upvotes: 0

Views: 77

Answers (1)

Iłya Bursov
Iłya Bursov

Reputation: 24146

there are two cases when unsigned hl > de:

  1. h > d
  2. h == d AND l > e

Upvotes: 1

Related Questions