aboutsummaryrefslogtreecommitdiff
path: root/op_string.h
blob: 66b598b23a77323ba15aa20464d06416258a85ee (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

void OPPROTO glue(glue(op_repz_scas, SUFFIX), STRING_SUFFIX)(void)
{
    int v1, v2, inc;

    if (CX != 0) {
        /* NOTE: the flags are not modified if CX == 0 */
        v1 = EAX & DATA_MASK;
        inc = (DF << SHIFT);
        do {
            v2 = glue(ldu, SUFFIX)(DI_ADDR);
            INC_DI();
            DEC_CX();
            if (v1 != v2)
                break;
        } while (CX != 0);
        CC_SRC = v2;
        CC_DST = v1 - v2;
        CC_OP = CC_OP_SUBB + SHIFT;
    }
    FORCE_RET();
}

void OPPROTO glue(glue(op_repnz_scas, SUFFIX), STRING_SUFFIX)(void)
{
    int v1, v2, inc;

    if (CX != 0) {
        /* NOTE: the flags are not modified if CX == 0 */
        v1 = EAX & DATA_MASK;
        inc = (DF << SHIFT);
        do {
            v2 = glue(ldu, SUFFIX)(DI_ADDR);
            INC_DI();
            DEC_CX();
            if (v1 == v2)
                break;
        } while (CX != 0);
        CC_SRC = v2;
        CC_DST = v1 - v2;
        CC_OP = CC_OP_SUBB + SHIFT;
    }
    FORCE_RET();
}

void OPPROTO glue(glue(op_repz_cmps, SUFFIX), STRING_SUFFIX)(void)
{
    int v1, v2, inc;
    if (CX != 0) {
        inc = (DF << SHIFT);
        do {
            v1 = glue(ldu, SUFFIX)(SI_ADDR);
            v2 = glue(ldu, SUFFIX)(DI_ADDR);
            INC_SI();
            INC_DI();
            DEC_CX();
            if (v1 != v2)
                break;
        } while (CX != 0);
        CC_SRC = v2;
        CC_DST = v1 - v2;
        CC_OP = CC_OP_SUBB + SHIFT;
    }
    FORCE_RET();
}

void OPPROTO glue(glue(op_repnz_cmps, SUFFIX), STRING_SUFFIX)(void)
{
    int v1, v2, inc;
    if (CX != 0) {
        inc = (DF << SHIFT);
        do {
            v1 = glue(ldu, SUFFIX)(SI_ADDR);
            v2 = glue(ldu, SUFFIX)(DI_ADDR);
            INC_SI();
            INC_DI();
            DEC_CX();
            if (v1 == v2)
                break;
        } while (CX != 0);
        CC_SRC = v2;
        CC_DST = v1 - v2;
        CC_OP = CC_OP_SUBB + SHIFT;
    }
    FORCE_RET();
}

#undef STRING_SUFFIX
#undef SI_ADDR
#undef DI_ADDR
#undef INC_SI
#undef INC_DI
#undef CX
#undef DEC_CX