URL
https://opencores.org/ocsvn/s80186/s80186/trunk
Subversion Repositories s80186
[/] [s80186/] [trunk/] [rtl/] [microcode/] [arithmetic.us] - Rev 2
Compare with Previous | Blame | View Log
// Copyright Jamie Iles, 2017
//
// This file is part of s80x86.
//
// s80x86 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// s80x86 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with s80x86. If not, see <http://www.gnu.org/licenses/>.
#ifndef ARITHMETIC_US
#define ARITHMETIC_US
#define ARITH_REGMEM_REG(opcode1, opcode2, alufunc, flags) \
.at opcode1; \
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, \
ra_modrm_rm_reg, jmp_rm_reg_mem alufunc ## opcode1 ##_reg, segment DS; \
.at opcode2; \
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, \
ra_modrm_rm_reg, jmp_rm_reg_mem alufunc ## opcode1 ##_reg, segment DS; \
.auto_address; \
alufunc ## opcode1 ## _reg: \
a_sel RA, b_sel RB, alu_op alufunc, \
rd_sel_source MODRM_RM_REG, update_flags flags, \
width WAUTO, next_instruction; \
alufunc ## opcode1 ## _mem: \
segment DS, mem_read, width WAUTO; \
a_sel MDR, b_sel RB, alu_op alufunc, mdr_write, \
update_flags flags, width WAUTO, segment DS, jmp write_complete;
#define ARITH_REG_REGMEM(opcode1, opcode2, alufunc, flags) \
.at opcode1; \
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, \
ra_modrm_rm_reg, jmp_rm_reg_mem alufunc ## opcode1 ## _reg, segment DS; \
.at opcode2; \
modrm_start, mar_write, mar_wr_sel EA, width WAUTO, \
ra_modrm_rm_reg, jmp_rm_reg_mem alufunc ## opcode1 ## _reg, segment DS; \
.auto_address; \
alufunc ## opcode1 ## _reg: \
a_sel RA, b_sel RB, alu_op alufunc, rd_sel_source MODRM_REG, \
update_flags flags, width WAUTO, \
next_instruction; \
alufunc ## opcode1 ## _mem: \
segment DS, mem_read, width WAUTO; \
a_sel MDR, b_sel RB, alu_op alufunc, rd_sel_source MODRM_REG, \
update_flags flags, width WAUTO, \
next_instruction;
#define ARITH_REGMEM_A(opcode1, opcode2, alufunc, flags) \
.at opcode1; \
read_immed, width WAUTO, ra_sel AL, jmp alufunc ## opcode1; \
.at opcode2; \
read_immed, width WAUTO, ra_sel AL, jmp alufunc ## opcode1; \
.auto_address; \
alufunc ## opcode1: \
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
rd_sel_source MICROCODE_RD_SEL, rd_sel AL, \
update_flags flags, width WAUTO, \
next_instruction;
#define ARITH_80_81(alufunc, flags) \
alufunc ## 80_81_reg: \
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
rd_sel_source MODRM_RM_REG, \
width WAUTO, update_flags flags, next_instruction; \
alufunc ## 80_81_mem: \
segment DS, mem_read, width WAUTO; \
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
mdr_write, update_flags flags, segment DS, width WAUTO, jmp write_complete;
#define ARITH_83(alufunc, flags) \
alufunc ## 83_reg: \
ra_modrm_rm_reg, jmp alufunc ## 83 ## regwrite; \
alufunc ## 83_mem: \
ra_modrm_rm_reg, segment DS, jmp alufunc ## 83 ## memwrite; \
alufunc ## 83 ## regwrite: \
a_sel RA, b_sel IMMEDIATE, alu_op alufunc, \
rd_sel_source MODRM_RM_REG, \
update_flags flags, next_instruction; \
alufunc ## 83 ## memwrite: \
segment DS, mem_read; \
a_sel MDR, b_sel IMMEDIATE, alu_op alufunc, \
mdr_write, update_flags flags, segment DS, jmp write_16_complete;
#endif // ARITHMETIC_US