Debian Codegraph @

src/cpu/core_dyn_x86/helpers.h

raw symbols SCIP
1 static bool dyn_helper_divb(Bit8u val) {
2 if (!val) return CPU_PrepareException(0,0);
3 Bitu quo=reg_ax / val;
4 Bit8u rem=(Bit8u)(reg_ax % val);
5 Bit8u quo8=(Bit8u)(quo&0xff);
6 if (quo>0xff) return CPU_PrepareException(0,0);
7 reg_ah=rem;
8 reg_al=quo8;
9 return false;
10 }
11
12 static bool dyn_helper_idivb(Bit8s val) {
13 if (!val) return CPU_PrepareException(0,0);
14 Bits quo=(Bit16s)reg_ax / val;
15 Bit8s rem=(Bit8s)((Bit16s)reg_ax % val);
16 Bit8s quo8s=(Bit8s)(quo&0xff);
17 if (quo!=(Bit16s)quo8s) return CPU_PrepareException(0,0);
18 reg_ah=rem;
19 reg_al=quo8s;
20 return false;
21 }
22
23 static bool dyn_helper_divw(Bit16u val) {
24 if (!val) return CPU_PrepareException(0,0);
25 Bitu num=(reg_dx<<16)|reg_ax;
26 Bitu quo=num/val;
27 Bit16u rem=(Bit16u)(num % val);
28 Bit16u quo16=(Bit16u)(quo&0xffff);
29 if (quo!=(Bit32u)quo16) return CPU_PrepareException(0,0);
30 reg_dx=rem;
31 reg_ax=quo16;
32 return false;
33 }
34
35 static bool dyn_helper_idivw(Bit16s val) {
36 if (!val) return CPU_PrepareException(0,0);
37 Bits num=(reg_dx<<16)|reg_ax;
38 Bits quo=num/val;
39 Bit16s rem=(Bit16s)(num % val);
40 Bit16s quo16s=(Bit16s)quo;
41 if (quo!=(Bit32s)quo16s) return CPU_PrepareException(0,0);
42 reg_dx=rem;
43 reg_ax=quo16s;
44 return false;
45 }
46
47 static bool dyn_helper_divd(Bit32u val) {
48 if (!val) return CPU_PrepareException(0,0);
49 Bit64u num=(((Bit64u)reg_edx)<<32)|reg_eax;
50 Bit64u quo=num/val;
51 Bit32u rem=(Bit32u)(num % val);
52 Bit32u quo32=(Bit32u)(quo&0xffffffff);
53 if (quo!=(Bit64u)quo32) return CPU_PrepareException(0,0);
54 reg_edx=rem;
55 reg_eax=quo32;
56 return false;
57 }
58
59 static bool dyn_helper_idivd(Bit32s val) {
60 if (!val) return CPU_PrepareException(0,0);
61 Bit64s num=(((Bit64u)reg_edx)<<32)|reg_eax;
62 Bit64s quo=num/val;
63 Bit32s rem=(Bit32s)(num % val);
64 Bit32s quo32s=(Bit32s)(quo&0xffffffff);
65 if (quo!=(Bit64s)quo32s) return CPU_PrepareException(0,0);
66 reg_edx=rem;
67 reg_eax=quo32s;
68 return false;
69 }