Skip to content

Commit f07c35f

Browse files
committed
[MC6800] Add CodeFormat
1 parent bc2af58 commit f07c35f

File tree

2 files changed

+274
-267
lines changed

2 files changed

+274
-267
lines changed

src/entry_mc6800.h

+25-10
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,54 @@ enum AddrMode : uint8_t {
4343
M_IDY = 12, // Indexed Y
4444
};
4545

46+
enum CodeFormat : uint8_t {
47+
CF_00 = 0, // 0x00
48+
CF_10 = 1, // 0x10
49+
CF_30 = 2, // 0x30
50+
};
51+
4652
struct Entry final : entry::Base<Config::opcode_t> {
4753
struct Flags final {
4854
uint16_t _attr;
4955

50-
static constexpr Flags create(AddrMode opr1, AddrMode opr2, AddrMode opr3) {
56+
static constexpr Flags create(CodeFormat cf, AddrMode opr1, AddrMode opr2, AddrMode opr3) {
5157
return Flags{static_cast<uint16_t>((static_cast<uint16_t>(opr1) << opr1_gp) |
5258
(static_cast<uint16_t>(opr2) << opr2_gp) |
53-
(static_cast<uint16_t>(opr3) << opr3_gp))};
59+
(static_cast<uint16_t>(opr3) << opr3_gp) |
60+
(static_cast<uint16_t>(cf) << cf_gp))};
5461
}
5562

56-
static constexpr Flags undef(AddrMode opr1) {
57-
return Flags{
58-
static_cast<uint16_t>((static_cast<uint16_t>(opr1) << opr1_gp) |
59-
(static_cast<uint16_t>(M_NONE) << opr2_gp) |
60-
(static_cast<uint16_t>(M_NONE) << opr3_gp) | undef_bm)};
63+
static constexpr Flags undef(CodeFormat cf, AddrMode opr1) {
64+
return Flags{static_cast<uint16_t>((static_cast<uint16_t>(opr1) << opr1_gp) |
65+
(static_cast<uint16_t>(cf) << cf_gp) | undef_bm)};
6166
}
6267

6368
AddrMode mode1() const { return AddrMode((_attr >> opr1_gp) & mode_gm); }
6469
AddrMode mode2() const { return AddrMode((_attr >> opr2_gp) & mode_gm); }
6570
AddrMode mode3() const { return AddrMode((_attr >> opr3_gp) & mode_gm); }
6671
bool undefined() const { return _attr & undef_bm; }
72+
uint8_t mask() const {
73+
static constexpr uint8_t MASK[] PROGMEM = {
74+
0x00, // CF_00 = 0
75+
0x10, // CF_10 = 1
76+
0x30, // CF_30 = 2
77+
};
78+
return pgm_read_byte(&MASK[(_attr >> cf_gp) & cf_gm]);
79+
}
6780

6881
private:
6982
static constexpr int opr1_gp = 0;
7083
static constexpr int opr2_gp = 4;
7184
static constexpr int opr3_gp = 8;
85+
static constexpr int cf_gp = 12;
7286
static constexpr int undef_bp = 15;
73-
static constexpr uint8_t mode_gm = 0x0F;
87+
static constexpr uint_fast8_t mode_gm = 0x0F;
88+
static constexpr uint_fast8_t cf_gm = 0x03;
7489
static constexpr uint16_t undef_bm = (1 << undef_bp);
7590
};
7691

77-
constexpr Entry(Config::opcode_t opCode, Flags flags, const /* PROGMEM */ char *name_P)
78-
: Base(name_P, opCode), _flags_P(flags) {}
92+
constexpr Entry(Config::opcode_t opc, Flags flags, const /* PROGMEM */ char *name_P)
93+
: Base(name_P, opc), _flags_P(flags) {}
7994

8095
Flags readFlags() const { return Flags{pgm_read_word(&_flags_P._attr)}; }
8196

0 commit comments

Comments
 (0)