| 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 |
|
|
.at 0x102;
|
| 19 |
|
|
debug_wait:
|
| 20 |
|
|
jmp debug_wait;
|
| 21 |
|
|
|
| 22 |
|
|
#define DEBUG_READ_GPR(reg, addr) \
|
| 23 |
|
|
.at addr; \
|
| 24 |
|
|
ra_sel reg, jmp debug_read_gpr;
|
| 25 |
|
|
|
| 26 |
|
|
#define DEBUG_READ_SR(reg, addr) \
|
| 27 |
|
|
.at addr; \
|
| 28 |
|
|
segment_force, segment reg, jmp debug_read_sr;
|
| 29 |
|
|
|
| 30 |
|
|
DEBUG_READ_GPR(AX, 0x103)
|
| 31 |
|
|
DEBUG_READ_GPR(CX, 0x104)
|
| 32 |
|
|
DEBUG_READ_GPR(DX, 0x105)
|
| 33 |
|
|
DEBUG_READ_GPR(BX, 0x106)
|
| 34 |
|
|
DEBUG_READ_GPR(SP, 0x107)
|
| 35 |
|
|
DEBUG_READ_GPR(BP, 0x108)
|
| 36 |
|
|
DEBUG_READ_GPR(SI, 0x109)
|
| 37 |
|
|
DEBUG_READ_GPR(DI, 0x10a)
|
| 38 |
|
|
DEBUG_READ_SR(ES, 0x10b)
|
| 39 |
|
|
DEBUG_READ_SR(CS, 0x10c)
|
| 40 |
|
|
DEBUG_READ_SR(SS, 0x10d)
|
| 41 |
|
|
DEBUG_READ_SR(DS, 0x10e)
|
| 42 |
|
|
|
| 43 |
|
|
#define DEBUG_WRITE_GPR(reg, addr) \
|
| 44 |
|
|
.at addr; \
|
| 45 |
|
|
b_sel TEMP, alu_op SELB, rd_sel_source MICROCODE_RD_SEL, rd_sel reg, \
|
| 46 |
|
|
jmp debug_wait;
|
| 47 |
|
|
|
| 48 |
|
|
#define DEBUG_WRITE_SR(reg, addr) \
|
| 49 |
|
|
.at addr; \
|
| 50 |
|
|
b_sel TEMP, alu_op SELB, segment_force, segment_wr_en, \
|
| 51 |
|
|
segment_force, segment reg, next_instruction, \
|
| 52 |
|
|
ext_int_inhibit, jmp debug_wait;
|
| 53 |
|
|
|
| 54 |
|
|
DEBUG_WRITE_GPR(AX, 0x113)
|
| 55 |
|
|
DEBUG_WRITE_GPR(CX, 0x114)
|
| 56 |
|
|
DEBUG_WRITE_GPR(DX, 0x115)
|
| 57 |
|
|
DEBUG_WRITE_GPR(BX, 0x116)
|
| 58 |
|
|
DEBUG_WRITE_GPR(SP, 0x117)
|
| 59 |
|
|
DEBUG_WRITE_GPR(BP, 0x118)
|
| 60 |
|
|
DEBUG_WRITE_GPR(SI, 0x119)
|
| 61 |
|
|
DEBUG_WRITE_GPR(DI, 0x11a)
|
| 62 |
|
|
DEBUG_WRITE_SR(ES, 0x11b)
|
| 63 |
|
|
DEBUG_WRITE_SR(CS, 0x11c)
|
| 64 |
|
|
DEBUG_WRITE_SR(SS, 0x11d)
|
| 65 |
|
|
DEBUG_WRITE_SR(DS, 0x11e)
|
| 66 |
|
|
|
| 67 |
|
|
.auto_address;
|
| 68 |
|
|
debug_read_gpr:
|
| 69 |
|
|
a_sel RA, alu_op SELA, tmp_wr_en, jmp debug_wait;
|
| 70 |
|
|
|
| 71 |
|
|
debug_read_sr:
|
| 72 |
|
|
b_sel SR, alu_op SELB, tmp_wr_en, jmp debug_wait;
|
| 73 |
|
|
|
| 74 |
|
|
// Get IP
|
| 75 |
|
|
.at 0x10f;
|
| 76 |
|
|
a_sel IP, alu_op SELA, tmp_wr_en, jmp debug_wait;
|
| 77 |
|
|
|
| 78 |
|
|
// Get flags
|
| 79 |
|
|
.at 0x110;
|
| 80 |
|
|
alu_op GETFLAGS, tmp_wr_en, jmp debug_wait;
|
| 81 |
|
|
|
| 82 |
|
|
// Set IP
|
| 83 |
|
|
.at 0x111;
|
| 84 |
|
|
b_sel TEMP, alu_op SELB, load_ip, next_instruction, ext_int_inhibit,
|
| 85 |
|
|
jmp debug_wait;
|
| 86 |
|
|
|
| 87 |
|
|
// Set flags
|
| 88 |
|
|
.at 0x112;
|
| 89 |
|
|
b_sel TEMP, alu_op SETFLAGSB, update_flags CF PF AF ZF SF TF IF DF OF,
|
| 90 |
|
|
jmp debug_wait;
|
| 91 |
|
|
|
| 92 |
|
|
// Write MAR
|
| 93 |
|
|
.at 0x11f;
|
| 94 |
|
|
b_sel TEMP, alu_op SELB, mar_wr_sel Q, mar_write, jmp debug_wait;
|
| 95 |
|
|
|
| 96 |
|
|
// Write MDR
|
| 97 |
|
|
.at 0x120;
|
| 98 |
|
|
b_sel TEMP, alu_op SELB, mdr_write, jmp debug_wait;
|
| 99 |
|
|
|
| 100 |
|
|
// Read 8
|
| 101 |
|
|
.at 0x121;
|
| 102 |
|
|
segment_force, segment DS, jmp debug_read8;
|
| 103 |
|
|
.auto_address;
|
| 104 |
|
|
debug_read8:
|
| 105 |
|
|
segment_force, segment DS, width W8, mem_read;
|
| 106 |
|
|
a_sel MDR, alu_op SELA, tmp_wr_en;
|
| 107 |
|
|
a_sel MAR, b_sel IMMEDIATE, immediate 0x1, alu_op ADD, mar_wr_sel Q,
|
| 108 |
|
|
mar_write, jmp debug_wait;
|
| 109 |
|
|
|
| 110 |
|
|
// Read 16
|
| 111 |
|
|
.at 0x122;
|
| 112 |
|
|
segment_force, segment DS, jmp debug_read16;
|
| 113 |
|
|
.auto_address;
|
| 114 |
|
|
debug_read16:
|
| 115 |
|
|
segment_force, segment DS, mem_read;
|
| 116 |
|
|
a_sel MDR, alu_op SELA, tmp_wr_en;
|
| 117 |
|
|
a_sel MAR, b_sel IMMEDIATE, immediate 0x2, alu_op ADD, mar_wr_sel Q,
|
| 118 |
|
|
mar_write, jmp debug_wait;
|
| 119 |
|
|
|
| 120 |
|
|
// Write 8
|
| 121 |
|
|
.at 0x123;
|
| 122 |
|
|
segment_force, segment DS, jmp debug_write8;
|
| 123 |
|
|
.auto_address;
|
| 124 |
|
|
debug_write8:
|
| 125 |
|
|
segment_force, segment DS, width W8, mem_write;
|
| 126 |
|
|
a_sel MAR, b_sel IMMEDIATE, immediate 0x1, alu_op ADD, mar_wr_sel Q,
|
| 127 |
|
|
mar_write, jmp debug_wait;
|
| 128 |
|
|
|
| 129 |
|
|
// Write 16
|
| 130 |
|
|
.at 0x124;
|
| 131 |
|
|
segment_force, segment DS, jmp debug_write16;
|
| 132 |
|
|
.auto_address;
|
| 133 |
|
|
debug_write16:
|
| 134 |
|
|
segment_force, segment DS, mem_write;
|
| 135 |
|
|
a_sel MAR, b_sel IMMEDIATE, immediate 0x2, alu_op ADD, mar_wr_sel Q,
|
| 136 |
|
|
mar_write, jmp debug_wait;
|
| 137 |
|
|
|
| 138 |
|
|
// Read 8 IO
|
| 139 |
|
|
.at 0x125;
|
| 140 |
|
|
segment_force, segment DS, jmp debug_read8io;
|
| 141 |
|
|
.auto_address;
|
| 142 |
|
|
debug_read8io:
|
| 143 |
|
|
segment_force, segment DS, width W8, mem_read, io;
|
| 144 |
|
|
a_sel MDR, alu_op SELA, tmp_wr_en, jmp debug_wait;
|
| 145 |
|
|
|
| 146 |
|
|
// Read 16 IO
|
| 147 |
|
|
.at 0x126;
|
| 148 |
|
|
segment_force, segment DS, jmp debug_read16io;
|
| 149 |
|
|
.auto_address;
|
| 150 |
|
|
debug_read16io:
|
| 151 |
|
|
segment_force, segment DS, mem_read, io;
|
| 152 |
|
|
a_sel MDR, alu_op SELA, tmp_wr_en, jmp debug_wait;
|
| 153 |
|
|
|
| 154 |
|
|
// Write 8 IO
|
| 155 |
|
|
.at 0x127;
|
| 156 |
|
|
segment_force, segment DS, jmp debug_write8io;
|
| 157 |
|
|
.auto_address;
|
| 158 |
|
|
debug_write8io:
|
| 159 |
|
|
segment_force, segment DS, width W8, mem_write, io, jmp debug_wait;
|
| 160 |
|
|
|
| 161 |
|
|
// Write 16 IO
|
| 162 |
|
|
.at 0x128;
|
| 163 |
|
|
segment_force, segment DS, jmp debug_write16io;
|
| 164 |
|
|
.auto_address;
|
| 165 |
|
|
debug_write16io:
|
| 166 |
|
|
segment_force, segment DS, mem_write, io, jmp debug_wait;
|