From: j8takagi Date: Mon, 1 Feb 2010 23:53:38 +0000 (+0900) Subject: ADDL、SUBL命令の内部構造を変更 X-Git-Tag: v0.1~74^2 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdbed778ff1f7c889e76e11538b51cbecd967e94;p=YACASL2.git ADDL、SUBL命令の内部構造を変更 --- 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 */