diff --git a/src/arduino_example.h b/src/arduino_example.h index 485b95fb..e5f179ed 100644 --- a/src/arduino_example.h +++ b/src/arduino_example.h @@ -118,7 +118,7 @@ struct Example { } return true; } - if (strcasecmp_P(line, PSTR("CPU")) == 0 || strncasecmp_P(line, PSTR("CPU "), 4) == 0) { + if (strcasecmp_P(line, PSTR("CPU")) == 0) { const auto cpu = skipSpaces(line + 3); if (*cpu == 0) return isAsm() ? printCpuList<>(_abegin, _aend) : printCpuList<>(_dbegin, _dend); @@ -140,7 +140,7 @@ struct Example { _cli.println(F("unknown CPU")); return true; } - if (strcasecmp_P(line, PSTR("ORG")) == 0 || strncasecmp_P(line, PSTR("ORG "), 4) == 0) { + if (!isAsm() && strncasecmp_P(line, PSTR("ORG"), 3) == 0) { const auto org = skipSpaces(line + 3); if (*org) { uint32_t addr; @@ -302,8 +302,12 @@ struct Example { printAddress(insn.address(), ':'); printBytes(insn.bytes(), insn.length()); _cli.println(); - _origin += insn.length() / addrUnit(); - _origin &= max - 1; + if (insn.address() == _origin) { + _origin += insn.length() / addrUnit(); + _origin &= max - 1; + } else { + _origin = insn.address(); + } } } diff --git a/src/asm_base.cpp b/src/asm_base.cpp index 4934065e..087930f0 100644 --- a/src/asm_base.cpp +++ b/src/asm_base.cpp @@ -45,7 +45,7 @@ PROGMEM constexpr Pseudos PSEUDO_TABLE{ARRAY_RANGE(PSEUDOS)}; Assembler::Assembler( const ValueParser::Plugins &plugins, const Pseudos &pseudos, const OptionBase *option) : _parser(plugins), - _pseudos(pseudos), + _pseudos(&pseudos), _commonOptions(&_opt_listRadix), _options(option), _opt_listRadix(this, &Assembler::setListRadix, OPT_INT_LIST_RADIX, OPT_DESC_LIST_RADIX, @@ -103,7 +103,7 @@ Error Assembler::encode(const char *line, Insn &insn, const SymbolTable *symtab) } Error Assembler::processPseudo(StrScanner &scan, Insn &insn) { - const auto *p = _pseudos.search(insn); + const auto *p = _pseudos->search(insn); if (p == nullptr) p = PSEUDO_TABLE.search(insn); return p ? p->invoke(this, scan, insn) : UNKNOWN_DIRECTIVE; diff --git a/src/asm_base.h b/src/asm_base.h index 06ec92a8..f17cdc4c 100644 --- a/src/asm_base.h +++ b/src/asm_base.h @@ -91,7 +91,7 @@ struct Assembler { protected: const ValueParser _parser; - const pseudo::Pseudos _pseudos; + const pseudo::Pseudos *const _pseudos; const Options _commonOptions; const Options _options; const IntOption _opt_listRadix; diff --git a/src/pseudos.h b/src/pseudos.h index 8c9949db..4846399e 100644 --- a/src/pseudos.h +++ b/src/pseudos.h @@ -32,7 +32,7 @@ struct Pseudo { using Handler = Error (Assembler::*)(StrScanner &scan, Insn &insn, uint8_t); constexpr Pseudo(const /*PROGMEM*/ char *name_P, Handler handler, uint8_t extra = 0) - : _name_P(name_P), _handler(handler), _extra(extra) {} + : _name_P(name_P), _handler_P(handler), _extra_P(extra) {} const /*PROGMEM*/ char *name_P() const { return reinterpret_cast(pgm_read_ptr(&_name_P)); @@ -45,24 +45,23 @@ struct Pseudo { private: const /*PROGMEM*/ char *const _name_P; - const Handler _handler; - const uint8_t _extra; + const Handler _handler_P; + const uint8_t _extra_P; Handler handler() const { Handler h; - memcpy_P(&h, &_handler, sizeof(Handler)); + memcpy_P(&h, &_handler_P, sizeof(Handler)); return h; } - uint8_t extra() const { return pgm_read_byte(&_extra); } + uint8_t extra() const { return pgm_read_byte(&_extra_P); } }; struct Pseudos { - constexpr Pseudos(const /*PROGMEM*/ Pseudo *table, const /*PROGMEM*/ Pseudo *end) : _table(table, end) {} + constexpr Pseudos(const /*PROGMEM*/ Pseudo *table_P, const /*PROGMEM*/ Pseudo *end_P) + : _table(table_P, end_P) {} - const Pseudo *search(const Insn &insn) const { - return _table.binarySearch(insn, comparator); - } + const Pseudo *search(const Insn &insn) const { return _table.binarySearch(insn, comparator); } private: const table::Table _table; diff --git a/src/reg_base.cpp b/src/reg_base.cpp index cb1ecb9e..716218dd 100644 --- a/src/reg_base.cpp +++ b/src/reg_base.cpp @@ -15,7 +15,6 @@ */ #include "reg_base.h" - #include #include @@ -24,8 +23,7 @@ namespace reg { namespace { -bool nameMatcher(int8_t &name, const NameEntry *item, int extra) { - UNUSED(extra); +bool nameMatcher(int8_t &name, const NameEntry *item, int) { return name == item->name(); } diff --git a/src/reg_base.h b/src/reg_base.h index 10e596e2..be615cd5 100644 --- a/src/reg_base.h +++ b/src/reg_base.h @@ -36,18 +36,18 @@ static inline bool isIdLetter(char c) { */ struct NameEntry { constexpr NameEntry(const /*PROGMEM*/ char *text_P, int8_t name) - : _text_P(text_P), _name(name) {} + : _text_P(text_P), _name_P(name) {} const /*PROGMEM*/ char *text_P() const { return reinterpret_cast(pgm_read_ptr(&_text_P)); } - int8_t name() const { return pgm_read_byte(&_name); } + int8_t name() const { return pgm_read_byte(&_name_P); } StrBuffer &outText(StrBuffer &out) const { return out.text_P(text_P()); } private: const /*PROGMEM*/ char *const _text_P; - const int8_t _name; + const int8_t _name_P; }; /** @@ -57,8 +57,8 @@ struct NameTable { /** * NameEntry array |table|~|end| must be sorted by NameEntry::text_P. */ - constexpr NameTable(const /*PROGMEM*/ NameEntry *table, const /*PROGMEM*/ NameEntry *end) - : _table(table, end) {} + constexpr NameTable(const /*PROGMEM*/ NameEntry *table_P, const /*PROGMEM*/ NameEntry *end_P) + : _table(table_P, end_P) {} /** * Return pointer to an entry which has |name| as NameEntry::name,