summaryrefslogtreecommitdiffstats
path: root/target-ppc/op_helper_mem.h
blob: fb90691f2ba2739b83ac1fcc80f23f38d3faa1c9 (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
void glue(do_lsw, MEMSUFFIX) (int dst)
{
    uint32_t tmp;
    int sh;

#if 0
    if (loglevel > 0) {
        fprintf(logfile, "%s: addr=0x%08x count=%d reg=%d\n",
                __func__, T0, T1, dst);
    }
#endif
    for (; T1 > 3; T1 -= 4, T0 += 4) {
        ugpr(dst++) = glue(ldl, MEMSUFFIX)(T0);
        if (dst == 32)
            dst = 0;
    }
    if (T1 > 0) {
        tmp = 0;
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8) {
            tmp |= glue(ldub, MEMSUFFIX)(T0) << sh;
        }
        ugpr(dst) = tmp;
    }
}

void glue(do_stsw, MEMSUFFIX) (int src)
{
    int sh;

#if 0
    if (loglevel > 0) {
        fprintf(logfile, "%s: addr=0x%08x count=%d reg=%d\n",
                __func__, T0, T1, src);
    }
#endif
    for (; T1 > 3; T1 -= 4, T0 += 4) {
        glue(stl, MEMSUFFIX)(T0, ugpr(src++));
        if (src == 32)
            src = 0;
    }
    if (T1 > 0) {
        for (sh = 24; T1 > 0; T1--, T0++, sh -= 8)
            glue(stb, MEMSUFFIX)(T0, (ugpr(src) >> sh) & 0xFF);
    }
}

void glue(do_lsw_le, MEMSUFFIX) (int dst)
{
    uint32_t tmp;
    int sh;

#if 0
    if (loglevel > 0) {
        fprintf(logfile, "%s: addr=0x%08x count=%d reg=%d\n",
                __func__, T0, T1, dst);
    }
#endif
    for (; T1 > 3; T1 -= 4, T0 += 4) {
        tmp = glue(ldl, MEMSUFFIX)(T0);
        ugpr(dst++) = ((tmp & 0xFF000000) >> 24) | ((tmp & 0x00FF0000) >> 8) |
            ((tmp & 0x0000FF00) << 8) | ((tmp & 0x000000FF) << 24);
        if (dst == 32)
            dst = 0;
    }
    if (T1 > 0) {
        tmp = 0;
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8) {
            tmp |= glue(ldub, MEMSUFFIX)(T0) << sh;
        }
        ugpr(dst) = tmp;
    }
}

void glue(do_stsw_le, MEMSUFFIX) (int src)
{
    uint32_t tmp;
    int sh;

#if 0
    if (loglevel > 0) {
        fprintf(logfile, "%s: addr=0x%08x count=%d reg=%d\n",
                __func__, T0, T1, src);
    }
#endif
    for (; T1 > 3; T1 -= 4, T0 += 4) {
        tmp = ((ugpr(src++) & 0xFF000000) >> 24);
        tmp |= ((ugpr(src++) & 0x00FF0000) >> 8);
        tmp |= ((ugpr(src++) & 0x0000FF00) << 8);
        tmp |= ((ugpr(src++) & 0x000000FF) << 24);
        glue(stl, MEMSUFFIX)(T0, tmp);
        if (src == 32)
            src = 0;
    }
    if (T1 > 0) {
        for (sh = 0; T1 > 0; T1--, T0++, sh += 8)
            glue(stb, MEMSUFFIX)(T0, (ugpr(src) >> sh) & 0xFF);
    }
}

#undef MEMSUFFIX