aboutsummaryrefslogtreecommitdiff
path: root/target-mips/op_helper_mem.c
blob: 69793b0b970f0387b524a7184af438654b88cf5b (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
void glue(do_lwl, MEMSUFFIX) (void)
{
#if defined (DEBUG_OP)
    target_ulong sav = T0;
#endif
    uint32_t tmp;

    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
    /* XXX: this is valid only in big-endian mode
     *      should be reverted for little-endian...
     */
    switch (T0 & 3) {
    case 0:
        T0 = tmp;
        break;
    case 1:
        T0 = (tmp << 8) | (T1 & 0x000000FF);
        break;
    case 2:
        T0 = (tmp << 16) | (T1 & 0x0000FFFF);
        break;
    case 3:
        T0 = (tmp << 24) | (T1 & 0x00FFFFFF);
        break;
    }
#if defined (DEBUG_OP)
    if (logfile) {
        fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
                __func__, sav, tmp, T1, T0);
    }
#endif
    RETURN();
}

void glue(do_lwr, MEMSUFFIX) (void)
{
#if defined (DEBUG_OP)
    target_ulong sav = T0;
#endif
    uint32_t tmp;

    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
    /* XXX: this is valid only in big-endian mode
     *      should be reverted for little-endian...
     */
    switch (T0 & 3) {
    case 0:
        T0 = (tmp >> 24) | (T1 & 0xFFFFFF00);
        break;
    case 1:
        T0 = (tmp >> 16) | (T1 & 0xFFFF0000);
        break;
    case 2:
        T0 = (tmp >> 8) | (T1 & 0xFF000000);
        break;
    case 3:
        T0 = tmp;
        break;
    }
#if defined (DEBUG_OP)
    if (logfile) {
        fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
                __func__, sav, tmp, T1, T0);
    }
#endif
    RETURN();
}

void glue(do_swl, MEMSUFFIX) (void)
{
#if defined (DEBUG_OP)
    target_ulong sav;
#endif
    uint32_t tmp;

    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
#if defined (DEBUG_OP)
    sav = tmp;
#endif
    /* XXX: this is valid only in big-endian mode
     *      should be reverted for little-endian...
     */
    switch (T0 & 3) {
    case 0:
        tmp = T1;
        break;
    case 1:
        tmp = (tmp & 0xFF000000) | (T1 >> 8);
        break;
    case 2:
        tmp = (tmp & 0xFFFF0000) | (T1 >> 16);
        break;
    case 3:
        tmp = (tmp & 0xFFFFFF00) | (T1 >> 24);
        break;
    }
    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
#if defined (DEBUG_OP)
    if (logfile) {
        fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
                __func__, T0, sav, T1, tmp);
    }
#endif
    RETURN();
}

void glue(do_swr, MEMSUFFIX) (void)
{
#if defined (DEBUG_OP)
    target_ulong sav;
#endif
    uint32_t tmp;

    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
#if defined (DEBUG_OP)
    sav = tmp;
#endif
    /* XXX: this is valid only in big-endian mode
     *      should be reverted for little-endian...
     */
    switch (T0 & 3) {
    case 0:
        tmp = (tmp & 0x00FFFFFF) | (T1 << 24);
        break;
    case 1:
        tmp = (tmp & 0x0000FFFF) | (T1 << 16);
        break;
    case 2:
        tmp = (tmp & 0x000000FF) | (T1 << 8);
        break;
    case 3:
        tmp = T1;
        break;
    }
    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
#if defined (DEBUG_OP)
    if (logfile) {
        fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
                __func__, T0, sav, T1, tmp);
    }
#endif
    RETURN();
}