LD GR1,A
ADDL GR1,B
RET
-A DC #FFEC ; -20
+A DC #FFEC ; 65516
B DC #000A ; 10
END
void subl(WORD r, WORD val)
{
- long s;
+ unsigned long o, s;
- if((s = sys->cpu->gr[r] + (~val + 1)) > 0x10000) {
+ o = sys->cpu->gr[r];
+ if((s = o + (~val + 1)) > 0x10000) {
s -= 0x10000;
}
sys->cpu->gr[r] = (WORD)s;
addl_subl_flagset(s);
- if(r < val) {
+ if(o < val) {
sys->cpu->fr += OF;
}
}
LD GR1,A
ADDL GR1,B
RET
-A DC #FFEC ; -20
+A DC #FFEC ; 65516
B DC #000A ; 10
END
#0003 #0006
../../../../as/cmd/ADDL/addl_r_adr__as1.casl: 5: RET
#0004 #8100
-../../../../as/cmd/ADDL/addl_r_adr__as1.casl: 6:A DC #FFEC ; -20
+../../../../as/cmd/ADDL/addl_r_adr__as1.casl: 6:A DC #FFEC ; 65516
#0005 #FFEC
../../../../as/cmd/ADDL/addl_r_adr__as1.casl: 7:B DC #000A ; 10
#0006 #000A
#0004: GR7: 0 = #0000 = 0000000000000000
#0004: SP: 8 = #0008 = 0000000000001000
#0004: PR: 4 = #0004 = 0000000000000100
-#0004: FR (OF SF ZF): 110
+#0004: FR (OF SF ZF): 010
#0004: Memory::::
#0004: adr : 0000 0001 0002 0003 0004 0005 0006 0007
#0004: 0000: 1010 0005 2210 0006 8100 FFEC 000A 0000
#0004: GR7: 0 = #0000 = 0000000000000000
#0004: SP: 8 = #0008 = 0000000000001000
#0004: PR: 4 = #0004 = 0000000000000100
-#0004: FR (OF SF ZF): 010
+#0004: FR (OF SF ZF): 110
#0004: Memory::::
#0004: adr : 0000 0001 0002 0003 0004 0005 0006 0007
#0004: 0000: 1010 0005 2310 0006 8100 FFEC FFF6 0000
-;;; SUBL r,adr 算術減算ではオーバーフロー、論理演算ではオーバーフローなし
+;;; SUBL r,adr 論理演算ではオーバーフローなし(算術減算ではオーバーフロー)
MAIN START
LD GR1,A
SUBL GR1,B
Assemble ../../../../as/cmd/SUBL/subl_r_adr__o.casl (0)
Assemble ../../../../as/cmd/SUBL/subl_r_adr__o.casl (1)
-../../../../as/cmd/SUBL/subl_r_adr__o.casl: 1:;;; SUBL r,adr 算術減算ではオーバーフロー、論理演算ではオーバーフローなし
+../../../../as/cmd/SUBL/subl_r_adr__o.casl: 1:;;; SUBL r,adr 論理演算ではオーバーフローなし(算術減算ではオーバーフロー)
../../../../as/cmd/SUBL/subl_r_adr__o.casl: 2:MAIN START
../../../../as/cmd/SUBL/subl_r_adr__o.casl: 3: LD GR1,A
#0000 #1010