From: j8takagi Date: Thu, 4 Feb 2010 01:03:57 +0000 (+0900) Subject: abs.caslで、SF,OFを返すように仕様変更 X-Git-Tag: v0.1~72 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a9e7118e7f1a32304a1ffba0cb7a4b44f90d9fe;p=YACASL2.git abs.caslで、SF,OFを返すように仕様変更 --- diff --git a/as/FUNC/abs.casl b/as/FUNC/abs.casl index ef7d045..35aa20d 100644 --- a/as/FUNC/abs.casl +++ b/as/FUNC/abs.casl @@ -1,9 +1,17 @@ ;;; GR1を絶対値に変換する +;;; 入力 GR1:-32768〜32767の整数 +;;; 出力 GR1:入力された整数の絶対値 +;;; OF:入力されたGR1が-32768の場合、1 +;;; SF:入力されたGR1が負数(-32767〜-1)の場合、1 ABS START AND GR1,GR1 JPL FIN JZE FIN - XOR GR1,=#FFFF - ADDA GR1,=1 + XOR GR1,ALLON + ADDA GR1,ONE + JOV FIN + CPL GR1,ALLON FIN RET +ONE DC 1 +ALLON DC #FFFF END diff --git a/as/FUNC/abs_call.casl b/as/FUNC/abs_call.casl index 4a73221..1d0c3b5 100644 --- a/as/FUNC/abs_call.casl +++ b/as/FUNC/abs_call.casl @@ -4,12 +4,26 @@ MAIN START LAD GR2,0 MLOOP CPA GR2,MLEN JZE MFIN + OUT SEP,MLEN LD GR1,MVAL,GR2 - CALL ABS CALL OUTA + CALL ABS + JOV PUTOV + JMI PUTM + OUT PLUS,=1 + JUMP PUTD +PUTM OUT MINUS,=1 + JUMP PUTD +PUTOV OUT OV,=2 +PUTD CALL OUTA + OUT SEP,MLEN LAD GR2,1,GR2 JUMP MLOOP MFIN RET MVAL DC 12,-12,1,-1,32767,-32767,0,-32768 MLEN DC 8 +SEP DC '--------' +PLUS DC '+' +MINUS DC '-' +OV DC 'OV' END diff --git a/as/FUNC/abs_call1.casl b/as/FUNC/abs_call1.casl new file mode 100644 index 0000000..b53de42 --- /dev/null +++ b/as/FUNC/abs_call1.casl @@ -0,0 +1,8 @@ +;;; ABSを呼び出す +;;; casl2 abs_call.casl abs.casl outa.casl +MAIN START + LD GR1,MVAL + CALL ABS +MFIN RET +MVAL DC -32768 + END