1 |
2 |
jamieiles |
// Copyright Jamie Iles, 2017
|
2 |
|
|
//
|
3 |
|
|
// This file is part of s80x86.
|
4 |
|
|
//
|
5 |
|
|
// s80x86 is free software: you can redistribute it and/or modify
|
6 |
|
|
// it under the terms of the GNU General Public License as published by
|
7 |
|
|
// the Free Software Foundation, either version 3 of the License, or
|
8 |
|
|
// (at your option) any later version.
|
9 |
|
|
//
|
10 |
|
|
// s80x86 is distributed in the hope that it will be useful,
|
11 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
// GNU General Public License for more details.
|
14 |
|
|
//
|
15 |
|
|
// You should have received a copy of the GNU General Public License
|
16 |
|
|
// along with s80x86. If not, see .
|
17 |
|
|
|
18 |
|
|
#ifndef COMPARISON_US
|
19 |
|
|
#define COMPARISON_US
|
20 |
|
|
|
21 |
|
|
#define COMP_REGMEM_REG(opcode1, opcode2, alufunc, flags) \
|
22 |
|
|
.at opcode1; \
|
23 |
|
|
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, segment DS, \
|
24 |
|
|
ra_modrm_rm_reg, jmp_rm_reg_mem comp ## alufunc ## opcode1 ##_reg; \
|
25 |
|
|
.at opcode2; \
|
26 |
|
|
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, segment DS, \
|
27 |
|
|
ra_modrm_rm_reg, jmp_rm_reg_mem comp ## alufunc ## opcode1 ##_reg; \
|
28 |
|
|
.auto_address; \
|
29 |
|
|
comp ## alufunc ## opcode1 ## _reg: \
|
30 |
|
|
a_sel RA, b_sel RB, alu_op alufunc, \
|
31 |
|
|
update_flags flags, width WAUTO, next_instruction; \
|
32 |
|
|
comp ## alufunc ## opcode1 ## _mem: \
|
33 |
|
|
segment DS, mem_read, width WAUTO; \
|
34 |
|
|
a_sel MDR, b_sel RB, alu_op alufunc, update_flags flags, \
|
35 |
|
|
width WAUTO, next_instruction;
|
36 |
|
|
|
37 |
|
|
#define COMP_REG_REGMEM(opcode1, opcode2, alufunc, flags) \
|
38 |
|
|
.at opcode1; \
|
39 |
|
|
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, segment DS, \
|
40 |
|
|
ra_modrm_rm_reg, jmp_rm_reg_mem comp ## alufunc ## opcode1 ## _reg; \
|
41 |
|
|
.at opcode2; \
|
42 |
|
|
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, segment DS, \
|
43 |
|
|
ra_modrm_rm_reg, jmp_rm_reg_mem comp ## alufunc ## opcode1 ## _reg; \
|
44 |
|
|
.auto_address; \
|
45 |
|
|
comp ## alufunc ## opcode1 ## _reg: \
|
46 |
|
|
a_sel RA, b_sel RB, alu_op alufunc, update_flags flags, width WAUTO, \
|
47 |
|
|
next_instruction; \
|
48 |
|
|
comp ## alufunc ## opcode1 ## _mem: \
|
49 |
|
|
segment DS, mem_read, width WAUTO; \
|
50 |
|
|
a_sel MDR, b_sel RB, alu_op alufunc, update_flags flags, \
|
51 |
|
|
width WAUTO, next_instruction;
|
52 |
|
|
|
53 |
|
|
#define COMP_REGMEM_A(opcode1, opcode2, alufunc, flags) \
|
54 |
|
|
.at opcode1; \
|
55 |
|
|
read_immed, width WAUTO, ra_sel AL, jmp comp ## alufunc ## opcode1; \
|
56 |
|
|
.at opcode2; \
|
57 |
|
|
read_immed, width WAUTO, ra_sel AL, jmp comp ## alufunc ## opcode1; \
|
58 |
|
|
.auto_address; \
|
59 |
|
|
comp ## alufunc ## opcode1: \
|
60 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
61 |
|
|
update_flags flags, width WAUTO, next_instruction;
|
62 |
|
|
|
63 |
|
|
#define COMP_80_81(alufunc, flags) \
|
64 |
|
|
comp ## alufunc ## 80_81_reg: \
|
65 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
66 |
|
|
update_flags flags, width WAUTO, next_instruction; \
|
67 |
|
|
comp ## alufunc ## 80_81_mem: \
|
68 |
|
|
segment DS, mem_read, width WAUTO; \
|
69 |
|
|
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
|
70 |
|
|
update_flags flags, width WAUTO, next_instruction;
|
71 |
|
|
|
72 |
|
|
#define COMP_82(alufunc, flags) \
|
73 |
|
|
comp ## alufunc ## 82_reg: \
|
74 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
75 |
|
|
width W8, update_flags flags, next_instruction; \
|
76 |
|
|
comp ## alufunc ## 82_mem: \
|
77 |
|
|
width W8, segment DS, mem_read; \
|
78 |
|
|
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
|
79 |
|
|
width W8, update_flags flags, next_instruction;
|
80 |
|
|
|
81 |
|
|
#define COMP_83(alufunc, flags) \
|
82 |
|
|
comp ## alufunc ## 83_reg: \
|
83 |
|
|
ra_modrm_rm_reg, jmp comp ## alufunc ## 83_regwrite; \
|
84 |
|
|
comp ## alufunc ## 83_mem: \
|
85 |
|
|
ra_modrm_rm_reg, segment DS, jmp comp ## alufunc ## 83_memwrite; \
|
86 |
|
|
comp ## alufunc ## 83_regwrite: \
|
87 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
88 |
|
|
update_flags flags, next_instruction; \
|
89 |
|
|
comp ## alufunc ## 83_memwrite: \
|
90 |
|
|
segment DS, mem_read; \
|
91 |
|
|
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
|
92 |
|
|
update_flags flags, next_instruction;
|
93 |
|
|
|
94 |
|
|
#define COMP_F6(alufunc, flags) \
|
95 |
|
|
comp ## alufunc ## f6_reg: \
|
96 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
97 |
|
|
update_flags flags, width W8, next_instruction; \
|
98 |
|
|
comp ## alufunc ## f6_mem: \
|
99 |
|
|
segment DS, mem_read, width W8; \
|
100 |
|
|
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
|
101 |
|
|
update_flags flags, width W8, next_instruction;
|
102 |
|
|
|
103 |
|
|
#define COMP_F7(alufunc, flags) \
|
104 |
|
|
comp ## alufunc ## f7_reg: \
|
105 |
|
|
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
|
106 |
|
|
update_flags flags, next_instruction; \
|
107 |
|
|
comp ## alufunc ## f7_mem: \
|
108 |
|
|
segment DS, mem_read; \
|
109 |
|
|
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
|
110 |
|
|
update_flags flags, next_instruction;
|
111 |
|
|
|
112 |
|
|
#endif // COMPARISON_US
|