Skip to content

Commit

Permalink
Implement fidivr
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Oct 5, 2018
1 parent 074656e commit 2ec1247
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 47 deletions.
2 changes: 2 additions & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xda0: TRACE("fiadd mem32"); FIADD(mem_addr,32); break;
case 0xda1: TRACE("fimul mem32"); FIMUL(mem_addr,32); break;
case 0xda4: TRACE("fisub mem32"); FISUB(mem_addr,32); break;
case 0xda5: TRACE("fisubr mem32"); FISUBR(mem_addr,32); break;
case 0xda6: TRACE("fidiv mem32"); FIDIV(mem_addr,32); break;
case 0xda7: TRACE("fidivr mem32"); FIDIVR(mem_addr,32); break;
case 0xdb0: TRACE("fild mem32"); FILD(mem_addr,32); break;
case 0xdb2: TRACE("fist mem32"); FIST(mem_addr,32); break;
case 0xdb3: TRACE("fistp mem32"); FIST(mem_addr,32); FPOP; break;
Expand Down
6 changes: 6 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ void fpu_imul16(struct cpu_state *cpu, int16_t *i) {
void fpu_idiv16(struct cpu_state *cpu, int16_t *i) {
ST(0) = f80_div(ST(0), f80_from_int(*i));
}
void fpu_idivr16(struct cpu_state *cpu, int16_t *i) {
ST(0) = f80_div(f80_from_int(*i), ST(0));
}

void fpu_iadd32(struct cpu_state *cpu, int32_t *i) {
ST(0) = f80_add(ST(0), f80_from_int(*i));
Expand All @@ -142,6 +145,9 @@ void fpu_imul32(struct cpu_state *cpu, int32_t *i) {
void fpu_idiv32(struct cpu_state *cpu, int32_t *i) {
ST(0) = f80_div(ST(0), f80_from_int(*i));
}
void fpu_idivr32(struct cpu_state *cpu, int32_t *i) {
ST(0) = f80_div(f80_from_int(*i), ST(0));
}

void fpu_addm32(struct cpu_state *cpu, float32 *f) {
ST(0) = f80_add(ST(0), f80_from_double(*f));
Expand Down
2 changes: 2 additions & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ void fpu_isub16(struct cpu_state *cpu, int16_t *i);
void fpu_isubr16(struct cpu_state *cpu, int16_t *i);
void fpu_imul16(struct cpu_state *cpu, int16_t *i);
void fpu_idiv16(struct cpu_state *cpu, int16_t *i);
void fpu_idivr16(struct cpu_state *cpu, int16_t *i);
void fpu_iadd32(struct cpu_state *cpu, int32_t *i);
void fpu_isub32(struct cpu_state *cpu, int32_t *i);
void fpu_isubr32(struct cpu_state *cpu, int32_t *i);
void fpu_imul32(struct cpu_state *cpu, int32_t *i);
void fpu_idiv32(struct cpu_state *cpu, int32_t *i);
void fpu_idivr32(struct cpu_state *cpu, int32_t *i);
void fpu_addm32(struct cpu_state *cpu, float *f);
void fpu_subm32(struct cpu_state *cpu, float *f);
void fpu_subrm32(struct cpu_state *cpu, float *f);
Expand Down
2 changes: 2 additions & 0 deletions emu/interp/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
dst = f80_div(dst, src)
#define FIDIV(val,z) \
ST(0) = f80_div(ST(0), f80_from_int((sint(z)) get(val,z)))
#define FIDIVR(val,z) \
ST(0) = f80_div(f80_from_int((sint(z)) get(val,z)), ST(0))
#define FDIVM(val,z) \
ST(0) = f80_div(ST(0), f80_from_float(get(val,z),z))
#define FDIVRM(val,z) \
Expand Down
100 changes: 54 additions & 46 deletions iSH.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@
BB792B5F1F96D90D00FFB7A4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
BB792B611F96D90D00FFB7A4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BB792B621F96D90D00FFB7A4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
BB7D931F2087C2880008DA78 /* cpu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpu.h; sourceTree = "<group>"; };
BB7D93202087C2880008DA78 /* cpuid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpuid.h; sourceTree = "<group>"; };
BB7D93212087C2880008DA78 /* decode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = decode.h; sourceTree = "<group>"; };
BB7D93232087C2880008DA78 /* fpu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fpu.h; sourceTree = "<group>"; };
BB7D93242087C2880008DA78 /* sse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sse.h; sourceTree = "<group>"; };
BB7D93252087C2880008DA78 /* interp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = interp.c; sourceTree = "<group>"; };
BB7D93262087C2880008DA78 /* interrupt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = interrupt.h; sourceTree = "<group>"; };
BB7D93272087C2880008DA78 /* memory.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; };
BB7D93282087C2880008DA78 /* memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
BB7D93292087C2880008DA78 /* modrm.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = modrm.c; sourceTree = "<group>"; };
BB7D932A2087C2880008DA78 /* modrm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = modrm.h; sourceTree = "<group>"; };
BB7D932B2087C2880008DA78 /* tlb.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tlb.c; sourceTree = "<group>"; };
BB7D932C2087C2880008DA78 /* tlb.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tlb.h; sourceTree = "<group>"; };
BB7D932D2087C2880008DA78 /* types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = types.h; sourceTree = "<group>"; };
BB7D93302087C2880008DA78 /* meson.build */ = {isa = PBXFileReference; lastKnownFileType = text; path = meson.build; sourceTree = "<group>"; };
BB7D93312087C2880008DA78 /* note.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = note.S; sourceTree = "<group>"; };
BB7D93322087C2880008DA78 /* vdso.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vdso.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -217,6 +203,24 @@
BB7D93802087C2890008DA78 /* tty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tty.h; sourceTree = "<group>"; };
BB7D93812087C2890008DA78 /* debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = "<group>"; };
BB7D93822087C2890008DA78 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
BB8636F92167F4F200E7ADC0 /* cpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpu.h; sourceTree = "<group>"; };
BB8636FA2167F4F200E7ADC0 /* cpuid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpuid.h; sourceTree = "<group>"; };
BB8636FB2167F4F200E7ADC0 /* decode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decode.h; sourceTree = "<group>"; };
BB8636FC2167F4F200E7ADC0 /* float80-test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "float80-test.c"; sourceTree = "<group>"; };
BB8636FD2167F4F200E7ADC0 /* float80.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = float80.c; sourceTree = "<group>"; };
BB8636FE2167F4F200E7ADC0 /* float80.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = float80.h; sourceTree = "<group>"; };
BB8636FF2167F4F200E7ADC0 /* fpu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fpu.c; sourceTree = "<group>"; };
BB8637002167F4F200E7ADC0 /* fpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fpu.h; sourceTree = "<group>"; };
BB8637022167F4F200E7ADC0 /* fpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fpu.h; sourceTree = "<group>"; };
BB8637032167F4F200E7ADC0 /* sse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sse.h; sourceTree = "<group>"; };
BB8637042167F4F200E7ADC0 /* interp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = interp.c; sourceTree = "<group>"; };
BB8637052167F4F200E7ADC0 /* interrupt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = interrupt.h; sourceTree = "<group>"; };
BB8637062167F4F200E7ADC0 /* memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; };
BB8637072167F4F200E7ADC0 /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
BB8637082167F4F200E7ADC0 /* modrm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modrm.h; sourceTree = "<group>"; };
BB8637092167F4F200E7ADC0 /* regid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regid.h; sourceTree = "<group>"; };
BB86370A2167F4F200E7ADC0 /* tlb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tlb.c; sourceTree = "<group>"; };
BB86370B2167F4F200E7ADC0 /* tlb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tlb.h; sourceTree = "<group>"; };
BB88F4722152F75A00A341FD /* frame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = frame.h; sourceTree = "<group>"; };
BB88F4742152F75A00A341FD /* bits.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = bits.S; sourceTree = "<group>"; };
BB88F4752152F75A00A341FD /* control.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = control.S; sourceTree = "<group>"; };
Expand Down Expand Up @@ -302,7 +306,7 @@
isa = PBXGroup;
children = (
BB88F4712152F75A00A341FD /* jit */,
BB7D931E2087C2880008DA78 /* emu */,
BB8636F82167F4F200E7ADC0 /* emu */,
BB7D936A2087C2890008DA78 /* fs */,
BB7D933C2087C2880008DA78 /* kernel */,
BB7D935C2087C2880008DA78 /* tools */,
Expand Down Expand Up @@ -386,35 +390,6 @@
name = Frameworks;
sourceTree = "<group>";
};
BB7D931E2087C2880008DA78 /* emu */ = {
isa = PBXGroup;
children = (
BB7D931F2087C2880008DA78 /* cpu.h */,
BB7D93202087C2880008DA78 /* cpuid.h */,
BB7D93212087C2880008DA78 /* decode.h */,
BB7D93222087C2880008DA78 /* interp */,
BB7D93252087C2880008DA78 /* interp.c */,
BB7D93262087C2880008DA78 /* interrupt.h */,
BB7D93272087C2880008DA78 /* memory.c */,
BB7D93282087C2880008DA78 /* memory.h */,
BB7D93292087C2880008DA78 /* modrm.c */,
BB7D932A2087C2880008DA78 /* modrm.h */,
BB7D932B2087C2880008DA78 /* tlb.c */,
BB7D932C2087C2880008DA78 /* tlb.h */,
BB7D932D2087C2880008DA78 /* types.h */,
);
path = emu;
sourceTree = "<group>";
};
BB7D93222087C2880008DA78 /* interp */ = {
isa = PBXGroup;
children = (
BB7D93232087C2880008DA78 /* fpu.h */,
BB7D93242087C2880008DA78 /* sse.h */,
);
path = interp;
sourceTree = "<group>";
};
BB7D932F2087C2880008DA78 /* vdso */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -525,6 +500,39 @@
path = fs;
sourceTree = "<group>";
};
BB8636F82167F4F200E7ADC0 /* emu */ = {
isa = PBXGroup;
children = (
BB8636F92167F4F200E7ADC0 /* cpu.h */,
BB8636FA2167F4F200E7ADC0 /* cpuid.h */,
BB8636FB2167F4F200E7ADC0 /* decode.h */,
BB8636FC2167F4F200E7ADC0 /* float80-test.c */,
BB8636FD2167F4F200E7ADC0 /* float80.c */,
BB8636FE2167F4F200E7ADC0 /* float80.h */,
BB8636FF2167F4F200E7ADC0 /* fpu.c */,
BB8637002167F4F200E7ADC0 /* fpu.h */,
BB8637012167F4F200E7ADC0 /* interp */,
BB8637042167F4F200E7ADC0 /* interp.c */,
BB8637052167F4F200E7ADC0 /* interrupt.h */,
BB8637062167F4F200E7ADC0 /* memory.c */,
BB8637072167F4F200E7ADC0 /* memory.h */,
BB8637082167F4F200E7ADC0 /* modrm.h */,
BB8637092167F4F200E7ADC0 /* regid.h */,
BB86370A2167F4F200E7ADC0 /* tlb.c */,
BB86370B2167F4F200E7ADC0 /* tlb.h */,
);
path = emu;
sourceTree = "<group>";
};
BB8637012167F4F200E7ADC0 /* interp */ = {
isa = PBXGroup;
children = (
BB8637022167F4F200E7ADC0 /* fpu.h */,
BB8637032167F4F200E7ADC0 /* sse.h */,
);
path = interp;
sourceTree = "<group>";
};
BB88F4712152F75A00A341FD /* jit */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1292,7 +1300,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ISH_LOG = "";
ISH_LOG = strace;
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1333,7 +1341,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ISH_LOG = "";
ISH_LOG = strace;
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
SDKROOT = iphoneos;
VALID_ARCHS = arm64;
Expand Down
3 changes: 2 additions & 1 deletion jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,15 @@ static inline bool gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define FSUB(src, dst) hhh(fpu_sub, src, dst)
#define FSUBM(val,z) h_read(fpu_subm, z)
#define FISUB(val,z) h_read(fpu_isub, z)
#define FISUBR(val,z) h_read(fpu_isubr, z)
#define FSUBR(src, dst) hhh(fpu_subr, src, dst)
#define FSUBRM(val,z) h_read(fpu_subrm, z)
#define FISUBR(val,z) h_read(fpu_isubr, z)
#define FMUL(src, dst) hhh(fpu_mul, src, dst)
#define FIMUL(val,z) h_read(fpu_imul, z)
#define FMULM(val,z) h_read(fpu_mulm, z)
#define FDIV(src, dst) hhh(fpu_div, src, dst)
#define FIDIV(val,z) h_read(fpu_idiv, z)
#define FIDIVR(val,z) h_read(fpu_idivr, z)
#define FDIVM(val,z) h_read(fpu_divm, z)
#define FDIVRM(val,z) h_read(fpu_divrm, z)

Expand Down

0 comments on commit 2ec1247

Please sign in to comment.