From fdbed778ff1f7c889e76e11538b51cbecd967e94 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Tue, 2 Feb 2010 08:53:38 +0900 Subject: [PATCH] =?utf8?q?ADDL=E3=80=81SUBL=E5=91=BD=E4=BB=A4=E3=81=AE?= =?utf8?q?=E5=86=85=E9=83=A8=E6=A7=8B=E9=80=A0=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/exec.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/exec.c b/src/exec.c index 4b3ed78..1862973 100644 --- a/src/exec.c +++ b/src/exec.c @@ -99,7 +99,7 @@ WORD addl(WORD val0, WORD val1) FR = 0x0; temp = val0 + val1; - if(temp > 65535) { + if(temp < 0 || temp > 65535) { FR += OF; } res = (WORD)(temp & 0xFFFF); @@ -114,21 +114,7 @@ WORD addl(WORD val0, WORD val1) /* 論理減算。フラグを設定して値を返す */ WORD subl(WORD val0, WORD val1) { - long temp; - WORD res; - FR = 0x0; - - temp = val0 - val1; - if(temp < 0) { - FR += OF; - } - res = (WORD)(temp & 0xFFFF); - if((res & 0x8000) > 0) { - FR += SF; - } else if(res == 0) { - FR += ZF; - } - return res; + return addl(val0, (~val1 + 1)); } /* 算術比較のフラグ設定。OFは常に0 */ -- 2.18.0