if-else逻辑简化

问题描述 投票:0回答:1

我有两个寄存器如下,

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

我无法像HL那样直接比较DEif(HL > DE)。相反,我必须将寄存器单独比较为H, L, D, E。我构建if-else结构可能性来了解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

我不确定我是否做得对。但是,如果是这样,可以将其中的三个简化?

algorithm if-statement logic boolean-logic
1个回答
1
投票

无符号hl> de有两种情况:

  1. h > d
  2. h == d AND l > e
© www.soinside.com 2019 - 2024. All rights reserved.