Initial
This commit is contained in:
64
as68hc11/backup/ASM6811.HPP
Normal file
64
as68hc11/backup/ASM6811.HPP
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef _AS68HC11_M68ASSEMBLER_HPP_
|
||||
#define _AS68HC11_M68ASSEMBLER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_OPENFILE_HPP_
|
||||
#include <common/openfile.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEMAP_HPP_
|
||||
#include <common/filemap.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
||||
#include <common/pview.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STDLIB_HPP_
|
||||
#include <common/stdlib.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_TABLE_HPP_
|
||||
#include <as68hc11/table.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_SCAN_HPP_
|
||||
#include <as68hc11/scan.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_PARSE_HPP_
|
||||
#include <as68hc11/parse.hpp>
|
||||
#endif
|
||||
|
||||
class M68Assembler
|
||||
{
|
||||
public:
|
||||
M68Assembler(void);
|
||||
virtual ~M68Assembler();
|
||||
bool assemble(const String &strPathFileName,const String &strPathOutFile);
|
||||
bool assemble(const String &strPathFileName);
|
||||
const String &strLastMessage(void)const;
|
||||
DWORD codeSize(void)const;
|
||||
DWORD lastLineNumber(void)const;
|
||||
private:
|
||||
enum{MaxScanBytes=128000,MaxParseBytes=512};
|
||||
M68Assembler(const M68Assembler &someM68Assembler);
|
||||
M68Assembler &operator=(const M68Assembler &someM68Assembler);
|
||||
bool operator==(const M68Assembler &someM68Assembler)const;
|
||||
void createSymbolTable(Table &symbols);
|
||||
void shuffle(Block<Symbol> &symbols);
|
||||
bool generateCode(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength);
|
||||
bool generateListing(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength);
|
||||
// bool generateS19(const String &strPathOutFile,Origins &origins,PureViewOfFile &rawCode,DWORD codeLength);
|
||||
bool generateS19(const String &strPathOutFile,PureViewOfFile &rawCode);
|
||||
|
||||
Table mSymbolTable;
|
||||
String mLastMessage;
|
||||
DWORD mLastLineNumber;
|
||||
DWORD mCodeSize;
|
||||
};
|
||||
|
||||
inline
|
||||
DWORD M68Assembler::codeSize(void)const
|
||||
{
|
||||
return mCodeSize;
|
||||
}
|
||||
#endif
|
||||
322
as68hc11/backup/Asm6811.cpp
Normal file
322
as68hc11/backup/Asm6811.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
#include <as68hc11/asm6811.hpp>
|
||||
#include <as68hc11/fmtlines.hpp>
|
||||
#include <as68hc11/S19Generator.hpp>
|
||||
#include <common/gdata.hpp>
|
||||
#include <common/diskinfo.hpp>
|
||||
|
||||
M68Assembler::M68Assembler(void)
|
||||
: mLastLineNumber(0)
|
||||
{
|
||||
createSymbolTable(mSymbolTable);
|
||||
}
|
||||
|
||||
M68Assembler::M68Assembler(const M68Assembler &someM68Assembler)
|
||||
{ // private implementation
|
||||
*this=someM68Assembler;
|
||||
}
|
||||
|
||||
M68Assembler::~M68Assembler()
|
||||
{
|
||||
}
|
||||
|
||||
M68Assembler &M68Assembler::operator=(const M68Assembler &/*someM68Assembler*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool M68Assembler::operator==(const M68Assembler &/*someM68Assembler*/)const
|
||||
{ // private implementation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const String &M68Assembler::strLastMessage(void)const
|
||||
{
|
||||
return mLastMessage;
|
||||
}
|
||||
|
||||
DWORD M68Assembler::lastLineNumber(void)const
|
||||
{
|
||||
return mLastLineNumber;
|
||||
}
|
||||
|
||||
void M68Assembler::createSymbolTable(Table &symbolTable)
|
||||
{
|
||||
Block<Symbol> symbols;
|
||||
|
||||
symbolTable.remove();
|
||||
|
||||
symbols.insert(&Symbol("aba",Scan::aba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x1B))));
|
||||
symbols.insert(&Symbol("abx",Scan::abx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3A))));
|
||||
symbols.insert(&Symbol("aby",Scan::aby1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3A,0x18))));
|
||||
symbols.insert(&Symbol("adca",Scan::adca1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x89),AddressMode(AddressMode::Direct,0x99),AddressMode(AddressMode::Extended,0xB9),AddressMode(AddressMode::Indexed,0xA9),AddressMode(AddressMode::Indexed,0xA9,0x18))));
|
||||
symbols.insert(&Symbol("adcb",Scan::adcb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC9),AddressMode(AddressMode::Direct,0xD9),AddressMode(AddressMode::Extended,0xF9),AddressMode(AddressMode::Indexed,0xE9),AddressMode(AddressMode::Indexed,0xE9,0x18))));
|
||||
symbols.insert(&Symbol("adda",Scan::adda1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x8B),AddressMode(AddressMode::Direct,0x9B),AddressMode(AddressMode::Extended,0xBB),AddressMode(AddressMode::Indexed,0xAB),AddressMode(AddressMode::Indexed,0xAB,0x18))));
|
||||
symbols.insert(&Symbol("addb",Scan::addb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xCB),AddressMode(AddressMode::Direct,0xDB),AddressMode(AddressMode::Extended,0xFB),AddressMode(AddressMode::Indexed,0xEB),AddressMode(AddressMode::Indexed,0xEB,0x18))));
|
||||
symbols.insert(&Symbol("addd",Scan::addd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xC3),AddressMode(AddressMode::Direct,0xD3),AddressMode(AddressMode::Extended,0xF3),AddressMode(AddressMode::Indexed,0xE3),AddressMode(AddressMode::Indexed,0xE3,0x18))));
|
||||
symbols.insert(&Symbol("anda",Scan::anda1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x84),AddressMode(AddressMode::Direct,0x94),AddressMode(AddressMode::Extended,0xB4),AddressMode(AddressMode::Indexed,0xA4),AddressMode(AddressMode::Indexed,0xA4,0x18))));
|
||||
symbols.insert(&Symbol("andb",Scan::andb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC4),AddressMode(AddressMode::Direct,0xD4),AddressMode(AddressMode::Extended,0xF4),AddressMode(AddressMode::Indexed,0xE4),AddressMode(AddressMode::Indexed,0xE4,0x18))));
|
||||
symbols.insert(&Symbol("asl",Scan::asl1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x78),AddressMode(AddressMode::Indexed,0x68),AddressMode(AddressMode::Indexed,0x68,0x18))));
|
||||
symbols.insert(&Symbol("asla",Scan::asla1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x48))));
|
||||
symbols.insert(&Symbol("aslb",Scan::aslb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x58))));
|
||||
symbols.insert(&Symbol("asld",Scan::asld1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x05))));
|
||||
symbols.insert(&Symbol("asr",Scan::asr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x77),AddressMode(AddressMode::Indexed,0x67),AddressMode(AddressMode::Indexed,0x67,0x18))));
|
||||
symbols.insert(&Symbol("asra",Scan::asra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x47))));
|
||||
symbols.insert(&Symbol("asrb",Scan::asrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x57))));
|
||||
symbols.insert(&Symbol("bcc",Scan::bcc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x24))));
|
||||
symbols.insert(&Symbol("bclr",Scan::bclr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectMask,0x15),AddressMode(AddressMode::IndexedMask,0x1D),AddressMode(AddressMode::IndexedMask,0x1D,0x18))));
|
||||
symbols.insert(&Symbol("bcs",Scan::bcs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x25))));
|
||||
symbols.insert(&Symbol("beq",Scan::beq1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x27))));
|
||||
symbols.insert(&Symbol("bge",Scan::bge1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2C))));
|
||||
symbols.insert(&Symbol("bgt",Scan::bgt1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2E))));
|
||||
symbols.insert(&Symbol("bhi",Scan::bhi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x22))));
|
||||
symbols.insert(&Symbol("bhs",Scan::bhs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x24))));
|
||||
symbols.insert(&Symbol("bita",Scan::bita1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x85),AddressMode(AddressMode::Direct,0x95),AddressMode(AddressMode::Extended,0xB5),AddressMode(AddressMode::Indexed,0xA5),AddressMode(AddressMode::Indexed,0xA5,0x18))));
|
||||
symbols.insert(&Symbol("bitb",Scan::bitb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC5),AddressMode(AddressMode::Direct,0xD5),AddressMode(AddressMode::Extended,0xF5),AddressMode(AddressMode::Indexed,0xE5),AddressMode(AddressMode::Indexed,0xE5,0x18))));
|
||||
symbols.insert(&Symbol("ble",Scan::ble1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2F))));
|
||||
symbols.insert(&Symbol("blo",Scan::blo1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x25))));
|
||||
symbols.insert(&Symbol("bls",Scan::bls1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x23))));
|
||||
symbols.insert(&Symbol("blt",Scan::blt1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2D))));
|
||||
symbols.insert(&Symbol("bmi",Scan::bmi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2B))));
|
||||
symbols.insert(&Symbol("bne",Scan::bne1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x26))));
|
||||
symbols.insert(&Symbol("bpl",Scan::bpl1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2A))));
|
||||
symbols.insert(&Symbol("bra",Scan::bra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x20))));
|
||||
symbols.insert(&Symbol("brclr",Scan::brclr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectRelativeMask,0x13),AddressMode(AddressMode::IndexedRelativeMask,0x1F),AddressMode(AddressMode::IndexedRelativeMask,0x1F,0x18))));
|
||||
symbols.insert(&Symbol("brn",Scan::brn1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x21))));
|
||||
symbols.insert(&Symbol("brset",Scan::brset1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectRelativeMask,0x12),AddressMode(AddressMode::IndexedRelativeMask,0x1E),AddressMode(AddressMode::IndexedRelativeMask,0x1E,0x18))));
|
||||
symbols.insert(&Symbol("bset",Scan::bset1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectMask,0x14),AddressMode(AddressMode::IndexedMask,0x1C),AddressMode(AddressMode::IndexedMask,0x1C,0x18))));
|
||||
symbols.insert(&Symbol("bsr",Scan::bsr1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x8D))));
|
||||
symbols.insert(&Symbol("bvc",Scan::bvc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x28))));
|
||||
symbols.insert(&Symbol("bvs",Scan::bvs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x29))));
|
||||
symbols.insert(&Symbol("cba",Scan::cba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x11))));
|
||||
symbols.insert(&Symbol("clc",Scan::clc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0C))));
|
||||
symbols.insert(&Symbol("cli",Scan::cli1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0E))));
|
||||
symbols.insert(&Symbol("clr",Scan::clr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7F),AddressMode(AddressMode::Indexed,0x6F),AddressMode(AddressMode::Indexed,0x6F,0x18))));
|
||||
symbols.insert(&Symbol("clra",Scan::clra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4F))));
|
||||
symbols.insert(&Symbol("clrb",Scan::clrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5F))));
|
||||
symbols.insert(&Symbol("clv",Scan::clv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0A))));
|
||||
symbols.insert(&Symbol("cmpa",Scan::cmpa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x81),AddressMode(AddressMode::Direct,0x91),AddressMode(AddressMode::Extended,0xB1),AddressMode(AddressMode::Indexed,0xA1),AddressMode(AddressMode::Indexed,0xA1,0x18))));
|
||||
symbols.insert(&Symbol("cmpb",Scan::cmpb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC1),AddressMode(AddressMode::Direct,0xD1),AddressMode(AddressMode::Extended,0xF1),AddressMode(AddressMode::Indexed,0xE1),AddressMode(AddressMode::Indexed,0xE1,0x18))));
|
||||
symbols.insert(&Symbol("com",Scan::com1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x73),AddressMode(AddressMode::Indexed,0x63),AddressMode(AddressMode::Indexed,0x63,0x18))));
|
||||
symbols.insert(&Symbol("coma",Scan::coma1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x43))));
|
||||
symbols.insert(&Symbol("comb",Scan::comb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x53))));
|
||||
symbols.insert(&Symbol("cpd",Scan::cpd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x83,0x1A),AddressMode(AddressMode::Direct,0x93,0x1A),AddressMode(AddressMode::Extended,0xB3,0x1A),AddressMode(AddressMode::Indexed,0xA3,0x1A),AddressMode(AddressMode::Indexed,0xA3,0xCD))));
|
||||
symbols.insert(&Symbol("cpx",Scan::cpx1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8C),AddressMode(AddressMode::Direct,0x9C),AddressMode(AddressMode::Extended,0xBC),AddressMode(AddressMode::Indexed,0xAC),AddressMode(AddressMode::Indexed,0xAC,0xCD))));
|
||||
symbols.insert(&Symbol("cpy",Scan::cpy1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8C,0x18),AddressMode(AddressMode::Direct,0x9C,0x18),AddressMode(AddressMode::Extended,0xBC,0x18),AddressMode(AddressMode::Indexed,0xAC,0x1A),AddressMode(AddressMode::Indexed,0xAC,0x18))));
|
||||
symbols.insert(&Symbol("daa",Scan::daa1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x19))));
|
||||
symbols.insert(&Symbol("dec",Scan::dec1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7A),AddressMode(AddressMode::Indexed,0x6A),AddressMode(AddressMode::Indexed,0x6A,0x18))));
|
||||
symbols.insert(&Symbol("deca",Scan::deca1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4A))));
|
||||
symbols.insert(&Symbol("decb",Scan::decb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5A))));
|
||||
symbols.insert(&Symbol("des",Scan::des1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x34))));
|
||||
symbols.insert(&Symbol("dex",Scan::dex1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x09))));
|
||||
symbols.insert(&Symbol("dey",Scan::dey1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x09,0x18))));
|
||||
symbols.insert(&Symbol("eora",Scan::eora1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x88),AddressMode(AddressMode::Direct,0x98),AddressMode(AddressMode::Extended,0xB8),AddressMode(AddressMode::Indexed,0xA8),AddressMode(AddressMode::Indexed,0xA8,0x18))));
|
||||
symbols.insert(&Symbol("eorb",Scan::eorb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC8),AddressMode(AddressMode::Direct,0xD8),AddressMode(AddressMode::Extended,0xF8),AddressMode(AddressMode::Indexed,0xE8),AddressMode(AddressMode::Indexed,0xE8,0x18))));
|
||||
symbols.insert(&Symbol("fdiv",Scan::fdiv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x03))));
|
||||
symbols.insert(&Symbol("idiv",Scan::idiv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x02))));
|
||||
symbols.insert(&Symbol("inc",Scan::inc1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7C),AddressMode(AddressMode::Indexed,0x6C),AddressMode(AddressMode::Indexed,0x6C,0x18))));
|
||||
symbols.insert(&Symbol("inca",Scan::inca1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4C))));
|
||||
symbols.insert(&Symbol("incb",Scan::incb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5C))));
|
||||
symbols.insert(&Symbol("ins",Scan::ins1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x31))));
|
||||
symbols.insert(&Symbol("inx",Scan::inx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x08))));
|
||||
symbols.insert(&Symbol("iny",Scan::iny1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x08,0x18))));
|
||||
symbols.insert(&Symbol("jmp",Scan::jmp1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7E),AddressMode(AddressMode::Indexed,0x6E),AddressMode(AddressMode::Indexed,0x6E,0x18))));
|
||||
symbols.insert(&Symbol("jsr",Scan::jsr1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0x9D),AddressMode(AddressMode::Extended,0xBD),AddressMode(AddressMode::Indexed,0xAD),AddressMode(AddressMode::Indexed,0xAD,0x18))));
|
||||
symbols.insert(&Symbol("ldaa",Scan::ldaa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x86),AddressMode(AddressMode::Direct,0x96),AddressMode(AddressMode::Extended,0xB6),AddressMode(AddressMode::Indexed,0xA6),AddressMode(AddressMode::Indexed,0xA6,0x18))));
|
||||
symbols.insert(&Symbol("ldab",Scan::ldab1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC6),AddressMode(AddressMode::Direct,0xD6),AddressMode(AddressMode::Extended,0xF6),AddressMode(AddressMode::Indexed,0xE6),AddressMode(AddressMode::Indexed,0xE6,0x18))));
|
||||
symbols.insert(&Symbol("ldd",Scan::ldd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCC),AddressMode(AddressMode::Direct,0xDC),AddressMode(AddressMode::Extended,0xFC),AddressMode(AddressMode::Indexed,0xEC),AddressMode(AddressMode::Indexed,0xEC,0x18))));
|
||||
symbols.insert(&Symbol("lds",Scan::lds1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8E),AddressMode(AddressMode::Direct,0x9E),AddressMode(AddressMode::Extended,0xBE),AddressMode(AddressMode::Indexed,0xAE),AddressMode(AddressMode::Indexed,0xAE,0x18))));
|
||||
symbols.insert(&Symbol("ldx",Scan::ldx1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCE),AddressMode(AddressMode::Direct,0xDE),AddressMode(AddressMode::Extended,0xFE),AddressMode(AddressMode::Indexed,0xEE),AddressMode(AddressMode::Indexed,0xEE,0xCD))));
|
||||
symbols.insert(&Symbol("ldy",Scan::ldy1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCE,0x18),AddressMode(AddressMode::Direct,0xDE,0x18),AddressMode(AddressMode::Extended,0xFE,0x18),AddressMode(AddressMode::Indexed,0xEE,0x1A),AddressMode(AddressMode::Indexed,0xEE,0x18))));
|
||||
symbols.insert(&Symbol("lsl",Scan::lsl1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x78),AddressMode(AddressMode::Indexed,0x68),AddressMode(AddressMode::Indexed,0x68,0x18))));
|
||||
symbols.insert(&Symbol("lsla",Scan::lsla1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x48))));
|
||||
symbols.insert(&Symbol("lslb",Scan::lslb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x58))));
|
||||
symbols.insert(&Symbol("lsld",Scan::lsld1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x05))));
|
||||
symbols.insert(&Symbol("lsr",Scan::lsr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x74),AddressMode(AddressMode::Indexed,0x64),AddressMode(AddressMode::Indexed,0x64,0x18))));
|
||||
symbols.insert(&Symbol("lsra",Scan::lsra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x44))));
|
||||
symbols.insert(&Symbol("lsrb",Scan::lsrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x54))));
|
||||
symbols.insert(&Symbol("lsrd",Scan::lsrd1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x04))));
|
||||
symbols.insert(&Symbol("mul",Scan::mul1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3D))));
|
||||
symbols.insert(&Symbol("neg",Scan::neg1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x70),AddressMode(AddressMode::Indexed,0x60),AddressMode(AddressMode::Indexed,0x60,0x18))));
|
||||
symbols.insert(&Symbol("nega",Scan::nega1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x40))));
|
||||
symbols.insert(&Symbol("negb",Scan::negb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x50))));
|
||||
symbols.insert(&Symbol("nop",Scan::nop1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x01))));
|
||||
symbols.insert(&Symbol("oraa",Scan::oraa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x8A),AddressMode(AddressMode::Direct,0x9A),AddressMode(AddressMode::Extended,0xBA),AddressMode(AddressMode::Indexed,0xAA),AddressMode(AddressMode::Indexed,0xAA,0x18))));
|
||||
symbols.insert(&Symbol("orab",Scan::orab1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xCA),AddressMode(AddressMode::Direct,0xDA),AddressMode(AddressMode::Extended,0xFA),AddressMode(AddressMode::Indexed,0xEA),AddressMode(AddressMode::Indexed,0xEA,0x18))));
|
||||
symbols.insert(&Symbol("psha",Scan::psha1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x36))));
|
||||
symbols.insert(&Symbol("pshb",Scan::pshb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x37))));
|
||||
symbols.insert(&Symbol("pshx",Scan::pshx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3C))));
|
||||
symbols.insert(&Symbol("pshy",Scan::pshy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3C,0x18))));
|
||||
symbols.insert(&Symbol("pula",Scan::pula1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x32))));
|
||||
symbols.insert(&Symbol("pulb",Scan::pulb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x33))));
|
||||
symbols.insert(&Symbol("pulx",Scan::pulx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x38))));
|
||||
symbols.insert(&Symbol("puly",Scan::puly1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x38,0x18))));
|
||||
symbols.insert(&Symbol("rol",Scan::rol1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x79),AddressMode(AddressMode::Indexed,0x69),AddressMode(AddressMode::Indexed,0x69,0x18))));
|
||||
symbols.insert(&Symbol("rola",Scan::rola1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x49))));
|
||||
symbols.insert(&Symbol("rolb",Scan::rolb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x59))));
|
||||
symbols.insert(&Symbol("ror",Scan::ror1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x76),AddressMode(AddressMode::Indexed,0x66),AddressMode(AddressMode::Indexed,0x66,0x18))));
|
||||
symbols.insert(&Symbol("rora",Scan::rora1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x46))));
|
||||
symbols.insert(&Symbol("rorb",Scan::rorb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x56))));
|
||||
symbols.insert(&Symbol("rti",Scan::rti1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3B))));
|
||||
symbols.insert(&Symbol("rts",Scan::rts1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x39))));
|
||||
symbols.insert(&Symbol("sba",Scan::sba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x10))));
|
||||
symbols.insert(&Symbol("sbca",Scan::sbca1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x82),AddressMode(AddressMode::Direct,0x92),AddressMode(AddressMode::Extended,0xB2),AddressMode(AddressMode::Indexed,0xA2),AddressMode(AddressMode::Indexed,0xA2,0x18))));
|
||||
symbols.insert(&Symbol("sbcb",Scan::sbcb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC2),AddressMode(AddressMode::Direct,0xD2),AddressMode(AddressMode::Extended,0xF2),AddressMode(AddressMode::Indexed,0xE2),AddressMode(AddressMode::Indexed,0xE2,0x18))));
|
||||
symbols.insert(&Symbol("sec",Scan::sec1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0D))));
|
||||
symbols.insert(&Symbol("sei",Scan::sei1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0F))));
|
||||
symbols.insert(&Symbol("sev",Scan::sev1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0B))));
|
||||
symbols.insert(&Symbol("staa",Scan::staa1,Symbol::KeywordSymbol,Instruction(4,Instruction::SingleByte,AddressMode(AddressMode::Direct,0x97),AddressMode(AddressMode::Extended,0xB7),AddressMode(AddressMode::Indexed,0xA7),AddressMode(AddressMode::Indexed,0xA7,0x18))));
|
||||
symbols.insert(&Symbol("stab",Scan::stab1,Symbol::KeywordSymbol,Instruction(4,Instruction::SingleByte,AddressMode(AddressMode::Direct,0xD7),AddressMode(AddressMode::Extended,0xF7),AddressMode(AddressMode::Indexed,0xE7),AddressMode(AddressMode::Indexed,0xE7,0x18))));
|
||||
symbols.insert(&Symbol("std",Scan::std1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDD),AddressMode(AddressMode::Extended,0xFD),AddressMode(AddressMode::Indexed,0xED),AddressMode(AddressMode::Indexed,0xED,0x18))));
|
||||
symbols.insert(&Symbol("stop",Scan::stop1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0xCF))));
|
||||
symbols.insert(&Symbol("sts",Scan::sts1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0x9F),AddressMode(AddressMode::Extended,0xBF),AddressMode(AddressMode::Indexed,0xAF),AddressMode(AddressMode::Indexed,0xAF,0x18))));
|
||||
symbols.insert(&Symbol("stx",Scan::stx1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDF),AddressMode(AddressMode::Extended,0xFF),AddressMode(AddressMode::Indexed,0xEF),AddressMode(AddressMode::Indexed,0xEF,0xCD))));
|
||||
symbols.insert(&Symbol("sty",Scan::sty1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDF,0x18),AddressMode(AddressMode::Extended,0xFF,0x18),AddressMode(AddressMode::Indexed,0xEF,0x1A),AddressMode(AddressMode::Indexed,0xEF,0x18))));
|
||||
symbols.insert(&Symbol("suba",Scan::suba1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x80),AddressMode(AddressMode::Direct,0x90),AddressMode(AddressMode::Extended,0xB0),AddressMode(AddressMode::Indexed,0xA0),AddressMode(AddressMode::Indexed,0xA0,0x18))));
|
||||
symbols.insert(&Symbol("subb",Scan::subb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC0),AddressMode(AddressMode::Direct,0xD0),AddressMode(AddressMode::Extended,0xF0),AddressMode(AddressMode::Indexed,0xE0),AddressMode(AddressMode::Indexed,0xE0,0x18))));
|
||||
symbols.insert(&Symbol("subd",Scan::subd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x83),AddressMode(AddressMode::Direct,0x93),AddressMode(AddressMode::Extended,0xB3),AddressMode(AddressMode::Indexed,0xA3),AddressMode(AddressMode::Indexed,0xA3,0x18))));
|
||||
symbols.insert(&Symbol("swi",Scan::swi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3F))));
|
||||
symbols.insert(&Symbol("tab",Scan::tab1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x16))));
|
||||
symbols.insert(&Symbol("tap",Scan::tap1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x06))));
|
||||
symbols.insert(&Symbol("tba",Scan::tba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x17))));
|
||||
symbols.insert(&Symbol("test",Scan::test1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x00))));
|
||||
symbols.insert(&Symbol("tpa",Scan::tpa1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x07))));
|
||||
symbols.insert(&Symbol("tst",Scan::tst1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7D),AddressMode(AddressMode::Indexed,0x6D),AddressMode(AddressMode::Indexed,0x6D,0x18))));
|
||||
symbols.insert(&Symbol("tsta",Scan::tsta1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4D))));
|
||||
symbols.insert(&Symbol("tstb",Scan::tstb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5D))));
|
||||
symbols.insert(&Symbol("tsx",Scan::tsx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x30))));
|
||||
symbols.insert(&Symbol("tsy",Scan::tsy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Indexed,0x30,0x18))));
|
||||
symbols.insert(&Symbol("txs",Scan::txs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x35))));
|
||||
symbols.insert(&Symbol("tys",Scan::tys1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x35,0x18))));
|
||||
symbols.insert(&Symbol("wai",Scan::wai1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3E))));
|
||||
symbols.insert(&Symbol("xgdx",Scan::xgdx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x8F))));
|
||||
symbols.insert(&Symbol("xgdy",Scan::xgdy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x8F,0x18))));
|
||||
symbols.insert(&Symbol("ix",Scan::ix1,Symbol::RegisterSymbol));
|
||||
symbols.insert(&Symbol("iy",Scan::iy1,Symbol::RegisterSymbol));
|
||||
symbols.insert(&Symbol("org",Scan::origin1,Symbol::DirectiveSymbol));
|
||||
symbols.insert(&Symbol("equ",Scan::equ1,Symbol::DirectiveSymbol));
|
||||
symbols.insert(&Symbol("rmb",Scan::rmb1,Symbol::DirectiveSymbol));
|
||||
shuffle(symbols);
|
||||
for(int index=0;index<symbols.size();index++)symbolTable.insert(symbols[index]);
|
||||
}
|
||||
|
||||
void M68Assembler::shuffle(Block<Symbol> &symbols)
|
||||
{
|
||||
int swapFrom;
|
||||
int swapTo;
|
||||
double ratio;
|
||||
Symbol swapItem;
|
||||
|
||||
if(!symbols.size())return;
|
||||
ratio=((double)symbols.size()-1.00)/(double)RAND_MAX;
|
||||
for(int index=0;index<symbols.size();index++)
|
||||
{
|
||||
swapFrom=::rand()*ratio;
|
||||
swapTo=::rand()*ratio;
|
||||
swapItem=symbols[swapFrom];
|
||||
symbols[swapFrom]=symbols[swapTo];
|
||||
symbols[swapTo]=swapItem;
|
||||
}
|
||||
}
|
||||
|
||||
bool M68Assembler::assemble(const String &strPathFileName)
|
||||
{
|
||||
String strPathOutFile(strPathFileName);
|
||||
|
||||
strPathOutFile=strPathFileName.betweenString(0,'.');
|
||||
if(strPathOutFile==strPathFileName)return FALSE;
|
||||
strPathOutFile+=String(".bin");
|
||||
return assemble(strPathFileName,strPathOutFile);
|
||||
}
|
||||
|
||||
bool M68Assembler::assemble(const String &strPathFileName,const String &strPathOutFile)
|
||||
{
|
||||
FileHandle inFile;
|
||||
bool returnCode;
|
||||
|
||||
mCodeSize=0;
|
||||
if(!inFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead))return FALSE;
|
||||
FileMap inMap(inFile);
|
||||
FileMap outMap("SCANOUT",0,MaxScanBytes);
|
||||
FileMap parseMap("PARSEOUT",0,MaxParseBytes);
|
||||
PureViewOfFile inView(inMap);
|
||||
PureViewOfFile outView(outMap);
|
||||
PureViewOfFile parseView(parseMap);
|
||||
Scan scanner(inView,outView,mSymbolTable);
|
||||
scanner.analyze();
|
||||
outView.rewind();
|
||||
|
||||
for(int index=0;index<parseView.size();index++)parseView.write((BYTE)0x01);
|
||||
parseView.rewind();
|
||||
Parse parser(outView,parseView);
|
||||
parser.parse();
|
||||
mLastLineNumber=parser.lastLineNumber();
|
||||
if(Parse::Error==parser.status())
|
||||
{
|
||||
String strMessage;
|
||||
returnCode=FALSE;
|
||||
::sprintf(strMessage,"%s at line number %d\n",(char*)parser.lastMessage(),parser.lastLineNumber());
|
||||
mLastMessage=strMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnCode=TRUE;
|
||||
mLastMessage=parser.lastMessage();
|
||||
mCodeSize=parser.codeBytes();
|
||||
generateCode(strPathOutFile,parseView,parser.codeBytes());
|
||||
// generateListing(strPathOutFile,parseView,parser.codeBytes());
|
||||
// generateS19(strPathOutFile,parser.origins(),parseView,parser.codeBytes());
|
||||
generateS19(strPathOutFile,parseView);
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
bool M68Assembler::generateCode(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength)
|
||||
{
|
||||
FileHandle outFile;
|
||||
|
||||
parseView.rewind();
|
||||
if(!outFile.open(strPathOutFile,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite))return FALSE;
|
||||
outFile.write((BYTE*)parseView.base(),codeLength);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool M68Assembler::generateListing(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength)
|
||||
{
|
||||
FileHandle outFile;
|
||||
String strPathHexFile;
|
||||
FormatLines formatLines;
|
||||
Block<String> codeLines;
|
||||
GlobalData<BYTE> codeBytes;
|
||||
DiskInfo diskInfo;
|
||||
|
||||
strPathHexFile=strPathOutFile.betweenString(0,'.');
|
||||
if(strPathHexFile==strPathOutFile)return false;
|
||||
strPathHexFile+=".lst";
|
||||
diskInfo.unlink(strPathHexFile);
|
||||
if(!codeLength)return FALSE;
|
||||
codeBytes.size(codeLength);
|
||||
::memcpy((BYTE*)&codeBytes[0],(BYTE*)parseView.base(),codeLength);
|
||||
formatLines.hexLines(codeLines,codeBytes);
|
||||
if(!outFile.open(strPathHexFile,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite))return FALSE;
|
||||
for(int index=0;index<codeLines.size();index++)outFile.writeLine(codeLines[index]);
|
||||
outFile.close();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool M68Assembler::generateS19(const String &strPathOutFile,PureViewOfFile &rawCode)
|
||||
{
|
||||
String strPathS19File;
|
||||
DiskInfo diskInfo;
|
||||
|
||||
strPathS19File=strPathOutFile.betweenString(0,'.');
|
||||
if(strPathS19File==strPathOutFile)return false;
|
||||
strPathS19File+=".s19";
|
||||
diskInfo.unlink(strPathS19File);
|
||||
S19Generator::generateCode(rawCode,strPathS19File);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
44
as68hc11/backup/CACHE.HPP
Normal file
44
as68hc11/backup/CACHE.HPP
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _AS68HC11_CACHE_HPP_
|
||||
#define _AS68HC11_CACHE_HPP_
|
||||
#ifndef _AS68HC11_CACHEITEM_HPP_
|
||||
#include <as68hc11/cacheitm.hpp>
|
||||
#endif
|
||||
|
||||
template <class T,class U>
|
||||
class MRUCache
|
||||
{
|
||||
public:
|
||||
enum{CacheLength=10};
|
||||
MRUCache(void);
|
||||
virtual ~MRUCache();
|
||||
WORD isInCache(CacheItem<T,U> &cacheItem);
|
||||
void insert(CacheItem<T,U> &cacheItem);
|
||||
void clear(void);
|
||||
private:
|
||||
void pullCache(void);
|
||||
|
||||
Block<CacheItem<T,U> > mCacheBlock;
|
||||
};
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
MRUCache<T,U>::MRUCache(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
MRUCache<T,U>::~MRUCache()
|
||||
{
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
void MRUCache<T,U>::clear(void)
|
||||
{
|
||||
mCacheBlock.remove();
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <apiparse/cache.tpp>
|
||||
#endif
|
||||
#endif
|
||||
39
as68hc11/backup/CACHE.TPP
Normal file
39
as68hc11/backup/CACHE.TPP
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _AS68HC11_CACHE_TPP_
|
||||
#define _AS68HC11_CACHE_TPP_
|
||||
|
||||
template <class T,class U>
|
||||
WORD MRUCache<T,U>::isInCache(CacheItem<T,U> &cacheItem)
|
||||
{
|
||||
for(short itemIndex=0;itemIndex<mCacheBlock.size();itemIndex++)
|
||||
if(mCacheBlock[itemIndex].cacheItem()==cacheItem.cacheItem())
|
||||
{
|
||||
cacheItem.cacheItem(mCacheBlock[itemIndex].cacheItem());
|
||||
cacheItem.cacheExtraInfo(mCacheBlock[itemIndex].cacheExtraInfo());
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
void MRUCache<T,U>::insert(CacheItem<T,U> &cacheItem)
|
||||
{
|
||||
if(mCacheBlock.size()<CacheLength)
|
||||
{
|
||||
mCacheBlock.insert(&CacheItem<T,U>());
|
||||
pullCache();
|
||||
mCacheBlock[0]=cacheItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pullCache();
|
||||
mCacheBlock[0]=cacheItem;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
void MRUCache<T,U>::pullCache(void)
|
||||
{
|
||||
for(short itemIndex=mCacheBlock.size()-1;itemIndex>0;itemIndex--)
|
||||
mCacheBlock[itemIndex]=mCacheBlock[itemIndex-1];
|
||||
}
|
||||
#endif
|
||||
43
as68hc11/backup/CACHEBLK.CPP
Normal file
43
as68hc11/backup/CACHEBLK.CPP
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <as68hc11/cacheblk.hpp>
|
||||
#include <as68hc11/psymbolc.hpp>
|
||||
|
||||
void CacheBlock::insert(Block<ParseSymbol> &parseSymbols)
|
||||
{
|
||||
for(int itemIndex=0;itemIndex<parseSymbols.size();itemIndex++)insert(parseSymbols[itemIndex]);
|
||||
}
|
||||
|
||||
void CacheBlock::remove(const ParseSymbol &parseSymbol)
|
||||
{
|
||||
ParseSymbolCount parseSymbolCount(parseSymbol);
|
||||
SmartPointer<ParseSymbolCount> parseSymbolNodePtr;
|
||||
if(!searchItem(parseSymbolCount,parseSymbolNodePtr))return;
|
||||
parseSymbolNodePtr->refCount(parseSymbolNodePtr->refCount()-1);
|
||||
if(parseSymbolNodePtr->refCount()<0)parseSymbolNodePtr->refCount(0);
|
||||
}
|
||||
|
||||
BOOL CacheBlock::symbolIn(Scan::ScanSymbols scanSymbol)
|
||||
{
|
||||
ParseSymbol parseSymbol(scanSymbol);
|
||||
ParseSymbolCount parseSymbolCount(parseSymbol);
|
||||
SmartPointer<ParseSymbolCount> parseSymbolNodePtr;
|
||||
if(!searchItem(parseSymbolCount,parseSymbolNodePtr))return FALSE;
|
||||
return parseSymbolNodePtr->refCount();
|
||||
}
|
||||
|
||||
void CacheBlock::insert(const ParseSymbol &parseSymbol)
|
||||
{
|
||||
ParseSymbolCount parseSymbolCount(parseSymbol);
|
||||
SmartPointer<ParseSymbolCount> parseSymbolNodePtr;
|
||||
if(!searchItem(parseSymbolCount,parseSymbolNodePtr))
|
||||
{
|
||||
parseSymbolCount.refCount(1);
|
||||
BTree<ParseSymbolCount>::insert(parseSymbolCount);
|
||||
}
|
||||
else parseSymbolNodePtr->refCount(parseSymbolNodePtr->refCount()+1);
|
||||
}
|
||||
|
||||
void CacheBlock::remove(Block<ParseSymbol> &parseSymbols)
|
||||
{
|
||||
for(int itemIndex=0;itemIndex<parseSymbols.size();itemIndex++)remove(parseSymbols[itemIndex]);
|
||||
}
|
||||
|
||||
42
as68hc11/backup/CACHEBLK.HPP
Normal file
42
as68hc11/backup/CACHEBLK.HPP
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _AS68HC11_CACHEBLOCK_HPP_
|
||||
#define _AS68HC11_CACHEBLOCK_HPP_
|
||||
#ifndef _BSPTREE_BTREE_HPP_
|
||||
#include <bsptree/btree.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_SCAN_HPP_
|
||||
#include <as68hc11/scan.hpp>
|
||||
#endif
|
||||
|
||||
class ParseSymbolCount;
|
||||
class ParseSymbol;
|
||||
|
||||
class CacheBlock : private BTree<ParseSymbolCount>
|
||||
{
|
||||
public:
|
||||
CacheBlock(void);
|
||||
virtual ~CacheBlock();
|
||||
void insert(const ParseSymbol &parseSymbol);
|
||||
void insert(Block<ParseSymbol> &parseSymbols);
|
||||
void remove(const ParseSymbol &parseSymbol);
|
||||
void remove(Block<ParseSymbol> &parseSymbols);
|
||||
BOOL symbolIn(Scan::ScanSymbols symbolValue);
|
||||
DWORD size(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
CacheBlock::CacheBlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CacheBlock::~CacheBlock()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CacheBlock::size(void)const
|
||||
{
|
||||
return leaves();
|
||||
}
|
||||
#endif
|
||||
89
as68hc11/backup/CACHEITM.HPP
Normal file
89
as68hc11/backup/CACHEITM.HPP
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef _AS68HC11_CACHEITEM_HPP_
|
||||
#define _AS68HC11_CACHEITEM_HPP_
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
|
||||
template <class T,class U>
|
||||
class CacheItem
|
||||
{
|
||||
public:
|
||||
CacheItem(void);
|
||||
CacheItem(const CacheItem<T,U> &someCacheItem);
|
||||
virtual ~CacheItem();
|
||||
CacheItem<T,U> &operator=(const CacheItem<T,U> &someCacheItem);
|
||||
WORD operator==(const CacheItem<T,U> &someCacheItem)const;
|
||||
const SmartPointer<U> &cacheItem(void)const;
|
||||
void cacheItem(const SmartPointer<U> &cacheItem);
|
||||
const T &cacheExtraInfo(void)const;
|
||||
void cacheExtraInfo(const T &cacheExtraInfo);
|
||||
private:
|
||||
SmartPointer<U> mCacheItem;
|
||||
T mCacheExtraInfo;
|
||||
};
|
||||
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
CacheItem<T,U>::CacheItem(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
CacheItem<T,U>::CacheItem(const CacheItem<T,U> &someCacheItem)
|
||||
{
|
||||
*this=someCacheItem;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
CacheItem<T,U>::~CacheItem()
|
||||
{
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
CacheItem<T,U> &CacheItem<T,U>::operator=(const CacheItem<T,U> &someCacheItem)
|
||||
{
|
||||
mCacheItem=someCacheItem.mCacheItem;
|
||||
mCacheExtraInfo=someCacheItem.mCacheExtraInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
WORD CacheItem<T,U>::operator==(const CacheItem<T,U> &someCacheItem)const
|
||||
{
|
||||
return (mCacheItem==someCacheItem.mCacheItem&&
|
||||
mCacheExtraInfo==someCacheItem.mCacheExtraInfo);
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
const SmartPointer<U> &CacheItem<T,U>::cacheItem(void)const
|
||||
{
|
||||
return mCacheItem;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
void CacheItem<T,U>::cacheItem(const SmartPointer<U> &cacheItem)
|
||||
{
|
||||
mCacheItem=cacheItem;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
const T &CacheItem<T,U>::cacheExtraInfo(void)const
|
||||
{
|
||||
return mCacheExtraInfo;
|
||||
}
|
||||
|
||||
template <class T,class U>
|
||||
inline
|
||||
void CacheItem<T,U>::cacheExtraInfo(const T &cacheExtraInfo)
|
||||
{
|
||||
mCacheExtraInfo=cacheExtraInfo;
|
||||
}
|
||||
#endif
|
||||
125
as68hc11/backup/CODEPTR.HPP
Normal file
125
as68hc11/backup/CODEPTR.HPP
Normal file
@@ -0,0 +1,125 @@
|
||||
#ifndef _AS68HC11_CODEPOINTER_HPP_
|
||||
#define _AS68HC11_CODEPOINTER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class CodePointer
|
||||
{
|
||||
public:
|
||||
CodePointer(void);
|
||||
CodePointer(const CodePointer &someCodePointer);
|
||||
CodePointer(DWORD origin,DWORD position);
|
||||
virtual ~CodePointer();
|
||||
CodePointer &operator=(const CodePointer &someCodePointer);
|
||||
BOOL operator==(const CodePointer &someCodePointer)const;
|
||||
CodePointer &operator++(void);
|
||||
CodePointer &operator++(int postFixDummy);
|
||||
CodePointer &operator+=(DWORD value);
|
||||
CodePointer &operator-=(DWORD value);
|
||||
DWORD origin(void)const;
|
||||
void origin(DWORD origin);
|
||||
DWORD position(void)const;
|
||||
void position(DWORD position);
|
||||
void reset(void);
|
||||
private:
|
||||
DWORD mOrigin;
|
||||
DWORD mPosition;
|
||||
};
|
||||
|
||||
inline
|
||||
CodePointer::CodePointer(void)
|
||||
: mOrigin(0), mPosition(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer::CodePointer(DWORD origin,DWORD position)
|
||||
: mOrigin(origin), mPosition(position)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer::CodePointer(const CodePointer &someCodePointer)
|
||||
{
|
||||
*this=someCodePointer;
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer::~CodePointer()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &CodePointer::operator=(const CodePointer &someCodePointer)
|
||||
{
|
||||
origin(someCodePointer.origin());
|
||||
position(someCodePointer.position());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL CodePointer::operator==(const CodePointer &someCodePointer)const
|
||||
{
|
||||
return (origin()==someCodePointer.origin()&&position()==someCodePointer.position());
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &CodePointer::operator++(void)
|
||||
{
|
||||
position(position()+1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &CodePointer::operator++(int postfixDummy)
|
||||
{
|
||||
return operator++();
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &CodePointer::operator+=(DWORD value)
|
||||
{
|
||||
position(position()+value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &CodePointer::operator-=(DWORD value)
|
||||
{
|
||||
position(position()-value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CodePointer::origin(void)const
|
||||
{
|
||||
return mOrigin;
|
||||
}
|
||||
|
||||
inline
|
||||
void CodePointer::origin(DWORD origin)
|
||||
{
|
||||
mOrigin=origin;
|
||||
position(origin);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD CodePointer::position(void)const
|
||||
{
|
||||
return mPosition;
|
||||
}
|
||||
|
||||
inline
|
||||
void CodePointer::position(DWORD position)
|
||||
{
|
||||
mPosition=position;
|
||||
}
|
||||
|
||||
inline
|
||||
void CodePointer::reset(void)
|
||||
{
|
||||
origin(0);
|
||||
position(0);
|
||||
}
|
||||
#endif
|
||||
240
as68hc11/backup/Emit.hpp
Normal file
240
as68hc11/backup/Emit.hpp
Normal file
@@ -0,0 +1,240 @@
|
||||
#ifndef _AS68HC11_EMIT_HPP_
|
||||
#define _AS68HC11_EMIT_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
||||
#include <common/pview.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_CODEPOINTER_HPP_
|
||||
#include <as68hc11/codeptr.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_ORIGIN_HPP_
|
||||
#include <as68hc11/origin.hpp>
|
||||
#endif
|
||||
|
||||
class Emit
|
||||
{
|
||||
public:
|
||||
Emit(PureViewOfFile &inputView,PureViewOfFile &outputView);
|
||||
virtual ~Emit();
|
||||
void emit(const char *lpLiteralValue);
|
||||
void emit(const String &literalValue);
|
||||
void emit(int code,int type,int identifier);
|
||||
void emit(int code);
|
||||
void emit(int code,double value);
|
||||
void emit(int code,int op);
|
||||
void emit(BYTE value);
|
||||
void emit(WORD value);
|
||||
int peek(int &someInt);
|
||||
int read(void);
|
||||
int read(void *variable,size_t size);
|
||||
int read(String &strLiteralString);
|
||||
int read(int &someInt);
|
||||
int read(double &someDouble);
|
||||
int read(BYTE &value);
|
||||
BYTE hiByte(DWORD value)const;
|
||||
BYTE loByte(DWORD value)const;
|
||||
void emitting(int);
|
||||
int emitting(void)const;
|
||||
PureViewOfFile &inputView(void);
|
||||
PureViewOfFile &outputView(void);
|
||||
CodePointer &codePointer(void);
|
||||
// Origins &origins(void);
|
||||
private:
|
||||
int mIsEmitting;
|
||||
char mLastSymbol;
|
||||
PureViewOfFile &mInputView;
|
||||
PureViewOfFile &mOutputView;
|
||||
CodePointer mCodePointer;
|
||||
// Origins mOrigins;
|
||||
};
|
||||
|
||||
inline
|
||||
Emit::Emit(PureViewOfFile &inputView,PureViewOfFile &outputView)
|
||||
: mIsEmitting(TRUE), mInputView(inputView), mOutputView(outputView)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Emit::~Emit()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emitting(int isEmitting)
|
||||
{
|
||||
mIsEmitting=isEmitting;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::emitting(void)const
|
||||
{
|
||||
return mIsEmitting;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(void)
|
||||
{
|
||||
if(!mInputView.read((unsigned char&)mLastSymbol))return 0xFFFF;
|
||||
return mLastSymbol;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(void *variable,size_t size)
|
||||
{
|
||||
if(!mInputView.read((char*)variable,size))return 0xFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(String &strLiteralString)
|
||||
{
|
||||
String strLiteral;
|
||||
int strLength;
|
||||
|
||||
read(strLength);
|
||||
strLiteral.reserve(strLength+1);
|
||||
if(0xFFFF==read((char*)strLiteral,strLength))return 0xFFFF;
|
||||
strLiteralString=strLiteral;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::peek(int &someInt)
|
||||
{
|
||||
if(!mInputView.peek(someInt))return 0xFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(BYTE &value)
|
||||
{
|
||||
if(!mInputView.read(value))return 0xFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(int &someInt)
|
||||
{
|
||||
if(!mInputView.read(someInt))return 0xFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
int Emit::read(double &someDouble)
|
||||
{
|
||||
if(!mInputView.read(someDouble))return 0xFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(int code)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(code);
|
||||
mCodePointer+=sizeof(code);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(int code,int type,int identifier)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(code);
|
||||
mOutputView.write(type);
|
||||
mOutputView.write(identifier);
|
||||
mCodePointer+=sizeof(code)+sizeof(type)+sizeof(identifier);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(int code,double value)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(code);
|
||||
mOutputView.write(value);
|
||||
mCodePointer+=sizeof(code)+sizeof(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(int code,int op)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(code);
|
||||
mOutputView.write(op);
|
||||
mCodePointer+=sizeof(code)+sizeof(op);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(WORD value)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(hiByte(value));
|
||||
mOutputView.write(loByte(value));
|
||||
mCodePointer+=sizeof(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(BYTE value)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
mOutputView.write(value);
|
||||
mCodePointer+=sizeof(value);
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(const char *lpLiteralValue)
|
||||
{
|
||||
if(!mIsEmitting||!lpLiteralValue)return;
|
||||
String strLiteral(lpLiteralValue);
|
||||
mOutputView.write(strLiteral);
|
||||
mCodePointer+=strLiteral.length();
|
||||
}
|
||||
|
||||
inline
|
||||
void Emit::emit(const String &literalValue)
|
||||
{
|
||||
if(!mIsEmitting)return;
|
||||
int stringLength(literalValue.length());
|
||||
mOutputView.write(stringLength);
|
||||
mOutputView.write(literalValue);
|
||||
mCodePointer+=sizeof(stringLength)+stringLength;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE Emit::hiByte(DWORD value)const
|
||||
{
|
||||
return (BYTE)(((WORD)value)>>0x08);
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE Emit::loByte(DWORD value)const
|
||||
{
|
||||
return (BYTE)value;
|
||||
}
|
||||
|
||||
inline
|
||||
PureViewOfFile &Emit::inputView(void)
|
||||
{
|
||||
return mInputView;
|
||||
}
|
||||
|
||||
inline
|
||||
PureViewOfFile &Emit::outputView(void)
|
||||
{
|
||||
return mOutputView;
|
||||
}
|
||||
|
||||
inline
|
||||
CodePointer &Emit::codePointer(void)
|
||||
{
|
||||
return mCodePointer;
|
||||
}
|
||||
|
||||
/*
|
||||
inline
|
||||
Origins &Emit::origins(void)
|
||||
{
|
||||
return mOrigins;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
113
as68hc11/backup/Equate.hpp
Normal file
113
as68hc11/backup/Equate.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#ifndef _AS68HC11_EQUATE_HPP_
|
||||
#define _AS68HC11_EQUATE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class Equate
|
||||
{
|
||||
public:
|
||||
enum Disposition{Absolute,Reference};
|
||||
Equate(void);
|
||||
Equate(const Equate &someEquate);
|
||||
Equate(const String &strLabel,DWORD value=0,Disposition disposition=Reference);
|
||||
virtual ~Equate();
|
||||
Equate &operator=(const Equate &someEquate);
|
||||
BOOL operator==(const Equate &someEquate)const;
|
||||
BOOL operator<(const Equate &someEquate)const;
|
||||
const String &strLabel(void)const;
|
||||
void strLabel(const String &strLabel);
|
||||
DWORD value(void)const;
|
||||
void value(DWORD value);
|
||||
Disposition disposition(void)const;
|
||||
void disposition(Disposition disposition);
|
||||
private:
|
||||
String mStrLabel;
|
||||
DWORD mValue;
|
||||
Disposition mDisposition;
|
||||
};
|
||||
|
||||
inline
|
||||
Equate::Equate(void)
|
||||
: mValue(0), mDisposition(Reference)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Equate::Equate(const Equate &someEquate)
|
||||
{
|
||||
*this=someEquate;
|
||||
}
|
||||
|
||||
inline
|
||||
Equate::Equate(const String &strLabel,DWORD value,Disposition disposition)
|
||||
: mStrLabel(strLabel), mValue(value), mDisposition(disposition)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Equate::~Equate()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Equate &Equate::operator=(const Equate &someEquate)
|
||||
{
|
||||
strLabel(someEquate.strLabel());
|
||||
value(someEquate.value());
|
||||
disposition(someEquate.disposition());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Equate::operator==(const Equate &someEquate)const
|
||||
{
|
||||
return (strLabel()==someEquate.strLabel());
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
BOOL Equate::operator<(const Equate &someEquate)const
|
||||
{
|
||||
return (strLabel()<someEquate.strLabel());
|
||||
}
|
||||
|
||||
inline
|
||||
const String &Equate::strLabel(void)const
|
||||
{
|
||||
return mStrLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
void Equate::strLabel(const String &strLabel)
|
||||
{
|
||||
mStrLabel=strLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Equate::value(void)const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
inline
|
||||
void Equate::value(DWORD value)
|
||||
{
|
||||
mValue=value;
|
||||
}
|
||||
|
||||
inline
|
||||
Equate::Disposition Equate::disposition(void)const
|
||||
{
|
||||
return mDisposition;
|
||||
}
|
||||
|
||||
inline
|
||||
void Equate::disposition(Disposition disposition)
|
||||
{
|
||||
mDisposition=disposition;
|
||||
}
|
||||
#endif
|
||||
66
as68hc11/backup/FMTLINES.CPP
Normal file
66
as68hc11/backup/FMTLINES.CPP
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <as68hc11/fmtlines.hpp>
|
||||
#include <common/stdio.hpp>
|
||||
|
||||
DWORD FormatLines::hexasciiLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData)
|
||||
{
|
||||
Block<String> asciiLines;
|
||||
Block<String> hexLines;
|
||||
String tmpString;
|
||||
DWORD lineCount;
|
||||
|
||||
formatLines(asciiLines,globalData,HexCharsPerLine,ASCIILine);
|
||||
formatLines(hexLines,globalData,HexCharsPerLine,HexLine);
|
||||
lineCount=asciiLines.size();
|
||||
for(DWORD itemIndex=0;itemIndex<lineCount;itemIndex++)
|
||||
{
|
||||
tmpString=hexLines[itemIndex]+asciiLines[itemIndex];
|
||||
lineStrings.insert(&tmpString);
|
||||
}
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
DWORD FormatLines::formatLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD charsPerLine,LineType lineType)
|
||||
{
|
||||
DWORD byteCount(globalData.size());
|
||||
WORD charCount;
|
||||
String charString;
|
||||
String charLine;
|
||||
BYTE charByte;
|
||||
BYTE prevByte;
|
||||
|
||||
if(!byteCount)return byteCount;
|
||||
charCount=0;
|
||||
for(DWORD itemIndex=0;itemIndex<byteCount;itemIndex++)
|
||||
{
|
||||
charByte=globalData[itemIndex];
|
||||
if(itemIndex&&(!(itemIndex%charsPerLine)))
|
||||
{
|
||||
if(HexLine==lineType)charLine.upper();
|
||||
lineStrings.insert(&charLine);
|
||||
*((char*)charLine)=0;
|
||||
charCount=0;
|
||||
}
|
||||
if(HexLine==lineType)::sprintf(charString,"%02x",charByte);
|
||||
else
|
||||
{
|
||||
if(isprint(charByte))::sprintf(charString,"%c",charByte);
|
||||
else charString=".";
|
||||
}
|
||||
charCount++;
|
||||
charLine+=charString;
|
||||
if(HexLine==lineType)charLine+=" ";
|
||||
}
|
||||
while(charCount<charsPerLine)
|
||||
{
|
||||
if(HexLine==lineType)charLine+="?? ";
|
||||
else charLine+="?";
|
||||
charCount++;
|
||||
}
|
||||
if(charLine.length())
|
||||
{
|
||||
if(HexLine==lineType)charLine.upper();
|
||||
lineStrings.insert(&charLine);
|
||||
}
|
||||
return lineStrings.size();
|
||||
}
|
||||
|
||||
51
as68hc11/backup/FMTLINES.HPP
Normal file
51
as68hc11/backup/FMTLINES.HPP
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _AS68HC11_FORMATLINES_HPP_
|
||||
#define _AS68HC11_FORMATLINES_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#include <common/gdata.hpp>
|
||||
#endif
|
||||
|
||||
class FormatLines
|
||||
{
|
||||
public:
|
||||
enum{HexCharsPerLine=0x10,ASCIICharsPerLine=0x20};
|
||||
FormatLines(void);
|
||||
virtual ~FormatLines();
|
||||
DWORD hexLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD hexCharsPerLine=HexCharsPerLine);
|
||||
DWORD asciiLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD asciiCharsPerLine=ASCIICharsPerLine);
|
||||
DWORD hexasciiLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData);
|
||||
private:
|
||||
enum LineType{HexLine,ASCIILine};
|
||||
DWORD formatLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD charsPerLine,LineType lineType);
|
||||
};
|
||||
|
||||
inline
|
||||
FormatLines::FormatLines(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FormatLines::~FormatLines()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FormatLines::hexLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD hexCharsPerLine)
|
||||
{
|
||||
return formatLines(lineStrings,globalData,hexCharsPerLine,HexLine);
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD FormatLines::asciiLines(Block<String> &lineStrings,GlobalData<BYTE> &globalData,WORD asciiCharsPerLine)
|
||||
{
|
||||
return formatLines(lineStrings,globalData,asciiCharsPerLine,ASCIILine);
|
||||
}
|
||||
#endif
|
||||
257
as68hc11/backup/INSTRCTN.CPP
Normal file
257
as68hc11/backup/INSTRCTN.CPP
Normal file
@@ -0,0 +1,257 @@
|
||||
#include <as68hc11/instrctn.hpp>
|
||||
|
||||
Instruction::operator String(void)
|
||||
{
|
||||
String strInstruction;
|
||||
|
||||
strInstruction.reserve(1024);
|
||||
for(int index=0;index<size();index++)strInstruction+=String("\n\t")+(String)operator[](index);
|
||||
return strInstruction;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasInherentMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasInherentMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasImmediateMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasImmediateMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasDirectMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasDirectMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasExtendedMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasExtendedMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasRelativeMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasRelativeMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasIndexedMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasIndexedMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasPreByte(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasPreByte(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasIndexedRelativeMaskMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasIndexedRelativeMaskMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasDirectRelativeMaskMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasDirectRelativeMaskMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasRelativeMaskMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasRelativeMaskMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasMaskMode(void)const
|
||||
{
|
||||
WORD indexForm;
|
||||
return hasMaskMode(indexForm);
|
||||
}
|
||||
|
||||
BOOL Instruction::hasInherentMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
indexForm=0xFFFF;
|
||||
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Inherent&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasImmediateMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Immediate&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasDirectMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Direct&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasExtendedMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Extended&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasRelativeMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Relative&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasIndexedMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Indexed&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasIndexedRelativeMaskMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if((AddressMode::Indexed&attribute)&&(AddressMode::Relative&attribute)&&(AddressMode::Mask&attribute))
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasDirectRelativeMaskMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if((AddressMode::Direct&attribute)&&(AddressMode::Relative&attribute)&&(AddressMode::Mask&attribute))
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasRelativeMaskMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if((AddressMode::Relative&attribute)&&(AddressMode::Mask&attribute))
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasMaskMode(WORD &indexForm)const
|
||||
{
|
||||
AddressMode::Attribute attribute;
|
||||
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)
|
||||
{
|
||||
attribute=((Instruction&)*this).operator[](index).attribute();
|
||||
if(AddressMode::Mask&attribute)
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Instruction::hasPreByte(WORD &indexForm)const
|
||||
{
|
||||
indexForm=0xFFFF;
|
||||
for(int index=0;index<size();index++)if(((Instruction&)*this).operator[](index).prebyte())
|
||||
{
|
||||
indexForm=index;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
103
as68hc11/backup/Instrctn.hpp
Normal file
103
as68hc11/backup/Instrctn.hpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef _AS68HC11_INSTRUCTION_HPP_
|
||||
#define _AS68HC11_INSTRUCTION_HPP_
|
||||
#ifndef _AS68HC11_ADDRESSMODE_HPP_
|
||||
#include <as68hc11/mode.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
|
||||
class Instruction : public Array<AddressMode>
|
||||
{
|
||||
public:
|
||||
enum RegisterLength{SingleByte,DoubleByte,NotApplicable};
|
||||
Instruction(void);
|
||||
Instruction(const Instruction &someInstruction);
|
||||
Instruction(int count,RegisterLength registerLength=NotApplicable,...);
|
||||
virtual ~Instruction();
|
||||
Instruction &operator=(const Instruction &someInstruction);
|
||||
BOOL operator==(const Instruction &someInstruction)const;
|
||||
operator String(void);
|
||||
RegisterLength registerLength(void)const;
|
||||
void registerLength(RegisterLength registerLength);
|
||||
BOOL hasInherentMode(void)const;
|
||||
BOOL hasImmediateMode(void)const;
|
||||
BOOL hasDirectMode(void)const;
|
||||
BOOL hasExtendedMode(void)const;
|
||||
BOOL hasRelativeMode(void)const;
|
||||
BOOL hasIndexedMode(void)const;
|
||||
BOOL hasIndexedRelativeMaskMode(void)const;
|
||||
BOOL hasDirectRelativeMaskMode(void)const;
|
||||
BOOL hasRelativeMaskMode(void)const;
|
||||
BOOL hasMaskMode(void)const;
|
||||
BOOL hasPreByte(void)const;
|
||||
BOOL hasInherentMode(WORD &indexForm)const;
|
||||
BOOL hasImmediateMode(WORD &indexForm)const;
|
||||
BOOL hasDirectMode(WORD &indexForm)const;
|
||||
BOOL hasExtendedMode(WORD &indexForm)const;
|
||||
BOOL hasRelativeMode(WORD &indexForm)const;
|
||||
BOOL hasIndexedMode(WORD &indexForm)const;
|
||||
BOOL hasIndexedRelativeMaskMode(WORD &indexForm)const;
|
||||
BOOL hasDirectRelativeMaskMode(WORD &indexForm)const;
|
||||
BOOL hasRelativeMaskMode(WORD &indexForm)const;
|
||||
BOOL hasMaskMode(WORD &indexForm)const;
|
||||
BOOL hasPreByte(WORD &indexForm)const;
|
||||
private:
|
||||
RegisterLength mRegisterLength;
|
||||
};
|
||||
|
||||
inline
|
||||
Instruction::Instruction(void)
|
||||
: mRegisterLength(NotApplicable)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Instruction::Instruction(int count,RegisterLength registerLength,...)
|
||||
: mRegisterLength(registerLength)
|
||||
{
|
||||
va_list varList;
|
||||
|
||||
size(count);
|
||||
va_start(varList,registerLength);
|
||||
for(int index=0;index<count;index++)Array<AddressMode>::operator[](index)=va_arg(varList,AddressMode);
|
||||
}
|
||||
|
||||
inline
|
||||
Instruction::Instruction(const Instruction &someInstruction)
|
||||
{
|
||||
*this=someInstruction;
|
||||
}
|
||||
|
||||
inline
|
||||
Instruction::~Instruction()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Instruction &Instruction::operator=(const Instruction &someInstruction)
|
||||
{
|
||||
Array<AddressMode>::operator=(someInstruction);
|
||||
registerLength(someInstruction.registerLength());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Instruction::operator==(const Instruction &someInstruction)const
|
||||
{
|
||||
return (Array<AddressMode>::operator==(someInstruction)&&
|
||||
registerLength()==someInstruction.registerLength());
|
||||
}
|
||||
|
||||
inline
|
||||
Instruction::RegisterLength Instruction::registerLength(void)const
|
||||
{
|
||||
return mRegisterLength;
|
||||
}
|
||||
|
||||
inline
|
||||
void Instruction::registerLength(RegisterLength registerLength)
|
||||
{
|
||||
mRegisterLength=registerLength;
|
||||
}
|
||||
#endif
|
||||
72
as68hc11/backup/Labelgen.hpp
Normal file
72
as68hc11/backup/Labelgen.hpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef _AS68HC11_LABELGENERATOR_HPP_
|
||||
#define _AS68HC11_LABELGENERATOR_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _BSPTREE_BINARYTREE_HPP_
|
||||
#include <bsptree/bintree.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_LABEL_HPP_
|
||||
#include <as68hc11/label.hpp>
|
||||
#endif
|
||||
|
||||
class LabelGenerator : private BinaryTree<Label>
|
||||
{
|
||||
public:
|
||||
LabelGenerator(void);
|
||||
virtual ~LabelGenerator();
|
||||
BOOL insert(const Label &someLabel);
|
||||
BOOL searchItem(const Label &someItem,SmartPointer<Label> &nodeItem);
|
||||
BOOL find(Label &someLabel);
|
||||
private:
|
||||
LabelGenerator(const LabelGenerator &someLabelGenerator);
|
||||
LabelGenerator &operator=(const LabelGenerator &someLabelGenerator);
|
||||
BOOL operator==(const LabelGenerator &someLabelGenerator)const;
|
||||
};
|
||||
|
||||
inline
|
||||
LabelGenerator::LabelGenerator(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
LabelGenerator::LabelGenerator(const LabelGenerator &someLabelGenerator)
|
||||
{ // private implementation
|
||||
*this=someLabelGenerator;
|
||||
}
|
||||
|
||||
inline
|
||||
LabelGenerator::~LabelGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
LabelGenerator &LabelGenerator::operator=(const LabelGenerator &/*someLabelGenerator*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL LabelGenerator::operator==(const LabelGenerator &someLabelGenerator)const
|
||||
{ // private implementation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL LabelGenerator::insert(const Label &someLabel)
|
||||
{
|
||||
return BinaryTree<Label>::insert(someLabel);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL LabelGenerator::find(Label &someLabel)
|
||||
{
|
||||
return BinaryTree<Label>::searchItem(someLabel);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL LabelGenerator::searchItem(const Label &someItem,SmartPointer<Label> &nodeItem)
|
||||
{
|
||||
return BinaryTree<Label>::searchItem(someItem,nodeItem);
|
||||
}
|
||||
#endif
|
||||
20
as68hc11/backup/MODE.CPP
Normal file
20
as68hc11/backup/MODE.CPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <as68hc11/mode.hpp>
|
||||
#include <common/stdio.hpp>
|
||||
|
||||
AddressMode::operator String(void)
|
||||
{
|
||||
String strString;
|
||||
String strAttribute;
|
||||
|
||||
if(Inherent==attribute())strAttribute="Inherent ";
|
||||
else if(Immediate==attribute())strAttribute="Immediate";
|
||||
else if(Direct==attribute())strAttribute="Direct ";
|
||||
else if(Extended==attribute())strAttribute="Extended ";
|
||||
else if(Indexed==attribute())strAttribute="Indexed ";
|
||||
else if(Relative==attribute())strAttribute="Relative ";
|
||||
else strAttribute="Unknown";
|
||||
if(prebyte())::sprintf(strString,"\topcode:0x%02lx prebyte:0x%02lx",int(opcode()),int(prebyte()));
|
||||
else ::sprintf(strString,"\topcode:0x%02lx",int(opcode()));
|
||||
strAttribute+=String(" ")+strString;
|
||||
return strAttribute;
|
||||
}
|
||||
12
as68hc11/backup/Main.cpp
Normal file
12
as68hc11/backup/Main.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <common/windows.hpp>
|
||||
#include <as68hc11/asm6811.hpp>
|
||||
|
||||
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
||||
{
|
||||
M68Assembler m68Assembler;
|
||||
m68Assembler.assemble("test9.asm");
|
||||
// m68Assembler.assemble("test7.asm");
|
||||
// m68Assembler.assemble("test8.asm");
|
||||
::OutputDebugString(m68Assembler.strLastMessage()+String("\n"));
|
||||
return FALSE;
|
||||
}
|
||||
108
as68hc11/backup/Mode.hpp
Normal file
108
as68hc11/backup/Mode.hpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef _AS68HC11_ADDRESSMODE_HPP_
|
||||
#define _AS68HC11_ADDRESSMODE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class AddressMode
|
||||
{
|
||||
public:
|
||||
enum Attribute{None=0x0000,Inherent=0x001,Immediate=0x0002,Direct=0x0004,Extended=0x0008,Indexed=0x0010,Relative=0x0020,Mask=0x0040,IndexedRelativeMask=Indexed|Relative|Mask,DirectRelativeMask=Direct|Relative|Mask,IndexedMask=Indexed|Mask,DirectMask=Direct|Mask};
|
||||
AddressMode(void);
|
||||
AddressMode(const AddressMode &someAddressMode);
|
||||
AddressMode(Attribute attribute,BYTE opcode,BYTE prebyte=0x00);
|
||||
virtual ~AddressMode();
|
||||
AddressMode &operator=(const AddressMode &someAddressMode);
|
||||
BOOL operator==(const AddressMode &someAddressMode)const;
|
||||
operator String(void);
|
||||
Attribute attribute(void)const;
|
||||
void attribute(Attribute attribute);
|
||||
BYTE opcode(void)const;
|
||||
void opcode(BYTE opcode);
|
||||
BYTE prebyte(void)const;
|
||||
void prebyte(BYTE prebyte);
|
||||
private:
|
||||
Attribute mAttribute;
|
||||
BYTE mOpCode;
|
||||
BYTE mPreByte;
|
||||
};
|
||||
|
||||
inline
|
||||
AddressMode::AddressMode(void)
|
||||
: mAttribute(None), mOpCode(0x00), mPreByte(0x00)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
AddressMode::AddressMode(const AddressMode &someAddressMode)
|
||||
{
|
||||
*this=someAddressMode;
|
||||
}
|
||||
|
||||
inline
|
||||
AddressMode::AddressMode(Attribute attribute,BYTE opcode,BYTE prebyte)
|
||||
: mAttribute(attribute), mOpCode(opcode), mPreByte(prebyte)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
AddressMode::~AddressMode()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
AddressMode &AddressMode::operator=(const AddressMode &someAddressMode)
|
||||
{
|
||||
attribute(someAddressMode.attribute());
|
||||
opcode(someAddressMode.opcode());
|
||||
prebyte(someAddressMode.prebyte());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL AddressMode::operator==(const AddressMode &someAddressMode)const
|
||||
{
|
||||
return (attribute()==someAddressMode.attribute()&&
|
||||
opcode()==someAddressMode.opcode()&&
|
||||
prebyte()==someAddressMode.prebyte());
|
||||
}
|
||||
|
||||
inline
|
||||
AddressMode::Attribute AddressMode::attribute(void)const
|
||||
{
|
||||
return mAttribute;
|
||||
}
|
||||
|
||||
inline
|
||||
void AddressMode::attribute(Attribute attribute)
|
||||
{
|
||||
mAttribute=attribute;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE AddressMode::opcode(void)const
|
||||
{
|
||||
return mOpCode;
|
||||
}
|
||||
|
||||
inline
|
||||
void AddressMode::opcode(BYTE opcode)
|
||||
{
|
||||
mOpCode=opcode;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE AddressMode::prebyte(void)const
|
||||
{
|
||||
return mPreByte;
|
||||
}
|
||||
|
||||
inline
|
||||
void AddressMode::prebyte(BYTE prebyte)
|
||||
{
|
||||
mPreByte=prebyte;
|
||||
}
|
||||
#endif
|
||||
69
as68hc11/backup/Origin.hpp
Normal file
69
as68hc11/backup/Origin.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef _AS68HC11_ORIGIN_HPP_
|
||||
#define _AS68HC11_ORIGIN_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
class Origin;
|
||||
typedef Block<Origin> Origins;
|
||||
|
||||
class Origin
|
||||
{
|
||||
public:
|
||||
Origin();
|
||||
Origin(DWORD origin,DWORD position);
|
||||
virtual ~Origin();
|
||||
DWORD getOrigin(void)const;
|
||||
void setOrigin(DWORD origin);
|
||||
DWORD getPosition(void)const;
|
||||
void setPosition(DWORD position);
|
||||
private:
|
||||
DWORD mOrigin; // memory address in MCU of where to generate this code
|
||||
DWORD mPosition; // position of code in the code generation stream
|
||||
};
|
||||
|
||||
inline
|
||||
Origin::Origin()
|
||||
: mOrigin(0), mPosition(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Origin::Origin(DWORD origin,DWORD position)
|
||||
: mOrigin(origin), mPosition(position)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Origin::~Origin()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Origin::getOrigin(void)const
|
||||
{
|
||||
return mOrigin;
|
||||
}
|
||||
|
||||
inline
|
||||
void Origin::setOrigin(DWORD origin)
|
||||
{
|
||||
mOrigin=origin;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Origin::getPosition(void)const
|
||||
{
|
||||
return mPosition;
|
||||
}
|
||||
|
||||
inline
|
||||
void Origin::setPosition(DWORD position)
|
||||
{
|
||||
mPosition=position;
|
||||
}
|
||||
#endif
|
||||
|
||||
47
as68hc11/backup/PSYMBOL.HPP
Normal file
47
as68hc11/backup/PSYMBOL.HPP
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _AS68HC11_PSYMBOL_HPP_
|
||||
#define _AS68HC11_PSYMBOL_HPP_
|
||||
#ifndef _AS68HC11_SCAN_HPP_
|
||||
#include <as68hc11/scan.hpp>
|
||||
#endif
|
||||
|
||||
class ParseSymbol
|
||||
{
|
||||
public:
|
||||
ParseSymbol(Scan::ScanSymbols symbol);
|
||||
ParseSymbol(const ParseSymbol &parseSymbol);
|
||||
virtual ~ParseSymbol();
|
||||
Scan::ScanSymbols value(void)const;
|
||||
int operator==(const ParseSymbol &parseSymbol)const;
|
||||
private:
|
||||
Scan::ScanSymbols mSymbol;
|
||||
};
|
||||
|
||||
inline
|
||||
ParseSymbol::ParseSymbol(Scan::ScanSymbols symbol)
|
||||
: mSymbol(symbol)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbol::ParseSymbol(const ParseSymbol &parseSymbol)
|
||||
: mSymbol(parseSymbol.mSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbol::~ParseSymbol()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Scan::ScanSymbols ParseSymbol::value(void)const
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
inline
|
||||
int ParseSymbol::operator==(const ParseSymbol &parseSymbol)const
|
||||
{
|
||||
return mSymbol==parseSymbol.mSymbol;
|
||||
}
|
||||
#endif
|
||||
71
as68hc11/backup/PSYMBOLC.HPP
Normal file
71
as68hc11/backup/PSYMBOLC.HPP
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef _AS68HC11_PARSESYMBOLCOUNT_HPP_
|
||||
#define _AS68HC11_PARSESYMBOLCOUNT_HPP_
|
||||
#ifndef _AS68HC11_PSYMBOL_HPP_
|
||||
#include <as68hc11/psymbol.hpp>
|
||||
#endif
|
||||
|
||||
class ParseSymbolCount : public ParseSymbol
|
||||
{
|
||||
public:
|
||||
ParseSymbolCount(Scan::ScanSymbols symbol);
|
||||
ParseSymbolCount(const ParseSymbolCount &someParseSymbolCount);
|
||||
ParseSymbolCount(const ParseSymbol &someParseSymbol);
|
||||
virtual ~ParseSymbolCount();
|
||||
ParseSymbolCount &operator=(const ParseSymbolCount &someParseSymbolCount);
|
||||
BOOL operator<(const ParseSymbolCount &someParseSymbolCount)const;
|
||||
DWORD refCount(void)const;
|
||||
void refCount(DWORD refCount);
|
||||
private:
|
||||
DWORD mRefCount;
|
||||
};
|
||||
|
||||
inline
|
||||
ParseSymbolCount::ParseSymbolCount(Scan::ScanSymbols symbol)
|
||||
: ParseSymbol(symbol)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbolCount::ParseSymbolCount(const ParseSymbolCount &someParseSymbolCount)
|
||||
: ParseSymbol((ParseSymbol&)someParseSymbolCount)
|
||||
{
|
||||
*this=someParseSymbolCount;
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbolCount::ParseSymbolCount(const ParseSymbol &someParseSymbol)
|
||||
: ParseSymbol(someParseSymbol), mRefCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbolCount::~ParseSymbolCount()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ParseSymbolCount &ParseSymbolCount::operator=(const ParseSymbolCount &someParseSymbolCount)
|
||||
{
|
||||
(ParseSymbol&)*this=(ParseSymbol&)someParseSymbolCount;
|
||||
refCount(someParseSymbolCount.refCount());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL ParseSymbolCount::operator<(const ParseSymbolCount &someParseSymbolCount)const
|
||||
{
|
||||
return value()<someParseSymbolCount.value();
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD ParseSymbolCount::refCount(void)const
|
||||
{
|
||||
return mRefCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void ParseSymbolCount::refCount(DWORD refCount)
|
||||
{
|
||||
mRefCount=refCount;
|
||||
}
|
||||
#endif
|
||||
1280
as68hc11/backup/Parse.cpp
Normal file
1280
as68hc11/backup/Parse.cpp
Normal file
File diff suppressed because it is too large
Load Diff
228
as68hc11/backup/Parse.hpp
Normal file
228
as68hc11/backup/Parse.hpp
Normal file
@@ -0,0 +1,228 @@
|
||||
#ifndef _AS68HC11_PARSE_HPP_
|
||||
#define _AS68HC11_PARSE_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_OPENFILE_HPP_
|
||||
#include <common/openfile.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_SCAN_HPP_
|
||||
#include <as68hc11/scan.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_EMIT_HPP_
|
||||
#include <as68hc11/emit.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_PSYMBOL_HPP_
|
||||
#include <as68hc11/psymbol.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_PARSESYMBOLCOUNT_HPP_
|
||||
#include <as68hc11/psymbolc.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_CACHEBLOCK_HPP_
|
||||
#include <as68hc11/cacheblk.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_LABELGENERATOR_HPP_
|
||||
#include <as68hc11/labelgen.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_FIXUP_HPP_
|
||||
#include <as68hc11/fixup.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_EQUATE_HPP_
|
||||
#include <as68hc11/equate.hpp>
|
||||
#endif
|
||||
|
||||
class Parse : public Emit
|
||||
{
|
||||
public:
|
||||
enum Status{Error,Ok};
|
||||
enum ParseSymbols{codestart2,codeend2,purecode2};
|
||||
Parse(PureViewOfFile &srcView,PureViewOfFile &dstView);
|
||||
virtual ~Parse();
|
||||
BOOL parse(void);
|
||||
DWORD codeBytes(void)const;
|
||||
Status status(void)const;
|
||||
String lastMessage(void)const;
|
||||
DWORD lastLineNumber(void)const;
|
||||
private:
|
||||
enum {FirstLine=1};
|
||||
enum MaxBits{MaxBit16=0xFFFF,MaxBit8=0xFF};
|
||||
enum {MaxForwardJump=128,MaxBackwardJump=-128};
|
||||
enum ErrorCode{IllegalAddressingModeForMnemonic,ExpectedIndexRegister,OperandSizeMustMatch,
|
||||
ValueOutOfRangeForInstruction,SymbolAlreadyDefined,SymbolNotDefined,BranchOutOfRange,
|
||||
SymbolAlreadyDifferentKind,DivideByZero};
|
||||
void insertSymbols(Block<ParseSymbol> &groupSymbols);
|
||||
void insertSymbols(const ParseSymbol &groupSymbol);
|
||||
void removeSymbols(Block<ParseSymbol> &groupSymbols);
|
||||
void removeSymbols(const ParseSymbol &groupSymbol);
|
||||
BOOL symbolIn(Block<ParseSymbol> &parseSymbols)const;
|
||||
BOOL symbolIn(const ParseSymbol &parseSymbol)const;
|
||||
BOOL peekSymbolIn(const ParseSymbol &parseSymbol);
|
||||
Scan::ScanSymbols currentSymbolType(void)const;
|
||||
void parseLabelExtended(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseLabelDirect(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseLabelImmediate(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseDirectExtended(SmartPointer<Symbol> ¤tSymbol,WORD indexForm,Scan::ScanSymbols peekSymbol);
|
||||
void parseRelativeMask(SmartPointer<Symbol> ¤tSymbol,Scan::ScanSymbols peekSymbol);
|
||||
void parseMask(SmartPointer<Symbol> ¤tSymbol,Scan::ScanSymbols peekSymbol);
|
||||
void parseIndexed(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseRelative(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseImmediate(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseInherent(SmartPointer<Symbol> ¤tSymbol,WORD indexForm);
|
||||
void parseIndex(SmartPointer<Symbol> ¤tSymbol,SmartPointer<AddressMode> &addressMode,DWORD &expressionResult);
|
||||
BOOL emitEquate(SmartPointer<Symbol> ¤tSymbol,Equate &equate);
|
||||
BOOL emitLabel(SmartPointer<Symbol> ¤tSymbol,Label &label);
|
||||
void insertLabelFixup(SmartPointer<Symbol> ¤tSymbol,Label &label);
|
||||
void parseBranch(void);
|
||||
void simpleExpression(DWORD &expressionResult);
|
||||
void expression(DWORD &expressionResult);
|
||||
DWORD term(void);
|
||||
void factor(DWORD &expressionResult);
|
||||
void errorExpect(Symbol::SymbolType symbolType);
|
||||
void expect(Scan::ScanSymbols symbol);
|
||||
void syntaxError(int expectedSymbol);
|
||||
void createSimpleExpressionSymbols(void);
|
||||
void createStatementSymbols(void);
|
||||
void createTermSymbols(void);
|
||||
void createMathSymbols(void);
|
||||
void createAddSymbols(void);
|
||||
void createSignSymbols(void);
|
||||
void createFactorSymbols(void);
|
||||
void createExpressionSymbols(void);
|
||||
void errorExpect(int scanSymbol);
|
||||
void error(ErrorCode errorCode,const String &strExtraMessage=String());
|
||||
void keywordStatement(void);
|
||||
void labelStatement(void);
|
||||
void equateStatement(void);
|
||||
void originStatement(void);
|
||||
void userStatement(void);
|
||||
void rmbStatement(void);
|
||||
void statement(void);
|
||||
void parseLiteral(void);
|
||||
void syntaxCheck(void);
|
||||
void syntaxError(void);
|
||||
DWORD origin(void)const;
|
||||
BOOL resolve(void);
|
||||
WORD nextSymbol(void);
|
||||
BOOL isInEquates(const String &strLabel);
|
||||
BOOL isInLabels(const String &strLabel);
|
||||
BOOL isInError(void)const;
|
||||
BOOL inRange(DWORD value,MaxBits maxBits=MaxBit16)const;
|
||||
BOOL jumpInRange(int distance)const;
|
||||
|
||||
CacheBlock mParseSymbols;
|
||||
BOOL mIsInError;
|
||||
DWORD mNumeralValue;
|
||||
DWORD mLastLineNumber;
|
||||
DWORD mLineNumber;
|
||||
String mLastMessage;
|
||||
SmartPointer<Symbol> mCurrentSymbol;
|
||||
Scan::ScanSymbols mCurrentSymbolType;
|
||||
Block<ParseSymbol> mStatementSymbols;
|
||||
Block<ParseSymbol> mSimpleExpressionSymbols;
|
||||
Block<ParseSymbol> mExpressionSymbols;
|
||||
Block<ParseSymbol> mTermSymbols;
|
||||
Block<ParseSymbol> mMathSymbols;
|
||||
Block<ParseSymbol> mAddSymbols;
|
||||
Block<ParseSymbol> mSignSymbols;
|
||||
Block<ParseSymbol> mFactorSymbols;
|
||||
LabelGenerator mLabelGenerator;
|
||||
BinaryTree<Equate> mEquates;
|
||||
Block<Fixup> mFixups;
|
||||
String mLiteralValue;
|
||||
FileHandle mLogFile;
|
||||
DWORD mCodeBytes;
|
||||
};
|
||||
|
||||
inline
|
||||
void Parse::insertSymbols(Block<ParseSymbol> &groupSymbols)
|
||||
{
|
||||
mParseSymbols.insert(groupSymbols);
|
||||
}
|
||||
|
||||
inline
|
||||
void Parse::insertSymbols(const ParseSymbol &groupSymbol)
|
||||
{
|
||||
mParseSymbols.insert(groupSymbol);
|
||||
}
|
||||
|
||||
inline
|
||||
void Parse::removeSymbols(Block<ParseSymbol> &groupSymbols)
|
||||
{
|
||||
mParseSymbols.remove(groupSymbols);
|
||||
}
|
||||
|
||||
inline
|
||||
void Parse::removeSymbols(const ParseSymbol &groupSymbol)
|
||||
{
|
||||
mParseSymbols.remove(groupSymbol);
|
||||
}
|
||||
|
||||
inline
|
||||
Parse::Status Parse::status(void)const
|
||||
{
|
||||
if(mIsInError)return Error;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
inline
|
||||
String Parse::lastMessage(void)const
|
||||
{
|
||||
return mLastMessage;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Parse::lastLineNumber(void)const
|
||||
{
|
||||
return mLastLineNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Parse::isInError(void)const
|
||||
{
|
||||
return mIsInError;
|
||||
}
|
||||
|
||||
inline
|
||||
Scan::ScanSymbols Parse::currentSymbolType(void)const
|
||||
{
|
||||
return mCurrentSymbolType;
|
||||
}
|
||||
|
||||
inline
|
||||
void Parse::expect(Scan::ScanSymbols symbol)
|
||||
{
|
||||
if(symbol==currentSymbolType())nextSymbol();
|
||||
else syntaxError(symbol);
|
||||
syntaxCheck();
|
||||
}
|
||||
|
||||
inline
|
||||
void Parse::syntaxCheck(void)
|
||||
{
|
||||
if(!mParseSymbols.symbolIn(currentSymbolType()))syntaxError();
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Parse::inRange(DWORD value,MaxBits maxBits)const
|
||||
{
|
||||
if(MaxBit16==maxBits&&value>MaxBit16)return FALSE;
|
||||
else if(MaxBit8==maxBits&&value>MaxBit8)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Parse::jumpInRange(int distance)const
|
||||
{
|
||||
if(distance>MaxForwardJump||distance<MaxBackwardJump)return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Parse::codeBytes(void)const
|
||||
{
|
||||
return mCodeBytes;
|
||||
}
|
||||
#endif
|
||||
47
as68hc11/backup/S19Generator.cpp
Normal file
47
as68hc11/backup/S19Generator.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <as68hc11/S19Generator.hpp>
|
||||
|
||||
bool S19Generator::generateCode(PureViewOfFile &rawCode,const String &strPathOutput)
|
||||
{
|
||||
File outFile;
|
||||
DWORD genBytes=0;
|
||||
String endLine;
|
||||
|
||||
endLine="S9030000FC";
|
||||
rawCode.rewind();
|
||||
if(!outFile.open(strPathOutput,"wb"))return false;
|
||||
generateLines(rawCode.tell(),rawCode.size(),rawCode,outFile);
|
||||
outFile.writeLine(endLine);
|
||||
::OutputDebugString(endLine+String("\r\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void S19Generator::generateLines(DWORD origin,DWORD codeSize,PureViewOfFile &rawCode,File &outFile)
|
||||
{
|
||||
String strByte;
|
||||
BYTE codeByte;
|
||||
int checksum=0;
|
||||
|
||||
while(codeSize>0)
|
||||
{
|
||||
String strLine;
|
||||
checksum=0;
|
||||
int bytesInLine=codeSize<MaxDataBytesPerLine?codeSize:MaxDataBytesPerLine;
|
||||
::sprintf(strLine,"S1%02x%04x",bytesInLine+1+2,origin);
|
||||
checksum+=(bytesInLine+1+2);
|
||||
checksum+=origin;
|
||||
for(int index=0;index<bytesInLine;index++,codeSize--,origin++)
|
||||
{
|
||||
rawCode.read(codeByte);
|
||||
checksum+=codeByte;
|
||||
::sprintf(strByte,"%02x",codeByte);
|
||||
strLine+=strByte;
|
||||
}
|
||||
checksum=checksum&0xFF;
|
||||
checksum=~checksum;
|
||||
::sprintf(strByte,"%02x",(BYTE)checksum);
|
||||
strLine+=strByte;
|
||||
strLine.upper();
|
||||
::OutputDebugString(strLine+String("\r\n"));
|
||||
outFile.writeLine(strLine);
|
||||
}
|
||||
}
|
||||
28
as68hc11/backup/S19Generator.hpp
Normal file
28
as68hc11/backup/S19Generator.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _AS68HC11_S19GENERATOR_HPP_
|
||||
#define _AS68HC11_S19GENERATOR_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
||||
#include <common/pview.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILE_HPP_
|
||||
#include <common/file.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_ORIGIN_HPP_
|
||||
#include <as68hc11/origin.hpp>
|
||||
#endif
|
||||
|
||||
class S19Generator
|
||||
{
|
||||
public:
|
||||
enum{MaxDataBytesPerLine=32};
|
||||
// static bool generateCode(Origins &origins,PureViewOfFile &rawCode,DWORD codeLength,const String &strPathOutput);
|
||||
static bool generateCode(PureViewOfFile &rawCode,const String &strPathOutFile);
|
||||
private:
|
||||
static void generateLines(DWORD origin,DWORD codeSize,PureViewOfFile &rawCode,File &outFile);
|
||||
};
|
||||
#endif
|
||||
19
as68hc11/backup/SYMBOL.CPP
Normal file
19
as68hc11/backup/SYMBOL.CPP
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <as68hc11/symbol.hpp>
|
||||
#include <common/stdio.hpp>
|
||||
|
||||
Symbol::operator String(void)
|
||||
{
|
||||
String strSymbol;
|
||||
String strSymbolType;
|
||||
|
||||
if(ConstantSymbol==symbolType())strSymbolType="ConstantSymbol";
|
||||
else if(KeywordSymbol==symbolType())strSymbolType="KeywordSymbol";
|
||||
else if(RegisterSymbol==symbolType())strSymbolType="RegisterSymbol";
|
||||
else if(DirectiveSymbol==symbolType())strSymbolType="DirectiveSymbol";
|
||||
else if(UserSymbol==symbolType())strSymbolType="UserSymbol";
|
||||
else if(UnknownSymbol==symbolType())strSymbolType="UnknownSymbol";
|
||||
::sprintf(strSymbol,"'%s' id:%d type:%s",(char*)symbolName(),identifier(),(char*)strSymbolType);
|
||||
strSymbol+=String(" ")+Instruction::operator String();
|
||||
return strSymbol;
|
||||
}
|
||||
|
||||
200
as68hc11/backup/Scan.cpp
Normal file
200
as68hc11/backup/Scan.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
#include <as68hc11/scan.hpp>
|
||||
#include <as68hc11/symbol.hpp>
|
||||
#include <as68hc11/table.hpp>
|
||||
#include <common/pointer.hpp>
|
||||
|
||||
Scan::Scan(PureViewOfFile &inFile,PureViewOfFile &outFile,Table &symbolTable)
|
||||
: Emit(inFile,outFile), mSymbolTable(symbolTable)
|
||||
{
|
||||
}
|
||||
|
||||
Scan::~Scan(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Scan::analyze(void)
|
||||
{
|
||||
readch();
|
||||
while((int)mChar!=-1&&mChar!=0x001A)
|
||||
{
|
||||
skipSeparators();
|
||||
if(0xFFFF==mChar||0x001A==mChar)break;
|
||||
if(isdigit(mChar))scanNumeral();
|
||||
else if('\r'==mChar)scanNewLine();
|
||||
else if(','==mChar){emit(comma1);readch();}
|
||||
else if('['==mChar){emit(leftbracket1);readch();}
|
||||
else if(']'==mChar){emit(rightbracket1);readch();}
|
||||
else if('*'==mChar){emit(asterisk1);readch();}
|
||||
else if('/'==mChar){emit(divide1);readch();}
|
||||
else if('+'==mChar){emit(plus1);readch();}
|
||||
else if('-'==mChar){emit(minus1);readch();}
|
||||
else if('('==mChar){emit(leftparen1);readch();}
|
||||
else if(')'==mChar){emit(rightparen1);readch();}
|
||||
else if('\''==mChar)scanCharacter();
|
||||
else if(';'==mChar)scanComment();
|
||||
else if(isalpha(mChar))scanWord();
|
||||
else scanUnknown();
|
||||
}
|
||||
emit(endtext1);
|
||||
}
|
||||
|
||||
void Scan::scanNewLine(void)
|
||||
{
|
||||
emit(newline1);
|
||||
readch();
|
||||
if(mChar=='\n')readch();
|
||||
}
|
||||
|
||||
void Scan::skipSeparators(void)
|
||||
{
|
||||
while(mChar==SpaceChar||mChar==TabChar)readch();
|
||||
}
|
||||
|
||||
void Scan::scanComment(void)
|
||||
{
|
||||
readch();
|
||||
while(mChar!='\r'&&mChar!=0xFFFF)readch();
|
||||
}
|
||||
|
||||
void Scan::scanCharacter(void)
|
||||
{
|
||||
int character;
|
||||
|
||||
readch();
|
||||
character=mChar;
|
||||
readch();
|
||||
*((char*)mWordString)=0;
|
||||
mWordString+=character;
|
||||
while(0xFFFF!=mChar&&'\''!=mChar&&0x0D!=mChar)
|
||||
{
|
||||
mWordString+=mChar;
|
||||
readch();
|
||||
}
|
||||
readch();
|
||||
emit(apostrophe1);
|
||||
emit(literal1);
|
||||
emit(mWordString);
|
||||
emit(apostrophe1);
|
||||
}
|
||||
|
||||
BOOL Scan::scanNumeral(void)
|
||||
{
|
||||
char chBuffer[128];
|
||||
char chIndex(0);
|
||||
int value(0);
|
||||
|
||||
while(0xFFFF!=mChar&&(isdigit(mChar)||isInHex(mChar)))
|
||||
{
|
||||
if(chIndex>=sizeof(chBuffer))return FALSE;
|
||||
chBuffer[chIndex++]=mChar;
|
||||
readch();
|
||||
}
|
||||
if('h'==mChar||'H'==mChar){hex(chBuffer,chIndex);readch();}
|
||||
else if('b'==mChar||'B'==mChar){binary(chBuffer,chIndex);readch();}
|
||||
else if(chIndex>0&&('b'==chBuffer[chIndex-1]||'B'==chBuffer[chIndex-1]))binary(chBuffer,chIndex-1);
|
||||
else decimal(chBuffer,chIndex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void Scan::hex(char chBuffer[],int chIndex)
|
||||
{
|
||||
int value(0);
|
||||
int multiplier(1);
|
||||
|
||||
for(--chIndex;chIndex>=0;chIndex--)
|
||||
{
|
||||
switch(chBuffer[chIndex])
|
||||
{
|
||||
case '0' : break;
|
||||
case '1' : {value+=multiplier;break;}
|
||||
case '2' : {value+=multiplier*2;break;}
|
||||
case '3' : {value+=multiplier*3;break;}
|
||||
case '4' : {value+=multiplier*4;break;}
|
||||
case '5' : {value+=multiplier*5;break;}
|
||||
case '6' : {value+=multiplier*6;break;}
|
||||
case '7' : {value+=multiplier*7;break;}
|
||||
case '8' : {value+=multiplier*8;break;}
|
||||
case '9' : {value+=multiplier*9;break;}
|
||||
case 'a' :
|
||||
case 'A' : {value+=multiplier*10;break;}
|
||||
case 'b' :
|
||||
case 'B' : {value+=multiplier*11;break;}
|
||||
case 'c' :
|
||||
case 'C' : {value+=multiplier*12;break;}
|
||||
case 'd' :
|
||||
case 'D' : {value+=multiplier*13;break;}
|
||||
case 'e' :
|
||||
case 'E' : {value+=multiplier*14;break;}
|
||||
case 'f' :
|
||||
case 'F' : {value+=multiplier*15;break;}
|
||||
default : {emit(unknown1);return;}
|
||||
}
|
||||
multiplier*=16;
|
||||
}
|
||||
emit(numeral1,value);
|
||||
}
|
||||
|
||||
void Scan::binary(char chBuffer[],int chIndex)
|
||||
{
|
||||
int value(0);
|
||||
int multiplier(1);
|
||||
|
||||
for(--chIndex;chIndex>=0;chIndex--)
|
||||
{
|
||||
switch(chBuffer[chIndex])
|
||||
{
|
||||
case '0' : break;
|
||||
case '1' : {value+=multiplier;break;}
|
||||
default : {emit(unknown1);return;}
|
||||
}
|
||||
multiplier*=2;
|
||||
}
|
||||
emit(numeral1,value);
|
||||
}
|
||||
|
||||
void Scan::decimal(char chBuffer[],int chIndex)
|
||||
{
|
||||
int value(0);
|
||||
int multiplier(1);
|
||||
|
||||
for(--chIndex;chIndex>=0;chIndex--)
|
||||
{
|
||||
switch(chBuffer[chIndex])
|
||||
{
|
||||
case '0' : break;
|
||||
case '1' : {value+=multiplier;break;}
|
||||
case '2' : {value+=multiplier*2;break;}
|
||||
case '3' : {value+=multiplier*3;break;}
|
||||
case '4' : {value+=multiplier*4;break;}
|
||||
case '5' : {value+=multiplier*5;break;}
|
||||
case '6' : {value+=multiplier*6;break;}
|
||||
case '7' : {value+=multiplier*7;break;}
|
||||
case '8' : {value+=multiplier*8;break;}
|
||||
case '9' : {value+=multiplier*9;break;}
|
||||
default : {emit(unknown1);return;}
|
||||
}
|
||||
multiplier*=10;
|
||||
}
|
||||
emit(numeral1,value);
|
||||
}
|
||||
|
||||
void Scan::scanWord(void)
|
||||
{
|
||||
SmartPointer<Symbol> symbol;
|
||||
|
||||
*((char*)mWordString)=0;
|
||||
while(0x0D!=mChar&&!isKeySymbol()&&0xFFFF!=mChar&&SpaceChar!=mChar&&TabChar!=mChar)
|
||||
{
|
||||
mWordString+=mChar;
|
||||
readch();
|
||||
}
|
||||
if(mWordString.isNull())return;
|
||||
if(mSymbolTable.locateSymbol(mWordString,symbol))
|
||||
{
|
||||
if(Symbol::DirectiveSymbol==symbol->symbolType())emit(symbol->identifier());
|
||||
else emit(name1,int((Symbol*)symbol));
|
||||
}
|
||||
else if(':'==mChar){emit(label1);emit(mWordString);readch();}
|
||||
else {emit(literal1);emit(mWordString);}
|
||||
}
|
||||
|
||||
79
as68hc11/backup/Scan.hpp
Normal file
79
as68hc11/backup/Scan.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef _AS68HC11_SCAN_HPP_
|
||||
#define _AS68HC11_SCAN_HPP_
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_EMIT_HPP_
|
||||
#include <as68hc11/emit.hpp>
|
||||
#endif
|
||||
|
||||
class Table;
|
||||
|
||||
class Scan : public Emit
|
||||
{
|
||||
public:
|
||||
enum ScanSymbols{unknown1,name1,asterisk1,apostrophe1,equ1,origin1,rmb1,comma1,label1,literal1,leftbracket1,rightbracket1,numeral1,
|
||||
char1,divide1,plus1,minus1,leftparen1,rightparen1,newline1,endtext1,
|
||||
ix1,iy1,aba1,abx1,aby1,adca1,adcb1,adda1,addb1,addd1,anda1,andb1,asl1,asla1,aslb1,
|
||||
asld1,asr1,asra1,asrb1,bcc1,bclr1,bcs1,beq1,bge1,bgt1,bhi1,bhs1,bita1,bitb1,ble1,blo1,
|
||||
bls1,blt1,bmi1,bne1,bpl1,bra1,brclr1,brn1,brset1,bset1,bsr1,bvc1,bvs1,cba1,clc1,cli1,clr1,
|
||||
clra1,clrb1,clv1,cmpa1,cmpb1,com1,coma1,comb1,cpd1,cpx1,cpy1,daa1,dec1,deca1,decb1,des1,
|
||||
dex1,dey1,eora1,eorb1,fdiv1,idiv1,inc1,inca1,incb1,ins1,inx1,iny1,jmp1,jsr1,ldaa1,ldab1,
|
||||
ldd1,lds1,ldx1,ldy1,lsl1,lsla1,lslb1,lsld1,lsr1,lsra1,lsrb1,lsrd1,mul1,neg1,nega1,negb1,
|
||||
nop1,oraa1,orab1,psha1,pshb1,pshx1,pshy1,pula1,pulb1,pulx1,puly1,rol1,rola1,rolb1,ror1,
|
||||
rora1,rorb1,rti1,rts1,sba1,sbca1,sbcb1,sec1,sei1,sev1,staa1,stab1,std1,stop1,sts1,stx1,
|
||||
sty1,suba1,subb1,subd1,swi1,tab1,tap1,tba1,test1,tpa1,tst1,tsta1,tstb1,tsx1,tsy1,txs1,
|
||||
tys1,wai1,xgdx1,xgdy1,end1};
|
||||
Scan(PureViewOfFile &srcView,PureViewOfFile &dstView,Table &symbolTable);
|
||||
virtual ~Scan();
|
||||
void analyze(void);
|
||||
private:
|
||||
enum {SpaceChar=32,TabChar=9};
|
||||
void readch(void);
|
||||
void skipSeparators(void);
|
||||
BOOL scanNumeral(void);
|
||||
void scanNewLine(void);
|
||||
void scanWord(void);
|
||||
void scanComment(void);
|
||||
void scanCharacter(void);
|
||||
void scanUnknown(void);
|
||||
void hex(char chBuffer[],int chIndex);
|
||||
void binary(char chBuffer[],int chIndex);
|
||||
void decimal(char chBuffer[],int chIndex);
|
||||
BOOL isKeySymbol(void)const;
|
||||
BOOL isInHex(int chr)const;
|
||||
|
||||
WORD mUserSymbols;
|
||||
Table &mSymbolTable;
|
||||
String mWordString;
|
||||
BOOL mIsInError;
|
||||
int mChar;
|
||||
};
|
||||
|
||||
inline
|
||||
void Scan::readch(void)
|
||||
{
|
||||
mChar=read();
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Scan::isKeySymbol(void)const
|
||||
{
|
||||
return (' '==mChar||','==mChar||'['==mChar||']'==mChar||':'==mChar||'*'==mChar||'/'==mChar||'+'==mChar||'-'==mChar||'('==mChar||')'==mChar);
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Scan::isInHex(int chr)const
|
||||
{
|
||||
if('A'==chr||'B'==chr||'C'==chr||'D'==chr||'E'==chr||'F'==chr||
|
||||
'a'==chr||'b'==chr||'c'==chr||'d'==chr||'e'==chr||'f'==chr)return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline
|
||||
void Scan::scanUnknown(void)
|
||||
{
|
||||
readch();
|
||||
emit(unknown1);
|
||||
}
|
||||
#endif
|
||||
128
as68hc11/backup/Symbol.hpp
Normal file
128
as68hc11/backup/Symbol.hpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#ifndef _AS68HC11_SYMBOL_HPP_
|
||||
#define _AS68HC11_SYMBOL_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_INSTRUCTION_HPP_
|
||||
#include <as68hc11/instrctn.hpp>
|
||||
#endif
|
||||
|
||||
class Symbol : public Instruction
|
||||
{
|
||||
public:
|
||||
enum SymbolType{ConstantSymbol,KeywordSymbol,RegisterSymbol,DirectiveSymbol,UserSymbol,UnknownSymbol};
|
||||
Symbol(void);
|
||||
Symbol(const Symbol &someSymbol);
|
||||
Symbol(const String &symbolString,int identifier=0,SymbolType symbolType=UnknownSymbol,const Instruction &instruction=Instruction());
|
||||
virtual ~Symbol();
|
||||
Symbol &operator=(const Symbol &someSymbol);
|
||||
BOOL operator==(const Symbol &someSymbol)const;
|
||||
BOOL operator==(const String &symbolString)const;
|
||||
BOOL operator<(const Symbol &someSymbol)const;
|
||||
BOOL operator>(const Symbol &someSymbol)const;
|
||||
operator String(void);
|
||||
const String &symbolName(void)const;
|
||||
void symbolName(const String &symbolName);
|
||||
int identifier(void)const;
|
||||
void identifier(int identifier);
|
||||
SymbolType symbolType(void)const;
|
||||
void symbolType(SymbolType symbolType);
|
||||
private:
|
||||
String mSymbolName;
|
||||
int mIdentifier;
|
||||
SymbolType mSymbolType;
|
||||
};
|
||||
|
||||
inline
|
||||
Symbol::Symbol(void)
|
||||
: mIdentifier(0), mSymbolType(UnknownSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Symbol::Symbol(const Symbol &someSymbol)
|
||||
{
|
||||
*this=someSymbol;
|
||||
}
|
||||
|
||||
inline
|
||||
Symbol::Symbol(const String &symbolString,int identifier,SymbolType symbolType,const Instruction &instruction)
|
||||
: mSymbolName(symbolString), mSymbolType(symbolType), mIdentifier(identifier), Instruction(instruction)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Symbol::~Symbol()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Symbol::operator==(const Symbol &someSymbol)const
|
||||
{
|
||||
return mSymbolName==someSymbol.mSymbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Symbol::operator==(const String &symbolName)const
|
||||
{
|
||||
return mSymbolName==symbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Symbol::operator<(const Symbol &someSymbol)const
|
||||
{
|
||||
return mSymbolName<someSymbol.mSymbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Symbol::operator>(const Symbol &someSymbol)const
|
||||
{
|
||||
return mSymbolName>someSymbol.mSymbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
Symbol &Symbol::operator=(const Symbol &someSymbol)
|
||||
{
|
||||
symbolName(someSymbol.symbolName());
|
||||
identifier(someSymbol.identifier());
|
||||
symbolType(someSymbol.symbolType());
|
||||
(Instruction&)*this=(Instruction&)someSymbol;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const String &Symbol::symbolName(void)const
|
||||
{
|
||||
return mSymbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
void Symbol::symbolName(const String &symbolName)
|
||||
{
|
||||
mSymbolName=symbolName;
|
||||
}
|
||||
|
||||
inline
|
||||
Symbol::SymbolType Symbol::symbolType(void)const
|
||||
{
|
||||
return mSymbolType;
|
||||
}
|
||||
|
||||
inline
|
||||
void Symbol::symbolType(SymbolType symbolType)
|
||||
{
|
||||
mSymbolType=symbolType;
|
||||
}
|
||||
|
||||
inline
|
||||
int Symbol::identifier(void)const
|
||||
{
|
||||
return mIdentifier;
|
||||
}
|
||||
|
||||
inline
|
||||
void Symbol::identifier(int identifier)
|
||||
{
|
||||
mIdentifier=identifier;
|
||||
}
|
||||
#endif
|
||||
51
as68hc11/backup/TABLE.CPP
Normal file
51
as68hc11/backup/TABLE.CPP
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <as68hc11/table.hpp>
|
||||
#include <as68hc11/symbol.hpp>
|
||||
|
||||
Table::Table(void)
|
||||
{
|
||||
}
|
||||
|
||||
Table::~Table()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL Table::locateSymbol(const String &symbolString,SmartPointer<Symbol> &symbol)
|
||||
{
|
||||
Symbol srchSymbol(symbolString);
|
||||
return searchItem(srchSymbol,symbol);
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOL Table::locateSymbolString(String &symbolString,int &tableIndex)
|
||||
{
|
||||
size_t numSymbols((size_t)size());
|
||||
|
||||
for(int index=0;index<numSymbols;index++)
|
||||
{
|
||||
if(operator[](index)==symbolString)
|
||||
{
|
||||
tableIndex=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL Table::locateSymbolIdentifier(int symbolIdentifier,int &tableIndex)
|
||||
{
|
||||
size_t numSymbols((size_t)size());
|
||||
|
||||
for(int index=0;index<numSymbols;index++)
|
||||
{
|
||||
if(operator[](index).identifier()==symbolIdentifier)
|
||||
{
|
||||
tableIndex=index;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
20
as68hc11/backup/TABLE.HPP
Normal file
20
as68hc11/backup/TABLE.HPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _AS68HC11_TABLE_HPP_
|
||||
#define _AS68HC11_TABLE_HPP_
|
||||
#ifndef _BSPTREE_BINARYTREE_HPP_
|
||||
#include <bsptree/bintree.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_SYMBOL_HPP_
|
||||
#include <as68hc11/symbol.hpp>
|
||||
#endif
|
||||
|
||||
class String;
|
||||
|
||||
class Table : public BinaryTree<Symbol>
|
||||
{
|
||||
public:
|
||||
Table(void);
|
||||
virtual ~Table();
|
||||
BOOL locateSymbol(const String &symbolString,SmartPointer<Symbol> &symbol);
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
161
as68hc11/backup/fixup.hpp
Normal file
161
as68hc11/backup/fixup.hpp
Normal file
@@ -0,0 +1,161 @@
|
||||
#ifndef _AS68HC11_FIXUP_HPP_
|
||||
#define _AS68HC11_FIXUP_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _AS68HC11_LABEL_HPP_
|
||||
#include <as68hc11/label.hpp>
|
||||
#endif
|
||||
|
||||
class Fixup
|
||||
{
|
||||
public:
|
||||
enum Kind{Label,Equate};
|
||||
enum BitCount{Bit16,Bit8};
|
||||
enum AddressMode{Relative,Absolute};
|
||||
Fixup(void);
|
||||
Fixup(const Fixup &someFixup);
|
||||
Fixup(const String &strLabel,DWORD offset,DWORD position,Kind kind,BitCount bitCount=Bit8,AddressMode addressMode=Relative);
|
||||
virtual ~Fixup();
|
||||
Fixup &operator=(const Fixup &someFixup);
|
||||
BOOL operator==(const Fixup &someFixup)const;
|
||||
DWORD offset(void)const;
|
||||
void offset(DWORD offset);
|
||||
DWORD position(void)const;
|
||||
void position(DWORD position);
|
||||
const String &strLabel(void)const;
|
||||
void strLabel(const String &strLabel);
|
||||
Kind kind(void)const;
|
||||
void kind(Kind kind);
|
||||
BitCount bitCount(void)const;
|
||||
void bitCount(BitCount bitCount);
|
||||
AddressMode addressMode(void)const;
|
||||
void addressMode(AddressMode addressMode);
|
||||
private:
|
||||
String mStrLabel;
|
||||
DWORD mOffset;
|
||||
DWORD mPosition;
|
||||
Kind mKind;
|
||||
BitCount mBitCount;
|
||||
AddressMode mAddressMode;
|
||||
};
|
||||
|
||||
inline
|
||||
Fixup::Fixup(void)
|
||||
: mOffset(0), mPosition(0), mKind(Label), mBitCount(Bit8), mAddressMode(Relative)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::Fixup(const String &strLabel,DWORD offset,DWORD position,Kind kind,BitCount bitCount,AddressMode addressMode)
|
||||
: mStrLabel(strLabel), mOffset(offset), mKind(kind), mBitCount(bitCount), mAddressMode(addressMode),
|
||||
mPosition(position)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::Fixup(const Fixup &someFixup)
|
||||
{
|
||||
*this=someFixup;
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::~Fixup()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup &Fixup::operator=(const Fixup &someFixup)
|
||||
{
|
||||
strLabel(someFixup.strLabel());
|
||||
offset(someFixup.offset());
|
||||
position(someFixup.position());
|
||||
strLabel(someFixup.strLabel());
|
||||
bitCount(someFixup.bitCount());
|
||||
addressMode(someFixup.addressMode());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Fixup::operator==(const Fixup &someFixup)const
|
||||
{
|
||||
return (strLabel()==someFixup.strLabel()&&
|
||||
offset()==someFixup.offset()&&
|
||||
position()==someFixup.position()&&
|
||||
strLabel()==someFixup.strLabel()&&
|
||||
bitCount()==someFixup.bitCount()&&
|
||||
addressMode()==someFixup.addressMode());
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Fixup::offset(void)const
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::offset(DWORD offset)
|
||||
{
|
||||
mOffset=offset;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Fixup::position(void)const
|
||||
{
|
||||
return mPosition;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::position(DWORD position)
|
||||
{
|
||||
mPosition=position;
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::Kind Fixup::kind(void)const
|
||||
{
|
||||
return mKind;
|
||||
}
|
||||
|
||||
inline
|
||||
const String &Fixup::strLabel(void)const
|
||||
{
|
||||
return mStrLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::strLabel(const String &strLabel)
|
||||
{
|
||||
mStrLabel=strLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::kind(Kind kind)
|
||||
{
|
||||
mKind=kind;
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::BitCount Fixup::bitCount(void)const
|
||||
{
|
||||
return mBitCount;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::bitCount(BitCount bitCount)
|
||||
{
|
||||
mBitCount=bitCount;
|
||||
}
|
||||
|
||||
inline
|
||||
Fixup::AddressMode Fixup::addressMode(void)const
|
||||
{
|
||||
return mAddressMode;
|
||||
}
|
||||
|
||||
inline
|
||||
void Fixup::addressMode(AddressMode addressMode)
|
||||
{
|
||||
mAddressMode=addressMode;
|
||||
}
|
||||
#endif
|
||||
119
as68hc11/backup/label.hpp
Normal file
119
as68hc11/backup/label.hpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef _AS68HC11_LABEL_HPP_
|
||||
#define _AS68HC11_LABEL_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class Label
|
||||
{
|
||||
public:
|
||||
enum Disposition{Absolute,Reference,Ignore};
|
||||
Label(void);
|
||||
Label(const Label &someLabel);
|
||||
Label(const String &strLabel,DWORD offset=0L,Disposition disposition=Reference);
|
||||
virtual ~Label();
|
||||
Label &operator=(const Label &someLabel);
|
||||
BOOL operator==(const Label &someLabel)const;
|
||||
BOOL operator<(const Label &someLabel)const;
|
||||
BOOL operator>(const Label &someLabel)const;
|
||||
const String &strLabel(void)const;
|
||||
void strLabel(const String &strLabel);
|
||||
DWORD offset(void)const;
|
||||
void offset(DWORD offset);
|
||||
Disposition disposition(void)const;
|
||||
void disposition(Disposition disposition);
|
||||
private:
|
||||
String mStrLabel;
|
||||
DWORD mOffset;
|
||||
Disposition mDisposition;
|
||||
};
|
||||
|
||||
inline
|
||||
Label::Label(void)
|
||||
: mOffset(0), mDisposition(Ignore)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Label::Label(const String &strLabel,DWORD offset,Disposition disposition)
|
||||
: mStrLabel(strLabel), mOffset(offset), mDisposition(disposition)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Label::Label(const Label &someLabel)
|
||||
{
|
||||
*this=someLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
Label::~Label()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Label &Label::operator=(const Label &someLabel)
|
||||
{
|
||||
strLabel(someLabel.strLabel());
|
||||
offset(someLabel.offset());
|
||||
disposition(someLabel.disposition());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Label::operator==(const Label &someLabel)const
|
||||
{
|
||||
return (strLabel()==someLabel.strLabel());
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Label::operator<(const Label &someLabel)const
|
||||
{
|
||||
return (strLabel()<someLabel.strLabel());
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL Label::operator>(const Label &someLabel)const
|
||||
{
|
||||
return (strLabel()>someLabel.strLabel());
|
||||
}
|
||||
|
||||
inline
|
||||
const String &Label::strLabel(void)const
|
||||
{
|
||||
return mStrLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
void Label::strLabel(const String &strLabel)
|
||||
{
|
||||
mStrLabel=strLabel;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Label::offset(void)const
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
inline
|
||||
void Label::offset(DWORD offset)
|
||||
{
|
||||
mOffset=offset;
|
||||
}
|
||||
|
||||
inline
|
||||
Label::Disposition Label::disposition(void)const
|
||||
{
|
||||
return mDisposition;
|
||||
}
|
||||
|
||||
inline
|
||||
void Label::disposition(Disposition disposition)
|
||||
{
|
||||
mDisposition=disposition;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user