OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [rtl/] [microcode/] [mul.us] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
// Multiplicand in TEMP, multiplier in MDR
19
mulf6_reg:
20
    width W8, a_sel RA, alu_op SELA, mdr_write, ra_sel AL, jmp do_mul8;
21
mulf6_mem:
22
    width W8, segment DS, mem_read, ra_sel AL, jmp do_mul8;
23
do_mul8:
24
    width W8, a_sel RA, alu_op SELA, tmp_wr_en;
25
    // 8-bit multiplication yields a 16-bit result so move the result into
26
    // TEMP to later transfer to AX as a 16-bit operation.
27
    width W8, a_sel MDR, b_sel TEMP, alu_op MUL, update_flags ZF OF CF,
28
        tmp_wr_en;
29
    b_sel TEMP, alu_op SELB, rd_sel_source MICROCODE_RD_SEL, rd_sel AX,
30
        next_instruction;
31
 
32
// Multiplicand in TEMP, multiplier in MDR
33
mulf7_reg:
34
    a_sel RA, alu_op SELA, mdr_write, ra_sel AX, jmp do_mul16;
35
mulf7_mem:
36
    segment DS, mem_read, ra_sel AX, jmp do_mul16;
37
do_mul16:
38
    a_sel RA, alu_op SELA, tmp_wr_en;
39
    a_sel MDR, b_sel TEMP, alu_op MUL, update_flags ZF OF CF,
40
        tmp_wr_sel Q_HIGH, tmp_wr_en, rd_sel_source MICROCODE_RD_SEL,
41
        rd_sel AX;
42
    b_sel TEMP, alu_op SELB, rd_sel_source MICROCODE_RD_SEL, rd_sel DX,
43
        next_instruction;
44
 
45
// imultiplicand in TEMP, imultiplier in MDR
46
imulf6_reg:
47
    width W8, a_sel RA, alu_op SELA, mdr_write, ra_sel AL, jmp do_imul8;
48
imulf6_mem:
49
    width W8, segment DS, mem_read, ra_sel AL, jmp do_imul8;
50
do_imul8:
51
    width W8, a_sel RA, alu_op SELA, tmp_wr_en;
52
    // 8-bit imultiplication yields a 16-bit result so move the result into
53
    // TEMP to later transfer to AX as a 16-bit operation.
54
    width W8, a_sel MDR, b_sel TEMP, alu_op IMUL, update_flags ZF OF CF,
55
        tmp_wr_en;
56
    b_sel TEMP, alu_op SELB, rd_sel_source MICROCODE_RD_SEL, rd_sel AX,
57
        next_instruction;
58
 
59
// imultiplicand in TEMP, imultiplier in MDR
60
imulf7_reg:
61
    a_sel RA, alu_op SELA, mdr_write, ra_sel AX, jmp do_imul16;
62
imulf7_mem:
63
    segment DS, mem_read, ra_sel AX, jmp do_imul16;
64
do_imul16:
65
    a_sel RA, alu_op SELA, tmp_wr_en;
66
    a_sel MDR, b_sel TEMP, alu_op IMUL, update_flags ZF OF CF,
67
        tmp_wr_sel Q_HIGH, tmp_wr_en, rd_sel_source MICROCODE_RD_SEL,
68
        rd_sel AX;
69
    b_sel TEMP, alu_op SELB, rd_sel_source MICROCODE_RD_SEL, rd_sel DX,
70
        next_instruction;
71
 
72
.at 0x6b;
73
    modrm_start, mar_write mar_wr_sel EA, jmp imul_6b;
74
.auto_address;
75
imul_6b:
76
    width W8, read_immed;
77
    ra_modrm_rm_reg, segment DS, jmp_rm_reg_mem imul6b_reg;
78
imul6b_reg:
79
    a_sel RA, b_sel IMMEDIATE, alu_op IMUL, update_flags ZF OF CF,
80
        rd_sel_source MODRM_REG, next_instruction;
81
imul6b_mem:
82
    segment DS, mem_read;
83
    a_sel MDR, b_sel IMMEDIATE, alu_op IMUL, update_flags ZF OF CF,
84
        rd_sel_source MODRM_REG, next_instruction;
85
 
86
.at 0x69;
87
    modrm_start, mar_write mar_wr_sel EA, jmp imul_69;
88
.auto_address;
89
imul_69:
90
    // Now that we have the immediate, everything is the same as opcode 6b
91
    read_immed, ra_modrm_rm_reg, segment DS, jmp_rm_reg_mem imul6b_reg;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.