c5a2c66820f2fe5206493663b641d71b4f71e4f2
[reactos.git] / lib / 3rdparty / softx86 / softx86 / clc.c
1 /*
2 * clc.c
3 *
4 * Copyright (C) 2003, 2004 Jonathan Campbell <jcampbell@mdjk.com>
5 *
6 * Decompiler and executioneer for CLC/CLD/CLI/CMC/STC/STD/STI instructions.
7 *
8 ***********************************************************************************
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 ************************************************************************************/
23
24 #include <softx86.h>
25 #include <memory.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include "optable.h"
29 #include "clc.h"
30 #include "drooling_duh.h"
31
32 int Sfx86OpcodeExec_clx(sx86_ubyte opcode,softx86_ctx* ctx)
33 {
34 if (opcode == 0xF5) { // CMC
35 ctx->state->reg_flags.val ^= SX86_CPUFLAG_CARRY;
36 return 1;
37 }
38
39 if (opcode == 0xF8) { // CLC
40 ctx->state->reg_flags.val &= ~SX86_CPUFLAG_CARRY;
41 return 1;
42 }
43
44 if (opcode == 0xF9) { // STC
45 ctx->state->reg_flags.val |= SX86_CPUFLAG_CARRY;
46 return 1;
47 }
48
49 if (opcode == 0xFA) { // CLI
50 ctx->state->reg_flags.val &= ~SX86_CPUFLAG_INTENABLE;
51 return 1;
52 }
53
54 if (opcode == 0xFB) { // STI
55 ctx->state->reg_flags.val |= SX86_CPUFLAG_INTENABLE;
56 return 1;
57 }
58
59 if (opcode == 0xFC) { // CLD
60 ctx->state->reg_flags.val &= ~SX86_CPUFLAG_DIRECTIONREV;
61 return 1;
62 }
63
64 if (opcode == 0xFD) { // STD
65 ctx->state->reg_flags.val |= SX86_CPUFLAG_DIRECTIONREV;
66 return 1;
67 }
68
69 return 0;
70 }
71
72 int Sfx86OpcodeDec_clx(sx86_ubyte opcode,softx86_ctx* ctx,char buf[128])
73 {
74 if (opcode == 0xF5) { // CMC
75 strcpy(buf,"CMC");
76 return 1;
77 }
78
79 if (opcode == 0xF8) { // CLC
80 strcpy(buf,"CLC");
81 return 1;
82 }
83
84 if (opcode == 0xF9) { // STC
85 strcpy(buf,"STC");
86 return 1;
87 }
88
89 if (opcode == 0xFA) { // CLI
90 strcpy(buf,"CLI");
91 return 1;
92 }
93
94 if (opcode == 0xFB) { // STI
95 strcpy(buf,"STI");
96 return 1;
97 }
98
99 if (opcode == 0xFC) { // CLD
100 strcpy(buf,"CLD");
101 return 1;
102 }
103
104 if (opcode == 0xFD) { // STD
105 strcpy(buf,"STD");
106 return 1;
107 }
108
109 return 0;
110 }