vendredi 1 mars 2019

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?

Aucun commentaire:

Enregistrer un commentaire