about summary refs log tree commit diff stats
path: root/src/emu/x64run66dd.c
blob: b1673064ba744a3c34b9d378f22e13e388abbc88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#define _GNU_SOURCE
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>

#include "debug.h"
#include "box64stack.h"
#include "x64emu.h"
#include "x64emu_private.h"
#include "x64run_private.h"
#include "x64primop.h"
#include "x64trace.h"
#include "x87emu_private.h"
#include "box64context.h"
#include "bridge.h"

#include "modrm.h"

#ifdef TEST_INTERPRETER
uintptr_t Test66DD(x64test_t *test, rex_t rex, uintptr_t addr)
#else
uintptr_t Run66DD(x64emu_t *emu, rex_t rex, uintptr_t addr)
#endif
{
    uint8_t nextop;
    reg64_t *oped;
    #ifdef TEST_INTERPRETER
    x64emu_t* emu = test->emu;
    #endif

    nextop = F8;
    switch (nextop) {
        case 0xC0:
        case 0xC1:
        case 0xC2:
        case 0xC3:
        case 0xC4:
        case 0xC5:
        case 0xC6:
        case 0xC7:
        case 0xC8:
        case 0xC9:
        case 0xCA:
        case 0xCB:
        case 0xCC:
        case 0xCD:
        case 0xCE:
        case 0xCF:
        case 0xD0:
        case 0xE0:
        case 0xE5:
        case 0xE8:
        case 0xE9:
        case 0xEA:
        case 0xEB:
        case 0xEC:
        case 0xED:
        case 0xEE:
        case 0xFC:
        case 0xE1:
        case 0xE4:
        case 0xF0:
        case 0xF1:
        case 0xF2:
        case 0xF3:
        case 0xF4:
        case 0xF5:
        case 0xF6:
        case 0xF7:
        case 0xF8:
        case 0xF9:
        case 0xFA:
        case 0xFB:
        case 0xFD:
        case 0xFE:
        case 0xFF:
            return 0;
        default:
        switch((nextop>>3)&7) {
            case 4: /* FRSTOR m94byte */
                GETEW(0);
                fpu_loadenv(emu, (char*)ED, 1);
                // get the STx
                {
                    char* p =(char*)ED;
                    p += 14;
                    for (int i=0; i<8; ++i) {
                        LD2D(p, &emu->x87[7-i].d);
                        p+=10;
                    }
                }
                break;
            case 6: /* FNSAVE m94byte */
                GETEW(0);
                // ENV first...
                #ifndef TEST_INTERPRETER
                fpu_savenv(emu, (char*)ED, 1);
                // save the STx
                {
                    char* p =(char*)ED;
                    p += 14;
                    for (int i=0; i<8; ++i) {
                        D2LD(&emu->x87[7-i].d, p);
                        p+=10;
                    }
                }
                #endif
                reset_fpu(emu);
                break;
            default:
                return 0;
        }
    }
    return addr;
}