ops_template.h 13.4 KB
Newer Older
bellard's avatar
bellard committed
1
2
3
4
5
6
/*
 *  i386 micro operations (included several times to generate
 *  different operand sizes)
 * 
 *  Copyright (c) 2003 Fabrice Bellard
 *
7
8
9
10
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
bellard's avatar
bellard committed
11
 *
12
13
14
15
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
bellard's avatar
bellard committed
16
 *
17
18
19
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
bellard's avatar
bellard committed
20
 */
bellard's avatar
bellard committed
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
#define DATA_BITS (1 << (3 + SHIFT))
#define SHIFT_MASK (DATA_BITS - 1)
#define SIGN_MASK (1 << (DATA_BITS - 1))

#if DATA_BITS == 8
#define SUFFIX b
#define DATA_TYPE uint8_t
#define DATA_STYPE int8_t
#define DATA_MASK 0xff
#elif DATA_BITS == 16
#define SUFFIX w
#define DATA_TYPE uint16_t
#define DATA_STYPE int16_t
#define DATA_MASK 0xffff
#elif DATA_BITS == 32
#define SUFFIX l
#define DATA_TYPE uint32_t
#define DATA_STYPE int32_t
#define DATA_MASK 0xffffffff
#else
#error unhandled operand size
#endif

/* dynamic flags computation */

static int glue(compute_all_add, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
    src1 = CC_SRC;
    src2 = CC_DST - CC_SRC;
    cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
bellard's avatar
bellard committed
55
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
56
57
58
59
60
61
62
63
64
65
66
67
68
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
    of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_add, SUFFIX)(void)
{
    int src1, cf;
    src1 = CC_SRC;
    cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1;
    return cf;
}

bellard's avatar
bellard committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
static int glue(compute_all_adc, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
    src1 = CC_SRC;
    src2 = CC_DST - CC_SRC - 1;
    cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
    of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_adc, SUFFIX)(void)
{
    int src1, cf;
    src1 = CC_SRC;
    cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1;
    return cf;
}

bellard's avatar
bellard committed
92
93
94
95
static int glue(compute_all_sub, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
96
97
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
98
99
100
    cf = (DATA_TYPE)src1 < (DATA_TYPE)src2;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
bellard's avatar
bellard committed
101
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
102
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
bellard's avatar
bellard committed
103
    of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
bellard's avatar
bellard committed
104
105
106
107
108
109
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_sub, SUFFIX)(void)
{
    int src1, src2, cf;
110
111
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
112
113
114
115
116
117
118
119
    cf = (DATA_TYPE)src1 < (DATA_TYPE)src2;
    return cf;
}

static int glue(compute_all_sbb, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
120
121
    src1 = CC_DST + CC_SRC + 1;
    src2 = CC_SRC;
bellard's avatar
bellard committed
122
123
124
125
126
127
128
129
130
131
132
133
    cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
    of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O;
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_sbb, SUFFIX)(void)
{
    int src1, src2, cf;
134
135
    src1 = CC_DST + CC_SRC + 1;
    src2 = CC_SRC;
bellard's avatar
bellard committed
136
    cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2;
bellard's avatar
bellard committed
137
138
139
140
141
142
143
144
145
    return cf;
}

static int glue(compute_all_logic, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    cf = 0;
    pf = parity_table[(uint8_t)CC_DST];
    af = 0;
bellard's avatar
bellard committed
146
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
    of = 0;
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_logic, SUFFIX)(void)
{
    return 0;
}

static int glue(compute_all_inc, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
    src1 = CC_DST - 1;
    src2 = 1;
    cf = CC_SRC;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
bellard's avatar
bellard committed
166
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
167
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
bellard's avatar
bellard committed
168
    of = ((CC_DST & DATA_MASK) == SIGN_MASK) << 11;
bellard's avatar
bellard committed
169
170
171
    return cf | pf | af | zf | sf | of;
}

bellard's avatar
bellard committed
172
#if DATA_BITS == 32
bellard's avatar
bellard committed
173
174
175
176
static int glue(compute_c_inc, SUFFIX)(void)
{
    return CC_SRC;
}
bellard's avatar
bellard committed
177
#endif
bellard's avatar
bellard committed
178
179
180
181
182
183
184
185
186
187

static int glue(compute_all_dec, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    int src1, src2;
    src1 = CC_DST + 1;
    src2 = 1;
    cf = CC_SRC;
    pf = parity_table[(uint8_t)CC_DST];
    af = (CC_DST ^ src1 ^ src2) & 0x10;
bellard's avatar
bellard committed
188
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
189
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
bellard's avatar
bellard committed
190
    of = ((CC_DST & DATA_MASK) == ((uint32_t)SIGN_MASK - 1)) << 11;
bellard's avatar
bellard committed
191
192
193
194
195
196
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_all_shl, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
197
    cf = (CC_SRC >> (DATA_BITS - 1)) & CC_C;
bellard's avatar
bellard committed
198
199
    pf = parity_table[(uint8_t)CC_DST];
    af = 0; /* undefined */
bellard's avatar
bellard committed
200
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
bellard's avatar
bellard committed
201
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
202
203
    /* of is defined if shift count == 1 */
    of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O;
bellard's avatar
bellard committed
204
205
206
207
    return cf | pf | af | zf | sf | of;
}

static int glue(compute_c_shl, SUFFIX)(void)
bellard's avatar
bellard committed
208
209
210
211
212
213
{
    return (CC_SRC >> (DATA_BITS - 1)) & CC_C;
}

#if DATA_BITS == 32
static int glue(compute_c_sar, SUFFIX)(void)
bellard's avatar
bellard committed
214
215
216
{
    return CC_SRC & 1;
}
bellard's avatar
bellard committed
217
218
219
220
221
222
223
224
225
226
#endif

static int glue(compute_all_sar, SUFFIX)(void)
{
    int cf, pf, af, zf, sf, of;
    cf = CC_SRC & 1;
    pf = parity_table[(uint8_t)CC_DST];
    af = 0; /* undefined */
    zf = ((DATA_TYPE)CC_DST == 0) << 6;
    sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80;
227
228
    /* of is defined if shift count == 1 */
    of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O; 
bellard's avatar
bellard committed
229
230
    return cf | pf | af | zf | sf | of;
}
bellard's avatar
bellard committed
231
232
233
234
235
236

/* various optimized jumps cases */

void OPPROTO glue(op_jb_sub, SUFFIX)(void)
{
    int src1, src2;
237
238
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
239
240

    if ((DATA_TYPE)src1 < (DATA_TYPE)src2)
bellard's avatar
bellard committed
241
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
242
    else
bellard's avatar
bellard committed
243
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
244
245
246
247
248
    FORCE_RET();
}

void OPPROTO glue(op_jz_sub, SUFFIX)(void)
{
bellard's avatar
bellard committed
249
    if ((DATA_TYPE)CC_DST == 0)
bellard's avatar
bellard committed
250
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
251
    else
bellard's avatar
bellard committed
252
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
253
254
255
256
257
258
    FORCE_RET();
}

void OPPROTO glue(op_jbe_sub, SUFFIX)(void)
{
    int src1, src2;
259
260
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
261
262

    if ((DATA_TYPE)src1 <= (DATA_TYPE)src2)
bellard's avatar
bellard committed
263
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
264
    else
bellard's avatar
bellard committed
265
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
266
267
268
269
270
271
    FORCE_RET();
}

void OPPROTO glue(op_js_sub, SUFFIX)(void)
{
    if (CC_DST & SIGN_MASK)
bellard's avatar
bellard committed
272
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
273
    else
bellard's avatar
bellard committed
274
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
275
276
277
278
279
280
    FORCE_RET();
}

void OPPROTO glue(op_jl_sub, SUFFIX)(void)
{
    int src1, src2;
281
282
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
283
284

    if ((DATA_STYPE)src1 < (DATA_STYPE)src2)
bellard's avatar
bellard committed
285
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
286
    else
bellard's avatar
bellard committed
287
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
288
289
290
291
292
293
    FORCE_RET();
}

void OPPROTO glue(op_jle_sub, SUFFIX)(void)
{
    int src1, src2;
294
295
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
296
297

    if ((DATA_STYPE)src1 <= (DATA_STYPE)src2)
bellard's avatar
bellard committed
298
        JUMP_TB(PARAM1, 0, PARAM2);
bellard's avatar
bellard committed
299
    else
bellard's avatar
bellard committed
300
        JUMP_TB(PARAM1, 1, PARAM3);
bellard's avatar
bellard committed
301
302
303
    FORCE_RET();
}

bellard's avatar
bellard committed
304
305
306
307
308
309
310
311
312
313
314
315
/* oldies */

#if DATA_BITS >= 16

void OPPROTO glue(op_loopnz, SUFFIX)(void)
{
    unsigned int tmp;
    int eflags;
    eflags = cc_table[CC_OP].compute_all();
    tmp = (ECX - 1) & DATA_MASK;
    ECX = (ECX & ~DATA_MASK) | tmp;
    if (tmp != 0 && !(eflags & CC_Z))
bellard's avatar
bellard committed
316
        EIP = PARAM1;
bellard's avatar
bellard committed
317
    else
bellard's avatar
bellard committed
318
        EIP = PARAM2;
bellard's avatar
bellard committed
319
320
321
322
323
324
325
326
327
328
329
    FORCE_RET();
}

void OPPROTO glue(op_loopz, SUFFIX)(void)
{
    unsigned int tmp;
    int eflags;
    eflags = cc_table[CC_OP].compute_all();
    tmp = (ECX - 1) & DATA_MASK;
    ECX = (ECX & ~DATA_MASK) | tmp;
    if (tmp != 0 && (eflags & CC_Z))
bellard's avatar
bellard committed
330
        EIP = PARAM1;
bellard's avatar
bellard committed
331
    else
bellard's avatar
bellard committed
332
        EIP = PARAM2;
bellard's avatar
bellard committed
333
334
335
336
337
338
339
340
341
    FORCE_RET();
}

void OPPROTO glue(op_loop, SUFFIX)(void)
{
    unsigned int tmp;
    tmp = (ECX - 1) & DATA_MASK;
    ECX = (ECX & ~DATA_MASK) | tmp;
    if (tmp != 0)
bellard's avatar
bellard committed
342
        EIP = PARAM1;
bellard's avatar
bellard committed
343
    else
bellard's avatar
bellard committed
344
        EIP = PARAM2;
bellard's avatar
bellard committed
345
346
347
348
349
350
    FORCE_RET();
}

void OPPROTO glue(op_jecxz, SUFFIX)(void)
{
    if ((DATA_TYPE)ECX == 0)
bellard's avatar
bellard committed
351
        EIP = PARAM1;
bellard's avatar
bellard committed
352
    else
bellard's avatar
bellard committed
353
        EIP = PARAM2;
bellard's avatar
bellard committed
354
355
356
357
358
    FORCE_RET();
}

#endif

bellard's avatar
bellard committed
359
360
361
362
363
/* various optimized set cases */

void OPPROTO glue(op_setb_T0_sub, SUFFIX)(void)
{
    int src1, src2;
364
365
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
366
367
368
369
370
371

    T0 = ((DATA_TYPE)src1 < (DATA_TYPE)src2);
}

void OPPROTO glue(op_setz_T0_sub, SUFFIX)(void)
{
bellard's avatar
bellard committed
372
    T0 = ((DATA_TYPE)CC_DST == 0);
bellard's avatar
bellard committed
373
374
375
376
377
}

void OPPROTO glue(op_setbe_T0_sub, SUFFIX)(void)
{
    int src1, src2;
378
379
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
380
381
382
383
384
385
386
387
388
389
390
391

    T0 = ((DATA_TYPE)src1 <= (DATA_TYPE)src2);
}

void OPPROTO glue(op_sets_T0_sub, SUFFIX)(void)
{
    T0 = lshift(CC_DST, -(DATA_BITS - 1)) & 1;
}

void OPPROTO glue(op_setl_T0_sub, SUFFIX)(void)
{
    int src1, src2;
392
393
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
394
395
396
397
398
399
400

    T0 = ((DATA_STYPE)src1 < (DATA_STYPE)src2);
}

void OPPROTO glue(op_setle_T0_sub, SUFFIX)(void)
{
    int src1, src2;
401
402
    src1 = CC_DST + CC_SRC;
    src2 = CC_SRC;
bellard's avatar
bellard committed
403
404
405
406
407
408

    T0 = ((DATA_STYPE)src1 <= (DATA_STYPE)src2);
}

/* shifts */

bellard's avatar
bellard committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
void OPPROTO glue(glue(op_shl, SUFFIX), _T0_T1)(void)
{
    int count;
    count = T1 & 0x1f;
    T0 = T0 << count;
    FORCE_RET();
}

void OPPROTO glue(glue(op_shr, SUFFIX), _T0_T1)(void)
{
    int count;
    count = T1 & 0x1f;
    T0 &= DATA_MASK;
    T0 = T0 >> count;
    FORCE_RET();
}

void OPPROTO glue(glue(op_sar, SUFFIX), _T0_T1)(void)
{
    int count, src;
    count = T1 & 0x1f;
    src = (DATA_STYPE)T0;
    T0 = src >> count;
    FORCE_RET();
}

435
436
#undef MEM_WRITE
#include "ops_template_mem.h"
437

438
439
#define MEM_WRITE
#include "ops_template_mem.h"
bellard's avatar
bellard committed
440

bellard's avatar
bellard committed
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* bit operations */
#if DATA_BITS >= 16

void OPPROTO glue(glue(op_bt, SUFFIX), _T0_T1_cc)(void)
{
    int count;
    count = T1 & SHIFT_MASK;
    CC_SRC = T0 >> count;
}

void OPPROTO glue(glue(op_bts, SUFFIX), _T0_T1_cc)(void)
{
    int count;
    count = T1 & SHIFT_MASK;
455
    T1 = T0 >> count;
bellard's avatar
bellard committed
456
457
458
459
460
461
462
    T0 |= (1 << count);
}

void OPPROTO glue(glue(op_btr, SUFFIX), _T0_T1_cc)(void)
{
    int count;
    count = T1 & SHIFT_MASK;
463
    T1 = T0 >> count;
bellard's avatar
bellard committed
464
465
466
467
468
469
470
    T0 &= ~(1 << count);
}

void OPPROTO glue(glue(op_btc, SUFFIX), _T0_T1_cc)(void)
{
    int count;
    count = T1 & SHIFT_MASK;
471
    T1 = T0 >> count;
bellard's avatar
bellard committed
472
473
474
    T0 ^= (1 << count);
}

bellard's avatar
bellard committed
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
void OPPROTO glue(glue(op_bsf, SUFFIX), _T0_cc)(void)
{
    int res, count;
    res = T0 & DATA_MASK;
    if (res != 0) {
        count = 0;
        while ((res & 1) == 0) {
            count++;
            res >>= 1;
        }
        T0 = count;
        CC_DST = 1; /* ZF = 1 */
    } else {
        CC_DST = 0; /* ZF = 1 */
    }
    FORCE_RET();
}

void OPPROTO glue(glue(op_bsr, SUFFIX), _T0_cc)(void)
{
    int res, count;
    res = T0 & DATA_MASK;
    if (res != 0) {
        count = DATA_BITS - 1;
        while ((res & SIGN_MASK) == 0) {
            count--;
            res <<= 1;
        }
        T0 = count;
        CC_DST = 1; /* ZF = 1 */
    } else {
        CC_DST = 0; /* ZF = 1 */
    }
    FORCE_RET();
}

bellard's avatar
bellard committed
511
512
#endif

513
514
515
516
517
518
519
#if DATA_BITS == 32
void OPPROTO op_update_bt_cc(void)
{
    CC_SRC = T1;
}
#endif

bellard's avatar
bellard committed
520
/* string operations */
521
522
523
524
525
526
527
528
529
530
531
532
533
/* XXX: maybe use lower level instructions to ease 16 bit / segment handling */

#define STRING_SUFFIX _fast
#define SI_ADDR (void *)ESI
#define DI_ADDR (void *)EDI
#define INC_SI() ESI += inc
#define INC_DI() EDI += inc
#define CX ECX
#define DEC_CX() ECX--
#include "op_string.h"

#define STRING_SUFFIX _a32
#define SI_ADDR (uint8_t *)A0 + ESI
bellard's avatar
bellard committed
534
#define DI_ADDR env->segs[R_ES].base + EDI
535
536
537
538
539
540
541
542
#define INC_SI() ESI += inc
#define INC_DI() EDI += inc
#define CX ECX
#define DEC_CX() ECX--
#include "op_string.h"

#define STRING_SUFFIX _a16
#define SI_ADDR (uint8_t *)A0 + (ESI & 0xffff)
bellard's avatar
bellard committed
543
#define DI_ADDR env->segs[R_ES].base + (EDI & 0xffff)
544
545
546
547
548
#define INC_SI() ESI = (ESI & ~0xffff) | ((ESI + inc) & 0xffff)
#define INC_DI() EDI = (EDI & ~0xffff) | ((EDI + inc) & 0xffff)
#define CX (ECX & 0xffff)
#define DEC_CX() ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff)
#include "op_string.h"
bellard's avatar
bellard committed
549

550
551
552
553
554
555
556
557
558
void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void)
{
    T0 = DF << SHIFT;
}

void OPPROTO glue(op_string_jz_sub, SUFFIX)(void)
{
    if ((DATA_TYPE)CC_DST == 0)
        JUMP_TB(PARAM1, 1, PARAM2);
bellard's avatar
bellard committed
559
    FORCE_RET();
560
561
562
563
564
565
}

void OPPROTO glue(op_string_jnz_sub, SUFFIX)(void)
{
    if ((DATA_TYPE)CC_DST != 0)
        JUMP_TB(PARAM1, 1, PARAM2);
bellard's avatar
bellard committed
566
    FORCE_RET();
567
568
569
570
571
572
573
}

#if DATA_BITS >= 16
void OPPROTO glue(op_jz_ecx, SUFFIX)(void)
{
    if ((DATA_TYPE)ECX == 0)
        JUMP_TB(PARAM1, 1, PARAM2);
bellard's avatar
bellard committed
574
    FORCE_RET();
575
576
577
}
#endif

bellard's avatar
bellard committed
578
579
580
581
/* port I/O */

void OPPROTO glue(glue(op_out, SUFFIX), _T0_T1)(void)
{
582
    glue(cpu_x86_out, SUFFIX)(env, T0 & 0xffff, T1 & DATA_MASK);
bellard's avatar
bellard committed
583
584
585
586
}

void OPPROTO glue(glue(op_in, SUFFIX), _T0_T1)(void)
{
587
    T1 = glue(cpu_x86_in, SUFFIX)(env, T0 & 0xffff);
bellard's avatar
bellard committed
588
589
}

590
591
592
593
594
595
596
597
598
599
void OPPROTO glue(glue(op_in, SUFFIX), _DX_T0)(void)
{
    T0 = glue(cpu_x86_in, SUFFIX)(env, EDX & 0xffff);
}

void OPPROTO glue(glue(op_out, SUFFIX), _DX_T0)(void)
{
    glue(cpu_x86_out, SUFFIX)(env, EDX & 0xffff, T0);
}

bellard's avatar
bellard committed
600
601
602
603
604
605
606
#undef DATA_BITS
#undef SHIFT_MASK
#undef SIGN_MASK
#undef DATA_TYPE
#undef DATA_STYPE
#undef DATA_MASK
#undef SUFFIX