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 |
|
|
pop8f_reg:
|
19 |
|
|
a_sel RA, alu_op SELA, mar_wr_sel Q, mar_write,
|
20 |
|
|
segment_force, segment SS, jmp pop8f_reg_restore;
|
21 |
|
|
pop8f_mem:
|
22 |
|
|
a_sel RA, alu_op SELA, mar_wr_sel Q, mar_write,
|
23 |
|
|
segment_force, segment SS, jmp pop8f_mem_restore;
|
24 |
|
|
pop8f_reg_restore:
|
25 |
|
|
segment_force, segment SS, mem_read, ra_sel SP;
|
26 |
|
|
a_sel RA, b_sel IMMEDIATE, immediate 0x2, alu_op ADD,
|
27 |
|
|
rd_sel SP, rd_sel_source MICROCODE_RD_SEL;
|
28 |
|
|
a_sel MDR, alu_op SELA, rd_sel_source MODRM_RM_REG,
|
29 |
|
|
next_instruction;
|
30 |
|
|
pop8f_mem_restore:
|
31 |
|
|
segment_force, segment SS, mem_read, ra_sel SP;
|
32 |
|
|
a_sel RA, b_sel IMMEDIATE, immediate 0x2, alu_op ADD,
|
33 |
|
|
rd_sel SP, rd_sel_source MICROCODE_RD_SEL;
|
34 |
|
|
mar_write, mar_wr_sel EA, segment DS, jmp write_16_complete;
|
35 |
|
|
|
36 |
|
|
#define POP_GPR(opcode, reg) \
|
37 |
|
|
.at opcode; \
|
38 |
|
|
ra_sel SP, jmp pop_gpr ## reg; \
|
39 |
|
|
.auto_address; \
|
40 |
|
|
pop_gpr ## reg: \
|
41 |
|
|
a_sel RA, alu_op SELA, mar_wr_sel Q, mar_write, \
|
42 |
|
|
segment_force, segment SS; \
|
43 |
|
|
segment_force, segment SS, mem_read, ra_sel SP; \
|
44 |
|
|
a_sel RA, b_sel IMMEDIATE, immediate 0x2, alu_op ADD, \
|
45 |
|
|
rd_sel SP, rd_sel_source MICROCODE_RD_SEL; \
|
46 |
|
|
a_sel MDR, alu_op SELA, rd_sel reg, \
|
47 |
|
|
rd_sel_source MICROCODE_RD_SEL, next_instruction;
|
48 |
|
|
|
49 |
|
|
#define POP_SR(opcode, reg) \
|
50 |
|
|
.at opcode; \
|
51 |
|
|
ra_sel SP, jmp pop_sr ## reg; \
|
52 |
|
|
.auto_address; \
|
53 |
|
|
pop_sr ## reg: \
|
54 |
|
|
a_sel RA, alu_op SELA, mar_wr_sel Q, mar_write, \
|
55 |
|
|
segment_force, segment SS; \
|
56 |
|
|
segment_force, segment SS, mem_read, ra_sel SP; \
|
57 |
|
|
a_sel RA, b_sel IMMEDIATE, immediate 0x2, alu_op ADD, \
|
58 |
|
|
rd_sel SP, rd_sel_source MICROCODE_RD_SEL; \
|
59 |
|
|
a_sel MDR, alu_op SELA, segment_force, segment reg, \
|
60 |
|
|
segment_wr_en, ext_int_inhibit, next_instruction;
|
61 |
|
|
|
62 |
|
|
POP_SR(0x07, ES)
|
63 |
|
|
POP_SR(0x17, SS)
|
64 |
|
|
POP_SR(0x1f, DS)
|
65 |
|
|
|
66 |
|
|
POP_GPR(0x58, AX)
|
67 |
|
|
POP_GPR(0x59, CX)
|
68 |
|
|
POP_GPR(0x5a, DX)
|
69 |
|
|
POP_GPR(0x5b, BX)
|
70 |
|
|
POP_GPR(0x5c, SP)
|
71 |
|
|
POP_GPR(0x5d, BP)
|
72 |
|
|
POP_GPR(0x5e, SI)
|
73 |
|
|
POP_GPR(0x5f, DI)
|
74 |
|
|
|
75 |
|
|
.at 0x9d;
|
76 |
|
|
ra_sel SP, jmp popf;
|
77 |
|
|
.auto_address;
|
78 |
|
|
popf:
|
79 |
|
|
alu_op SELA, mar_wr_sel Q, mar_write, segment_force, segment SS;
|
80 |
|
|
segment_force, segment SS, mem_read, ra_sel SP;
|
81 |
|
|
a_sel RA, b_sel IMMEDIATE, immediate 0x2, alu_op ADD,
|
82 |
|
|
rd_sel SP, rd_sel_source MICROCODE_RD_SEL;
|
83 |
|
|
a_sel MDR, alu_op SETFLAGSA, update_flags CF PF AF ZF SF TF IF DF OF,
|
84 |
|
|
next_instruction;
|