From 32f2b2d12cdf48fce63e7c8a22480446cea99ed1 Mon Sep 17 00:00:00 2001 From: Marek Karcz Date: Mon, 14 Mar 2016 00:28:53 -0400 Subject: [PATCH] Version 2.0 New features. Bug fixes. --- VMachine.cpp | 1899 ++--- VMachine.h | 169 +- eh_basic_kow.asm | 17448 +++++++++++++++++++++--------------------- ehbas.dat | 4128 +++++----- hello_world.bas | 10 +- main.cpp | 1387 ++-- makefile.mingw | 116 +- makeming.bat | 6 +- microchess.asm | 2102 ++--- microchess.cfg | 32 +- microchess.dat | 228 +- microchess.lst | 2066 ++--- microchess.o | Bin 11613 -> 0 bytes numbers.bas | 20 +- t_adc_bcd_01.65s | 196 +- t_adc_bcd_01.dat | 72 +- t_sbc_bcd_01.65s | 168 +- t_sbc_bcd_01.dat | 72 +- tall.dat | 218 +- tb.dat | 796 +- tbe.dat | 846 +- test_char_io_01.65s | 98 +- test_char_io_01.dat | 30 +- testall.asm | 1906 ++--- testall.dat | 390 +- testall.lst | 1920 ++--- testall_cl65.cfg | 48 +- testbcd.dat | 138 +- tinybasic.dat | 1548 ++-- 29 files changed, 19035 insertions(+), 19022 deletions(-) delete mode 100644 microchess.o diff --git a/VMachine.cpp b/VMachine.cpp index 944585e..15a0ffa 100644 --- a/VMachine.cpp +++ b/VMachine.cpp @@ -1,943 +1,956 @@ - -#include -#include -#include -#include "system.h" -#include "VMachine.h" -#include "MKGenException.h" - -#if defined(WINDOWS) -#include -#endif - -using namespace std; - -namespace MKBasic { - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ - -/* - *-------------------------------------------------------------------- - * Method: VMachine() - * Purpose: Default class constructor. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -VMachine::VMachine() -{ - InitVM(); -} - -/* - *-------------------------------------------------------------------- - * Method: VMachine() - * Purpose: Custom class constructor. - * Arguments: romfname - name of the ROM definition file - * ramfname - name of the RAM definition file - * Returns: n/a - *-------------------------------------------------------------------- - */ -VMachine::VMachine(string romfname, string ramfname) -{ - InitVM(); - LoadROM(romfname); - LoadRAM(ramfname); -} - -/* - *-------------------------------------------------------------------- - * Method: ~VMachine() - * Purpose: Class destructor. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -VMachine::~VMachine() -{ - delete mpDisp; - delete mpCPU; - delete mpROM; - delete mpRAM; -} - -/* - *-------------------------------------------------------------------- - * Method: InitVM() - * Purpose: Initialize class. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::InitVM() -{ - mOpInterrupt = false; - mpRAM = new Memory(); - - mAutoExec = false; - mCharIOAddr = CHARIO_ADDR; - mCharIOActive = mCharIO = false; - if (NULL == mpRAM) { - throw MKGenException("Unable to initialize VM (RAM)."); - } - mRunAddr = mpRAM->Peek16bit(0xFFFC); // address under RESET vector - mpROM = new Memory(); - if (NULL == mpROM) { - throw MKGenException("Unable to initialize VM (ROM)."); - } - mpCPU = new MKCpu(mpRAM); - if (NULL == mpCPU) { - throw MKGenException("Unable to initialize VM (CPU)."); - } - mpDisp = new Display(); - if (NULL == mpDisp) { - throw MKGenException("Unable to initialize VM (Display)."); - } -} - -#if defined(WINDOWS) - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::ClearScreen() -{ - HANDLE hStdOut; - CONSOLE_SCREEN_BUFFER_INFO csbi; - DWORD count; - DWORD cellCount; - COORD homeCoords = { 0, 0 }; - - hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); - if (hStdOut == INVALID_HANDLE_VALUE) return; - - /* Get the number of cells in the current buffer */ - if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return; - cellCount = csbi.dwSize.X *csbi.dwSize.Y; - - /* Fill the entire buffer with spaces */ - if (!FillConsoleOutputCharacter( - hStdOut, - (TCHAR) ' ', - cellCount, - homeCoords, - &count - )) return; - - /* Fill the entire buffer with the current colors and attributes */ - if (!FillConsoleOutputAttribute( - hStdOut, - csbi.wAttributes, - cellCount, - homeCoords, - &count - )) return; - - /* Move the cursor home */ - SetConsoleCursorPosition( hStdOut, homeCoords ); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::ScrHome() -{ - HANDLE hStdOut; - COORD homeCoords = { 0, 0 }; - - hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); - if (hStdOut == INVALID_HANDLE_VALUE) return; - - /* Move the cursor home */ - SetConsoleCursorPosition( hStdOut, homeCoords ); -} - -#endif - -#if defined(LINUX) - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::ClearScreen() -{ - system("clear"); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::ScrHome() -{ - cout << "\033[1;1H"; -} - -#endif - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::ShowDisp() -{ - if (mCharIOActive) { - ScrHome(); - mpDisp->ShowScr(); - } -} - -/* - *-------------------------------------------------------------------- - * Method: Run() - * Purpose: Run VM until software break instruction. - * Arguments: n/a - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Run() -{ - Regs *cpureg = NULL; - - mOpInterrupt = false; - ClearScreen(); - ShowDisp(); - while (true) { - cpureg = Step(); - if (mCharIO) { - ShowDisp(); - } - if (cpureg->SoftIrq || mOpInterrupt) - break; - } - - ShowDisp(); - - return cpureg; -} - -/* - *-------------------------------------------------------------------- - * Method: Run() - * Purpose: Run VM from specified address until software break - * instruction. - * Arguments: addr - start execution address - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Run(unsigned short addr) -{ - mRunAddr = addr; - return Run(); -} - -/* - *-------------------------------------------------------------------- - * Method: Exec() - * Purpose: Run VM from current address until last RTS. - * NOTE: Stack must be empty! - * Arguments: n/a - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Exec() -{ - Regs *cpureg = NULL; - - mOpInterrupt = false; - ClearScreen(); - ShowDisp(); - while (true) { - cpureg = Step(); - if (mCharIO) { - ShowDisp(); - } - if (cpureg->LastRTS || mOpInterrupt) break; - } - - ShowDisp(); - - return cpureg; -} - -/* - *-------------------------------------------------------------------- - * Method: Exec() - * Purpose: Run VM from specified address until RTS. - * Arguments: addr - start execution address - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Exec(unsigned short addr) -{ - mRunAddr = addr; - return Exec(); -} - -/* - *-------------------------------------------------------------------- - * Method: Step() - * Purpose: Execute single opcode. - * Arguments: n/a - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Step() -{ - unsigned short addr = mRunAddr; - Regs *cpureg = NULL; - - cpureg = mpCPU->ExecOpcode(addr); - addr = cpureg->PtrAddr; - mRunAddr = addr; - - if (mCharIOActive && !mOpInterrupt) { - char c = -1; - mCharIO = false; - while ((c = mpRAM->GetCharOut()) != -1) { - mOpInterrupt = (c == OPINTERRUPT); - if (!mOpInterrupt) { - mpDisp->PutChar(c); - mCharIO = true; - } - } - } - - return cpureg; -} - -/* - *-------------------------------------------------------------------- - * Method: Step() - * Purpose: Execute single opcode. - * Arguments: addr (unsigned short) - opcode address - * Returns: Pointer to CPU registers and flags. - *-------------------------------------------------------------------- - */ -Regs *VMachine::Step(unsigned short addr) -{ - mRunAddr = addr; - return Step(); -} - -/* - *-------------------------------------------------------------------- - * Method: LoadROM() - * Purpose: Load data from memory definition file to the memory. - * Arguments: romfname - name of the ROM file definition - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::LoadROM(string romfname) -{ - LoadMEM(romfname, mpROM); -} - -/* - *-------------------------------------------------------------------- - * Method: LoadRAM() - * Purpose: Load data from memory definition file to the memory. - * Arguments: ramfname - name of the RAM file definition - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::LoadRAM(string ramfname) -{ - LoadMEM(ramfname, mpRAM); - //mpRAM->EnableROM(); -} - -/* - *-------------------------------------------------------------------- - * Method: LoadRAMBin() - * Purpose: Load data from binary image file to the memory. - * Arguments: ramfname - name of the RAM file definition - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::LoadRAMBin(string ramfname) -{ - FILE *fp = NULL; - unsigned short addr = 0x0000; - int n = 0; - Memory *pm = mpRAM; - - if ((fp = fopen(ramfname.c_str(), "rb")) != NULL) { - while (0 == feof(fp) && 0 == ferror(fp)) { - unsigned char val = fgetc(fp); - pm->Poke8bit(addr, val); - addr++; n++; - } - fclose(fp); - if (n <= 0xFFFF) { - cout << "WARNING: Unexpected EOF." << endl; - } - } - else { - cout << "WARNING: Unable to open memory image file: " << ramfname << endl; - cout << "Press [ENTER]..."; - getchar(); - } -} - -/* - *-------------------------------------------------------------------- - * Method: LoadMEM() - * Purpose: Load data from memory definition file to the memory. - * Arguments: memfname - name of memory definition file - * pmem - pointer to memory object - * Returns: n/a - * Details: - * Format of the memory definition file: - * [; comment] - * [ADDR - * address] - * [data] - * [ORG - * address] - * [data] - * [IOADDR - * address] - * [ROMBEGIN - * address] - * [ROMEND - * address] - * [ENIO] - * [ENROM] - * [EXEC - * addrress] - * - * Where: - * [] - optional token - * ADDR - label indicating that starting address will follow in next - * line, it also defines run address - * ORG - label indicating that the address counter will change to the - * value provided in next line - * IOADDR - label indicating that char IO trap address will be defined - * in the next line - * ROMBEGIN - label indicating that ROM begin address will be defined - * in the next line - * ROMEND - label indicating that ROM end address will be defined - * in the next line - * ENIO - label enabling char IO emulation - * ENROM - label enabling ROM emulation - * EXEC - label enabling auto-execute of code, address follows in the - * next line - * address - decimal or hexadecimal (prefix $) address in memory - * E.g: - * ADDR - * $200 - * - * or - * - * ADDR - * 512 - * - * changes the default start address (256) to 512. - * - * ORG - * 49152 - * - * moves address counter to address 49152, following data will be - * loaded from that address forward - * - * data - the multi-line stream of decimal of hexadecimal ($xx) values - * of size unsigned char (byte: 0-255) separated with spaces - * or commas. - * E.g.: - * $00 $00 $00 $00 - * $00 $00 $00 $00 - * - * or - * - * $00,$00,$00,$00 - * - * or - * - * 0 0 0 0 - * - * or - * - * 0,0,0,0 - * 0 0 0 0 - *-------------------------------------------------------------------- - */ -void VMachine::LoadMEM(string memfname, Memory *pmem) -{ - FILE *fp = NULL; - char line[256] = "\0"; - int lc = 0, errc = 0; - unsigned short addr = 0, rombegin = 0, romend = 0; - unsigned int nAddr; - bool enrom = false, enio = false, runset = false; - bool ioset = false, execset = false, rombegset = false; - bool romendset = false; - Memory *pm = pmem; - - if ((fp = fopen(memfname.c_str(), "r")) != NULL) { - while (0 == feof(fp) && 0 == ferror(fp)) - { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - // change run address (can be done only once) - if (0 == strncmp(line, "ADDR", 4)) { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (!runset) { - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - addr = nAddr; - } else { - addr = (unsigned short) atoi(line); - } - mRunAddr = addr; - runset = true; - } else { - errc++; - cout << "LINE #" << dec << lc << " WARNING: Run address was already set. Ignoring..." << endl; - } - continue; - } - // change address counter - if (0 == strncmp(line, "ORG", 3)) { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - addr = nAddr; - } else { - addr = (unsigned short) atoi(line); - } - continue; - } - // define I/O emulation address (once) - if (0 == strncmp(line, "IOADDR", 6)) { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (!ioset) { - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - mCharIOAddr = nAddr; - } else { - mCharIOAddr = (unsigned short) atoi(line); - } - ioset = true; - } else { - errc++; - cout << "LINE #" << dec << lc << " WARNING: I/O address was already set. Ignoring..." << endl; - } - continue; - } - // enable character I/O emulation - if (0 == strncmp(line, "ENIO", 4)) { - enio = true; - continue; - } - // enable ROM emulation - if (0 == strncmp(line, "ENROM", 5)) { - enrom = true; - continue; - } - // auto execute from address - if (0 == strncmp(line, "EXEC", 4)) { - mAutoExec = true; - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (!execset) { - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - mRunAddr = nAddr; - } else { - mRunAddr = (unsigned short) atoi(line); - } - execset = true; - } else { - errc++; - cout << "LINE #" << dec << lc << " WARNING: auto-exec address was already set. Ignoring..." << endl; - } - continue; - } - // define ROM begin address - if (0 == strncmp(line, "ROMBEGIN", 8)) { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (!rombegset) { - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - rombegin = nAddr; - } else { - rombegin = (unsigned short) atoi(line); - } - rombegset = true; - } else { - errc++; - cout << "LINE #" << dec << lc << " WARNING: ROM-begin address was already set. Ignoring..." << endl; - } - continue; - } - // define ROM end address - if (0 == strncmp(line, "ROMEND", 6)) { - line[0] = '\0'; - fgets(line, 256, fp); - lc++; - if (!romendset) { - if (*line == '$') { - sscanf(line+1, "%04x", &nAddr); - romend = nAddr; - } else { - romend = (unsigned short) atoi(line); - } - romendset = true; - } else { - errc++; - cout << "LINE #" << dec << lc << " WARNING: ROM-end address was already set. Ignoring..." << endl; - } - continue; - } - if (';' == *line) continue; // skip comment lines - char *s = strtok (line, " ,"); - while (NULL != s) { - unsigned int nVal; - if (*s == '$') { - sscanf(s+1, "%02x", &nVal); - pm->Poke8bit(addr++, (unsigned short)nVal); - } else { - pm->Poke8bit(addr++, (unsigned short)atoi(s)); - } - s = strtok(NULL, " ,"); - } - } - fclose(fp); - if (rombegin > MIN_ROM_BEGIN && romend > rombegin) { - if (enrom) - pm->EnableROM(rombegin, romend); - else - pm->SetROM(rombegin, romend); - } else { - if (enrom) pm->EnableROM(); - } - if (enio) { - SetCharIO(mCharIOAddr, false); - } - } - else { - cout << "WARNING: Unable to open memory definition file: " << memfname << endl; - errc++; - } - if (errc) { - cout << "Found " << dec << errc << ((errc > 1) ? " problems." : " problem.") << endl; - cout << "Press [ENTER] to continue..."; - getchar(); - } -} - -/* - *-------------------------------------------------------------------- - * Method: MemPeek8bit() - * Purpose: Read value from specified RAM address. - * Arguments: addr - RAM address (0..0xFFFF) - * Returns: unsigned short - value read from specified RAM address - *-------------------------------------------------------------------- - */ -unsigned short VMachine::MemPeek8bit(unsigned short addr) -{ - unsigned short ret = 0; - - ret = (unsigned short)mpRAM->Peek8bit(addr); - - return ret; -} - -/* - *-------------------------------------------------------------------- - * Method: MemPoke8bit() - * Purpose: Write value to specified RAM address. - * Arguments: addr - RAM address (0..0xFFFF) - * v - 8-bit byte value - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::MemPoke8bit(unsigned short addr, unsigned char v) -{ - mpRAM->Poke8bit(addr, v); -} - -/* - *-------------------------------------------------------------------- - * Method: GetRegs() - * Purpose: Return pointer to CPU status register. - * Arguments: n/a - * Returns: pointer to status register - *-------------------------------------------------------------------- - */ -Regs *VMachine::GetRegs() -{ - return mpCPU->GetRegs(); -} - -/* - *-------------------------------------------------------------------- - * Method: SetCharIO() - * Purpose: Activates and sets an address of basic character I/O - * emulation (console). - * Arguments: addr - address of I/O area (0x0000..0xFFFF) - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::SetCharIO(unsigned short addr, bool echo) -{ - mCharIOAddr = addr; - mCharIOActive = true; - mpRAM->SetCharIO(addr, echo); - mpDisp->ClrScr(); -} - -/* - *-------------------------------------------------------------------- - * Method: DisableCharIO() - * Purpose: Deactivates basic character I/O emulation (console). - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::DisableCharIO() -{ - mCharIOActive = false; - mpRAM->DisableCharIO(); -} - -/* - *-------------------------------------------------------------------- - * Method: GetCharIOAddr() - * Purpose: Returns current address of basic character I/O area. - * Arguments: n/a - * Returns: address of I/O area - *-------------------------------------------------------------------- - */ -unsigned short VMachine::GetCharIOAddr() -{ - return mCharIOAddr; -} - -/* - *-------------------------------------------------------------------- - * Method: GetCharIOActive() - * Purpose: Returns status of character I/O emulation. - * Arguments: n/a - * Returns: true if I/O emulation active - *-------------------------------------------------------------------- - */ -bool VMachine::GetCharIOActive() -{ - return mCharIOActive; -} - -/* - *-------------------------------------------------------------------- - * Method: ShowIO() - * Purpose: Show contents of emulated char I/O. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::ShowIO() -{ - if (mCharIOActive) - mpDisp->ShowScr(); -} - -/* - *-------------------------------------------------------------------- - * Method: IsAutoExec() - * Purpose: Return status of auto-execute flag. - * Arguments: n/a - * Returns: bool - true if auto-exec flag is enabled. - *-------------------------------------------------------------------- - */ -bool VMachine::IsAutoExec() -{ - return mAutoExec; -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::EnableROM() -{ - mpRAM->EnableROM(); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::DisableROM() -{ - mpRAM->DisableROM(); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::SetROM(unsigned short start, unsigned short end) -{ - mpRAM->SetROM(start, end); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void VMachine::EnableROM(unsigned short start, unsigned short end) -{ - mpRAM->EnableROM(start, end); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -unsigned short VMachine::GetROMBegin() -{ - return mpRAM->GetROMBegin(); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -unsigned short VMachine::GetROMEnd() -{ - return mpRAM->GetROMEnd(); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -bool VMachine::IsROMEnabled() -{ - return mpRAM->IsROMEnabled(); -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -unsigned short VMachine::GetRunAddr() -{ - return mRunAddr; -} - -/* - *-------------------------------------------------------------------- - * Method: SetOpInterrupt() - * Purpose: Set the flag indicating operator interrupt. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -void VMachine::SetOpInterrupt() -{ - mOpInterrupt = true; -} - -/* - *-------------------------------------------------------------------- - * Method: GetExecHistory() - * Purpose: Return history of executed opcodes (last 20). - * Arguments: n/a - * Returns: queue - *-------------------------------------------------------------------- - */ -queue VMachine::GetExecHistory() -{ - return mpCPU->GetExecHistory(); -} - -/* - *-------------------------------------------------------------------- - * Method: Disassemble() - * Purpose: Disassemble code in memory. Return next instruction - * address. - * Arguments: addr - address in memory - * buf - character buffer for disassembled instruction - * Returns: unsigned short - address of next instruction - *-------------------------------------------------------------------- - */ -unsigned short VMachine::Disassemble(unsigned short addr, char *buf) -{ - return mpCPU->Disassemble(addr, buf); -} - -} // namespace MKBasic + +#include +#include +#include +#include "system.h" +#include "VMachine.h" +#include "MKGenException.h" + +#if defined(WINDOWS) +#include +#endif + +using namespace std; + +namespace MKBasic { + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ + +/* + *-------------------------------------------------------------------- + * Method: VMachine() + * Purpose: Default class constructor. + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +VMachine::VMachine() +{ + InitVM(); +} + +/* + *-------------------------------------------------------------------- + * Method: VMachine() + * Purpose: Custom class constructor. + * Arguments: romfname - name of the ROM definition file + * ramfname - name of the RAM definition file + * Returns: n/a + *-------------------------------------------------------------------- + */ +VMachine::VMachine(string romfname, string ramfname) +{ + InitVM(); + LoadROM(romfname); + LoadRAM(ramfname); +} + +/* + *-------------------------------------------------------------------- + * Method: ~VMachine() + * Purpose: Class destructor. + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +VMachine::~VMachine() +{ + delete mpDisp; + delete mpCPU; + delete mpROM; + delete mpRAM; +} + +/* + *-------------------------------------------------------------------- + * Method: InitVM() + * Purpose: Initialize class. + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::InitVM() +{ + mOpInterrupt = false; + mpRAM = new Memory(); + + mAutoExec = false; + mCharIOAddr = CHARIO_ADDR; + mCharIOActive = mCharIO = false; + if (NULL == mpRAM) { + throw MKGenException("Unable to initialize VM (RAM)."); + } + mRunAddr = mpRAM->Peek16bit(0xFFFC); // address under RESET vector + mpROM = new Memory(); + if (NULL == mpROM) { + throw MKGenException("Unable to initialize VM (ROM)."); + } + mpCPU = new MKCpu(mpRAM); + if (NULL == mpCPU) { + throw MKGenException("Unable to initialize VM (CPU)."); + } + mpDisp = new Display(); + if (NULL == mpDisp) { + throw MKGenException("Unable to initialize VM (Display)."); + } +} + +#if defined(WINDOWS) + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::ClearScreen() +{ + HANDLE hStdOut; + CONSOLE_SCREEN_BUFFER_INFO csbi; + DWORD count; + DWORD cellCount; + COORD homeCoords = { 0, 0 }; + + hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); + if (hStdOut == INVALID_HANDLE_VALUE) return; + + /* Get the number of cells in the current buffer */ + if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return; + cellCount = csbi.dwSize.X *csbi.dwSize.Y; + + /* Fill the entire buffer with spaces */ + if (!FillConsoleOutputCharacter( + hStdOut, + (TCHAR) ' ', + cellCount, + homeCoords, + &count + )) return; + + /* Fill the entire buffer with the current colors and attributes */ + if (!FillConsoleOutputAttribute( + hStdOut, + csbi.wAttributes, + cellCount, + homeCoords, + &count + )) return; + + /* Move the cursor home */ + SetConsoleCursorPosition( hStdOut, homeCoords ); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::ScrHome() +{ + HANDLE hStdOut; + COORD homeCoords = { 0, 0 }; + + hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); + if (hStdOut == INVALID_HANDLE_VALUE) return; + + /* Move the cursor home */ + SetConsoleCursorPosition( hStdOut, homeCoords ); +} + +#endif + +#if defined(LINUX) + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::ClearScreen() +{ + system("clear"); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::ScrHome() +{ + cout << "\033[1;1H"; +} + +#endif + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::ShowDisp() +{ + if (mCharIOActive) { + ScrHome(); + mpDisp->ShowScr(); + } +} + +/* + *-------------------------------------------------------------------- + * Method: Run() + * Purpose: Run VM until software break instruction. + * Arguments: n/a + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Run() +{ + Regs *cpureg = NULL; + + mOpInterrupt = false; + ClearScreen(); + ShowDisp(); + while (true) { + cpureg = Step(); + if (mCharIO) { + ShowDisp(); + } + if (cpureg->SoftIrq || mOpInterrupt) + break; + } + + ShowDisp(); + + return cpureg; +} + +/* + *-------------------------------------------------------------------- + * Method: Run() + * Purpose: Run VM from specified address until software break + * instruction. + * Arguments: addr - start execution address + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Run(unsigned short addr) +{ + mRunAddr = addr; + return Run(); +} + +/* + *-------------------------------------------------------------------- + * Method: Exec() + * Purpose: Run VM from current address until last RTS. + * NOTE: Stack must be empty! + * Arguments: n/a + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Exec() +{ + Regs *cpureg = NULL; + + mOpInterrupt = false; + ClearScreen(); + ShowDisp(); + while (true) { + cpureg = Step(); + if (mCharIO) { + ShowDisp(); + } + if (cpureg->LastRTS || mOpInterrupt) break; + } + + ShowDisp(); + + return cpureg; +} + +/* + *-------------------------------------------------------------------- + * Method: Exec() + * Purpose: Run VM from specified address until RTS. + * Arguments: addr - start execution address + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Exec(unsigned short addr) +{ + mRunAddr = addr; + return Exec(); +} + +/* + *-------------------------------------------------------------------- + * Method: Step() + * Purpose: Execute single opcode. + * Arguments: n/a + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Step() +{ + unsigned short addr = mRunAddr; + Regs *cpureg = NULL; + + cpureg = mpCPU->ExecOpcode(addr); + addr = cpureg->PtrAddr; + mRunAddr = addr; + + if (mCharIOActive && !mOpInterrupt) { + char c = -1; + mCharIO = false; + while ((c = mpRAM->GetCharOut()) != -1) { + mOpInterrupt = mOpInterrupt || (c == OPINTERRUPT); + if (!mOpInterrupt) { + mpDisp->PutChar(c); + mCharIO = true; + } + } + } + + return cpureg; +} + +/* + *-------------------------------------------------------------------- + * Method: Step() + * Purpose: Execute single opcode. + * Arguments: addr (unsigned short) - opcode address + * Returns: Pointer to CPU registers and flags. + *-------------------------------------------------------------------- + */ +Regs *VMachine::Step(unsigned short addr) +{ + mRunAddr = addr; + return Step(); +} + +/* + *-------------------------------------------------------------------- + * Method: LoadROM() + * Purpose: Load data from memory definition file to the memory. + * Arguments: romfname - name of the ROM file definition + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::LoadROM(string romfname) +{ + LoadMEM(romfname, mpROM); +} + +/* + *-------------------------------------------------------------------- + * Method: LoadRAM() + * Purpose: Load data from memory definition file to the memory. + * Arguments: ramfname - name of the RAM file definition + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::LoadRAM(string ramfname) +{ + LoadMEM(ramfname, mpRAM); + //mpRAM->EnableROM(); +} + +/* + *-------------------------------------------------------------------- + * Method: LoadRAMBin() + * Purpose: Load data from binary image file to the memory. + * Arguments: ramfname - name of the RAM file definition + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::LoadRAMBin(string ramfname) +{ + FILE *fp = NULL; + unsigned short addr = 0x0000; + int n = 0; + Memory *pm = mpRAM; + + if ((fp = fopen(ramfname.c_str(), "rb")) != NULL) { + while (0 == feof(fp) && 0 == ferror(fp)) { + unsigned char val = fgetc(fp); + pm->Poke8bit(addr, val); + addr++; n++; + } + fclose(fp); + if (n <= 0xFFFF) { + cout << "WARNING: Unexpected EOF." << endl; + } + } + else { + cout << "WARNING: Unable to open memory image file: " << ramfname << endl; + cout << "Press [ENTER]..."; + getchar(); + } +} + +/* + *-------------------------------------------------------------------- + * Method: LoadMEM() + * Purpose: Load data from memory definition file to the memory. + * Arguments: memfname - name of memory definition file + * pmem - pointer to memory object + * Returns: n/a + * Details: + * Format of the memory definition file: + * [; comment] + * [ADDR + * address] + * [data] + * [ORG + * address] + * [data] + * [IOADDR + * address] + * [ROMBEGIN + * address] + * [ROMEND + * address] + * [ENIO] + * [ENROM] + * [EXEC + * addrress] + * + * Where: + * [] - optional token + * ADDR - label indicating that starting address will follow in next + * line, it also defines run address + * ORG - label indicating that the address counter will change to the + * value provided in next line + * IOADDR - label indicating that char IO trap address will be defined + * in the next line + * ROMBEGIN - label indicating that ROM begin address will be defined + * in the next line + * ROMEND - label indicating that ROM end address will be defined + * in the next line + * ENIO - label enabling char IO emulation + * ENROM - label enabling ROM emulation + * EXEC - label enabling auto-execute of code, address follows in the + * next line + * address - decimal or hexadecimal (prefix $) address in memory + * E.g: + * ADDR + * $200 + * + * or + * + * ADDR + * 512 + * + * changes the default start address (256) to 512. + * + * ORG + * 49152 + * + * moves address counter to address 49152, following data will be + * loaded from that address forward + * + * data - the multi-line stream of decimal of hexadecimal ($xx) values + * of size unsigned char (byte: 0-255) separated with spaces + * or commas. + * E.g.: + * $00 $00 $00 $00 + * $00 $00 $00 $00 + * + * or + * + * $00,$00,$00,$00 + * + * or + * + * 0 0 0 0 + * + * or + * + * 0,0,0,0 + * 0 0 0 0 + *-------------------------------------------------------------------- + */ +void VMachine::LoadMEM(string memfname, Memory *pmem) +{ + FILE *fp = NULL; + char line[256] = "\0"; + int lc = 0, errc = 0; + unsigned short addr = 0, rombegin = 0, romend = 0; + unsigned int nAddr; + bool enrom = false, enio = false, runset = false; + bool ioset = false, execset = false, rombegset = false; + bool romendset = false; + Memory *pm = pmem; + + if ((fp = fopen(memfname.c_str(), "r")) != NULL) { + while (0 == feof(fp) && 0 == ferror(fp)) + { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + // change run address (can be done only once) + if (0 == strncmp(line, "ADDR", 4)) { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (!runset) { + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + addr = nAddr; + } else { + addr = (unsigned short) atoi(line); + } + mRunAddr = addr; + runset = true; + } else { + errc++; + cout << "LINE #" << dec << lc << " WARNING: Run address was already set. Ignoring..." << endl; + } + continue; + } + // change address counter + if (0 == strncmp(line, "ORG", 3)) { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + addr = nAddr; + } else { + addr = (unsigned short) atoi(line); + } + continue; + } + // define I/O emulation address (once) + if (0 == strncmp(line, "IOADDR", 6)) { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (!ioset) { + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + mCharIOAddr = nAddr; + } else { + mCharIOAddr = (unsigned short) atoi(line); + } + ioset = true; + } else { + errc++; + cout << "LINE #" << dec << lc << " WARNING: I/O address was already set. Ignoring..." << endl; + } + continue; + } + // enable character I/O emulation + if (0 == strncmp(line, "ENIO", 4)) { + enio = true; + continue; + } + // enable ROM emulation + if (0 == strncmp(line, "ENROM", 5)) { + enrom = true; + continue; + } + // auto execute from address + if (0 == strncmp(line, "EXEC", 4)) { + mAutoExec = true; + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (!execset) { + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + mRunAddr = nAddr; + } else { + mRunAddr = (unsigned short) atoi(line); + } + execset = true; + } else { + errc++; + cout << "LINE #" << dec << lc << " WARNING: auto-exec address was already set. Ignoring..." << endl; + } + continue; + } + // define ROM begin address + if (0 == strncmp(line, "ROMBEGIN", 8)) { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (!rombegset) { + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + rombegin = nAddr; + } else { + rombegin = (unsigned short) atoi(line); + } + rombegset = true; + } else { + errc++; + cout << "LINE #" << dec << lc << " WARNING: ROM-begin address was already set. Ignoring..." << endl; + } + continue; + } + // define ROM end address + if (0 == strncmp(line, "ROMEND", 6)) { + line[0] = '\0'; + fgets(line, 256, fp); + lc++; + if (!romendset) { + if (*line == '$') { + sscanf(line+1, "%04x", &nAddr); + romend = nAddr; + } else { + romend = (unsigned short) atoi(line); + } + romendset = true; + } else { + errc++; + cout << "LINE #" << dec << lc << " WARNING: ROM-end address was already set. Ignoring..." << endl; + } + continue; + } + if (';' == *line) continue; // skip comment lines + char *s = strtok (line, " ,"); + while (NULL != s) { + unsigned int nVal; + if (*s == '$') { + sscanf(s+1, "%02x", &nVal); + pm->Poke8bit(addr++, (unsigned short)nVal); + } else { + pm->Poke8bit(addr++, (unsigned short)atoi(s)); + } + s = strtok(NULL, " ,"); + } + } + fclose(fp); + if (rombegin > MIN_ROM_BEGIN && romend > rombegin) { + if (enrom) + pm->EnableROM(rombegin, romend); + else + pm->SetROM(rombegin, romend); + } else { + if (enrom) pm->EnableROM(); + } + if (enio) { + SetCharIO(mCharIOAddr, false); + } + } + else { + cout << "WARNING: Unable to open memory definition file: " << memfname << endl; + errc++; + } + if (errc) { + cout << "Found " << dec << errc << ((errc > 1) ? " problems." : " problem.") << endl; + cout << "Press [ENTER] to continue..."; + getchar(); + } +} + +/* + *-------------------------------------------------------------------- + * Method: MemPeek8bit() + * Purpose: Read value from specified RAM address. + * Arguments: addr - RAM address (0..0xFFFF) + * Returns: unsigned short - value read from specified RAM address + *-------------------------------------------------------------------- + */ +unsigned short VMachine::MemPeek8bit(unsigned short addr) +{ + unsigned short ret = 0; + + ret = (unsigned short)mpRAM->Peek8bit(addr); + + return ret; +} + +/* + *-------------------------------------------------------------------- + * Method: MemPoke8bit() + * Purpose: Write value to specified RAM address. + * Arguments: addr - RAM address (0..0xFFFF) + * v - 8-bit byte value + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::MemPoke8bit(unsigned short addr, unsigned char v) +{ + mpRAM->Poke8bit(addr, v); +} + +/* + *-------------------------------------------------------------------- + * Method: GetRegs() + * Purpose: Return pointer to CPU status register. + * Arguments: n/a + * Returns: pointer to status register + *-------------------------------------------------------------------- + */ +Regs *VMachine::GetRegs() +{ + return mpCPU->GetRegs(); +} + +/* + *-------------------------------------------------------------------- + * Method: SetCharIO() + * Purpose: Activates and sets an address of basic character I/O + * emulation (console). + * Arguments: addr - address of I/O area (0x0000..0xFFFF) + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::SetCharIO(unsigned short addr, bool echo) +{ + mCharIOAddr = addr; + mCharIOActive = true; + mpRAM->SetCharIO(addr, echo); + mpDisp->ClrScr(); +} + +/* + *-------------------------------------------------------------------- + * Method: DisableCharIO() + * Purpose: Deactivates basic character I/O emulation (console). + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::DisableCharIO() +{ + mCharIOActive = false; + mpRAM->DisableCharIO(); +} + +/* + *-------------------------------------------------------------------- + * Method: GetCharIOAddr() + * Purpose: Returns current address of basic character I/O area. + * Arguments: n/a + * Returns: address of I/O area + *-------------------------------------------------------------------- + */ +unsigned short VMachine::GetCharIOAddr() +{ + return mCharIOAddr; +} + +/* + *-------------------------------------------------------------------- + * Method: GetCharIOActive() + * Purpose: Returns status of character I/O emulation. + * Arguments: n/a + * Returns: true if I/O emulation active + *-------------------------------------------------------------------- + */ +bool VMachine::GetCharIOActive() +{ + return mCharIOActive; +} + +/* + *-------------------------------------------------------------------- + * Method: ShowIO() + * Purpose: Show contents of emulated char I/O. + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::ShowIO() +{ + if (mCharIOActive) + mpDisp->ShowScr(); +} + +/* + *-------------------------------------------------------------------- + * Method: IsAutoExec() + * Purpose: Return status of auto-execute flag. + * Arguments: n/a + * Returns: bool - true if auto-exec flag is enabled. + *-------------------------------------------------------------------- + */ +bool VMachine::IsAutoExec() +{ + return mAutoExec; +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::EnableROM() +{ + mpRAM->EnableROM(); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::DisableROM() +{ + mpRAM->DisableROM(); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::SetROM(unsigned short start, unsigned short end) +{ + mpRAM->SetROM(start, end); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void VMachine::EnableROM(unsigned short start, unsigned short end) +{ + mpRAM->EnableROM(start, end); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +unsigned short VMachine::GetROMBegin() +{ + return mpRAM->GetROMBegin(); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +unsigned short VMachine::GetROMEnd() +{ + return mpRAM->GetROMEnd(); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +bool VMachine::IsROMEnabled() +{ + return mpRAM->IsROMEnabled(); +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +unsigned short VMachine::GetRunAddr() +{ + return mRunAddr; +} + +/* + *-------------------------------------------------------------------- + * Method: SetOpInterrupt() + * Purpose: Set the flag indicating operator interrupt. + * Arguments: bool - new value of the flag + * Returns: n/a + *-------------------------------------------------------------------- + */ +void VMachine::SetOpInterrupt(bool opint) +{ + mOpInterrupt = opint; +} + +/* + *-------------------------------------------------------------------- + * Method: IsOpInterrupt() + * Purpose: Return the flag indicating operator interrupt status. + * Arguments: n/a + * Returns: bool - true if operator interrupt flag was set + *-------------------------------------------------------------------- + */ +bool VMachine::IsOpInterrupt() +{ + return mOpInterrupt; +} + +/* + *-------------------------------------------------------------------- + * Method: GetExecHistory() + * Purpose: Return history of executed opcodes (last 20). + * Arguments: n/a + * Returns: queue + *-------------------------------------------------------------------- + */ +queue VMachine::GetExecHistory() +{ + return mpCPU->GetExecHistory(); +} + +/* + *-------------------------------------------------------------------- + * Method: Disassemble() + * Purpose: Disassemble code in memory. Return next instruction + * address. + * Arguments: addr - address in memory + * buf - character buffer for disassembled instruction + * Returns: unsigned short - address of next instruction + *-------------------------------------------------------------------- + */ +unsigned short VMachine::Disassemble(unsigned short addr, char *buf) +{ + return mpCPU->Disassemble(addr, buf); +} + +} // namespace MKBasic diff --git a/VMachine.h b/VMachine.h index 8281a34..97d784b 100644 --- a/VMachine.h +++ b/VMachine.h @@ -1,84 +1,85 @@ -#ifndef VMACHINE_H -#define VMACHINE_H - -#include -#include -#include "system.h" -#include "MKCpu.h" -#include "Memory.h" -#include "Display.h" - -//#define WINDOWS 1 -#if defined (WINDOWS) -#include -#endif - -#define IOREFRESH 32 -#define OPINTERRUPT 25 // operator interrupt code (CTRL-Y) - -using namespace std; - -namespace MKBasic { - -class VMachine -{ - public: - VMachine(); - VMachine(string romfname, string ramfname); - ~VMachine(); - - void InitVM(); - Regs *Run(); - Regs *Run(unsigned short addr); - Regs *Exec(); - Regs *Exec(unsigned short addr); - Regs *Step(); - Regs *Step(unsigned short addr); - void LoadROM(string romfname); - void LoadRAM(string ramfname); - void LoadRAMBin(string ramfname); - unsigned short MemPeek8bit(unsigned short addr); - void MemPoke8bit(unsigned short addr, unsigned char v); - Regs *GetRegs(); - void SetCharIO(unsigned short addr, bool echo); - void DisableCharIO(); - unsigned short GetCharIOAddr(); - bool GetCharIOActive(); - void ShowIO(); - void ClearScreen(); - void ScrHome(); - bool IsAutoExec(); - void EnableROM(); - void DisableROM(); - void SetROM(unsigned short start, unsigned short end); - void EnableROM(unsigned short start, unsigned short end); - unsigned short GetROMBegin(); - unsigned short GetROMEnd(); - bool IsROMEnabled(); - unsigned short GetRunAddr(); - void SetOpInterrupt(); - queue GetExecHistory(); - unsigned short Disassemble(unsigned short addr, char *buf); - - protected: - - private: - - MKCpu *mpCPU; - Memory *mpROM; - Memory *mpRAM; - Display *mpDisp; - unsigned short mRunAddr; - unsigned short mCharIOAddr; - bool mCharIOActive; - bool mCharIO; - bool mOpInterrupt; // operator interrupt from console - bool mAutoExec; - - void LoadMEM(string memfname, Memory *pmem); - void ShowDisp(); -}; - -} // namespace MKBasic - -#endif +#ifndef VMACHINE_H +#define VMACHINE_H + +#include +#include +#include "system.h" +#include "MKCpu.h" +#include "Memory.h" +#include "Display.h" + +//#define WINDOWS 1 +#if defined (WINDOWS) +#include +#endif + +#define IOREFRESH 32 +#define OPINTERRUPT 25 // operator interrupt code (CTRL-Y) + +using namespace std; + +namespace MKBasic { + +class VMachine +{ + public: + VMachine(); + VMachine(string romfname, string ramfname); + ~VMachine(); + + void InitVM(); + Regs *Run(); + Regs *Run(unsigned short addr); + Regs *Exec(); + Regs *Exec(unsigned short addr); + Regs *Step(); + Regs *Step(unsigned short addr); + void LoadROM(string romfname); + void LoadRAM(string ramfname); + void LoadRAMBin(string ramfname); + unsigned short MemPeek8bit(unsigned short addr); + void MemPoke8bit(unsigned short addr, unsigned char v); + Regs *GetRegs(); + void SetCharIO(unsigned short addr, bool echo); + void DisableCharIO(); + unsigned short GetCharIOAddr(); + bool GetCharIOActive(); + void ShowIO(); + void ClearScreen(); + void ScrHome(); + bool IsAutoExec(); + void EnableROM(); + void DisableROM(); + void SetROM(unsigned short start, unsigned short end); + void EnableROM(unsigned short start, unsigned short end); + unsigned short GetROMBegin(); + unsigned short GetROMEnd(); + bool IsROMEnabled(); + unsigned short GetRunAddr(); + void SetOpInterrupt(bool opint); + bool IsOpInterrupt(); + queue GetExecHistory(); + unsigned short Disassemble(unsigned short addr, char *buf); + + protected: + + private: + + MKCpu *mpCPU; + Memory *mpROM; + Memory *mpRAM; + Display *mpDisp; + unsigned short mRunAddr; + unsigned short mCharIOAddr; + bool mCharIOActive; + bool mCharIO; + bool mOpInterrupt; // operator interrupt from console + bool mAutoExec; + + void LoadMEM(string memfname, Memory *pmem); + void ShowDisp(); +}; + +} // namespace MKBasic + +#endif diff --git a/eh_basic_kow.asm b/eh_basic_kow.asm index 382b368..bd9a07d 100644 --- a/eh_basic_kow.asm +++ b/eh_basic_kow.asm @@ -1,8724 +1,8724 @@ - -; The code below was copied and adapted from Lee Davison’s -; code of EhBasic to be ran in Michal Kowalski's 6502 emulator. -; Original comments and credits follow: -; -; Enhanced BASIC to assemble under 6502 simulator, $ver 2.22 - -; $E7E1 $E7CF $E7C6 $E7D3 $E7D1 $E7D5 $E7CF $E81E $E825 - -; 2.00 new revision numbers start here -; 2.01 fixed LCASE$() and UCASE$() -; 2.02 new get value routine done -; 2.03 changed RND() to galoise method -; 2.04 fixed SPC() -; 2.05 new get value routine fixed -; 2.06 changed USR() code -; 2.07 fixed STR$() -; 2.08 changed INPUT and READ to remove need for $00 start to input buffer -; 2.09 fixed RND() -; 2.10 integrated missed changes from an earlier version -; 2.20 added ELSE to IF .. THEN and fixed IF .. GOTO to cause error -; 2.21 fixed IF .. THEN RETURN to not cause error -; 2.22 fixed RND() breaking the get byte routine - -; zero page use .. - -LAB_WARM = $00 ; BASIC warm start entry point -Wrmjpl = LAB_WARM+1; BASIC warm start vector jump low byte -Wrmjph = LAB_WARM+2; BASIC warm start vector jump high byte - -Usrjmp = $0A ; USR function JMP address -Usrjpl = Usrjmp+1 ; USR function JMP vector low byte -Usrjph = Usrjmp+2 ; USR function JMP vector high byte -Nullct = $0D ; nulls output after each line -TPos = $0E ; BASIC terminal position byte -TWidth = $0F ; BASIC terminal width byte -Iclim = $10 ; input column limit -Itempl = $11 ; temporary integer low byte -Itemph = Itempl+1 ; temporary integer high byte - -nums_1 = Itempl ; number to bin/hex string convert MSB -nums_2 = nums_1+1 ; number to bin/hex string convert -nums_3 = nums_1+2 ; number to bin/hex string convert LSB - -Srchc = $5B ; search character -Temp3 = Srchc ; temp byte used in number routines -Scnquo = $5C ; scan-between-quotes flag -Asrch = Scnquo ; alt search character - -XOAw_l = Srchc ; eXclusive OR, OR and AND word low byte -XOAw_h = Scnquo ; eXclusive OR, OR and AND word high byte - -Ibptr = $5D ; input buffer pointer -Dimcnt = Ibptr ; # of dimensions -Tindx = Ibptr ; token index - -Defdim = $5E ; default DIM flag -Dtypef = $5F ; data type flag, $FF=string, $00=numeric -Oquote = $60 ; open quote flag (b7) (Flag: DATA scan; LIST quote; memory) -Gclctd = $60 ; garbage collected flag -Sufnxf = $61 ; subscript/FNX flag, 1xxx xxx = FN(0xxx xxx) -Imode = $62 ; input mode flag, $00=INPUT, $80=READ - -Cflag = $63 ; comparison evaluation flag - -TabSiz = $64 ; TAB step size (was input flag) - -next_s = $65 ; next descriptor stack address - - ; these two bytes form a word pointer to the item - ; currently on top of the descriptor stack -last_sl = $66 ; last descriptor stack address low byte -last_sh = $67 ; last descriptor stack address high byte (always $00) - -des_sk = $68 ; descriptor stack start address (temp strings) - -; = $70 ; End of descriptor stack - -ut1_pl = $71 ; utility pointer 1 low byte -ut1_ph = ut1_pl+1 ; utility pointer 1 high byte -ut2_pl = $73 ; utility pointer 2 low byte -ut2_ph = ut2_pl+1 ; utility pointer 2 high byte - -Temp_2 = ut1_pl ; temp byte for block move - -FACt_1 = $75 ; FAC temp mantissa1 -FACt_2 = FACt_1+1 ; FAC temp mantissa2 -FACt_3 = FACt_2+1 ; FAC temp mantissa3 - -dims_l = FACt_2 ; array dimension size low byte -dims_h = FACt_3 ; array dimension size high byte - -TempB = $78 ; temp page 0 byte - -Smeml = $79 ; start of mem low byte (Start-of-Basic) -Smemh = Smeml+1 ; start of mem high byte (Start-of-Basic) -Svarl = $7B ; start of vars low byte (Start-of-Variables) -Svarh = Svarl+1 ; start of vars high byte (Start-of-Variables) -Sarryl = $7D ; var mem end low byte (Start-of-Arrays) -Sarryh = Sarryl+1 ; var mem end high byte (Start-of-Arrays) -Earryl = $7F ; array mem end low byte (End-of-Arrays) -Earryh = Earryl+1 ; array mem end high byte (End-of-Arrays) -Sstorl = $81 ; string storage low byte (String storage (moving down)) -Sstorh = Sstorl+1 ; string storage high byte (String storage (moving down)) -Sutill = $83 ; string utility ptr low byte -Sutilh = Sutill+1 ; string utility ptr high byte -Ememl = $85 ; end of mem low byte (Limit-of-memory) -Ememh = Ememl+1 ; end of mem high byte (Limit-of-memory) -Clinel = $87 ; current line low byte (Basic line number) -Clineh = Clinel+1 ; current line high byte (Basic line number) -Blinel = $89 ; break line low byte (Previous Basic line number) -Blineh = Blinel+1 ; break line high byte (Previous Basic line number) - -Cpntrl = $8B ; continue pointer low byte -Cpntrh = Cpntrl+1 ; continue pointer high byte - -Dlinel = $8D ; current DATA line low byte -Dlineh = Dlinel+1 ; current DATA line high byte - -Dptrl = $8F ; DATA pointer low byte -Dptrh = Dptrl+1 ; DATA pointer high byte - -Rdptrl = $91 ; read pointer low byte -Rdptrh = Rdptrl+1 ; read pointer high byte - -Varnm1 = $93 ; current var name 1st byte -Varnm2 = Varnm1+1 ; current var name 2nd byte - -Cvaral = $95 ; current var address low byte -Cvarah = Cvaral+1 ; current var address high byte - -Frnxtl = $97 ; var pointer for FOR/NEXT low byte -Frnxth = Frnxtl+1 ; var pointer for FOR/NEXT high byte - -Tidx1 = Frnxtl ; temp line index - -Lvarpl = Frnxtl ; let var pointer low byte -Lvarph = Frnxth ; let var pointer high byte - -prstk = $99 ; precedence stacked flag - -comp_f = $9B ; compare function flag, bits 0,1 and 2 used - ; bit 2 set if > - ; bit 1 set if = - ; bit 0 set if < - -func_l = $9C ; function pointer low byte -func_h = func_l+1 ; function pointer high byte - -garb_l = func_l ; garbage collection working pointer low byte -garb_h = func_h ; garbage collection working pointer high byte - -des_2l = $9E ; string descriptor_2 pointer low byte -des_2h = des_2l+1 ; string descriptor_2 pointer high byte - -g_step = $A0 ; garbage collect step size - -Fnxjmp = $A1 ; jump vector for functions -Fnxjpl = Fnxjmp+1 ; functions jump vector low byte -Fnxjph = Fnxjmp+2 ; functions jump vector high byte - -g_indx = Fnxjpl ; garbage collect temp index - -FAC2_r = $A3 ; FAC2 rounding byte - -Adatal = $A4 ; array data pointer low byte -Adatah = Adatal+1 ; array data pointer high byte - -Nbendl = Adatal ; new block end pointer low byte -Nbendh = Adatah ; new block end pointer high byte - -Obendl = $A6 ; old block end pointer low byte -Obendh = Obendl+1 ; old block end pointer high byte - -numexp = $A8 ; string to float number exponent count -expcnt = $A9 ; string to float exponent count - -numbit = numexp ; bit count for array element calculations - -numdpf = $AA ; string to float decimal point flag -expneg = $AB ; string to float eval exponent -ve flag - -Astrtl = numdpf ; array start pointer low byte -Astrth = expneg ; array start pointer high byte - -Histrl = numdpf ; highest string low byte -Histrh = expneg ; highest string high byte - -Baslnl = numdpf ; BASIC search line pointer low byte -Baslnh = expneg ; BASIC search line pointer high byte - -Fvar_l = numdpf ; find/found variable pointer low byte -Fvar_h = expneg ; find/found variable pointer high byte - -Ostrtl = numdpf ; old block start pointer low byte -Ostrth = expneg ; old block start pointer high byte - -Vrschl = numdpf ; variable search pointer low byte -Vrschh = expneg ; variable search pointer high byte - -FAC1_e = $AC ; FAC1 exponent -FAC1_1 = FAC1_e+1 ; FAC1 mantissa1 -FAC1_2 = FAC1_e+2 ; FAC1 mantissa2 -FAC1_3 = FAC1_e+3 ; FAC1 mantissa3 -FAC1_s = FAC1_e+4 ; FAC1 sign (b7) - -str_ln = FAC1_e ; string length -str_pl = FAC1_1 ; string pointer low byte -str_ph = FAC1_2 ; string pointer high byte - -des_pl = FAC1_2 ; string descriptor pointer low byte -des_ph = FAC1_3 ; string descriptor pointer high byte - -mids_l = FAC1_3 ; MID$ string temp length byte - -negnum = $B1 ; string to float eval -ve flag -numcon = $B1 ; series evaluation constant count - -FAC1_o = $B2 ; FAC1 overflow byte - -FAC2_e = $B3 ; FAC2 exponent -FAC2_1 = FAC2_e+1 ; FAC2 mantissa1 -FAC2_2 = FAC2_e+2 ; FAC2 mantissa2 -FAC2_3 = FAC2_e+3 ; FAC2 mantissa3 -FAC2_s = FAC2_e+4 ; FAC2 sign (b7) - -FAC_sc = $B8 ; FAC sign comparison, Acc#1 vs #2 -FAC1_r = $B9 ; FAC1 rounding byte - -ssptr_l = FAC_sc ; string start pointer low byte -ssptr_h = FAC1_r ; string start pointer high byte - -sdescr = FAC_sc ; string descriptor pointer - -csidx = $BA ; line crunch save index -Asptl = csidx ; array size/pointer low byte -Aspth = $BB ; array size/pointer high byte - -Btmpl = Asptl ; BASIC pointer temp low byte -Btmph = Aspth ; BASIC pointer temp low byte - -Cptrl = Asptl ; BASIC pointer temp low byte -Cptrh = Aspth ; BASIC pointer temp low byte - -Sendl = Asptl ; BASIC pointer temp low byte -Sendh = Aspth ; BASIC pointer temp low byte - -LAB_IGBY = $BC ; get next BASIC byte subroutine - -LAB_GBYT = $C2 ; get current BASIC byte subroutine -Bpntrl = $C3 ; BASIC execute (get byte) pointer low byte -Bpntrh = Bpntrl+1 ; BASIC execute (get byte) pointer high byte - -; = $D7 ; end of get BASIC char subroutine - -Rbyte4 = $D8 ; extra PRNG byte -Rbyte1 = Rbyte4+1 ; most significant PRNG byte -Rbyte2 = Rbyte4+2 ; middle PRNG byte -Rbyte3 = Rbyte4+3 ; least significant PRNG byte - -NmiBase = $DC ; NMI handler enabled/setup/triggered flags - ; bit function - ; === ======== - ; 7 interrupt enabled - ; 6 interrupt setup - ; 5 interrupt happened -; = $DD ; NMI handler addr low byte -; = $DE ; NMI handler addr high byte -IrqBase = $DF ; IRQ handler enabled/setup/triggered flags -; = $E0 ; IRQ handler addr low byte -; = $E1 ; IRQ handler addr high byte - -; = $DE ; unused -; = $DF ; unused -; = $E0 ; unused -; = $E1 ; unused -; = $E2 ; unused -; = $E3 ; unused -; = $E4 ; unused -; = $E5 ; unused -; = $E6 ; unused -; = $E7 ; unused -; = $E8 ; unused -; = $E9 ; unused -; = $EA ; unused -; = $EB ; unused -; = $EC ; unused -; = $ED ; unused -; = $EE ; unused - -Decss = $EF ; number to decimal string start -Decssp1 = Decss+1 ; number to decimal string start - -; = $FF ; decimal string end - -; token values needed for BASIC - -; primary command tokens (can start a statement) - -TK_END = $80 ; END token -TK_FOR = TK_END+1 ; FOR token -TK_NEXT = TK_FOR+1 ; NEXT token -TK_DATA = TK_NEXT+1 ; DATA token -TK_INPUT = TK_DATA+1 ; INPUT token -TK_DIM = TK_INPUT+1 ; DIM token -TK_READ = TK_DIM+1 ; READ token -TK_LET = TK_READ+1 ; LET token -TK_DEC = TK_LET+1 ; DEC token -TK_GOTO = TK_DEC+1 ; GOTO token -TK_RUN = TK_GOTO+1 ; RUN token -TK_IF = TK_RUN+1 ; IF token -TK_RESTORE = TK_IF+1 ; RESTORE token -TK_GOSUB = TK_RESTORE+1 ; GOSUB token -TK_RETIRQ = TK_GOSUB+1 ; RETIRQ token -TK_RETNMI = TK_RETIRQ+1 ; RETNMI token -TK_RETURN = TK_RETNMI+1 ; RETURN token -TK_REM = TK_RETURN+1 ; REM token -TK_STOP = TK_REM+1 ; STOP token -TK_ON = TK_STOP+1 ; ON token -TK_NULL = TK_ON+1 ; NULL token -TK_INC = TK_NULL+1 ; INC token -TK_WAIT = TK_INC+1 ; WAIT token -TK_LOAD = TK_WAIT+1 ; LOAD token -TK_SAVE = TK_LOAD+1 ; SAVE token -TK_DEF = TK_SAVE+1 ; DEF token -TK_POKE = TK_DEF+1 ; POKE token -TK_DOKE = TK_POKE+1 ; DOKE token -TK_CALL = TK_DOKE+1 ; CALL token -TK_DO = TK_CALL+1 ; DO token -TK_LOOP = TK_DO+1 ; LOOP token -TK_PRINT = TK_LOOP+1 ; PRINT token -TK_CONT = TK_PRINT+1 ; CONT token -TK_LIST = TK_CONT+1 ; LIST token -TK_CLEAR = TK_LIST+1 ; CLEAR token -TK_NEW = TK_CLEAR+1 ; NEW token -TK_WIDTH = TK_NEW+1 ; WIDTH token -TK_GET = TK_WIDTH+1 ; GET token -TK_SWAP = TK_GET+1 ; SWAP token -TK_BITSET = TK_SWAP+1 ; BITSET token -TK_BITCLR = TK_BITSET+1 ; BITCLR token -TK_IRQ = TK_BITCLR+1 ; IRQ token -TK_NMI = TK_IRQ+1 ; NMI token - -; secondary command tokens, can't start a statement - -TK_TAB = TK_NMI+1 ; TAB token -TK_ELSE = TK_TAB+1 ; ELSE token -TK_TO = TK_ELSE+1 ; TO token -TK_FN = TK_TO+1 ; FN token -TK_SPC = TK_FN+1 ; SPC token -TK_THEN = TK_SPC+1 ; THEN token -TK_NOT = TK_THEN+1 ; NOT token -TK_STEP = TK_NOT+1 ; STEP token -TK_UNTIL = TK_STEP+1 ; UNTIL token -TK_WHILE = TK_UNTIL+1 ; WHILE token -TK_OFF = TK_WHILE+1 ; OFF token - -; opperator tokens - -TK_PLUS = TK_OFF+1 ; + token -TK_MINUS = TK_PLUS+1 ; - token -TK_MUL = TK_MINUS+1 ; * token -TK_DIV = TK_MUL+1 ; / token -TK_POWER = TK_DIV+1 ; ^ token -TK_AND = TK_POWER+1 ; AND token -TK_EOR = TK_AND+1 ; EOR token -TK_OR = TK_EOR+1 ; OR token -TK_RSHIFT = TK_OR+1 ; RSHIFT token -TK_LSHIFT = TK_RSHIFT+1 ; LSHIFT token -TK_GT = TK_LSHIFT+1 ; > token -TK_EQUAL = TK_GT+1 ; = token -TK_LT = TK_EQUAL+1 ; < token - -; functions tokens - -TK_SGN = TK_LT+1 ; SGN token -TK_INT = TK_SGN+1 ; INT token -TK_ABS = TK_INT+1 ; ABS token -TK_USR = TK_ABS+1 ; USR token -TK_FRE = TK_USR+1 ; FRE token -TK_POS = TK_FRE+1 ; POS token -TK_SQR = TK_POS+1 ; SQR token -TK_RND = TK_SQR+1 ; RND token -TK_LOG = TK_RND+1 ; LOG token -TK_EXP = TK_LOG+1 ; EXP token -TK_COS = TK_EXP+1 ; COS token -TK_SIN = TK_COS+1 ; SIN token -TK_TAN = TK_SIN+1 ; TAN token -TK_ATN = TK_TAN+1 ; ATN token -TK_PEEK = TK_ATN+1 ; PEEK token -TK_DEEK = TK_PEEK+1 ; DEEK token -TK_SADD = TK_DEEK+1 ; SADD token -TK_LEN = TK_SADD+1 ; LEN token -TK_STRS = TK_LEN+1 ; STR$ token -TK_VAL = TK_STRS+1 ; VAL token -TK_ASC = TK_VAL+1 ; ASC token -TK_UCASES = TK_ASC+1 ; UCASE$ token -TK_LCASES = TK_UCASES+1 ; LCASE$ token -TK_CHRS = TK_LCASES+1 ; CHR$ token -TK_HEXS = TK_CHRS+1 ; HEX$ token -TK_BINS = TK_HEXS+1 ; BIN$ token -TK_BITTST = TK_BINS+1 ; BITTST token -TK_MAX = TK_BITTST+1 ; MAX token -TK_MIN = TK_MAX+1 ; MIN token -TK_PI = TK_MIN+1 ; PI token -TK_TWOPI = TK_PI+1 ; TWOPI token -TK_VPTR = TK_TWOPI+1 ; VARPTR token -TK_LEFTS = TK_VPTR+1 ; LEFT$ token -TK_RIGHTS = TK_LEFTS+1 ; RIGHT$ token -TK_MIDS = TK_RIGHTS+1 ; MID$ token - -; offsets from a base of X or Y - -PLUS_0 = $00 ; X or Y plus 0 -PLUS_1 = $01 ; X or Y plus 1 -PLUS_2 = $02 ; X or Y plus 2 -PLUS_3 = $03 ; X or Y plus 3 - -LAB_STAK = $0100 ; stack bottom, no offset - -LAB_SKFE = LAB_STAK+$FE - ; flushed stack address -LAB_SKFF = LAB_STAK+$FF - ; flushed stack address - -ccflag = $0200 ; BASIC CTRL-C flag, 00 = enabled, 01 = dis -ccbyte = ccflag+1 ; BASIC CTRL-C byte -ccnull = ccbyte+1 ; BASIC CTRL-C byte timeout - -VEC_CC = ccnull+1 ; ctrl c check vector - -VEC_IN = VEC_CC+2 ; input vector -VEC_OUT = VEC_IN+2 ; output vector -VEC_LD = VEC_OUT+2 ; load vector -VEC_SV = VEC_LD+2 ; save vector - -; Ibuffs can now be anywhere in RAM, ensure that the max length is < $80 - -IRQ_vec = VEC_SV+2 - -Ibuffs = IRQ_vec+$14 ; start of input buffer after IRQ/NMI code -Ibuffe = Ibuffs+$47 ; end of input buffer - - .ORG $FFC0 - -; I/O routines for Michal Kowalski's 6502 emulator. - -CHRIN - LDA $E004 ; Read from char IO address, non-blocking - BEQ ECHRIN ; if null, assume no character in buffer - CMP #'a' ; < 'a'? - BCC DCHRIN ; yes, done - CMP #'{' ; >= '{'? - BCS DCHRIN ; yes, done - AND #$5F ; no, convert to upper case -DCHRIN - SEC ; These is character waiting, set CARRY flag - RTS -ECHRIN - CLC ; no character in buffer, clear CARRY - RTS - -CHROUT - STA $E001 ; write to char IO address - AND #$FF ; set flags - RTS - - -Ram_base = $0300 ; start of user RAM (set as needed, should be page aligned) -Ram_top = $C000 ; end of user RAM+1 (set as needed, should be page aligned) - -; This start can be changed to suit your system - - *= $C000 - -; BASIC cold start entry point - -; new page 2 initialisation, copy block to ccflag on - -LAB_COLD - CLD - LDY #PG2_TABE-PG2_TABS-1 - ; byte count-1 -LAB_2D13 - LDA PG2_TABS,Y ; get byte - STA ccflag,Y ; store in page 2 - DEY ; decrement count - BPL LAB_2D13 ; loop if not done - - LDX #$FF ; set byte - STX Ibuffs - STX Clineh ; set current line high byte (set immediate mode) - TXS ; reset stack pointer - - LDA #$4C ; code for JMP - STA Fnxjmp ; save for jump vector for functions - -; copy block from LAB_2CEE to $00BC - $00D3 - - LDX #StrTab-LAB_2CEE ; set byte count -LAB_2D4E - LDA LAB_2CEE-1,X ; get byte from table - STA LAB_IGBY-1,X ; save byte in page zero - DEX ; decrement count - BNE LAB_2D4E ; loop if not all done - -; copy block from StrTab to $0000 - $0012 - -LAB_GMEM - LDX #EndTab-StrTab-1 ; set byte count-1 -TabLoop - LDA StrTab,X ; get byte from table - STA PLUS_0,X ; save byte in page zero - DEX ; decrement count - BPL TabLoop ; loop if not all done - -; set-up start values - - LDA #$00 ; clear A - STA NmiBase ; clear NMI handler enabled flag - STA IrqBase ; clear IRQ handler enabled flag - STA FAC1_o ; clear FAC1 overflow byte - STA last_sh ; clear descriptor stack top item pointer high byte - - LDA #$0E ; set default tab size - STA TabSiz ; save it - LDA #$03 ; set garbage collect step size for descriptor stack - STA g_step ; save it - LDX #des_sk ; descriptor stack start - STX next_s ; set descriptor stack pointer - JSR LAB_CRLF ; print CR/LF - LDA #LAB_MSZM ; point to memory size message (high addr) - JSR LAB_18C3 ; print null terminated string from memory - JSR LAB_INLN ; print "? " and get BASIC input - STX Bpntrl ; set BASIC execute pointer low byte - STY Bpntrh ; set BASIC execute pointer high byte - JSR LAB_GBYT ; get last byte back - - BNE LAB_2DAA ; branch if not null (user typed something) - - LDY #$00 ; else clear Y - ; character was null so get memory size the hard way - ; we get here with Y=0 and Itempl/h = Ram_base -LAB_2D93 - INC Itempl ; increment temporary integer low byte - BNE LAB_2D99 ; branch if no overflow - - INC Itemph ; increment temporary integer high byte - LDA Itemph ; get high byte - CMP #>Ram_top ; compare with top of RAM+1 - BEQ LAB_2DB6 ; branch if match (end of user RAM) - -LAB_2D99 - LDA #$55 ; set test byte - STA (Itempl),Y ; save via temporary integer - CMP (Itempl),Y ; compare via temporary integer - BNE LAB_2DB6 ; branch if fail - - ASL ; shift test byte left (now $AA) - STA (Itempl),Y ; save via temporary integer - CMP (Itempl),Y ; compare via temporary integer - BEQ LAB_2D93 ; if ok go do next byte - - BNE LAB_2DB6 ; branch if fail - -LAB_2DAA - JSR LAB_2887 ; get FAC1 from string - LDA FAC1_e ; get FAC1 exponent - CMP #$98 ; compare with exponent = 2^24 - BCS LAB_GMEM ; if too large go try again - - JSR LAB_F2FU ; save integer part of FAC1 in temporary integer - ; (no range check) - -LAB_2DB6 - LDA Itempl ; get temporary integer low byte - LDY Itemph ; get temporary integer high byte - CPY #Ram_top ; compare with top of RAM high byte -; BCC MEM_OK ; branch if < RAM top - -; BNE LAB_GMEM ; if too large go try again - ; else was = so compare low bytes -; CMP #Ram_base ; set start addr high byte - STY Smeml ; save start of mem low byte - STX Smemh ; save start of mem high byte - -; this line is only needed if Ram_base is not $xx00 - -; LDY #$00 ; clear Y - TYA ; clear A - STA (Smeml),Y ; clear first byte - INC Smeml ; increment start of mem low byte - -; these two lines are only needed if Ram_base is $xxFF - -; BNE LAB_2E05 ; branch if no rollover - -; INC Smemh ; increment start of mem high byte -LAB_2E05 - JSR LAB_CRLF ; print CR/LF - JSR LAB_1463 ; do "NEW" and "CLEAR" - LDA Ememl ; get end of mem low byte - SEC ; set carry for subtract - SBC Smeml ; subtract start of mem low byte - TAX ; copy to X - LDA Ememh ; get end of mem high byte - SBC Smemh ; subtract start of mem high byte - JSR LAB_295E ; print XA as unsigned integer (bytes free) - LDA #LAB_SMSG ; point to sign-on message (high addr) - JSR LAB_18C3 ; print null terminated string from memory - LDA #LAB_1274 ; warm start vector high byte - STA Wrmjpl ; save warm start vector low byte - STY Wrmjph ; save warm start vector high byte - JMP (Wrmjpl) ; go do warm start - -; open up space in memory -; move (Ostrtl)-(Obendl) to new block ending at (Nbendl) - -; Nbendl,Nbendh - new block end address (A/Y) -; Obendl,Obendh - old block end address -; Ostrtl,Ostrth - old block start address - -; returns with .. - -; Nbendl,Nbendh - new block start address (high byte - $100) -; Obendl,Obendh - old block start address (high byte - $100) -; Ostrtl,Ostrth - old block start address (unchanged) - -LAB_11CF - JSR LAB_121F ; check available memory, "Out of memory" error if no room - ; addr to check is in AY (low/high) - STA Earryl ; save new array mem end low byte - STY Earryh ; save new array mem end high byte - -; open up space in memory -; move (Ostrtl)-(Obendl) to new block ending at (Nbendl) -; don't set array end - -LAB_11D6 - SEC ; set carry for subtract - LDA Obendl ; get block end low byte - SBC Ostrtl ; subtract block start low byte - TAY ; copy MOD(block length/$100) byte to Y - LDA Obendh ; get block end high byte - SBC Ostrth ; subtract block start high byte - TAX ; copy block length high byte to X - INX ; +1 to allow for count=0 exit - TYA ; copy block length low byte to A - BEQ LAB_120A ; branch if length low byte=0 - - ; block is (X-1)*256+Y bytes, do the Y bytes first - - SEC ; set carry for add + 1, two's complement - EOR #$FF ; invert low byte for subtract - ADC Obendl ; add block end low byte - - STA Obendl ; save corrected old block end low byte - BCS LAB_11F3 ; branch if no underflow - - DEC Obendh ; else decrement block end high byte - SEC ; set carry for add + 1, two's complement -LAB_11F3 - TYA ; get MOD(block length/$100) byte - EOR #$FF ; invert low byte for subtract - ADC Nbendl ; add destination end low byte - STA Nbendl ; save modified new block end low byte - BCS LAB_1203 ; branch if no underflow - - DEC Nbendh ; else decrement block end high byte - BCC LAB_1203 ; branch always - -LAB_11FF - LDA (Obendl),Y ; get byte from source - STA (Nbendl),Y ; copy byte to destination -LAB_1203 - DEY ; decrement index - BNE LAB_11FF ; loop until Y=0 - - ; now do Y=0 indexed byte - LDA (Obendl),Y ; get byte from source - STA (Nbendl),Y ; save byte to destination -LAB_120A - DEC Obendh ; decrement source pointer high byte - DEC Nbendh ; decrement destination pointer high byte - DEX ; decrement block count - BNE LAB_1203 ; loop until count = $0 - - RTS - -; check room on stack for A bytes -; stack too deep? do OM error - -LAB_1212 - STA TempB ; save result in temp byte - TSX ; copy stack - CPX TempB ; compare new "limit" with stack - BCC LAB_OMER ; if stack < limit do "Out of memory" error then warm start - - RTS - -; check available memory, "Out of memory" error if no room -; addr to check is in AY (low/high) - -LAB_121F - CPY Sstorh ; compare bottom of string mem high byte - BCC LAB_124B ; if less then exit (is ok) - - BNE LAB_1229 ; skip next test if greater (tested <) - - ; high byte was =, now do low byte - CMP Sstorl ; compare with bottom of string mem low byte - BCC LAB_124B ; if less then exit (is ok) - - ; addr is > string storage ptr (oops!) -LAB_1229 - PHA ; push addr low byte - LDX #$08 ; set index to save Adatal to expneg inclusive - TYA ; copy addr high byte (to push on stack) - - ; save misc numeric work area -LAB_122D - PHA ; push byte - LDA Adatal-1,X ; get byte from Adatal to expneg ( ,$00 not pushed) - DEX ; decrement index - BPL LAB_122D ; loop until all done - - JSR LAB_GARB ; garbage collection routine - - ; restore misc numeric work area - LDX #$00 ; clear the index to restore bytes -LAB_1238 - PLA ; pop byte - STA Adatal,X ; save byte to Adatal to expneg - INX ; increment index - CPX #$08 ; compare with end + 1 - BMI LAB_1238 ; loop if more to do - - PLA ; pop addr high byte - TAY ; copy back to Y - PLA ; pop addr low byte - CPY Sstorh ; compare bottom of string mem high byte - BCC LAB_124B ; if less then exit (is ok) - - BNE LAB_OMER ; if greater do "Out of memory" error then warm start - - ; high byte was =, now do low byte - CMP Sstorl ; compare with bottom of string mem low byte - BCS LAB_OMER ; if >= do "Out of memory" error then warm start - - ; ok exit, carry clear -LAB_124B - RTS - -; do "Out of memory" error then warm start - -LAB_OMER - LDX #$0C ; error code $0C ("Out of memory" error) - -; do error #X, then warm start - -LAB_XERR - JSR LAB_CRLF ; print CR/LF - - LDA LAB_BAER,X ; get error message pointer low byte - LDY LAB_BAER+1,X ; get error message pointer high byte - JSR LAB_18C3 ; print null terminated string from memory - - JSR LAB_1491 ; flush stack and clear continue flag - LDA #LAB_EMSG ; point to " Error" high addr -LAB_1269 - JSR LAB_18C3 ; print null terminated string from memory - LDY Clineh ; get current line high byte - INY ; increment it - BEQ LAB_1274 ; go do warm start (was immediate mode) - - ; else print line number - JSR LAB_2953 ; print " in line [LINE #]" - -; BASIC warm start entry point -; wait for Basic command - -LAB_1274 - ; clear ON IRQ/NMI bytes - LDA #$00 ; clear A - STA IrqBase ; clear enabled byte - STA NmiBase ; clear enabled byte - LDA #LAB_RMSG ; point to "Ready" message high byte - - JSR LAB_18C3 ; go do print string - CLC - -; wait for Basic command (no "Ready") - -LAB_127D - JSR LAB_1357 ; call for BASIC input -LAB_1280 - STX Bpntrl ; set BASIC execute pointer low byte - STY Bpntrh ; set BASIC execute pointer high byte - JSR LAB_GBYT ; scan memory - BEQ LAB_127D ; loop while null - -; got to interpret input line now .. - - LDX #$FF ; current line to null value - STX Clineh ; set current line high byte - BCC LAB_1295 ; branch if numeric character (handle new BASIC line) - - ; no line number .. immediate mode - JSR LAB_13A6 ; crunch keywords into Basic tokens - JMP LAB_15F6 ; go scan and interpret code - -; handle new BASIC line - -LAB_1295 - JSR LAB_GFPN ; get fixed-point number into temp integer - JSR LAB_13A6 ; crunch keywords into Basic tokens - STY Ibptr ; save index pointer to end of crunched line - JSR LAB_SSLN ; search BASIC for temp integer line number - BCC LAB_12E6 ; branch if not found - - ; aroooogah! line # already exists! delete it - LDY #$01 ; set index to next line pointer high byte - LDA (Baslnl),Y ; get next line pointer high byte - STA ut1_ph ; save it - LDA Svarl ; get start of vars low byte - STA ut1_pl ; save it - LDA Baslnh ; get found line pointer high byte - STA ut2_ph ; save it - LDA Baslnl ; get found line pointer low byte - DEY ; decrement index - SBC (Baslnl),Y ; subtract next line pointer low byte - CLC ; clear carry for add - ADC Svarl ; add start of vars low byte - STA Svarl ; save new start of vars low byte - STA ut2_pl ; save destination pointer low byte - LDA Svarh ; get start of vars high byte - ADC #$FF ; -1 + carry - STA Svarh ; save start of vars high byte - SBC Baslnh ; subtract found line pointer high byte - TAX ; copy to block count - SEC ; set carry for subtract - LDA Baslnl ; get found line pointer low byte - SBC Svarl ; subtract start of vars low byte - TAY ; copy to bytes in first block count - BCS LAB_12D0 ; branch if overflow - - INX ; increment block count (correct for =0 loop exit) - DEC ut2_ph ; decrement destination high byte -LAB_12D0 - CLC ; clear carry for add - ADC ut1_pl ; add source pointer low byte - BCC LAB_12D8 ; branch if no overflow - - DEC ut1_ph ; else decrement source pointer high byte - CLC ; clear carry - - ; close up memory to delete old line -LAB_12D8 - LDA (ut1_pl),Y ; get byte from source - STA (ut2_pl),Y ; copy to destination - INY ; increment index - BNE LAB_12D8 ; while <> 0 do this block - - INC ut1_ph ; increment source pointer high byte - INC ut2_ph ; increment destination pointer high byte - DEX ; decrement block count - BNE LAB_12D8 ; loop until all done - - ; got new line in buffer and no existing same # -LAB_12E6 - LDA Ibuffs ; get byte from start of input buffer - BEQ LAB_1319 ; if null line just go flush stack/vars and exit - - ; got new line and it isn't empty line - LDA Ememl ; get end of mem low byte - LDY Ememh ; get end of mem high byte - STA Sstorl ; set bottom of string space low byte - STY Sstorh ; set bottom of string space high byte - LDA Svarl ; get start of vars low byte (end of BASIC) - STA Obendl ; save old block end low byte - LDY Svarh ; get start of vars high byte (end of BASIC) - STY Obendh ; save old block end high byte - ADC Ibptr ; add input buffer pointer (also buffer length) - BCC LAB_1301 ; branch if no overflow from add - - INY ; else increment high byte -LAB_1301 - STA Nbendl ; save new block end low byte (move to, low byte) - STY Nbendh ; save new block end high byte - JSR LAB_11CF ; open up space in memory - ; old start pointer Ostrtl,Ostrth set by the find line call - LDA Earryl ; get array mem end low byte - LDY Earryh ; get array mem end high byte - STA Svarl ; save start of vars low byte - STY Svarh ; save start of vars high byte - LDY Ibptr ; get input buffer pointer (also buffer length) - DEY ; adjust for loop type -LAB_1311 - LDA Ibuffs-4,Y ; get byte from crunched line - STA (Baslnl),Y ; save it to program memory - DEY ; decrement count - CPY #$03 ; compare with first byte-1 - BNE LAB_1311 ; continue while count <> 3 - - LDA Itemph ; get line # high byte - STA (Baslnl),Y ; save it to program memory - DEY ; decrement count - LDA Itempl ; get line # low byte - STA (Baslnl),Y ; save it to program memory - DEY ; decrement count - LDA #$FF ; set byte to allow chain rebuild. if you didn't set this - ; byte then a zero already here would stop the chain rebuild - ; as it would think it was the [EOT] marker. - STA (Baslnl),Y ; save it to program memory - -LAB_1319 - JSR LAB_1477 ; reset execution to start, clear vars and flush stack - LDX Smeml ; get start of mem low byte - LDA Smemh ; get start of mem high byte - LDY #$01 ; index to high byte of next line pointer -LAB_1325 - STX ut1_pl ; set line start pointer low byte - STA ut1_ph ; set line start pointer high byte - LDA (ut1_pl),Y ; get it - BEQ LAB_133E ; exit if end of program - -; rebuild chaining of Basic lines - - LDY #$04 ; point to first code byte of line - ; there is always 1 byte + [EOL] as null entries are deleted -LAB_1330 - INY ; next code byte - LDA (ut1_pl),Y ; get byte - BNE LAB_1330 ; loop if not [EOL] - - SEC ; set carry for add + 1 - TYA ; copy end index - ADC ut1_pl ; add to line start pointer low byte - TAX ; copy to X - LDY #$00 ; clear index, point to this line's next line pointer - STA (ut1_pl),Y ; set next line pointer low byte - TYA ; clear A - ADC ut1_ph ; add line start pointer high byte + carry - INY ; increment index to high byte - STA (ut1_pl),Y ; save next line pointer low byte - BCC LAB_1325 ; go do next line, branch always, carry clear - - -LAB_133E - JMP LAB_127D ; else we just wait for Basic command, no "Ready" - -; print "? " and get BASIC input - -LAB_INLN - JSR LAB_18E3 ; print "?" character - JSR LAB_18E0 ; print " " - BNE LAB_1357 ; call for BASIC input and return - -; receive line from keyboard - - ; $08 as delete key (BACKSPACE on standard keyboard) -LAB_134B - JSR LAB_PRNA ; go print the character - DEX ; decrement the buffer counter (delete) - .byte $2C ; make LDX into BIT abs - -; call for BASIC input (main entry point) - -LAB_1357 - LDX #$00 ; clear BASIC line buffer pointer -LAB_1359 - JSR V_INPT ; call scan input device - BCC LAB_1359 ; loop if no byte - - BEQ LAB_1359 ; loop until valid input (ignore NULLs) - - CMP #$07 ; compare with [BELL] - BEQ LAB_1378 ; branch if [BELL] - - CMP #$0D ; compare with [CR] - BEQ LAB_1384 ; do CR/LF exit if [CR] - - CPX #$00 ; compare pointer with $00 - BNE LAB_1374 ; branch if not empty - -; next two lines ignore any non print character and [SPACE] if input buffer empty - - CMP #$21 ; compare with [SP]+1 - BCC LAB_1359 ; if < ignore character - -LAB_1374 - CMP #$08 ; compare with [BACKSPACE] (delete last character) - BEQ LAB_134B ; go delete last character - -LAB_1378 - CPX #Ibuffe-Ibuffs ; compare character count with max - BCS LAB_138E ; skip store and do [BELL] if buffer full - - STA Ibuffs,X ; else store in buffer - INX ; increment pointer -LAB_137F - JSR LAB_PRNA ; go print the character - BNE LAB_1359 ; always loop for next character - -LAB_1384 - JMP LAB_1866 ; do CR/LF exit to BASIC - -; announce buffer full - -LAB_138E - LDA #$07 ; [BELL] character into A - BNE LAB_137F ; go print the [BELL] but ignore input character - ; branch always - -; crunch keywords into Basic tokens -; position independent buffer version .. -; faster, dictionary search version .... - -LAB_13A6 - LDY #$FF ; set save index (makes for easy math later) - - SEC ; set carry for subtract - LDA Bpntrl ; get basic execute pointer low byte - SBC #= go save byte then continue crunching - - CMP #'<' ; compare with "<" - BCS LAB_13CC ; if >= go crunch now - - CMP #'0' ; compare with "0" - BCS LAB_13EC ; if >= go save byte then continue crunching - - STA Scnquo ; save buffer byte as search character - CMP #$22 ; is it quote character? - BEQ LAB_1410 ; branch if so (copy quoted string) - - CMP #'*' ; compare with "*" - BCC LAB_13EC ; if < go save byte then continue crunching - - ; else crunch now -LAB_13CC - BIT Oquote ; get open quote/DATA token flag - BVS LAB_13EC ; branch if b6 of Oquote set (was DATA) - ; go save byte then continue crunching - - STX TempB ; save buffer read index - STY csidx ; copy buffer save index - LDY #TAB_1STC ; get keyword first character table high address - STY ut2_ph ; save pointer high byte - LDY #$00 ; clear table pointer - -LAB_13D0 - CMP (ut2_pl),Y ; compare with keyword first character table byte - BEQ LAB_13D1 ; go do word_table_chr if match - - BCC LAB_13EA ; if < keyword first character table byte go restore - ; Y and save to crunched - - INY ; else increment pointer - BNE LAB_13D0 ; and loop (branch always) - -; have matched first character of some keyword - -LAB_13D1 - TYA ; copy matching index - ASL ; *2 (bytes per pointer) - TAX ; copy to new index - LDA TAB_CHRT,X ; get keyword table pointer low byte - STA ut2_pl ; save pointer low byte - LDA TAB_CHRT+1,X ; get keyword table pointer high byte - STA ut2_ph ; save pointer high byte - - LDY #$FF ; clear table pointer (make -1 for start) - - LDX TempB ; restore buffer read index - -LAB_13D6 - INY ; next table byte - LDA (ut2_pl),Y ; get byte from table -LAB_13D8 - BMI LAB_13EA ; all bytes matched so go save token - - INX ; next buffer byte - CMP Ibuffs,X ; compare with byte from input buffer - BEQ LAB_13D6 ; go compare next if match - - BNE LAB_1417 ; branch if >< (not found keyword) - -LAB_13EA - LDY csidx ; restore save index - - ; save crunched to output -LAB_13EC - INX ; increment buffer index (to next input byte) - INY ; increment save index (to next output byte) - STA Ibuffs,Y ; save byte to output - CMP #$00 ; set the flags, set carry - BEQ LAB_142A ; do exit if was null [EOL] - - ; A holds token or byte here - SBC #':' ; subtract ":" (carry set by CMP #00) - BEQ LAB_13FF ; branch if it was ":" (is now $00) - - ; A now holds token-$3A - CMP #TK_DATA-$3A ; compare with DATA token - $3A - BNE LAB_1401 ; branch if not DATA - - ; token was : or DATA -LAB_13FF - STA Oquote ; save token-$3A (clear for ":", TK_DATA-$3A for DATA) -LAB_1401 - EOR #TK_REM-$3A ; effectively subtract REM token offset - BNE LAB_13AC ; If wasn't REM then go crunch rest of line - - STA Asrch ; else was REM so set search for [EOL] - - ; loop for REM, "..." etc. -LAB_1408 - LDA Ibuffs,X ; get byte from input buffer - BEQ LAB_13EC ; branch if null [EOL] - - CMP Asrch ; compare with stored character - BEQ LAB_13EC ; branch if match (end quote) - - ; entry for copy string in quotes, don't crunch -LAB_1410 - INY ; increment buffer save index - STA Ibuffs,Y ; save byte to output - INX ; increment buffer read index - BNE LAB_1408 ; loop while <> 0 (should never be 0!) - - ; not found keyword this go -LAB_1417 - LDX TempB ; compare has failed, restore buffer index (start byte!) - - ; now find the end of this word in the table -LAB_141B - LDA (ut2_pl),Y ; get table byte - PHP ; save status - INY ; increment table index - PLP ; restore byte status - BPL LAB_141B ; if not end of keyword go do next - - LDA (ut2_pl),Y ; get byte from keyword table - BNE LAB_13D8 ; go test next word if not zero byte (end of table) - - ; reached end of table with no match - LDA Ibuffs,X ; restore byte from input buffer - BPL LAB_13EA ; branch always (all bytes in buffer are $00-$7F) - ; go save byte in output and continue crunching - - ; reached [EOL] -LAB_142A - INY ; increment pointer - INY ; increment pointer (makes it next line pointer high byte) - STA Ibuffs,Y ; save [EOL] (marks [EOT] in immediate mode) - INY ; adjust for line copy - INY ; adjust for line copy - INY ; adjust for line copy - DEC Bpntrl ; allow for increment (change if buffer starts at $xxFF) - RTS - -; search Basic for temp integer line number from start of mem - -LAB_SSLN - LDA Smeml ; get start of mem low byte - LDX Smemh ; get start of mem high byte - -; search Basic for temp integer line number from AX -; returns carry set if found -; returns Baslnl/Baslnh pointer to found or next higher (not found) line - -; old 541 new 507 - -LAB_SHLN - LDY #$01 ; set index - STA Baslnl ; save low byte as current - STX Baslnh ; save high byte as current - LDA (Baslnl),Y ; get pointer high byte from addr - BEQ LAB_145F ; pointer was zero so we're done, do 'not found' exit - - LDY #$03 ; set index to line # high byte - LDA (Baslnl),Y ; get line # high byte - DEY ; decrement index (point to low byte) - CMP Itemph ; compare with temporary integer high byte - BNE LAB_1455 ; if <> skip low byte check - - LDA (Baslnl),Y ; get line # low byte - CMP Itempl ; compare with temporary integer low byte -LAB_1455 - BCS LAB_145E ; else if temp < this line, exit (passed line#) - -LAB_1456 - DEY ; decrement index to next line ptr high byte - LDA (Baslnl),Y ; get next line pointer high byte - TAX ; copy to X - DEY ; decrement index to next line ptr low byte - LDA (Baslnl),Y ; get next line pointer low byte - BCC LAB_SHLN ; go search for line # in temp (Itempl/Itemph) from AX - ; (carry always clear) - -LAB_145E - BEQ LAB_1460 ; exit if temp = found line #, carry is set - -LAB_145F - CLC ; clear found flag -LAB_1460 - RTS - -; perform NEW - -LAB_NEW - BNE LAB_1460 ; exit if not end of statement (to do syntax error) - -LAB_1463 - LDA #$00 ; clear A - TAY ; clear Y - STA (Smeml),Y ; clear first line, next line pointer, low byte - INY ; increment index - STA (Smeml),Y ; clear first line, next line pointer, high byte - CLC ; clear carry - LDA Smeml ; get start of mem low byte - ADC #$02 ; calculate end of BASIC low byte - STA Svarl ; save start of vars low byte - LDA Smemh ; get start of mem high byte - ADC #$00 ; add any carry - STA Svarh ; save start of vars high byte - -; reset execution to start, clear vars and flush stack - -LAB_1477 - CLC ; clear carry - LDA Smeml ; get start of mem low byte - ADC #$FF ; -1 - STA Bpntrl ; save BASIC execute pointer low byte - LDA Smemh ; get start of mem high byte - ADC #$FF ; -1+carry - STA Bpntrh ; save BASIC execute pointer high byte - -; "CLEAR" command gets here - -LAB_147A - LDA Ememl ; get end of mem low byte - LDY Ememh ; get end of mem high byte - STA Sstorl ; set bottom of string space low byte - STY Sstorh ; set bottom of string space high byte - LDA Svarl ; get start of vars low byte - LDY Svarh ; get start of vars high byte - STA Sarryl ; save var mem end low byte - STY Sarryh ; save var mem end high byte - STA Earryl ; save array mem end low byte - STY Earryh ; save array mem end high byte - JSR LAB_161A ; perform RESTORE command - -; flush stack and clear continue flag - -LAB_1491 - LDX #des_sk ; set descriptor stack pointer - STX next_s ; save descriptor stack pointer - PLA ; pull return address low byte - TAX ; copy return address low byte - PLA ; pull return address high byte - STX LAB_SKFE ; save to cleared stack - STA LAB_SKFF ; save to cleared stack - LDX #$FD ; new stack pointer - TXS ; reset stack - LDA #$00 ; clear byte - STA Cpntrh ; clear continue pointer high byte - STA Sufnxf ; clear subscript/FNX flag -LAB_14A6 - RTS - -; perform CLEAR - -LAB_CLEAR - BEQ LAB_147A ; if no following token go do "CLEAR" - - ; else there was a following token (go do syntax error) - RTS - -; perform LIST [n][-m] -; bigger, faster version (a _lot_ faster) - -LAB_LIST - BCC LAB_14BD ; branch if next character numeric (LIST n..) - - BEQ LAB_14BD ; branch if next character [NULL] (LIST) - - CMP #TK_MINUS ; compare with token for - - BNE LAB_14A6 ; exit if not - (LIST -m) - - ; LIST [[n][-m]] - ; this bit sets the n , if present, as the start and end -LAB_14BD - JSR LAB_GFPN ; get fixed-point number into temp integer - JSR LAB_SSLN ; search BASIC for temp integer line number - ; (pointer in Baslnl/Baslnh) - JSR LAB_GBYT ; scan memory - BEQ LAB_14D4 ; branch if no more characters - - ; this bit checks the - is present - CMP #TK_MINUS ; compare with token for - - BNE LAB_1460 ; return if not "-" (will be Syntax error) - - ; LIST [n]-m - ; the - was there so set m as the end value - JSR LAB_IGBY ; increment and scan memory - JSR LAB_GFPN ; get fixed-point number into temp integer - BNE LAB_1460 ; exit if not ok - -LAB_14D4 - LDA Itempl ; get temporary integer low byte - ORA Itemph ; OR temporary integer high byte - BNE LAB_14E2 ; branch if start set - - LDA #$FF ; set for -1 - STA Itempl ; set temporary integer low byte - STA Itemph ; set temporary integer high byte -LAB_14E2 - LDY #$01 ; set index for line - STY Oquote ; clear open quote flag - JSR LAB_CRLF ; print CR/LF - LDA (Baslnl),Y ; get next line pointer high byte - ; pointer initially set by search at LAB_14BD - BEQ LAB_152B ; if null all done so exit - JSR LAB_1629 ; do CRTL-C check vector - - INY ; increment index for line - LDA (Baslnl),Y ; get line # low byte - TAX ; copy to X - INY ; increment index - LDA (Baslnl),Y ; get line # high byte - CMP Itemph ; compare with temporary integer high byte - BNE LAB_14FF ; branch if no high byte match - - CPX Itempl ; compare with temporary integer low byte - BEQ LAB_1501 ; branch if = last line to do (< will pass next branch) - -LAB_14FF ; else .. - BCS LAB_152B ; if greater all done so exit - -LAB_1501 - STY Tidx1 ; save index for line - JSR LAB_295E ; print XA as unsigned integer - LDA #$20 ; space is the next character -LAB_1508 - LDY Tidx1 ; get index for line - AND #$7F ; mask top out bit of character -LAB_150C - JSR LAB_PRNA ; go print the character - CMP #$22 ; was it " character - BNE LAB_1519 ; branch if not - - ; we are either entering or leaving a pair of quotes - LDA Oquote ; get open quote flag - EOR #$FF ; toggle it - STA Oquote ; save it back -LAB_1519 - INY ; increment index - LDA (Baslnl),Y ; get next byte - BNE LAB_152E ; branch if not [EOL] (go print character) - TAY ; else clear index - LDA (Baslnl),Y ; get next line pointer low byte - TAX ; copy to X - INY ; increment index - LDA (Baslnl),Y ; get next line pointer high byte - STX Baslnl ; set pointer to line low byte - STA Baslnh ; set pointer to line high byte - BNE LAB_14E2 ; go do next line if not [EOT] - ; else .. -LAB_152B - RTS - -LAB_152E - BPL LAB_150C ; just go print it if not token byte - - ; else was token byte so uncrunch it (maybe) - BIT Oquote ; test the open quote flag - BMI LAB_150C ; just go print character if open quote set - - LDX #>LAB_KEYT ; get table address high byte - ASL ; *2 - ASL ; *4 - BCC LAB_152F ; branch if no carry - - INX ; else increment high byte - CLC ; clear carry for add -LAB_152F - ADC #LAB_159F ; set return address high byte - STA ut1_pl ; save return address low byte - STY ut1_ph ; save return address high byte - JMP LAB_1B66 ; round FAC1 and put on stack (returns to next instruction) - -LAB_159F - LDA #LAB_259C ; set 1 pointer high addr - JSR LAB_UFAC ; unpack memory (AY) into FAC1 - JSR LAB_GBYT ; scan memory - CMP #TK_STEP ; compare with STEP token - BNE LAB_15B3 ; jump if not "STEP" - - ;.was step so .. - JSR LAB_IGBY ; increment and scan memory - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch -LAB_15B3 - JSR LAB_27CA ; return A=FF,C=1/-ve A=01,C=0/+ve - STA FAC1_s ; set FAC1 sign (b7) - ; this is +1 for +ve step and -1 for -ve step, in NEXT we - ; compare the FOR value and the TO value and return +1 if - ; FOR > TO, 0 if FOR = TO and -1 if FOR < TO. the value - ; here (+/-1) is then compared to that result and if they - ; are the same (+ve and FOR > TO or -ve and FOR < TO) then - ; the loop is done - JSR LAB_1B5B ; push sign, round FAC1 and put on stack - LDA Frnxth ; get var pointer for FOR/NEXT high byte - PHA ; push on stack - LDA Frnxtl ; get var pointer for FOR/NEXT low byte - PHA ; push on stack - LDA #TK_FOR ; get FOR token - PHA ; push on stack - -; interpreter inner loop - -LAB_15C2 - JSR LAB_1629 ; do CRTL-C check vector - LDA Bpntrl ; get BASIC execute pointer low byte - LDY Bpntrh ; get BASIC execute pointer high byte - - LDX Clineh ; continue line is $FFxx for immediate mode - ; ($00xx for RUN from immediate mode) - INX ; increment it (now $00 if immediate mode) - BEQ LAB_15D1 ; branch if null (immediate mode) - - STA Cpntrl ; save continue pointer low byte - STY Cpntrh ; save continue pointer high byte -LAB_15D1 - LDY #$00 ; clear index - LDA (Bpntrl),Y ; get next byte - BEQ LAB_15DC ; branch if null [EOL] - - CMP #':' ; compare with ":" - BEQ LAB_15F6 ; branch if = (statement separator) - -LAB_15D9 - JMP LAB_SNER ; else syntax error then warm start - - ; have reached [EOL] -LAB_15DC - LDY #$02 ; set index - LDA (Bpntrl),Y ; get next line pointer high byte - CLC ; clear carry for no "BREAK" message - BEQ LAB_1651 ; if null go to immediate mode (was immediate or [EOT] - ; marker) - - INY ; increment index - LDA (Bpntrl),Y ; get line # low byte - STA Clinel ; save current line low byte - INY ; increment index - LDA (Bpntrl),Y ; get line # high byte - STA Clineh ; save current line high byte - TYA ; A now = 4 - ADC Bpntrl ; add BASIC execute pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - BCC LAB_15F6 ; branch if no overflow - - INC Bpntrh ; else increment BASIC execute pointer high byte -LAB_15F6 - JSR LAB_IGBY ; increment and scan memory - -LAB_15F9 - JSR LAB_15FF ; go interpret BASIC code from (Bpntrl) - -LAB_15FC - JMP LAB_15C2 ; loop - -; interpret BASIC code from (Bpntrl) - -LAB_15FF - BEQ LAB_1628 ; exit if zero [EOL] - -LAB_1602 - ASL ; *2 bytes per vector and normalise token - BCS LAB_1609 ; branch if was token - - JMP LAB_LET ; else go do implied LET - -LAB_1609 - CMP #[TK_TAB-$80]*2 ; compare normalised token * 2 with TAB - BCS LAB_15D9 ; branch if A>=TAB (do syntax error then warm start) - ; only tokens before TAB can start a line - TAY ; copy to index - LDA LAB_CTBL+1,Y ; get vector high byte - PHA ; onto stack - LDA LAB_CTBL,Y ; get vector low byte - PHA ; onto stack - JMP LAB_IGBY ; jump to increment and scan memory - ; then "return" to vector - -; CTRL-C check jump. this is called as a subroutine but exits back via a jump if a -; key press is detected. - -LAB_1629 - JMP (VEC_CC) ; ctrl c check vector - -; if there was a key press it gets back here .. - -LAB_1636 - CMP #$03 ; compare with CTRL-C - -; perform STOP - -LAB_STOP - BCS LAB_163B ; branch if token follows STOP - ; else just END -; END - -LAB_END - CLC ; clear the carry, indicate a normal program end -LAB_163B - BNE LAB_167A ; if wasn't CTRL-C or there is a following byte return - - LDA Bpntrh ; get the BASIC execute pointer high byte - EOR #>Ibuffs ; compare with buffer address high byte (Cb unchanged) - BEQ LAB_164F ; branch if the BASIC pointer is in the input buffer - ; (can't continue in immediate mode) - - ; else .. - EOR #>Ibuffs ; correct the bits - LDY Bpntrl ; get BASIC execute pointer low byte - STY Cpntrl ; save continue pointer low byte - STA Cpntrh ; save continue pointer high byte -LAB_1647 - LDA Clinel ; get current line low byte - LDY Clineh ; get current line high byte - STA Blinel ; save break line low byte - STY Blineh ; save break line high byte -LAB_164F - PLA ; pull return address low - PLA ; pull return address high -LAB_1651 - BCC LAB_165E ; if was program end just do warm start - - ; else .. - LDA #LAB_BMSG ; point to "Break" high byte - JMP LAB_1269 ; print "Break" and do warm start - -LAB_165E - JMP LAB_1274 ; go do warm start - -; perform RESTORE - -LAB_RESTORE - BNE LAB_RESTOREn ; branch if next character not null (RESTORE n) - -LAB_161A - SEC ; set carry for subtract - LDA Smeml ; get start of mem low byte - SBC #$01 ; -1 - LDY Smemh ; get start of mem high byte - BCS LAB_1624 ; branch if no underflow - -LAB_uflow - DEY ; else decrement high byte -LAB_1624 - STA Dptrl ; save DATA pointer low byte - STY Dptrh ; save DATA pointer high byte -LAB_1628 - RTS - - ; is RESTORE n -LAB_RESTOREn - JSR LAB_GFPN ; get fixed-point number into temp integer - JSR LAB_SNBL ; scan for next BASIC line - LDA Clineh ; get current line high byte - CMP Itemph ; compare with temporary integer high byte - BCS LAB_reset_search ; branch if >= (start search from beginning) - - TYA ; else copy line index to A - SEC ; set carry (+1) - ADC Bpntrl ; add BASIC execute pointer low byte - LDX Bpntrh ; get BASIC execute pointer high byte - BCC LAB_go_search ; branch if no overflow to high byte - - INX ; increment high byte - BCS LAB_go_search ; branch always (can never be carry clear) - -; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml) - -LAB_reset_search - LDA Smeml ; get start of mem low byte - LDX Smemh ; get start of mem high byte - -; search for line # in temp (Itempl/Itemph) from (AX) - -LAB_go_search - - JSR LAB_SHLN ; search Basic for temp integer line number from AX - BCS LAB_line_found ; if carry set go set pointer - - JMP LAB_16F7 ; else go do "Undefined statement" error - -LAB_line_found - ; carry already set for subtract - LDA Baslnl ; get pointer low byte - SBC #$01 ; -1 - LDY Baslnh ; get pointer high byte - BCS LAB_1624 ; branch if no underflow (save DATA pointer and return) - - BCC LAB_uflow ; else decrement high byte then save DATA pointer and - ; return (branch always) - -; perform NULL - -LAB_NULL - JSR LAB_GTBY ; get byte parameter - STX Nullct ; save new NULL count -LAB_167A - RTS - -; perform CONT - -LAB_CONT - BNE LAB_167A ; if following byte exit to do syntax error - - LDY Cpntrh ; get continue pointer high byte - BNE LAB_166C ; go do continue if we can - - LDX #$1E ; error code $1E ("Can't continue" error) - JMP LAB_XERR ; do error #X, then warm start - - ; we can continue so .. -LAB_166C - LDA #TK_ON ; set token for ON - JSR LAB_IRQ ; set IRQ flags - LDA #TK_ON ; set token for ON - JSR LAB_NMI ; set NMI flags - - STY Bpntrh ; save BASIC execute pointer high byte - LDA Cpntrl ; get continue pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - LDA Blinel ; get break line low byte - LDY Blineh ; get break line high byte - STA Clinel ; set current line low byte - STY Clineh ; set current line high byte - RTS - -; perform RUN - -LAB_RUN - BNE LAB_1696 ; branch if RUN n - JMP LAB_1477 ; reset execution to start, clear variables, flush stack and - ; return - -; does RUN n - -LAB_1696 - JSR LAB_147A ; go do "CLEAR" - BEQ LAB_16B0 ; get n and do GOTO n (branch always as CLEAR sets Z=1) - -; perform DO - -LAB_DO - LDA #$05 ; need 5 bytes for DO - JSR LAB_1212 ; check room on stack for A bytes - LDA Bpntrh ; get BASIC execute pointer high byte - PHA ; push on stack - LDA Bpntrl ; get BASIC execute pointer low byte - PHA ; push on stack - LDA Clineh ; get current line high byte - PHA ; push on stack - LDA Clinel ; get current line low byte - PHA ; push on stack - LDA #TK_DO ; token for DO - PHA ; push on stack - JSR LAB_GBYT ; scan memory - JMP LAB_15C2 ; go do interpreter inner loop - -; perform GOSUB - -LAB_GOSUB - LDA #$05 ; need 5 bytes for GOSUB - JSR LAB_1212 ; check room on stack for A bytes - LDA Bpntrh ; get BASIC execute pointer high byte - PHA ; push on stack - LDA Bpntrl ; get BASIC execute pointer low byte - PHA ; push on stack - LDA Clineh ; get current line high byte - PHA ; push on stack - LDA Clinel ; get current line low byte - PHA ; push on stack - LDA #TK_GOSUB ; token for GOSUB - PHA ; push on stack -LAB_16B0 - JSR LAB_GBYT ; scan memory - JSR LAB_GOTO ; perform GOTO n - JMP LAB_15C2 ; go do interpreter inner loop - ; (can't RTS, we used the stack!) - -; perform GOTO - -LAB_GOTO - JSR LAB_GFPN ; get fixed-point number into temp integer - JSR LAB_SNBL ; scan for next BASIC line - LDA Clineh ; get current line high byte - CMP Itemph ; compare with temporary integer high byte - BCS LAB_16D0 ; branch if >= (start search from beginning) - - TYA ; else copy line index to A - SEC ; set carry (+1) - ADC Bpntrl ; add BASIC execute pointer low byte - LDX Bpntrh ; get BASIC execute pointer high byte - BCC LAB_16D4 ; branch if no overflow to high byte - - INX ; increment high byte - BCS LAB_16D4 ; branch always (can never be carry) - -; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml) - -LAB_16D0 - LDA Smeml ; get start of mem low byte - LDX Smemh ; get start of mem high byte - -; search for line # in temp (Itempl/Itemph) from (AX) - -LAB_16D4 - JSR LAB_SHLN ; search Basic for temp integer line number from AX - BCC LAB_16F7 ; if carry clear go do "Undefined statement" error - ; (unspecified statement) - - ; carry already set for subtract - LDA Baslnl ; get pointer low byte - SBC #$01 ; -1 - STA Bpntrl ; save BASIC execute pointer low byte - LDA Baslnh ; get pointer high byte - SBC #$00 ; subtract carry - STA Bpntrh ; save BASIC execute pointer high byte -LAB_16E5 - RTS - -LAB_DONOK - LDX #$22 ; error code $22 ("LOOP without DO" error) - JMP LAB_XERR ; do error #X, then warm start - -; perform LOOP - -LAB_LOOP - TAY ; save following token - TSX ; copy stack pointer - LDA LAB_STAK+3,X ; get token byte from stack - CMP #TK_DO ; compare with DO token - BNE LAB_DONOK ; branch if no matching DO - - INX ; dump calling routine return address - INX ; dump calling routine return address - TXS ; correct stack - TYA ; get saved following token back - BEQ LoopAlways ; if no following token loop forever - ; (stack pointer in X) - - CMP #':' ; could be ':' - BEQ LoopAlways ; if :... loop forever - - SBC #TK_UNTIL ; subtract token for UNTIL, we know carry is set here - TAX ; copy to X (if it was UNTIL then Y will be correct) - BEQ DoRest ; branch if was UNTIL - - DEX ; decrement result - BNE LAB_16FC ; if not WHILE go do syntax error and warm start - ; only if the token was WHILE will this fail - - DEX ; set invert result byte -DoRest - STX Frnxth ; save invert result byte - JSR LAB_IGBY ; increment and scan memory - JSR LAB_EVEX ; evaluate expression - LDA FAC1_e ; get FAC1 exponent - BEQ DoCmp ; if =0 go do straight compare - - LDA #$FF ; else set all bits -DoCmp - TSX ; copy stack pointer - EOR Frnxth ; EOR with invert byte - BNE LoopDone ; if <> 0 clear stack and back to interpreter loop - - ; loop condition wasn't met so do it again -LoopAlways - LDA LAB_STAK+2,X ; get current line low byte - STA Clinel ; save current line low byte - LDA LAB_STAK+3,X ; get current line high byte - STA Clineh ; save current line high byte - LDA LAB_STAK+4,X ; get BASIC execute pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - LDA LAB_STAK+5,X ; get BASIC execute pointer high byte - STA Bpntrh ; save BASIC execute pointer high byte - JSR LAB_GBYT ; scan memory - JMP LAB_15C2 ; go do interpreter inner loop - - ; clear stack and back to interpreter loop -LoopDone - INX ; dump DO token - INX ; dump current line low byte - INX ; dump current line high byte - INX ; dump BASIC execute pointer low byte - INX ; dump BASIC execute pointer high byte - TXS ; correct stack - JMP LAB_DATA ; go perform DATA (find : or [EOL]) - -; do the return without gosub error - -LAB_16F4 - LDX #$04 ; error code $04 ("RETURN without GOSUB" error) - .byte $2C ; makes next line BIT LAB_0EA2 - -LAB_16F7 ; do undefined statement error - LDX #$0E ; error code $0E ("Undefined statement" error) - JMP LAB_XERR ; do error #X, then warm start - -; perform RETURN - -LAB_RETURN - BNE LAB_16E5 ; exit if following token (to allow syntax error) - -LAB_16E8 - PLA ; dump calling routine return address - PLA ; dump calling routine return address - PLA ; pull token - CMP #TK_GOSUB ; compare with GOSUB token - BNE LAB_16F4 ; branch if no matching GOSUB - -LAB_16FF - PLA ; pull current line low byte - STA Clinel ; save current line low byte - PLA ; pull current line high byte - STA Clineh ; save current line high byte - PLA ; pull BASIC execute pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - PLA ; pull BASIC execute pointer high byte - STA Bpntrh ; save BASIC execute pointer high byte - - ; now do the DATA statement as we could be returning into - ; the middle of an ON GOSUB n,m,p,q line - ; (the return address used by the DATA statement is the one - ; pushed before the GOSUB was executed!) - -; perform DATA - -LAB_DATA - JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL]) - - ; set BASIC execute pointer -LAB_170F - TYA ; copy index to A - CLC ; clear carry for add - ADC Bpntrl ; add BASIC execute pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - BCC LAB_1719 ; skip next if no carry - - INC Bpntrh ; else increment BASIC execute pointer high byte -LAB_1719 - RTS - -LAB_16FC - JMP LAB_SNER ; do syntax error then warm start - -; scan for next BASIC statement ([:] or [EOL]) -; returns Y as index to [:] or [EOL] - -LAB_SNBS - LDX #':' ; set look for character = ":" - .byte $2C ; makes next line BIT $00A2 - -; scan for next BASIC line -; returns Y as index to [EOL] - -LAB_SNBL - LDX #$00 ; set alt search character = [EOL] - LDY #$00 ; set search character = [EOL] - STY Asrch ; store search character -LAB_1725 - TXA ; get alt search character - EOR Asrch ; toggle search character, effectively swap with $00 - STA Asrch ; save swapped search character -LAB_172D - LDA (Bpntrl),Y ; get next byte - BEQ LAB_1719 ; exit if null [EOL] - - CMP Asrch ; compare with search character - BEQ LAB_1719 ; exit if found - - INY ; increment index - CMP #$22 ; compare current character with open quote - BNE LAB_172D ; if not open quote go get next character - - BEQ LAB_1725 ; if found go swap search character for alt search character - -; perform IF - -LAB_IF - JSR LAB_EVEX ; evaluate the expression - JSR LAB_GBYT ; scan memory - CMP #TK_THEN ; compare with THEN token - BEQ LAB_174B ; if it was THEN go do IF - - ; wasn't IF .. THEN so must be IF .. GOTO - CMP #TK_GOTO ; compare with GOTO token - BNE LAB_16FC ; if it wasn't GOTO go do syntax error - - LDX Bpntrl ; save the basic pointer low byte - LDY Bpntrh ; save the basic pointer high byte - JSR LAB_IGBY ; increment and scan memory - BCS LAB_16FC ; if not numeric go do syntax error - - STX Bpntrl ; restore the basic pointer low byte - STY Bpntrh ; restore the basic pointer high byte -LAB_174B - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_174E ; if the result was zero go look for an ELSE - - JSR LAB_IGBY ; else increment and scan memory - BCS LAB_174D ; if not numeric go do var or keyword - -LAB_174C - JMP LAB_GOTO ; else was numeric so do GOTO n - - ; is var or keyword -LAB_174D - CMP #TK_RETURN ; compare the byte with the token for RETURN - BNE LAB_174G ; if it wasn't RETURN go interpret BASIC code from (Bpntrl) - ; and return to this code to process any following code - - JMP LAB_1602 ; else it was RETURN so interpret BASIC code from (Bpntrl) - ; but don't return here - -LAB_174G - JSR LAB_15FF ; interpret BASIC code from (Bpntrl) - -; the IF was executed and there may be a following ELSE so the code needs to return -; here to check and ignore the ELSE if present - - LDY #$00 ; clear the index - LDA (Bpntrl),Y ; get the next BASIC byte - CMP #TK_ELSE ; compare it with the token for ELSE - BEQ LAB_DATA ; if ELSE ignore the following statement - -; there was no ELSE so continue execution of IF THEN [: ]. any -; following ELSE will, correctly, cause a syntax error - - RTS ; else return to the interpreter inner loop - -; perform ELSE after IF - -LAB_174E - LDY #$00 ; clear the BASIC byte index - LDX #$01 ; clear the nesting depth -LAB_1750 - INY ; increment the BASIC byte index - LDA (Bpntrl),Y ; get the next BASIC byte - BEQ LAB_1753 ; if EOL go add the pointer and return - - CMP #TK_IF ; compare the byte with the token for IF - BNE LAB_1752 ; if not IF token skip the depth increment - - INX ; else increment the nesting depth .. - BNE LAB_1750 ; .. and continue looking - -LAB_1752 - CMP #TK_ELSE ; compare the byte with the token for ELSE - BNE LAB_1750 ; if not ELSE token continue looking - - DEX ; was ELSE so decrement the nesting depth - BNE LAB_1750 ; loop if still nested - - INY ; increment the BASIC byte index past the ELSE - -; found the matching ELSE, now do <{n|statement}> - -LAB_1753 - TYA ; else copy line index to A - CLC ; clear carry for add - ADC Bpntrl ; add the BASIC execute pointer low byte - STA Bpntrl ; save the BASIC execute pointer low byte - BCC LAB_1754 ; branch if no overflow to high byte - - INC Bpntrh ; else increment the BASIC execute pointer high byte -LAB_1754 - JSR LAB_GBYT ; scan memory - BCC LAB_174C ; if numeric do GOTO n - ; the code will return to the interpreter loop at the - ; tail end of the GOTO - - JMP LAB_15FF ; interpret BASIC code from (Bpntrl) - ; the code will return to the interpreter loop at the - ; tail end of the - -; perform REM, skip (rest of) line - -LAB_REM - JSR LAB_SNBL ; scan for next BASIC line - JMP LAB_170F ; go set BASIC execute pointer and return, branch always - -LAB_16FD - JMP LAB_SNER ; do syntax error then warm start - -; perform ON - -LAB_ON - CMP #TK_IRQ ; was it IRQ token ? - BNE LAB_NOIN ; if not go check NMI - - JMP LAB_SIRQ ; else go set-up IRQ - -LAB_NOIN - CMP #TK_NMI ; was it NMI token ? - BNE LAB_NONM ; if not go do normal ON command - - JMP LAB_SNMI ; else go set-up NMI - -LAB_NONM - JSR LAB_GTBY ; get byte parameter - PHA ; push GOTO/GOSUB token - CMP #TK_GOSUB ; compare with GOSUB token - BEQ LAB_176B ; branch if GOSUB - - CMP #TK_GOTO ; compare with GOTO token -LAB_1767 - BNE LAB_16FD ; if not GOTO do syntax error then warm start - - -; next character was GOTO or GOSUB - -LAB_176B - DEC FAC1_3 ; decrement index (byte value) - BNE LAB_1773 ; branch if not zero - - PLA ; pull GOTO/GOSUB token - JMP LAB_1602 ; go execute it - -LAB_1773 - JSR LAB_IGBY ; increment and scan memory - JSR LAB_GFPN ; get fixed-point number into temp integer (skip this n) - ; (we could LDX #',' and JSR LAB_SNBL+2, then we - ; just BNE LAB_176B for the loop. should be quicker .. - ; no we can't, what if we meet a colon or [EOL]?) - CMP #$2C ; compare next character with "," - BEQ LAB_176B ; loop if "," - -LAB_177E - PLA ; else pull keyword token (run out of options) - ; also dump +/-1 pointer low byte and exit -LAB_177F - RTS - -; takes n * 106 + 11 cycles where n is the number of digits - -; get fixed-point number into temp integer - -LAB_GFPN - LDX #$00 ; clear reg - STX Itempl ; clear temporary integer low byte -LAB_1785 - STX Itemph ; save temporary integer high byte - BCS LAB_177F ; return if carry set, end of scan, character was - ; not 0-9 - - CPX #$19 ; compare high byte with $19 - TAY ; ensure Zb = 0 if the branch is taken - BCS LAB_1767 ; branch if >=, makes max line # 63999 because next - ; bit does *$0A, = 64000, compare at target will fail - ; and do syntax error - - SBC #'0'-1 ; subtract "0", $2F + carry, from byte - TAY ; copy binary digit - LDA Itempl ; get temporary integer low byte - ASL ; *2 low byte - ROL Itemph ; *2 high byte - ASL ; *2 low byte - ROL Itemph ; *2 high byte, *4 - ADC Itempl ; + low byte, *5 - STA Itempl ; save it - TXA ; get high byte copy to A - ADC Itemph ; + high byte, *5 - ASL Itempl ; *2 low byte, *10d - ROL ; *2 high byte, *10d - TAX ; copy high byte back to X - TYA ; get binary digit back - ADC Itempl ; add number low byte - STA Itempl ; save number low byte - BCC LAB_17B3 ; if no overflow to high byte get next character - - INX ; else increment high byte -LAB_17B3 - JSR LAB_IGBY ; increment and scan memory - JMP LAB_1785 ; loop for next character - -; perform DEC - -LAB_DEC - LDA #LAB_259C ; set +/-1 pointer high byte (both the same) - JSR LAB_246C ; add (AY) to FAC1 - JSR LAB_PFAC ; pack FAC1 into variable (Lvarpl) - - JSR LAB_GBYT ; scan memory - CMP #',' ; compare with "," - BNE LAB_177E ; exit if not "," (either end or error) - - ; was "," so another INCR variable to do - JSR LAB_IGBY ; increment and scan memory - JMP LAB_17B7 ; go do next var - -IncrErr - JMP LAB_1ABC ; do "Type mismatch" error then warm start - -; perform LET - -LAB_LET - JSR LAB_GVAR ; get var address - STA Lvarpl ; save var address low byte - STY Lvarph ; save var address high byte - LDA #TK_EQUAL ; get = token - JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start - LDA Dtypef ; get data type flag, $FF=string, $00=numeric - PHA ; push data type flag - JSR LAB_EVEX ; evaluate expression - PLA ; pop data type flag - ROL ; set carry if type = string - JSR LAB_CKTM ; type match check, set C for string - BNE LAB_17D5 ; branch if string - - JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return - -; string LET - -LAB_17D5 - LDY #$02 ; set index to pointer high byte - LDA (des_pl),Y ; get string pointer high byte - CMP Sstorh ; compare bottom of string space high byte - BCC LAB_17F4 ; if less assign value and exit (was in program memory) - - BNE LAB_17E6 ; branch if > - ; else was equal so compare low bytes - DEY ; decrement index - LDA (des_pl),Y ; get pointer low byte - CMP Sstorl ; compare bottom of string space low byte - BCC LAB_17F4 ; if less assign value and exit (was in program memory) - - ; pointer was >= to bottom of string space pointer -LAB_17E6 - LDY des_ph ; get descriptor pointer high byte - CPY Svarh ; compare start of vars high byte - BCC LAB_17F4 ; branch if less (descriptor is on stack) - - BNE LAB_17FB ; branch if greater (descriptor is not on stack) - - ; else high bytes were equal so .. - LDA des_pl ; get descriptor pointer low byte - CMP Svarl ; compare start of vars low byte - BCS LAB_17FB ; branch if >= (descriptor is not on stack) - -LAB_17F4 - LDA des_pl ; get descriptor pointer low byte - LDY des_ph ; get descriptor pointer high byte - JMP LAB_1811 ; clean stack, copy descriptor to variable and return - - ; make space and copy string -LAB_17FB - LDY #$00 ; index to length - LDA (des_pl),Y ; get string length - JSR LAB_209C ; copy string - LDA des_2l ; get descriptor pointer low byte - LDY des_2h ; get descriptor pointer high byte - STA ssptr_l ; save descriptor pointer low byte - STY ssptr_h ; save descriptor pointer high byte - JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill) - LDA #FAC1_e ; get descriptor pointer high byte - - ; clean stack and assign value to string variable -LAB_1811 - STA des_2l ; save descriptor_2 pointer low byte - STY des_2h ; save descriptor_2 pointer high byte - JSR LAB_22EB ; clean descriptor stack, YA = pointer - LDY #$00 ; index to length - LDA (des_2l),Y ; get string length - STA (Lvarpl),Y ; copy to let string variable - INY ; index to string pointer low byte - LDA (des_2l),Y ; get string pointer low byte - STA (Lvarpl),Y ; copy to let string variable - INY ; index to string pointer high byte - LDA (des_2l),Y ; get string pointer high byte - STA (Lvarpl),Y ; copy to let string variable - RTS - -; perform GET - -LAB_GET - JSR LAB_GVAR ; get var address - STA Lvarpl ; save var address low byte - STY Lvarph ; save var address high byte - JSR INGET ; get input byte - LDX Dtypef ; get data type flag, $FF=string, $00=numeric - BMI LAB_GETS ; go get string character - - ; was numeric get - TAY ; copy character to Y - JSR LAB_1FD0 ; convert Y to byte in FAC1 - JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return - -LAB_GETS - PHA ; save character - LDA #$01 ; string is single byte - BCS LAB_IsByte ; branch if byte received - - PLA ; string is null -LAB_IsByte - JSR LAB_MSSP ; make string space A bytes long A=$AC=length, - ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte - BEQ LAB_NoSt ; skip store if null string - - PLA ; get character back - LDY #$00 ; clear index - STA (str_pl),Y ; save byte in string (byte IS string!) -LAB_NoSt - JSR LAB_RTST ; check for space on descriptor stack then put address - ; and length on descriptor stack and update stack pointers - - JMP LAB_17D5 ; do string LET and return - -; perform PRINT - -LAB_1829 - JSR LAB_18C6 ; print string from Sutill/Sutilh -LAB_182C - JSR LAB_GBYT ; scan memory - -; PRINT - -LAB_PRINT - BEQ LAB_CRLF ; if nothing following just print CR/LF - -LAB_1831 - CMP #TK_TAB ; compare with TAB( token - BEQ LAB_18A2 ; go do TAB/SPC - - CMP #TK_SPC ; compare with SPC( token - BEQ LAB_18A2 ; go do TAB/SPC - - CMP #',' ; compare with "," - BEQ LAB_188B ; go do move to next TAB mark - - CMP #';' ; compare with ";" - BEQ LAB_18BD ; if ";" continue with PRINT processing - - JSR LAB_EVEX ; evaluate expression - BIT Dtypef ; test data type flag, $FF=string, $00=numeric - BMI LAB_1829 ; branch if string - - JSR LAB_296E ; convert FAC1 to string - JSR LAB_20AE ; print " terminated string to Sutill/Sutilh - LDY #$00 ; clear index - -; don't check fit if terminal width byte is zero - - LDA TWidth ; get terminal width byte - BEQ LAB_185E ; skip check if zero - - SEC ; set carry for subtract - SBC TPos ; subtract terminal position - SBC (des_pl),Y ; subtract string length - BCS LAB_185E ; branch if less than terminal width - - JSR LAB_CRLF ; else print CR/LF -LAB_185E - JSR LAB_18C6 ; print string from Sutill/Sutilh - BEQ LAB_182C ; always go continue processing line - -; CR/LF return to BASIC from BASIC input handler - -LAB_1866 - LDA #$00 ; clear byte - STA Ibuffs,X ; null terminate input - LDX #Ibuffs ; set Y to buffer start-1 high byte - -; print CR/LF - -LAB_CRLF - LDA #$0D ; load [CR] - JSR LAB_PRNA ; go print the character - LDA #$0A ; load [LF] - BNE LAB_PRNA ; go print the character and return, branch always - -LAB_188B - LDA TPos ; get terminal position - CMP Iclim ; compare with input column limit - BCC LAB_1897 ; branch if less - - JSR LAB_CRLF ; else print CR/LF (next line) - BNE LAB_18BD ; continue with PRINT processing (branch always) - -LAB_1897 - SEC ; set carry for subtract -LAB_1898 - SBC TabSiz ; subtract TAB size - BCS LAB_1898 ; loop if result was +ve - - EOR #$FF ; complement it - ADC #$01 ; +1 (twos complement) - BNE LAB_18B6 ; always print A spaces (result is never $00) - - ; do TAB/SPC -LAB_18A2 - PHA ; save token - JSR LAB_SGBY ; scan and get byte parameter - CMP #$29 ; is next character ) - BNE LAB_1910 ; if not do syntax error then warm start - - PLA ; get token back - CMP #TK_TAB ; was it TAB ? - BNE LAB_18B7 ; if not go do SPC - - ; calculate TAB offset - TXA ; copy integer value to A - SBC TPos ; subtract terminal position - BCC LAB_18BD ; branch if result was < 0 (can't TAB backwards) - - ; print A spaces -LAB_18B6 - TAX ; copy result to X -LAB_18B7 - TXA ; set flags on size for SPC - BEQ LAB_18BD ; branch if result was = $0, already here - - ; print X spaces -LAB_18BA - JSR LAB_18E0 ; print " " - DEX ; decrement count - BNE LAB_18BA ; loop if not all done - - ; continue with PRINT processing -LAB_18BD - JSR LAB_IGBY ; increment and scan memory - BNE LAB_1831 ; if more to print go do it - - RTS - -; print null terminated string from memory - -LAB_18C3 - JSR LAB_20AE ; print " terminated string to Sutill/Sutilh - -; print string from Sutill/Sutilh - -LAB_18C6 - JSR LAB_22B6 ; pop string off descriptor stack, or from top of string - ; space returns with A = length, X=$71=pointer low byte, - ; Y=$72=pointer high byte - LDY #$00 ; reset index - TAX ; copy length to X - BEQ LAB_188C ; exit (RTS) if null string - -LAB_18CD - - LDA (ut1_pl),Y ; get next byte - JSR LAB_PRNA ; go print the character - INY ; increment index - DEX ; decrement count - BNE LAB_18CD ; loop if not done yet - - RTS - - ; Print single format character -; print " " - -LAB_18E0 - LDA #$20 ; load " " - .byte $2C ; change next line to BIT LAB_3FA9 - -; print "?" character - -LAB_18E3 - LDA #$3F ; load "?" character - -; print character in A -; now includes the null handler -; also includes infinite line length code -; note! some routines expect this one to exit with Zb=0 - -LAB_PRNA - CMP #' ' ; compare with " " - BCC LAB_18F9 ; branch if less (non printing) - - ; else printable character - PHA ; save the character - -; don't check fit if terminal width byte is zero - - LDA TWidth ; get terminal width - BNE LAB_18F0 ; branch if not zero (not infinite length) - -; is "infinite line" so check TAB position - - LDA TPos ; get position - SBC TabSiz ; subtract TAB size, carry set by CMP #$20 above - BNE LAB_18F7 ; skip reset if different - - STA TPos ; else reset position - BEQ LAB_18F7 ; go print character - -LAB_18F0 - CMP TPos ; compare with terminal character position - BNE LAB_18F7 ; branch if not at end of line - - JSR LAB_CRLF ; else print CR/LF -LAB_18F7 - INC TPos ; increment terminal position - PLA ; get character back -LAB_18F9 - JSR V_OUTP ; output byte via output vector - CMP #$0D ; compare with [CR] - BNE LAB_188A ; branch if not [CR] - - ; else print nullct nulls after the [CR] - STX TempB ; save buffer index - LDX Nullct ; get null count - BEQ LAB_1886 ; branch if no nulls - - LDA #$00 ; load [NULL] -LAB_1880 - JSR LAB_PRNA ; go print the character - DEX ; decrement count - BNE LAB_1880 ; loop if not all done - - LDA #$0D ; restore the character (and set the flags) -LAB_1886 - STX TPos ; clear terminal position (X always = zero when we get here) - LDX TempB ; restore buffer index -LAB_188A - AND #$FF ; set the flags -LAB_188C - RTS - -; handle bad input data - -LAB_1904 - LDA Imode ; get input mode flag, $00=INPUT, $00=READ - BPL LAB_1913 ; branch if INPUT (go do redo) - - LDA Dlinel ; get current DATA line low byte - LDY Dlineh ; get current DATA line high byte - STA Clinel ; save current line low byte - STY Clineh ; save current line high byte -LAB_1910 - JMP LAB_SNER ; do syntax error then warm start - - ; mode was INPUT -LAB_1913 - LDA #LAB_REDO ; point to redo message (high addr) - JSR LAB_18C3 ; print null terminated string from memory - LDA Cpntrl ; get continue pointer low byte - LDY Cpntrh ; get continue pointer high byte - STA Bpntrl ; save BASIC execute pointer low byte - STY Bpntrh ; save BASIC execute pointer high byte - RTS - -; perform INPUT - -LAB_INPUT - CMP #$22 ; compare next byte with open quote - BNE LAB_1934 ; branch if no prompt string - - JSR LAB_1BC1 ; print "..." string - LDA #$3B ; load A with ";" - JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start - JSR LAB_18C6 ; print string from Sutill/Sutilh - - ; done with prompt, now get data -LAB_1934 - JSR LAB_CKRN ; check not Direct, back here if ok - JSR LAB_INLN ; print "? " and get BASIC input - LDA #$00 ; set mode = INPUT - CMP Ibuffs ; test first byte in buffer - BNE LAB_1953 ; branch if not null input - - CLC ; was null input so clear carry to exit program - JMP LAB_1647 ; go do BREAK exit - -; perform READ - -LAB_READ - LDX Dptrl ; get DATA pointer low byte - LDY Dptrh ; get DATA pointer high byte - LDA #$80 ; set mode = READ - -LAB_1953 - STA Imode ; set input mode flag, $00=INPUT, $80=READ - STX Rdptrl ; save READ pointer low byte - STY Rdptrh ; save READ pointer high byte - - ; READ or INPUT next variable from list -LAB_195B - JSR LAB_GVAR ; get (var) address - STA Lvarpl ; save address low byte - STY Lvarph ; save address high byte - LDA Bpntrl ; get BASIC execute pointer low byte - LDY Bpntrh ; get BASIC execute pointer high byte - STA Itempl ; save as temporary integer low byte - STY Itemph ; save as temporary integer high byte - LDX Rdptrl ; get READ pointer low byte - LDY Rdptrh ; get READ pointer high byte - STX Bpntrl ; set BASIC execute pointer low byte - STY Bpntrh ; set BASIC execute pointer high byte - JSR LAB_GBYT ; scan memory - BNE LAB_1988 ; branch if not null - - ; pointer was to null entry - BIT Imode ; test input mode flag, $00=INPUT, $80=READ - BMI LAB_19DD ; branch if READ - - ; mode was INPUT - JSR LAB_18E3 ; print "?" character (double ? for extended input) - JSR LAB_INLN ; print "? " and get BASIC input - STX Bpntrl ; set BASIC execute pointer low byte - STY Bpntrh ; set BASIC execute pointer high byte -LAB_1985 - JSR LAB_GBYT ; scan memory -LAB_1988 - BIT Dtypef ; test data type flag, $FF=string, $00=numeric - BPL LAB_19B0 ; branch if numeric - - ; else get string - STA Srchc ; save search character - CMP #$22 ; was it " ? - BEQ LAB_1999 ; branch if so - - LDA #':' ; else search character is ":" - STA Srchc ; set new search character - LDA #',' ; other search character is "," - CLC ; clear carry for add -LAB_1999 - STA Asrch ; set second search character - LDA Bpntrl ; get BASIC execute pointer low byte - LDY Bpntrh ; get BASIC execute pointer high byte - - ADC #$00 ; c is =1 if we came via the BEQ LAB_1999, else =0 - BCC LAB_19A4 ; branch if no execute pointer low byte rollover - - INY ; else increment high byte -LAB_19A4 - JSR LAB_20B4 ; print Srchc or Asrch terminated string to Sutill/Sutilh - JSR LAB_23F3 ; restore BASIC execute pointer from temp (Btmpl/Btmph) - JSR LAB_17D5 ; go do string LET - JMP LAB_19B6 ; go check string terminator - - ; get numeric INPUT -LAB_19B0 - JSR LAB_2887 ; get FAC1 from string - JSR LAB_PFAC ; pack FAC1 into (Lvarpl) -LAB_19B6 - JSR LAB_GBYT ; scan memory - BEQ LAB_19C5 ; branch if null (last entry) - - CMP #',' ; else compare with "," - BEQ LAB_19C2 ; branch if "," - - JMP LAB_1904 ; else go handle bad input data - - ; got good input data -LAB_19C2 - JSR LAB_IGBY ; increment and scan memory -LAB_19C5 - LDA Bpntrl ; get BASIC execute pointer low byte (temp READ/INPUT ptr) - LDY Bpntrh ; get BASIC execute pointer high byte (temp READ/INPUT ptr) - STA Rdptrl ; save for now - STY Rdptrh ; save for now - LDA Itempl ; get temporary integer low byte (temp BASIC execute ptr) - LDY Itemph ; get temporary integer high byte (temp BASIC execute ptr) - STA Bpntrl ; set BASIC execute pointer low byte - STY Bpntrh ; set BASIC execute pointer high byte - JSR LAB_GBYT ; scan memory - BEQ LAB_1A03 ; if null go do extra ignored message - - JSR LAB_1C01 ; else scan for "," , else do syntax error then warm start - JMP LAB_195B ; go INPUT next variable from list - - ; find next DATA statement or do "Out of DATA" error -LAB_19DD - JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL]) - INY ; increment index - TAX ; copy character ([:] or [EOL]) - BNE LAB_19F6 ; branch if [:] - - LDX #$06 ; set for "Out of DATA" error - INY ; increment index, now points to next line pointer high byte - LDA (Bpntrl),Y ; get next line pointer high byte - BEQ LAB_1A54 ; branch if end (eventually does error X) - - INY ; increment index - LDA (Bpntrl),Y ; get next line # low byte - STA Dlinel ; save current DATA line low byte - INY ; increment index - LDA (Bpntrl),Y ; get next line # high byte - INY ; increment index - STA Dlineh ; save current DATA line high byte -LAB_19F6 - LDA (Bpntrl),Y ; get byte - INY ; increment index - TAX ; copy to X - JSR LAB_170F ; set BASIC execute pointer - CPX #TK_DATA ; compare with "DATA" token - BEQ LAB_1985 ; was "DATA" so go do next READ - - BNE LAB_19DD ; go find next statement if not "DATA" - -; end of INPUT/READ routine - -LAB_1A03 - LDA Rdptrl ; get temp READ pointer low byte - LDY Rdptrh ; get temp READ pointer high byte - LDX Imode ; get input mode flag, $00=INPUT, $80=READ - BPL LAB_1A0E ; branch if INPUT - - JMP LAB_1624 ; save AY as DATA pointer and return - - ; we were getting INPUT -LAB_1A0E - LDY #$00 ; clear index - LDA (Rdptrl),Y ; get next byte - BNE LAB_1A1B ; error if not end of INPUT - - RTS - - ; user typed too much -LAB_1A1B - LDA #LAB_IMSG ; point to extra ignored message (high addr) - JMP LAB_18C3 ; print null terminated string from memory and return - -; search the stack for FOR activity -; exit with z=1 if FOR else exit with z=0 - -LAB_11A1 - TSX ; copy stack pointer - INX ; +1 pass return address - INX ; +2 pass return address - INX ; +3 pass calling routine return address - INX ; +4 pass calling routine return address -LAB_11A6 - LDA LAB_STAK+1,X ; get token byte from stack - CMP #TK_FOR ; is it FOR token - BNE LAB_11CE ; exit if not FOR token - - ; was FOR token - LDA Frnxth ; get var pointer for FOR/NEXT high byte - BNE LAB_11BB ; branch if not null - - LDA LAB_STAK+2,X ; get FOR variable pointer low byte - STA Frnxtl ; save var pointer for FOR/NEXT low byte - LDA LAB_STAK+3,X ; get FOR variable pointer high byte - STA Frnxth ; save var pointer for FOR/NEXT high byte -LAB_11BB - CMP LAB_STAK+3,X ; compare var pointer with stacked var pointer (high byte) - BNE LAB_11C7 ; branch if no match - - LDA Frnxtl ; get var pointer for FOR/NEXT low byte - CMP LAB_STAK+2,X ; compare var pointer with stacked var pointer (low byte) - BEQ LAB_11CE ; exit if match found - -LAB_11C7 - TXA ; copy index - CLC ; clear carry for add - ADC #$10 ; add FOR stack use size - TAX ; copy back to index - BNE LAB_11A6 ; loop if not at start of stack - -LAB_11CE - RTS - -; perform NEXT - -LAB_NEXT - BNE LAB_1A46 ; branch if NEXT var - - LDY #$00 ; else clear Y - BEQ LAB_1A49 ; branch always (no variable to search for) - -; NEXT var - -LAB_1A46 - JSR LAB_GVAR ; get variable address -LAB_1A49 - STA Frnxtl ; store variable pointer low byte - STY Frnxth ; store variable pointer high byte - ; (both cleared if no variable defined) - JSR LAB_11A1 ; search the stack for FOR activity - BEQ LAB_1A56 ; branch if found - - LDX #$00 ; else set error $00 ("NEXT without FOR" error) -LAB_1A54 - BEQ LAB_1ABE ; do error #X, then warm start - -LAB_1A56 - TXS ; set stack pointer, X set by search, dumps return addresses - - TXA ; copy stack pointer - SEC ; set carry for subtract - SBC #$F7 ; point to TO var - STA ut2_pl ; save pointer to TO var for compare - ADC #$FB ; point to STEP var - - LDY #>LAB_STAK ; point to stack page high byte - JSR LAB_UFAC ; unpack memory (STEP value) into FAC1 - TSX ; get stack pointer back - LDA LAB_STAK+8,X ; get step sign - STA FAC1_s ; save FAC1 sign (b7) - LDA Frnxtl ; get FOR variable pointer low byte - LDY Frnxth ; get FOR variable pointer high byte - JSR LAB_246C ; add (FOR variable) to FAC1 - JSR LAB_PFAC ; pack FAC1 into (FOR variable) - LDY #>LAB_STAK ; point to stack page high byte - JSR LAB_27FA ; compare FAC1 with (Y,ut2_pl) (TO value) - TSX ; get stack pointer back - CMP LAB_STAK+8,X ; compare step sign - BEQ LAB_1A9B ; branch if = (loop complete) - - ; loop back and do it all again - LDA LAB_STAK+$0D,X ; get FOR line low byte - STA Clinel ; save current line low byte - LDA LAB_STAK+$0E,X ; get FOR line high byte - STA Clineh ; save current line high byte - LDA LAB_STAK+$10,X ; get BASIC execute pointer low byte - STA Bpntrl ; save BASIC execute pointer low byte - LDA LAB_STAK+$0F,X ; get BASIC execute pointer high byte - STA Bpntrh ; save BASIC execute pointer high byte -LAB_1A98 - JMP LAB_15C2 ; go do interpreter inner loop - - ; loop complete so carry on -LAB_1A9B - TXA ; stack copy to A - ADC #$0F ; add $10 ($0F+carry) to dump FOR structure - TAX ; copy back to index - TXS ; copy to stack pointer - JSR LAB_GBYT ; scan memory - CMP #',' ; compare with "," - BNE LAB_1A98 ; branch if not "," (go do interpreter inner loop) - - ; was "," so another NEXT variable to do - JSR LAB_IGBY ; else increment and scan memory - JSR LAB_1A46 ; do NEXT (var) - -; evaluate expression and check is numeric, else do type mismatch - -LAB_EVNM - JSR LAB_EVEX ; evaluate expression - -; check if source is numeric, else do type mismatch - -LAB_CTNM - CLC ; destination is numeric - .byte $24 ; makes next line BIT $38 - -; check if source is string, else do type mismatch - -LAB_CTST - SEC ; required type is string - -; type match check, set C for string, clear C for numeric - -LAB_CKTM - BIT Dtypef ; test data type flag, $FF=string, $00=numeric - BMI LAB_1ABA ; branch if data type is string - - ; else data type was numeric - BCS LAB_1ABC ; if required type is string do type mismatch error -LAB_1AB9 - RTS - - ; data type was string, now check required type -LAB_1ABA - BCS LAB_1AB9 ; exit if required type is string - - ; else do type mismatch error -LAB_1ABC - LDX #$18 ; error code $18 ("Type mismatch" error) -LAB_1ABE - JMP LAB_XERR ; do error #X, then warm start - -; evaluate expression - -LAB_EVEX - LDX Bpntrl ; get BASIC execute pointer low byte - BNE LAB_1AC7 ; skip next if not zero - - DEC Bpntrh ; else decrement BASIC execute pointer high byte -LAB_1AC7 - DEC Bpntrl ; decrement BASIC execute pointer low byte - -LAB_EVEZ - LDA #$00 ; set null precedence (flag done) -LAB_1ACC - PHA ; push precedence byte - LDA #$02 ; 2 bytes - JSR LAB_1212 ; check room on stack for A bytes - JSR LAB_GVAL ; get value from line - LDA #$00 ; clear A - STA comp_f ; clear compare function flag -LAB_1ADB - JSR LAB_GBYT ; scan memory -LAB_1ADE - SEC ; set carry for subtract - SBC #TK_GT ; subtract token for > (lowest comparison function) - BCC LAB_1AFA ; branch if < TK_GT - - CMP #$03 ; compare with ">" to "<" tokens - BCS LAB_1AFA ; branch if >= TK_SGN (highest evaluation function +1) - - ; was token for > = or < (A = 0, 1 or 2) - CMP #$01 ; compare with token for = - ROL ; *2, b0 = carry (=1 if token was = or <) - ; (A = 0, 3 or 5) - EOR #$01 ; toggle b0 - ; (A = 1, 2 or 4. 1 if >, 2 if =, 4 if <) - EOR comp_f ; EOR with compare function flag bits - CMP comp_f ; compare with compare function flag - BCC LAB_1B53 ; if <(comp_f) do syntax error then warm start - ; was more than one <, = or >) - - STA comp_f ; save new compare function flag - JSR LAB_IGBY ; increment and scan memory - JMP LAB_1ADE ; go do next character - - ; token is < ">" or > "<" tokens -LAB_1AFA - LDX comp_f ; get compare function flag - BNE LAB_1B2A ; branch if compare function - - BCS LAB_1B78 ; go do functions - - ; else was < TK_GT so is operator or lower - ADC #TK_GT-TK_PLUS ; add # of operators (+, -, *, /, ^, AND, OR or EOR) - BCC LAB_1B78 ; branch if < + operator - - ; carry was set so token was +, -, *, /, ^, AND, OR or EOR - BNE LAB_1B0B ; branch if not + token - - BIT Dtypef ; test data type flag, $FF=string, $00=numeric - BPL LAB_1B0B ; branch if not string - - ; will only be $00 if type is string and token was + - JMP LAB_224D ; add strings, string 1 is in descriptor des_pl, string 2 - ; is in line, and return - -LAB_1B0B - STA ut1_pl ; save it - ASL ; *2 - ADC ut1_pl ; *3 - TAY ; copy to index -LAB_1B13 - PLA ; pull previous precedence - CMP LAB_OPPT,Y ; compare with precedence byte - BCS LAB_1B7D ; branch if A >= - - JSR LAB_CTNM ; check if source is numeric, else do type mismatch -LAB_1B1C - PHA ; save precedence -LAB_1B1D - JSR LAB_1B43 ; get vector, execute function then continue evaluation - PLA ; restore precedence - LDY prstk ; get precedence stacked flag - BPL LAB_1B3C ; branch if stacked values - - TAX ; copy precedence (set flags) - BEQ LAB_1B9D ; exit if done - - BNE LAB_1B86 ; else pop FAC2 and return, branch always - -LAB_1B2A - ROL Dtypef ; shift data type flag into Cb - TXA ; copy compare function flag - STA Dtypef ; clear data type flag, X is 0xxx xxxx - ROL ; shift data type into compare function byte b0 - LDX Bpntrl ; get BASIC execute pointer low byte - BNE LAB_1B34 ; branch if no underflow - - DEC Bpntrh ; else decrement BASIC execute pointer high byte -LAB_1B34 - DEC Bpntrl ; decrement BASIC execute pointer low byte -TK_LT_PLUS = TK_LT-TK_PLUS - LDY #TK_LT_PLUS*3 ; set offset to last operator entry - STA comp_f ; save new compare function flag - BNE LAB_1B13 ; branch always - -LAB_1B3C - CMP LAB_OPPT,Y ;.compare with stacked function precedence - BCS LAB_1B86 ; branch if A >=, pop FAC2 and return - - BCC LAB_1B1C ; branch always - -;.get vector, execute function then continue evaluation - -LAB_1B43 - LDA LAB_OPPT+2,Y ; get function vector high byte - PHA ; onto stack - LDA LAB_OPPT+1,Y ; get function vector low byte - PHA ; onto stack - ; now push sign, round FAC1 and put on stack - JSR LAB_1B5B ; function will return here, then the next RTS will call - ; the function - LDA comp_f ; get compare function flag - PHA ; push compare evaluation byte - LDA LAB_OPPT,Y ; get precedence byte - JMP LAB_1ACC ; continue evaluating expression - -LAB_1B53 - JMP LAB_SNER ; do syntax error then warm start - -; push sign, round FAC1 and put on stack - -LAB_1B5B - PLA ; get return addr low byte - STA ut1_pl ; save it - INC ut1_pl ; increment it (was ret-1 pushed? yes!) - ; note! no check is made on the high byte! if the calling - ; routine assembles to a page edge then this all goes - ; horribly wrong !!! - PLA ; get return addr high byte - STA ut1_ph ; save it - LDA FAC1_s ; get FAC1 sign (b7) - PHA ; push sign - -; round FAC1 and put on stack - -LAB_1B66 - JSR LAB_27BA ; round FAC1 - LDA FAC1_3 ; get FAC1 mantissa3 - PHA ; push on stack - LDA FAC1_2 ; get FAC1 mantissa2 - PHA ; push on stack - LDA FAC1_1 ; get FAC1 mantissa1 - PHA ; push on stack - LDA FAC1_e ; get FAC1 exponent - PHA ; push on stack - JMP (ut1_pl) ; return, sort of - -; do functions - -LAB_1B78 - LDY #$FF ; flag function - PLA ; pull precedence byte -LAB_1B7B - BEQ LAB_1B9D ; exit if done - -LAB_1B7D - CMP #$64 ; compare previous precedence with $64 - BEQ LAB_1B84 ; branch if was $64 (< function) - - JSR LAB_CTNM ; check if source is numeric, else do type mismatch -LAB_1B84 - STY prstk ; save precedence stacked flag - - ; pop FAC2 and return -LAB_1B86 - PLA ; pop byte - LSR ; shift out comparison evaluation lowest bit - STA Cflag ; save comparison evaluation flag - PLA ; pop exponent - STA FAC2_e ; save FAC2 exponent - PLA ; pop mantissa1 - STA FAC2_1 ; save FAC2 mantissa1 - PLA ; pop mantissa2 - STA FAC2_2 ; save FAC2 mantissa2 - PLA ; pop mantissa3 - STA FAC2_3 ; save FAC2 mantissa3 - PLA ; pop sign - STA FAC2_s ; save FAC2 sign (b7) - EOR FAC1_s ; EOR FAC1 sign (b7) - STA FAC_sc ; save sign compare (FAC1 EOR FAC2) -LAB_1B9D - LDA FAC1_e ; get FAC1 exponent - RTS - -; print "..." string to string util area - -LAB_1BC1 - LDA Bpntrl ; get BASIC execute pointer low byte - LDY Bpntrh ; get BASIC execute pointer high byte - ADC #$00 ; add carry to low byte - BCC LAB_1BCA ; branch if no overflow - - INY ; increment high byte -LAB_1BCA - JSR LAB_20AE ; print " terminated string to Sutill/Sutilh - JMP LAB_23F3 ; restore BASIC execute pointer from temp and return - -; get value from line - -LAB_GVAL - JSR LAB_IGBY ; increment and scan memory - BCS LAB_1BAC ; branch if not numeric character - - ; else numeric string found (e.g. 123) -LAB_1BA9 - JMP LAB_2887 ; get FAC1 from string and return - -; get value from line .. continued - - ; wasn't a number so .. -LAB_1BAC - TAX ; set the flags - BMI LAB_1BD0 ; if -ve go test token values - - ; else it is either a string, number, variable or () - CMP #'$' ; compare with "$" - BEQ LAB_1BA9 ; branch if "$", hex number - - CMP #'%' ; else compare with "%" - BEQ LAB_1BA9 ; branch if "%", binary number - - CMP #'.' ; compare with "." - BEQ LAB_1BA9 ; if so get FAC1 from string and return (e.g. was .123) - - ; it wasn't any sort of number so .. - CMP #$22 ; compare with " - BEQ LAB_1BC1 ; branch if open quote - - ; wasn't any sort of number so .. - -; evaluate expression within parentheses - - CMP #'(' ; compare with "(" - BNE LAB_1C18 ; if not "(" get (var), return value in FAC1 and $ flag - -LAB_1BF7 - JSR LAB_EVEZ ; evaluate expression, no decrement - -; all the 'scan for' routines return the character after the sought character - -; scan for ")" , else do syntax error then warm start - -LAB_1BFB - LDA #$29 ; load A with ")" - -; scan for CHR$(A) , else do syntax error then warm start - -LAB_SCCA - LDY #$00 ; clear index - CMP (Bpntrl),Y ; check next byte is = A - BNE LAB_SNER ; if not do syntax error then warm start - - JMP LAB_IGBY ; increment and scan memory then return - -; scan for "(" , else do syntax error then warm start - -LAB_1BFE - LDA #$28 ; load A with "(" - BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start - ; (branch always) - -; scan for "," , else do syntax error then warm start - -LAB_1C01 - LDA #$2C ; load A with "," - BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start - ; (branch always) - -; syntax error then warm start - -LAB_SNER - LDX #$02 ; error code $02 ("Syntax" error) - JMP LAB_XERR ; do error #X, then warm start - -; get value from line .. continued -; do tokens - -LAB_1BD0 - CMP #TK_MINUS ; compare with token for - - BEQ LAB_1C11 ; branch if - token (do set-up for functions) - - ; wasn't -n so .. - CMP #TK_PLUS ; compare with token for + - BEQ LAB_GVAL ; branch if + token (+n = n so ignore leading +) - - CMP #TK_NOT ; compare with token for NOT - BNE LAB_1BE7 ; branch if not token for NOT - - ; was NOT token -TK_EQUAL_PLUS = TK_EQUAL-TK_PLUS - LDY #TK_EQUAL_PLUS*3 ; offset to NOT function - BNE LAB_1C13 ; do set-up for function then execute (branch always) - -; do = compare - -LAB_EQUAL - JSR LAB_EVIR ; evaluate integer expression (no sign check) - LDA FAC1_3 ; get FAC1 mantissa3 - EOR #$FF ; invert it - TAY ; copy it - LDA FAC1_2 ; get FAC1 mantissa2 - EOR #$FF ; invert it - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; get value from line .. continued - - ; wasn't +, -, or NOT so .. -LAB_1BE7 - CMP #TK_FN ; compare with token for FN - BNE LAB_1BEE ; branch if not token for FN - - JMP LAB_201E ; go evaluate FNx - -; get value from line .. continued - - ; wasn't +, -, NOT or FN so .. -LAB_1BEE - SBC #TK_SGN ; subtract with token for SGN - BCS LAB_1C27 ; if a function token go do it - - JMP LAB_SNER ; else do syntax error - -; set-up for functions - -LAB_1C11 -TK_GT_PLUS = TK_GT-TK_PLUS - LDY #TK_GT_PLUS*3 ; set offset from base to > operator -LAB_1C13 - PLA ; dump return address low byte - PLA ; dump return address high byte - JMP LAB_1B1D ; execute function then continue evaluation - -; variable name set-up -; get (var), return value in FAC_1 and $ flag - -LAB_1C18 - JSR LAB_GVAR ; get (var) address - STA FAC1_2 ; save address low byte in FAC1 mantissa2 - STY FAC1_3 ; save address high byte in FAC1 mantissa3 - LDX Dtypef ; get data type flag, $FF=string, $00=numeric - BMI LAB_1C25 ; if string then return (does RTS) - -LAB_1C24 - JMP LAB_UFAC ; unpack memory (AY) into FAC1 - -LAB_1C25 - RTS - -; get value from line .. continued -; only functions left so .. - -; set up function references - -; new for V2.0+ this replaces a lot of IF .. THEN .. ELSEIF .. THEN .. that was needed -; to process function calls. now the function vector is computed and pushed on the stack -; and the preprocess offset is read. if the preprocess offset is non zero then the vector -; is calculated and the routine called, if not this routine just does RTS. whichever -; happens the RTS at the end of this routine, or the end of the preprocess routine, calls -; the function code - -; this also removes some less than elegant code that was used to bypass type checking -; for functions that returned strings - -LAB_1C27 - ASL ; *2 (2 bytes per function address) - TAY ; copy to index - - LDA LAB_FTBM,Y ; get function jump vector high byte - PHA ; push functions jump vector high byte - LDA LAB_FTBL,Y ; get function jump vector low byte - PHA ; push functions jump vector low byte - - LDA LAB_FTPM,Y ; get function pre process vector high byte - BEQ LAB_1C56 ; skip pre process if null vector - - PHA ; push functions pre process vector high byte - LDA LAB_FTPL,Y ; get function pre process vector low byte - PHA ; push functions pre process vector low byte - -LAB_1C56 - RTS ; do function, or pre process, call - -; process string expression in parenthesis - -LAB_PPFS - JSR LAB_1BF7 ; process expression in parenthesis - JMP LAB_CTST ; check if source is string then do function, - ; else do type mismatch - -; process numeric expression in parenthesis - -LAB_PPFN - JSR LAB_1BF7 ; process expression in parenthesis - JMP LAB_CTNM ; check if source is numeric then do function, - ; else do type mismatch - -; set numeric data type and increment BASIC execute pointer - -LAB_PPBI - LSR Dtypef ; clear data type flag, $FF=string, $00=numeric - JMP LAB_IGBY ; increment and scan memory then do function - -; process string for LEFT$, RIGHT$ or MID$ - -LAB_LRMS - JSR LAB_EVEZ ; evaluate (should be string) expression - JSR LAB_1C01 ; scan for ",", else do syntax error then warm start - JSR LAB_CTST ; check if source is string, else do type mismatch - - PLA ; get function jump vector low byte - TAX ; save functions jump vector low byte - PLA ; get function jump vector high byte - TAY ; save functions jump vector high byte - LDA des_ph ; get descriptor pointer high byte - PHA ; push string pointer high byte - LDA des_pl ; get descriptor pointer low byte - PHA ; push string pointer low byte - TYA ; get function jump vector high byte back - PHA ; save functions jump vector high byte - TXA ; get function jump vector low byte back - PHA ; save functions jump vector low byte - JSR LAB_GTBY ; get byte parameter - TXA ; copy byte parameter to A - RTS ; go do function - -; process numeric expression(s) for BIN$ or HEX$ - -LAB_BHSS - JSR LAB_EVEZ ; process expression - JSR LAB_CTNM ; check if source is numeric, else do type mismatch - LDA FAC1_e ; get FAC1 exponent - CMP #$98 ; compare with exponent = 2^24 - BCS LAB_BHER ; branch if n>=2^24 (is too big) - - JSR LAB_2831 ; convert FAC1 floating-to-fixed - LDX #$02 ; 3 bytes to do -LAB_CFAC - LDA FAC1_1,X ; get byte from FAC1 - STA nums_1,X ; save byte to temp - DEX ; decrement index - BPL LAB_CFAC ; copy FAC1 mantissa to temp - - JSR LAB_GBYT ; get next BASIC byte - LDX #$00 ; set default to no leading "0"s - CMP #')' ; compare with close bracket - BEQ LAB_1C54 ; if ")" go do rest of function - - JSR LAB_SCGB ; scan for "," and get byte - JSR LAB_GBYT ; get last byte back - CMP #')' ; is next character ) - BNE LAB_BHER ; if not ")" go do error - -LAB_1C54 - RTS ; else do function - -LAB_BHER - JMP LAB_FCER ; do function call error then warm start - -; perform EOR - -; added operator format is the same as AND or OR, precedence is the same as OR - -; this bit worked first time but it took a while to sort out the operator table -; pointers and offsets afterwards! - -LAB_EOR - JSR GetFirst ; get first integer expression (no sign check) - EOR XOAw_l ; EOR with expression 1 low byte - TAY ; save in Y - LDA FAC1_2 ; get FAC1 mantissa2 - EOR XOAw_h ; EOR with expression 1 high byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform OR - -LAB_OR - JSR GetFirst ; get first integer expression (no sign check) - ORA XOAw_l ; OR with expression 1 low byte - TAY ; save in Y - LDA FAC1_2 ; get FAC1 mantissa2 - ORA XOAw_h ; OR with expression 1 high byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform AND - -LAB_AND - JSR GetFirst ; get first integer expression (no sign check) - AND XOAw_l ; AND with expression 1 low byte - TAY ; save in Y - LDA FAC1_2 ; get FAC1 mantissa2 - AND XOAw_h ; AND with expression 1 high byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; get first value for OR, AND or EOR - -GetFirst - JSR LAB_EVIR ; evaluate integer expression (no sign check) - LDA FAC1_2 ; get FAC1 mantissa2 - STA XOAw_h ; save it - LDA FAC1_3 ; get FAC1 mantissa3 - STA XOAw_l ; save it - JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression) - JSR LAB_EVIR ; evaluate integer expression (no sign check) - LDA FAC1_3 ; get FAC1 mantissa3 -LAB_1C95 - RTS - -; perform comparisons - -; do < compare - -LAB_LTHAN - JSR LAB_CKTM ; type match check, set C for string - BCS LAB_1CAE ; branch if string - - ; do numeric < compare - LDA FAC2_s ; get FAC2 sign (b7) - ORA #$7F ; set all non sign bits - AND FAC2_1 ; and FAC2 mantissa1 (AND in sign bit) - STA FAC2_1 ; save FAC2 mantissa1 - LDA #FAC2_e ; set pointer high byte to FAC2 - JSR LAB_27F8 ; compare FAC1 with FAC2 (AY) - TAX ; copy result - JMP LAB_1CE1 ; go evaluate result - - ; do string < compare -LAB_1CAE - LSR Dtypef ; clear data type flag, $FF=string, $00=numeric - DEC comp_f ; clear < bit in compare function flag - JSR LAB_22B6 ; pop string off descriptor stack, or from top of string - ; space returns with A = length, X=pointer low byte, - ; Y=pointer high byte - STA str_ln ; save length - STX str_pl ; save string pointer low byte - STY str_ph ; save string pointer high byte - LDA FAC2_2 ; get descriptor pointer low byte - LDY FAC2_3 ; get descriptor pointer high byte - JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space - ; returns with A = length, X=pointer low byte, - ; Y=pointer high byte - STX FAC2_2 ; save string pointer low byte - STY FAC2_3 ; save string pointer high byte - TAX ; copy length - SEC ; set carry for subtract - SBC str_ln ; subtract string 1 length - BEQ LAB_1CD6 ; branch if str 1 length = string 2 length - - LDA #$01 ; set str 1 length > string 2 length - BCC LAB_1CD6 ; branch if so - - LDX str_ln ; get string 1 length - LDA #$FF ; set str 1 length < string 2 length -LAB_1CD6 - STA FAC1_s ; save length compare - LDY #$FF ; set index - INX ; adjust for loop -LAB_1CDB - INY ; increment index - DEX ; decrement count - BNE LAB_1CE6 ; branch if still bytes to do - - LDX FAC1_s ; get length compare back -LAB_1CE1 - BMI LAB_1CF2 ; branch if str 1 < str 2 - - CLC ; flag str 1 <= str 2 - BCC LAB_1CF2 ; go evaluate result - -LAB_1CE6 - LDA (FAC2_2),Y ; get string 2 byte - CMP (FAC1_1),Y ; compare with string 1 byte - BEQ LAB_1CDB ; loop if bytes = - - LDX #$FF ; set str 1 < string 2 - BCS LAB_1CF2 ; branch if so - - LDX #$01 ; set str 1 > string 2 -LAB_1CF2 - INX ; x = 0, 1 or 2 - TXA ; copy to A - ROL ; *2 (1, 2 or 4) - AND Cflag ; AND with comparison evaluation flag - BEQ LAB_1CFB ; branch if 0 (compare is false) - - LDA #$FF ; else set result true -LAB_1CFB - JMP LAB_27DB ; save A as integer byte and return - -LAB_1CFE - JSR LAB_1C01 ; scan for ",", else do syntax error then warm start - -; perform DIM - -LAB_DIM - TAX ; copy "DIM" flag to X - JSR LAB_1D10 ; search for variable - JSR LAB_GBYT ; scan memory - BNE LAB_1CFE ; scan for "," and loop if not null - - RTS - -; perform << (left shift) - -LAB_LSHIFT - JSR GetPair ; get integer expression and byte (no sign check) - LDA FAC1_2 ; get expression high byte - LDX TempB ; get shift count - BEQ NoShift ; branch if zero - - CPX #$10 ; compare bit count with 16d - BCS TooBig ; branch if >= - -Ls_loop - ASL FAC1_3 ; shift low byte - ROL ; shift high byte - DEX ; decrement bit count - BNE Ls_loop ; loop if shift not complete - - LDY FAC1_3 ; get expression low byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform >> (right shift) - -LAB_RSHIFT - JSR GetPair ; get integer expression and byte (no sign check) - LDA FAC1_2 ; get expression high byte - LDX TempB ; get shift count - BEQ NoShift ; branch if zero - - CPX #$10 ; compare bit count with 16d - BCS TooBig ; branch if >= - -Rs_loop - LSR ; shift high byte - ROR FAC1_3 ; shift low byte - DEX ; decrement bit count - BNE Rs_loop ; loop if shift not complete - -NoShift - LDY FAC1_3 ; get expression low byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -TooBig - LDA #$00 ; clear high byte - TAY ; copy to low byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -GetPair - JSR LAB_EVBY ; evaluate byte expression, result in X - STX TempB ; save it - JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression) - JMP LAB_EVIR ; evaluate integer expression (no sign check) - -; search for variable - -; return pointer to variable in Cvaral/Cvarah - -LAB_GVAR - LDX #$00 ; set DIM flag = $00 - JSR LAB_GBYT ; scan memory (1st character) -LAB_1D10 - STX Defdim ; save DIM flag -LAB_1D12 - STA Varnm1 ; save 1st character - AND #$7F ; clear FN flag bit - JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" - BCS LAB_1D1F ; branch if ok - - JMP LAB_SNER ; else syntax error then warm start - - ; was variable name so .. -LAB_1D1F - LDX #$00 ; clear 2nd character temp - STX Dtypef ; clear data type flag, $FF=string, $00=numeric - JSR LAB_IGBY ; increment and scan memory (2nd character) - BCC LAB_1D2D ; branch if character = "0"-"9" (ok) - - ; 2nd character wasn't "0" to "9" so .. - JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" - BCC LAB_1D38 ; branch if <"A" or >"Z" (go check if string) - -LAB_1D2D - TAX ; copy 2nd character - - ; ignore further (valid) characters in the variable name -LAB_1D2E - JSR LAB_IGBY ; increment and scan memory (3rd character) - BCC LAB_1D2E ; loop if character = "0"-"9" (ignore) - - JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" - BCS LAB_1D2E ; loop if character = "A"-"Z" (ignore) - - ; check if string variable -LAB_1D38 - CMP #'$' ; compare with "$" - BNE LAB_1D47 ; branch if not string - -; to introduce a new variable type (% suffix for integers say) then this branch -; will need to go to that check and then that branch, if it fails, go to LAB_1D47 - - ; type is string - LDA #$FF ; set data type = string - STA Dtypef ; set data type flag, $FF=string, $00=numeric - TXA ; get 2nd character back - ORA #$80 ; set top bit (indicate string var) - TAX ; copy back to 2nd character temp - JSR LAB_IGBY ; increment and scan memory - -; after we have determined the variable type we need to come back here to determine -; if it's an array of type. this would plug in a%(b[,c[,d]])) integer arrays nicely - - -LAB_1D47 ; gets here with character after var name in A - STX Varnm2 ; save 2nd character - ORA Sufnxf ; or with subscript/FNX flag (or FN name) - CMP #'(' ; compare with "(" - BNE LAB_1D53 ; branch if not "(" - - JMP LAB_1E17 ; go find, or make, array - -; either find or create var -; var name (1st two characters only!) is in Varnm1,Varnm2 - - ; variable name wasn't var(... so look for plain var -LAB_1D53 - LDA #$00 ; clear A - STA Sufnxf ; clear subscript/FNX flag - LDA Svarl ; get start of vars low byte - LDX Svarh ; get start of vars high byte - LDY #$00 ; clear index -LAB_1D5D - STX Vrschh ; save search address high byte -LAB_1D5F - STA Vrschl ; save search address low byte - CPX Sarryh ; compare high address with var space end - BNE LAB_1D69 ; skip next compare if <> - - ; high addresses were = so compare low addresses - CMP Sarryl ; compare low address with var space end - BEQ LAB_1D8B ; if not found go make new var - -LAB_1D69 - LDA Varnm1 ; get 1st character of var to find - CMP (Vrschl),Y ; compare with variable name 1st character - BNE LAB_1D77 ; branch if no match - - ; 1st characters match so compare 2nd characters - LDA Varnm2 ; get 2nd character of var to find - INY ; index to point to variable name 2nd character - CMP (Vrschl),Y ; compare with variable name 2nd character - BEQ LAB_1DD7 ; branch if match (found var) - - DEY ; else decrement index (now = $00) -LAB_1D77 - CLC ; clear carry for add - LDA Vrschl ; get search address low byte - ADC #$06 ; +6 (offset to next var name) - BCC LAB_1D5F ; loop if no overflow to high byte - - INX ; else increment high byte - BNE LAB_1D5D ; loop always (RAM doesn't extend to $FFFF !) - -; check byte, return C=0 if<"A" or >"Z" or "a" to "z" - -LAB_CASC - CMP #'a' ; compare with "a" - BCS LAB_1D83 ; go check <"z"+1 - -; check byte, return C=0 if<"A" or >"Z" - -LAB_1D82 - CMP #'A' ; compare with "A" - BCC LAB_1D8A ; exit if less - - ; carry is set - SBC #$5B ; subtract "Z"+1 - SEC ; set carry - SBC #$A5 ; subtract $A5 (restore byte) - ; carry clear if byte>$5A -LAB_1D8A - RTS - -LAB_1D83 - SBC #$7B ; subtract "z"+1 - SEC ; set carry - SBC #$85 ; subtract $85 (restore byte) - ; carry clear if byte>$7A - RTS - - ; reached end of variable mem without match - ; .. so create new variable -LAB_1D8B - PLA ; pop return address low byte - PHA ; push return address low byte -LAB_1C18p2 = LAB_1C18+2 - CMP #LAB_1D96 ; high byte point to $00,$00 - RTS - - ; create new numeric variable -LAB_1D98 - LDA Sarryl ; get var mem end low byte - LDY Sarryh ; get var mem end high byte - STA Ostrtl ; save old block start low byte - STY Ostrth ; save old block start high byte - LDA Earryl ; get array mem end low byte - LDY Earryh ; get array mem end high byte - STA Obendl ; save old block end low byte - STY Obendh ; save old block end high byte - CLC ; clear carry for add - ADC #$06 ; +6 (space for one var) - BCC LAB_1DAE ; branch if no overflow to high byte - - INY ; else increment high byte -LAB_1DAE - STA Nbendl ; set new block end low byte - STY Nbendh ; set new block end high byte - JSR LAB_11CF ; open up space in memory - LDA Nbendl ; get new start low byte - LDY Nbendh ; get new start high byte (-$100) - INY ; correct high byte - STA Sarryl ; save new var mem end low byte - STY Sarryh ; save new var mem end high byte - LDY #$00 ; clear index - LDA Varnm1 ; get var name 1st character - STA (Vrschl),Y ; save var name 1st character - INY ; increment index - LDA Varnm2 ; get var name 2nd character - STA (Vrschl),Y ; save var name 2nd character - LDA #$00 ; clear A - INY ; increment index - STA (Vrschl),Y ; initialise var byte - INY ; increment index - STA (Vrschl),Y ; initialise var byte - INY ; increment index - STA (Vrschl),Y ; initialise var byte - INY ; increment index - STA (Vrschl),Y ; initialise var byte - - ; found a match for var ((Vrschl) = ptr) -LAB_1DD7 - LDA Vrschl ; get var address low byte - CLC ; clear carry for add - ADC #$02 ; +2 (offset past var name bytes) - LDY Vrschh ; get var address high byte - BCC LAB_1DE1 ; branch if no overflow from add - - INY ; else increment high byte -LAB_1DE1 - STA Cvaral ; save current var address low byte - STY Cvarah ; save current var address high byte - RTS - -; set-up array pointer (Adatal/h) to first element in array -; set Adatal,Adatah to Astrtl,Astrth+2*Dimcnt+#$05 - -LAB_1DE6 - LDA Dimcnt ; get # of dimensions (1, 2 or 3) - ASL ; *2 (also clears the carry !) - ADC #$05 ; +5 (result is 7, 9 or 11 here) - ADC Astrtl ; add array start pointer low byte - LDY Astrth ; get array pointer high byte - BCC LAB_1DF2 ; branch if no overflow - - INY ; else increment high byte -LAB_1DF2 - STA Adatal ; save array data pointer low byte - STY Adatah ; save array data pointer high byte - RTS - -; evaluate integer expression - -LAB_EVIN - JSR LAB_IGBY ; increment and scan memory - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - -; evaluate integer expression (no check) - -LAB_EVPI - LDA FAC1_s ; get FAC1 sign (b7) - BMI LAB_1E12 ; do function call error if -ve - -; evaluate integer expression (no sign check) - -LAB_EVIR - LDA FAC1_e ; get FAC1 exponent - CMP #$90 ; compare with exponent = 2^16 (n>2^15) - BCC LAB_1E14 ; branch if n<2^16 (is ok) - - LDA #LAB_1DF7 ; set pointer high byte to -32768 - JSR LAB_27F8 ; compare FAC1 with (AY) -LAB_1E12 - BNE LAB_FCER ; if <> do function call error then warm start - -LAB_1E14 - JMP LAB_2831 ; convert FAC1 floating-to-fixed and return - -; find or make array - -LAB_1E17 - LDA Defdim ; get DIM flag - PHA ; push it - LDA Dtypef ; get data type flag, $FF=string, $00=numeric - PHA ; push it - LDY #$00 ; clear dimensions count - -; now get the array dimension(s) and stack it (them) before the data type and DIM flag - -LAB_1E1F - TYA ; copy dimensions count - PHA ; save it - LDA Varnm2 ; get array name 2nd byte - PHA ; save it - LDA Varnm1 ; get array name 1st byte - PHA ; save it - JSR LAB_EVIN ; evaluate integer expression - PLA ; pull array name 1st byte - STA Varnm1 ; restore array name 1st byte - PLA ; pull array name 2nd byte - STA Varnm2 ; restore array name 2nd byte - PLA ; pull dimensions count - TAY ; restore it - TSX ; copy stack pointer - LDA LAB_STAK+2,X ; get DIM flag - PHA ; push it - LDA LAB_STAK+1,X ; get data type flag - PHA ; push it - LDA FAC1_2 ; get this dimension size high byte - STA LAB_STAK+2,X ; stack before flag bytes - LDA FAC1_3 ; get this dimension size low byte - STA LAB_STAK+1,X ; stack before flag bytes - INY ; increment dimensions count - JSR LAB_GBYT ; scan memory - CMP #',' ; compare with "," - BEQ LAB_1E1F ; if found go do next dimension - - STY Dimcnt ; store dimensions count - JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start - PLA ; pull data type flag - STA Dtypef ; restore data type flag, $FF=string, $00=numeric - PLA ; pull DIM flag - STA Defdim ; restore DIM flag - LDX Sarryl ; get array mem start low byte - LDA Sarryh ; get array mem start high byte - -; now check to see if we are at the end of array memory (we would be if there were -; no arrays). - -LAB_1E5C - STX Astrtl ; save as array start pointer low byte - STA Astrth ; save as array start pointer high byte - CMP Earryh ; compare with array mem end high byte - BNE LAB_1E68 ; branch if not reached array mem end - - CPX Earryl ; else compare with array mem end low byte - BEQ LAB_1EA1 ; go build array if not found - - ; search for array -LAB_1E68 - LDY #$00 ; clear index - LDA (Astrtl),Y ; get array name first byte - INY ; increment index to second name byte - CMP Varnm1 ; compare with this array name first byte - BNE LAB_1E77 ; branch if no match - - LDA Varnm2 ; else get this array name second byte - CMP (Astrtl),Y ; compare with array name second byte - BEQ LAB_1E8D ; array found so branch - - ; no match -LAB_1E77 - INY ; increment index - LDA (Astrtl),Y ; get array size low byte - CLC ; clear carry for add - ADC Astrtl ; add array start pointer low byte - TAX ; copy low byte to X - INY ; increment index - LDA (Astrtl),Y ; get array size high byte - ADC Astrth ; add array mem pointer high byte - BCC LAB_1E5C ; if no overflow go check next array - -; do array bounds error - -LAB_1E85 - LDX #$10 ; error code $10 ("Array bounds" error) - .byte $2C ; makes next bit BIT LAB_08A2 - -; do function call error - -LAB_FCER - LDX #$08 ; error code $08 ("Function call" error) -LAB_1E8A - JMP LAB_XERR ; do error #X, then warm start - - ; found array, are we trying to dimension it? -LAB_1E8D - LDX #$12 ; set error $12 ("Double dimension" error) - LDA Defdim ; get DIM flag - BNE LAB_1E8A ; if we are trying to dimension it do error #X, then warm - ; start - -; found the array and we're not dimensioning it so we must find an element in it - - JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array - ; (Astrtl,Astrth points to start of array) - LDA Dimcnt ; get dimensions count - LDY #$04 ; set index to array's # of dimensions - CMP (Astrtl),Y ; compare with no of dimensions - BNE LAB_1E85 ; if wrong do array bounds error, could do "Wrong - ; dimensions" error here .. if we want a different - ; error message - - JMP LAB_1F28 ; found array so go get element - ; (could jump to LAB_1F28 as all LAB_1F24 does is take - ; Dimcnt and save it at (Astrtl),Y which is already the - ; same or we would have taken the BNE) - - ; array not found, so build it -LAB_1EA1 - JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array - ; (Astrtl,Astrth points to start of array) - JSR LAB_121F ; check available memory, "Out of memory" error if no room - ; addr to check is in AY (low/high) - LDY #$00 ; clear Y (don't need to clear A) - STY Aspth ; clear array data size high byte - LDA Varnm1 ; get variable name 1st byte - STA (Astrtl),Y ; save array name 1st byte - INY ; increment index - LDA Varnm2 ; get variable name 2nd byte - STA (Astrtl),Y ; save array name 2nd byte - LDA Dimcnt ; get dimensions count - LDY #$04 ; index to dimension count - STY Asptl ; set array data size low byte (four bytes per element) - STA (Astrtl),Y ; set array's dimensions count - - ; now calculate the size of the data space for the array - CLC ; clear carry for add (clear on subsequent loops) -LAB_1EC0 - LDX #$0B ; set default dimension value low byte - LDA #$00 ; set default dimension value high byte - BIT Defdim ; test default DIM flag - BVC LAB_1ED0 ; branch if b6 of Defdim is clear - - PLA ; else pull dimension value low byte - ADC #$01 ; +1 (allow for zeroeth element) - TAX ; copy low byte to X - PLA ; pull dimension value high byte - ADC #$00 ; add carry from low byte - -LAB_1ED0 - INY ; index to dimension value high byte - STA (Astrtl),Y ; save dimension value high byte - INY ; index to dimension value high byte - TXA ; get dimension value low byte - STA (Astrtl),Y ; save dimension value low byte - JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl) - STX Asptl ; save array data size low byte - STA Aspth ; save array data size high byte - LDY ut1_pl ; restore index (saved by subroutine) - DEC Dimcnt ; decrement dimensions count - BNE LAB_1EC0 ; loop while not = 0 - - ADC Adatah ; add size high byte to first element high byte - ; (carry is always clear here) - BCS LAB_1F45 ; if overflow go do "Out of memory" error - - STA Adatah ; save end of array high byte - TAY ; copy end high byte to Y - TXA ; get array size low byte - ADC Adatal ; add array start low byte - BCC LAB_1EF3 ; branch if no carry - - INY ; else increment end of array high byte - BEQ LAB_1F45 ; if overflow go do "Out of memory" error - - ; set-up mostly complete, now zero the array -LAB_1EF3 - JSR LAB_121F ; check available memory, "Out of memory" error if no room - ; addr to check is in AY (low/high) - STA Earryl ; save array mem end low byte - STY Earryh ; save array mem end high byte - LDA #$00 ; clear byte for array clear - INC Aspth ; increment array size high byte (now block count) - LDY Asptl ; get array size low byte (now index to block) - BEQ LAB_1F07 ; branch if low byte = $00 - -LAB_1F02 - DEY ; decrement index (do 0 to n-1) - STA (Adatal),Y ; zero byte - BNE LAB_1F02 ; loop until this block done - -LAB_1F07 - DEC Adatah ; decrement array pointer high byte - DEC Aspth ; decrement block count high byte - BNE LAB_1F02 ; loop until all blocks done - - INC Adatah ; correct for last loop - SEC ; set carry for subtract - LDY #$02 ; index to array size low byte - LDA Earryl ; get array mem end low byte - SBC Astrtl ; subtract array start low byte - STA (Astrtl),Y ; save array size low byte - INY ; index to array size high byte - LDA Earryh ; get array mem end high byte - SBC Astrth ; subtract array start high byte - STA (Astrtl),Y ; save array size high byte - LDA Defdim ; get default DIM flag - BNE LAB_1F7B ; exit (RET) if this was a DIM command - - ; else, find element - INY ; index to # of dimensions - -LAB_1F24 - LDA (Astrtl),Y ; get array's dimension count - STA Dimcnt ; save it - -; we have found, or built, the array. now we need to find the element - -LAB_1F28 - LDA #$00 ; clear byte - STA Asptl ; clear array data pointer low byte -LAB_1F2C - STA Aspth ; save array data pointer high byte - INY ; increment index (point to array bound high byte) - PLA ; pull array index low byte - TAX ; copy to X - STA FAC1_2 ; save index low byte to FAC1 mantissa2 - PLA ; pull array index high byte - STA FAC1_3 ; save index high byte to FAC1 mantissa3 - CMP (Astrtl),Y ; compare with array bound high byte - BCC LAB_1F48 ; branch if within bounds - - BNE LAB_1F42 ; if outside bounds do array bounds error - - ; else high byte was = so test low bytes - INY ; index to array bound low byte - TXA ; get array index low byte - CMP (Astrtl),Y ; compare with array bound low byte - BCC LAB_1F49 ; branch if within bounds - -LAB_1F42 - JMP LAB_1E85 ; else do array bounds error - -LAB_1F45 - JMP LAB_OMER ; do "Out of memory" error then warm start - -LAB_1F48 - INY ; index to array bound low byte -LAB_1F49 - LDA Aspth ; get array data pointer high byte - ORA Asptl ; OR with array data pointer low byte - BEQ LAB_1F5A ; branch if array data pointer = null (skip multiply) - - JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl) - TXA ; get result low byte - ADC FAC1_2 ; add index low byte from FAC1 mantissa2 - TAX ; save result low byte - TYA ; get result high byte - LDY ut1_pl ; restore index -LAB_1F5A - ADC FAC1_3 ; add index high byte from FAC1 mantissa3 - STX Asptl ; save array data pointer low byte - DEC Dimcnt ; decrement dimensions count - BNE LAB_1F2C ; loop if dimensions still to do - - ASL Asptl ; array data pointer low byte * 2 - ROL ; array data pointer high byte * 2 - ASL Asptl ; array data pointer low byte * 4 - ROL ; array data pointer high byte * 4 - TAY ; copy high byte - LDA Asptl ; get low byte - ADC Adatal ; add array data start pointer low byte - STA Cvaral ; save as current var address low byte - TYA ; get high byte back - ADC Adatah ; add array data start pointer high byte - STA Cvarah ; save as current var address high byte - TAY ; copy high byte to Y - LDA Cvaral ; get current var address low byte -LAB_1F7B - RTS - -; does XY = (Astrtl),Y * (Asptl) - -LAB_1F7C - STY ut1_pl ; save index - LDA (Astrtl),Y ; get dimension size low byte - STA dims_l ; save dimension size low byte - DEY ; decrement index - LDA (Astrtl),Y ; get dimension size high byte - STA dims_h ; save dimension size high byte - - LDA #$10 ; count = $10 (16 bit multiply) - STA numbit ; save bit count - LDX #$00 ; clear result low byte - LDY #$00 ; clear result high byte -LAB_1F8F - TXA ; get result low byte - ASL ; *2 - TAX ; save result low byte - TYA ; get result high byte - ROL ; *2 - TAY ; save result high byte - BCS LAB_1F45 ; if overflow go do "Out of memory" error - - ASL Asptl ; shift multiplier low byte - ROL Aspth ; shift multiplier high byte - BCC LAB_1FA8 ; skip add if no carry - - CLC ; else clear carry for add - TXA ; get result low byte - ADC dims_l ; add dimension size low byte - TAX ; save result low byte - TYA ; get result high byte - ADC dims_h ; add dimension size high byte - TAY ; save result high byte - BCS LAB_1F45 ; if overflow go do "Out of memory" error - -LAB_1FA8 - DEC numbit ; decrement bit count - BNE LAB_1F8F ; loop until all done - - RTS - -; perform FRE() - -LAB_FRE - LDA Dtypef ; get data type flag, $FF=string, $00=numeric - BPL LAB_1FB4 ; branch if numeric - - JSR LAB_22B6 ; pop string off descriptor stack, or from top of string - ; space returns with A = length, X=$71=pointer low byte, - ; Y=$72=pointer high byte - - ; FRE(n) was numeric so do this -LAB_1FB4 - JSR LAB_GARB ; go do garbage collection - SEC ; set carry for subtract - LDA Sstorl ; get bottom of string space low byte - SBC Earryl ; subtract array mem end low byte - TAY ; copy result to Y - LDA Sstorh ; get bottom of string space high byte - SBC Earryh ; subtract array mem end high byte - -; save and convert integer AY to FAC1 - -LAB_AYFC - LSR Dtypef ; clear data type flag, $FF=string, $00=numeric - STA FAC1_1 ; save FAC1 mantissa1 - STY FAC1_2 ; save FAC1 mantissa2 - LDX #$90 ; set exponent=2^16 (integer) - JMP LAB_27E3 ; set exp=X, clear FAC1_3, normalise and return - -; perform POS() - -LAB_POS - LDY TPos ; get terminal position - -; convert Y to byte in FAC1 - -LAB_1FD0 - LDA #$00 ; clear high byte - BEQ LAB_AYFC ; always save and convert integer AY to FAC1 and return - -; check not Direct (used by DEF and INPUT) - -LAB_CKRN - LDX Clineh ; get current line high byte - INX ; increment it - BNE LAB_1F7B ; return if can continue not direct mode - - ; else do illegal direct error -LAB_1FD9 - LDX #$16 ; error code $16 ("Illegal direct" error) -LAB_1FDB - JMP LAB_XERR ; go do error #X, then warm start - -; perform DEF - -LAB_DEF - JSR LAB_200B ; check FNx syntax - STA func_l ; save function pointer low byte - STY func_h ; save function pointer high byte - JSR LAB_CKRN ; check not Direct (back here if ok) - JSR LAB_1BFE ; scan for "(" , else do syntax error then warm start - LDA #$80 ; set flag for FNx - STA Sufnxf ; save subscript/FNx flag - JSR LAB_GVAR ; get (var) address - JSR LAB_CTNM ; check if source is numeric, else do type mismatch - JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start - LDA #TK_EQUAL ; get = token - JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start - LDA Cvarah ; get current var address high byte - PHA ; push it - LDA Cvaral ; get current var address low byte - PHA ; push it - LDA Bpntrh ; get BASIC execute pointer high byte - PHA ; push it - LDA Bpntrl ; get BASIC execute pointer low byte - PHA ; push it - JSR LAB_DATA ; go perform DATA - JMP LAB_207A ; put execute pointer and variable pointer into function - ; and return - -; check FNx syntax - -LAB_200B - LDA #TK_FN ; get FN" token - JSR LAB_SCCA ; scan for CHR$(A) , else do syntax error then warm start - ; return character after A - ORA #$80 ; set FN flag bit - STA Sufnxf ; save FN flag so array variable test fails - JSR LAB_1D12 ; search for FN variable - JMP LAB_CTNM ; check if source is numeric and return, else do type - ; mismatch - - ; Evaluate FNx -LAB_201E - JSR LAB_200B ; check FNx syntax - PHA ; push function pointer low byte - TYA ; copy function pointer high byte - PHA ; push function pointer high byte - JSR LAB_1BFE ; scan for "(", else do syntax error then warm start - JSR LAB_EVEX ; evaluate expression - JSR LAB_1BFB ; scan for ")", else do syntax error then warm start - JSR LAB_CTNM ; check if source is numeric, else do type mismatch - PLA ; pop function pointer high byte - STA func_h ; restore it - PLA ; pop function pointer low byte - STA func_l ; restore it - LDX #$20 ; error code $20 ("Undefined function" error) - LDY #$03 ; index to variable pointer high byte - LDA (func_l),Y ; get variable pointer high byte - BEQ LAB_1FDB ; if zero go do undefined function error - - STA Cvarah ; save variable address high byte - DEY ; index to variable address low byte - LDA (func_l),Y ; get variable address low byte - STA Cvaral ; save variable address low byte - TAX ; copy address low byte - - ; now stack the function variable value before use - INY ; index to mantissa_3 -LAB_2043 - LDA (Cvaral),Y ; get byte from variable - PHA ; stack it - DEY ; decrement index - BPL LAB_2043 ; loop until variable stacked - - LDY Cvarah ; get variable address high byte - JSR LAB_2778 ; pack FAC1 (function expression value) into (XY) - ; (function variable), return Y=0, always - LDA Bpntrh ; get BASIC execute pointer high byte - PHA ; push it - LDA Bpntrl ; get BASIC execute pointer low byte - PHA ; push it - LDA (func_l),Y ; get function execute pointer low byte - STA Bpntrl ; save as BASIC execute pointer low byte - INY ; index to high byte - LDA (func_l),Y ; get function execute pointer high byte - STA Bpntrh ; save as BASIC execute pointer high byte - LDA Cvarah ; get variable address high byte - PHA ; push it - LDA Cvaral ; get variable address low byte - PHA ; push it - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - PLA ; pull variable address low byte - STA func_l ; save variable address low byte - PLA ; pull variable address high byte - STA func_h ; save variable address high byte - JSR LAB_GBYT ; scan memory - BEQ LAB_2074 ; branch if null (should be [EOL] marker) - - JMP LAB_SNER ; else syntax error then warm start - -; restore Bpntrl,Bpntrh and function variable from stack - -LAB_2074 - PLA ; pull BASIC execute pointer low byte - STA Bpntrl ; restore BASIC execute pointer low byte - PLA ; pull BASIC execute pointer high byte - STA Bpntrh ; restore BASIC execute pointer high byte - -; put execute pointer and variable pointer into function - -LAB_207A - LDY #$00 ; clear index - PLA ; pull BASIC execute pointer low byte - STA (func_l),Y ; save to function - INY ; increment index - PLA ; pull BASIC execute pointer high byte - STA (func_l),Y ; save to function - INY ; increment index - PLA ; pull current var address low byte - STA (func_l),Y ; save to function - INY ; increment index - PLA ; pull current var address high byte - STA (func_l),Y ; save to function - RTS - -; perform STR$() - -LAB_STRS - JSR LAB_CTNM ; check if source is numeric, else do type mismatch - JSR LAB_296E ; convert FAC1 to string - LDA #Decssp1 ; set result string high pointer - BEQ LAB_20AE ; print null terminated string to Sutill/Sutilh - -; Do string vector -; copy des_pl/h to des_2l/h and make string space A bytes long - -LAB_209C - LDX des_pl ; get descriptor pointer low byte - LDY des_ph ; get descriptor pointer high byte - STX des_2l ; save descriptor pointer low byte - STY des_2h ; save descriptor pointer high byte - -; make string space A bytes long -; A=length, X=Sutill=ptr low byte, Y=Sutilh=ptr high byte - -LAB_MSSP - JSR LAB_2115 ; make space in string memory for string A long - ; return X=Sutill=ptr low byte, Y=Sutilh=ptr high byte - STX str_pl ; save string pointer low byte - STY str_ph ; save string pointer high byte - STA str_ln ; save length - RTS - -; Scan, set up string -; print " terminated string to Sutill/Sutilh - -LAB_20AE - LDX #$22 ; set terminator to " - STX Srchc ; set search character (terminator 1) - STX Asrch ; set terminator 2 - -; print [Srchc] or [Asrch] terminated string to Sutill/Sutilh -; source is AY - -LAB_20B4 - STA ssptr_l ; store string start low byte - STY ssptr_h ; store string start high byte - STA str_pl ; save string pointer low byte - STY str_ph ; save string pointer high byte - LDY #$FF ; set length to -1 -LAB_20BE - INY ; increment length - LDA (ssptr_l),Y ; get byte from string - BEQ LAB_20CF ; exit loop if null byte [EOS] - - CMP Srchc ; compare with search character (terminator 1) - BEQ LAB_20CB ; branch if terminator - - CMP Asrch ; compare with terminator 2 - BNE LAB_20BE ; loop if not terminator 2 - -LAB_20CB - CMP #$22 ; compare with " - BEQ LAB_20D0 ; branch if " (carry set if = !) - -LAB_20CF - CLC ; clear carry for add (only if [EOL] terminated string) -LAB_20D0 - STY str_ln ; save length in FAC1 exponent - TYA ; copy length to A - ADC ssptr_l ; add string start low byte - STA Sendl ; save string end low byte - LDX ssptr_h ; get string start high byte - BCC LAB_20DC ; branch if no low byte overflow - - INX ; else increment high byte -LAB_20DC - STX Sendh ; save string end high byte - LDA ssptr_h ; get string start high byte - CMP #>Ram_base ; compare with start of program memory - BCS LAB_RTST ; branch if not in utility area - - ; string in utility area, move to string memory - TYA ; copy length to A - JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes - ; long - LDX ssptr_l ; get string start low byte - LDY ssptr_h ; get string start high byte - JSR LAB_2298 ; store string A bytes long from XY to (Sutill) - -; check for space on descriptor stack then .. -; put string address and length on descriptor stack and update stack pointers - -LAB_RTST - LDX next_s ; get string stack pointer - CPX #des_sk+$09 ; compare with max+1 - BNE LAB_20F8 ; branch if space on string stack - - ; else do string too complex error - LDX #$1C ; error code $1C ("String too complex" error) -LAB_20F5 - JMP LAB_XERR ; do error #X, then warm start - -; put string address and length on descriptor stack and update stack pointers - -LAB_20F8 - LDA str_ln ; get string length - STA PLUS_0,X ; put on string stack - LDA str_pl ; get string pointer low byte - STA PLUS_1,X ; put on string stack - LDA str_ph ; get string pointer high byte - STA PLUS_2,X ; put on string stack - LDY #$00 ; clear Y - STX des_pl ; save string descriptor pointer low byte - STY des_ph ; save string descriptor pointer high byte (always $00) - DEY ; Y = $FF - STY Dtypef ; save data type flag, $FF=string - STX last_sl ; save old stack pointer (current top item) - INX ; update stack pointer - INX ; update stack pointer - INX ; update stack pointer - STX next_s ; save new top item value - RTS - -; Build descriptor -; make space in string memory for string A long -; return X=Sutill=ptr low byte, Y=Sutill=ptr high byte - -LAB_2115 - LSR Gclctd ; clear garbage collected flag (b7) - - ; make space for string A long -LAB_2117 - PHA ; save string length - EOR #$FF ; complement it - SEC ; set carry for subtract (twos comp add) - ADC Sstorl ; add bottom of string space low byte (subtract length) - LDY Sstorh ; get bottom of string space high byte - BCS LAB_2122 ; skip decrement if no underflow - - DEY ; decrement bottom of string space high byte -LAB_2122 - CPY Earryh ; compare with array mem end high byte - BCC LAB_2137 ; do out of memory error if less - - BNE LAB_212C ; if not = skip next test - - CMP Earryl ; compare with array mem end low byte - BCC LAB_2137 ; do out of memory error if less - -LAB_212C - STA Sstorl ; save bottom of string space low byte - STY Sstorh ; save bottom of string space high byte - STA Sutill ; save string utility ptr low byte - STY Sutilh ; save string utility ptr high byte - TAX ; copy low byte to X - PLA ; get string length back - RTS - -LAB_2137 - LDX #$0C ; error code $0C ("Out of memory" error) - LDA Gclctd ; get garbage collected flag - BMI LAB_20F5 ; if set then do error code X - - JSR LAB_GARB ; else go do garbage collection - LDA #$80 ; flag for garbage collected - STA Gclctd ; set garbage collected flag - PLA ; pull length - BNE LAB_2117 ; go try again (loop always, length should never be = $00) - -; garbage collection routine - -LAB_GARB - LDX Ememl ; get end of mem low byte - LDA Ememh ; get end of mem high byte - -; re-run routine from last ending - -LAB_214B - STX Sstorl ; set string storage low byte - STA Sstorh ; set string storage high byte - LDY #$00 ; clear index - STY garb_h ; clear working pointer high byte (flag no strings to move) - LDA Earryl ; get array mem end low byte - LDX Earryh ; get array mem end high byte - STA Histrl ; save as highest string low byte - STX Histrh ; save as highest string high byte - LDA #des_sk ; set descriptor stack pointer - STA ut1_pl ; save descriptor stack pointer low byte - STY ut1_ph ; save descriptor stack pointer high byte ($00) -LAB_2161 - CMP next_s ; compare with descriptor stack pointer - BEQ LAB_216A ; branch if = - - JSR LAB_21D7 ; go garbage collect descriptor stack - BEQ LAB_2161 ; loop always - - ; done stacked strings, now do string vars -LAB_216A - ASL g_step ; set step size = $06 - LDA Svarl ; get start of vars low byte - LDX Svarh ; get start of vars high byte - STA ut1_pl ; save as pointer low byte - STX ut1_ph ; save as pointer high byte -LAB_2176 - CPX Sarryh ; compare start of arrays high byte - BNE LAB_217E ; branch if no high byte match - - CMP Sarryl ; else compare start of arrays low byte - BEQ LAB_2183 ; branch if = var mem end - -LAB_217E - JSR LAB_21D1 ; go garbage collect strings - BEQ LAB_2176 ; loop always - - ; done string vars, now do string arrays -LAB_2183 - STA Nbendl ; save start of arrays low byte as working pointer - STX Nbendh ; save start of arrays high byte as working pointer - LDA #$04 ; set step size - STA g_step ; save step size -LAB_218B - LDA Nbendl ; get pointer low byte - LDX Nbendh ; get pointer high byte -LAB_218F - CPX Earryh ; compare with array mem end high byte - BNE LAB_219A ; branch if not at end - - CMP Earryl ; else compare with array mem end low byte - BEQ LAB_2216 ; tidy up and exit if at end - -LAB_219A - STA ut1_pl ; save pointer low byte - STX ut1_ph ; save pointer high byte - LDY #$02 ; set index - LDA (ut1_pl),Y ; get array size low byte - ADC Nbendl ; add start of this array low byte - STA Nbendl ; save start of next array low byte - INY ; increment index - LDA (ut1_pl),Y ; get array size high byte - ADC Nbendh ; add start of this array high byte - STA Nbendh ; save start of next array high byte - LDY #$01 ; set index - LDA (ut1_pl),Y ; get name second byte - BPL LAB_218B ; skip if not string array - -; was string array so .. - - LDY #$04 ; set index - LDA (ut1_pl),Y ; get # of dimensions - ASL ; *2 - ADC #$05 ; +5 (array header size) - JSR LAB_2208 ; go set up for first element -LAB_21C4 - CPX Nbendh ; compare with start of next array high byte - BNE LAB_21CC ; branch if <> (go do this array) - - CMP Nbendl ; else compare element pointer low byte with next array - ; low byte - BEQ LAB_218F ; if equal then go do next array - -LAB_21CC - JSR LAB_21D7 ; go defrag array strings - BEQ LAB_21C4 ; go do next array string (loop always) - -; defrag string variables -; enter with XA = variable pointer -; return with XA = next variable pointer - -LAB_21D1 - INY ; increment index (Y was $00) - LDA (ut1_pl),Y ; get var name byte 2 - BPL LAB_2206 ; if not string, step pointer to next var and return - - INY ; else increment index -LAB_21D7 - LDA (ut1_pl),Y ; get string length - BEQ LAB_2206 ; if null, step pointer to next string and return - - INY ; else increment index - LDA (ut1_pl),Y ; get string pointer low byte - TAX ; copy to X - INY ; increment index - LDA (ut1_pl),Y ; get string pointer high byte - CMP Sstorh ; compare bottom of string space high byte - BCC LAB_21EC ; branch if less - - BNE LAB_2206 ; if greater, step pointer to next string and return - - ; high bytes were = so compare low bytes - CPX Sstorl ; compare bottom of string space low byte - BCS LAB_2206 ; if >=, step pointer to next string and return - - ; string pointer is < string storage pointer (pos in mem) -LAB_21EC - CMP Histrh ; compare to highest string high byte - BCC LAB_2207 ; if <, step pointer to next string and return - - BNE LAB_21F6 ; if > update pointers, step to next and return - - ; high bytes were = so compare low bytes - CPX Histrl ; compare to highest string low byte - BCC LAB_2207 ; if <, step pointer to next string and return - - ; string is in string memory space -LAB_21F6 - STX Histrl ; save as new highest string low byte - STA Histrh ; save as new highest string high byte - LDA ut1_pl ; get start of vars(descriptors) low byte - LDX ut1_ph ; get start of vars(descriptors) high byte - STA garb_l ; save as working pointer low byte - STX garb_h ; save as working pointer high byte - DEY ; decrement index DIFFERS - DEY ; decrement index (should point to descriptor start) - STY g_indx ; save index pointer - - ; step pointer to next string -LAB_2206 - CLC ; clear carry for add -LAB_2207 - LDA g_step ; get step size -LAB_2208 - ADC ut1_pl ; add pointer low byte - STA ut1_pl ; save pointer low byte - BCC LAB_2211 ; branch if no overflow - - INC ut1_ph ; else increment high byte -LAB_2211 - LDX ut1_ph ; get pointer high byte - LDY #$00 ; clear Y - RTS - -; search complete, now either exit or set-up and move string - -LAB_2216 - DEC g_step ; decrement step size (now $03 for descriptor stack) - LDX garb_h ; get string to move high byte - BEQ LAB_2211 ; exit if nothing to move - - LDY g_indx ; get index byte back (points to descriptor) - CLC ; clear carry for add - LDA (garb_l),Y ; get string length - ADC Histrl ; add highest string low byte - STA Obendl ; save old block end low pointer - LDA Histrh ; get highest string high byte - ADC #$00 ; add any carry - STA Obendh ; save old block end high byte - LDA Sstorl ; get bottom of string space low byte - LDX Sstorh ; get bottom of string space high byte - STA Nbendl ; save new block end low byte - STX Nbendh ; save new block end high byte - JSR LAB_11D6 ; open up space in memory, don't set array end - LDY g_indx ; get index byte - INY ; point to descriptor low byte - LDA Nbendl ; get string pointer low byte - STA (garb_l),Y ; save new string pointer low byte - TAX ; copy string pointer low byte - INC Nbendh ; correct high byte (move sets high byte -1) - LDA Nbendh ; get new string pointer high byte - INY ; point to descriptor high byte - STA (garb_l),Y ; save new string pointer high byte - JMP LAB_214B ; re-run routine from last ending - ; (but don't collect this string) - -; concatenate -; add strings, string 1 is in descriptor des_pl, string 2 is in line - -LAB_224D - LDA des_ph ; get descriptor pointer high byte - PHA ; put on stack - LDA des_pl ; get descriptor pointer low byte - PHA ; put on stack - JSR LAB_GVAL ; get value from line - JSR LAB_CTST ; check if source is string, else do type mismatch - PLA ; get descriptor pointer low byte back - STA ssptr_l ; set pointer low byte - PLA ; get descriptor pointer high byte back - STA ssptr_h ; set pointer high byte - LDY #$00 ; clear index - LDA (ssptr_l),Y ; get length_1 from descriptor - CLC ; clear carry for add - ADC (des_pl),Y ; add length_2 - BCC LAB_226D ; branch if no overflow - - LDX #$1A ; else set error code $1A ("String too long" error) - JMP LAB_XERR ; do error #X, then warm start - -LAB_226D - JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes - ; long - JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill) - LDA des_2l ; get descriptor pointer low byte - LDY des_2h ; get descriptor pointer high byte - JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space - ; returns with A = length, ut1_pl = pointer low byte, - ; ut1_ph = pointer high byte - JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill) - LDA ssptr_l ;.set descriptor pointer low byte - LDY ssptr_h ;.set descriptor pointer high byte - JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space - ; returns with A = length, X=ut1_pl=pointer low byte, - ; Y=ut1_ph=pointer high byte - JSR LAB_RTST ; check for space on descriptor stack then put string - ; address and length on descriptor stack and update stack - ; pointers - JMP LAB_1ADB ;.continue evaluation - -; copy string from descriptor (sdescr) to (Sutill) - -LAB_228A - LDY #$00 ; clear index - LDA (sdescr),Y ; get string length - PHA ; save on stack - INY ; increment index - LDA (sdescr),Y ; get source string pointer low byte - TAX ; copy to X - INY ; increment index - LDA (sdescr),Y ; get source string pointer high byte - TAY ; copy to Y - PLA ; get length back - -; store string A bytes long from YX to (Sutill) - -LAB_2298 - STX ut1_pl ; save source string pointer low byte - STY ut1_ph ; save source string pointer high byte - -; store string A bytes long from (ut1_pl) to (Sutill) - -LAB_229C - TAX ; copy length to index (don't count with Y) - BEQ LAB_22B2 ; branch if = $0 (null string) no need to add zero length - - LDY #$00 ; zero pointer (copy forward) -LAB_22A0 - LDA (ut1_pl),Y ; get source byte - STA (Sutill),Y ; save destination byte - - INY ; increment index - DEX ; decrement counter - BNE LAB_22A0 ; loop while <> 0 - - TYA ; restore length from Y -LAB_22A9 - CLC ; clear carry for add - ADC Sutill ; add string utility ptr low byte - STA Sutill ; save string utility ptr low byte - BCC LAB_22B2 ; branch if no carry - - INC Sutilh ; else increment string utility ptr high byte -LAB_22B2 - RTS - -; evaluate string - -LAB_EVST - JSR LAB_CTST ; check if source is string, else do type mismatch - -; pop string off descriptor stack, or from top of string space -; returns with A = length, X=pointer low byte, Y=pointer high byte - -LAB_22B6 - LDA des_pl ; get descriptor pointer low byte - LDY des_ph ; get descriptor pointer high byte - -; pop (YA) descriptor off stack or from top of string space -; returns with A = length, X=ut1_pl=pointer low byte, Y=ut1_ph=pointer high byte - -LAB_22BA - STA ut1_pl ; save descriptor pointer low byte - STY ut1_ph ; save descriptor pointer high byte - JSR LAB_22EB ; clean descriptor stack, YA = pointer - PHP ; save status flags - LDY #$00 ; clear index - LDA (ut1_pl),Y ; get length from string descriptor - PHA ; put on stack - INY ; increment index - LDA (ut1_pl),Y ; get string pointer low byte from descriptor - TAX ; copy to X - INY ; increment index - LDA (ut1_pl),Y ; get string pointer high byte from descriptor - TAY ; copy to Y - PLA ; get string length back - PLP ; restore status - BNE LAB_22E6 ; branch if pointer <> last_sl,last_sh - - CPY Sstorh ; compare bottom of string space high byte - BNE LAB_22E6 ; branch if <> - - CPX Sstorl ; else compare bottom of string space low byte - BNE LAB_22E6 ; branch if <> - - PHA ; save string length - CLC ; clear carry for add - ADC Sstorl ; add bottom of string space low byte - STA Sstorl ; save bottom of string space low byte - BCC LAB_22E5 ; skip increment if no overflow - - INC Sstorh ; increment bottom of string space high byte -LAB_22E5 - PLA ; restore string length -LAB_22E6 - STX ut1_pl ; save string pointer low byte - STY ut1_ph ; save string pointer high byte - RTS - -; clean descriptor stack, YA = pointer -; checks if AY is on the descriptor stack, if so does a stack discard - -LAB_22EB - CPY last_sh ; compare pointer high byte - BNE LAB_22FB ; exit if <> - - CMP last_sl ; compare pointer low byte - BNE LAB_22FB ; exit if <> - - STA next_s ; save descriptor stack pointer - SBC #$03 ; -3 - STA last_sl ; save low byte -3 - LDY #$00 ; clear high byte -LAB_22FB - RTS - -; perform CHR$() - -LAB_CHRS - JSR LAB_EVBY ; evaluate byte expression, result in X - TXA ; copy to A - PHA ; save character - LDA #$01 ; string is single byte - JSR LAB_MSSP ; make string space A bytes long A=$AC=length, - ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte - PLA ; get character back - LDY #$00 ; clear index - STA (str_pl),Y ; save byte in string (byte IS string!) - JMP LAB_RTST ; check for space on descriptor stack then put string - ; address and length on descriptor stack and update stack - ; pointers - -; perform LEFT$() - -LAB_LEFT - PHA ; push byte parameter - JSR LAB_236F ; pull string data and byte parameter from stack - ; return pointer in des_2l/h, byte in A (and X), Y=0 - CMP (des_2l),Y ; compare byte parameter with string length - TYA ; clear A - BEQ LAB_2316 ; go do string copy (branch always) - -; perform RIGHT$() - -LAB_RIGHT - PHA ; push byte parameter - JSR LAB_236F ; pull string data and byte parameter from stack - ; return pointer in des_2l/h, byte in A (and X), Y=0 - CLC ; clear carry for add-1 - SBC (des_2l),Y ; subtract string length - EOR #$FF ; invert it (A=LEN(expression$)-l) - -LAB_2316 - BCC LAB_231C ; branch if string length > byte parameter - - LDA (des_2l),Y ; else make parameter = length - TAX ; copy to byte parameter copy - TYA ; clear string start offset -LAB_231C - PHA ; save string start offset -LAB_231D - TXA ; copy byte parameter (or string length if <) -LAB_231E - PHA ; save string length - JSR LAB_MSSP ; make string space A bytes long A=$AC=length, - ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte - LDA des_2l ; get descriptor pointer low byte - LDY des_2h ; get descriptor pointer high byte - JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space - ; returns with A = length, X=ut1_pl=pointer low byte, - ; Y=ut1_ph=pointer high byte - PLA ; get string length back - TAY ; copy length to Y - PLA ; get string start offset back - CLC ; clear carry for add - ADC ut1_pl ; add start offset to string start pointer low byte - STA ut1_pl ; save string start pointer low byte - BCC LAB_2335 ; branch if no overflow - - INC ut1_ph ; else increment string start pointer high byte -LAB_2335 - TYA ; copy length to A - JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill) - JMP LAB_RTST ; check for space on descriptor stack then put string - ; address and length on descriptor stack and update stack - ; pointers - -; perform MID$() - -LAB_MIDS - PHA ; push byte parameter - LDA #$FF ; set default length = 255 - STA mids_l ; save default length - JSR LAB_GBYT ; scan memory - CMP #')' ; compare with ")" - BEQ LAB_2358 ; branch if = ")" (skip second byte get) - - JSR LAB_1C01 ; scan for "," , else do syntax error then warm start - JSR LAB_GTBY ; get byte parameter (use copy in mids_l) -LAB_2358 - JSR LAB_236F ; pull string data and byte parameter from stack - ; return pointer in des_2l/h, byte in A (and X), Y=0 - DEX ; decrement start index - TXA ; copy to A - PHA ; save string start offset - CLC ; clear carry for sub-1 - LDX #$00 ; clear output string length - SBC (des_2l),Y ; subtract string length - BCS LAB_231D ; if start>string length go do null string - - EOR #$FF ; complement -length - CMP mids_l ; compare byte parameter - BCC LAB_231E ; if length>remaining string go do RIGHT$ - - LDA mids_l ; get length byte - BCS LAB_231E ; go do string copy (branch always) - -; pull string data and byte parameter from stack -; return pointer in des_2l/h, byte in A (and X), Y=0 - -LAB_236F - JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start - PLA ; pull return address low byte (return address) - STA Fnxjpl ; save functions jump vector low byte - PLA ; pull return address high byte (return address) - STA Fnxjph ; save functions jump vector high byte - PLA ; pull byte parameter - TAX ; copy byte parameter to X - PLA ; pull string pointer low byte - STA des_2l ; save it - PLA ; pull string pointer high byte - STA des_2h ; save it - LDY #$00 ; clear index - TXA ; copy byte parameter - BEQ LAB_23A8 ; if null do function call error then warm start - - INC Fnxjpl ; increment function jump vector low byte - ; (JSR pushes return addr-1. this is all very nice - ; but will go tits up if either call is on a page - ; boundary!) - JMP (Fnxjpl) ; in effect, RTS - -; perform LCASE$() - -LAB_LCASE - JSR LAB_EVST ; evaluate string - STA str_ln ; set string length - TAY ; copy length to Y - BEQ NoString ; branch if null string - - JSR LAB_MSSP ; make string space A bytes long A=length, - ; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte - STX str_pl ; save string pointer low byte - STY str_ph ; save string pointer high byte - TAY ; get string length back - -LC_loop - DEY ; decrement index - LDA (ut1_pl),Y ; get byte from string - JSR LAB_1D82 ; is character "A" to "Z" - BCC NoUcase ; branch if not upper case alpha - - ORA #$20 ; convert upper to lower case -NoUcase - STA (Sutill),Y ; save byte back to string - TYA ; test index - BNE LC_loop ; loop if not all done - - BEQ NoString ; tidy up and exit, branch always - -; perform UCASE$() - -LAB_UCASE - JSR LAB_EVST ; evaluate string - STA str_ln ; set string length - TAY ; copy length to Y - BEQ NoString ; branch if null string - - JSR LAB_MSSP ; make string space A bytes long A=length, - ; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte - STX str_pl ; save string pointer low byte - STY str_ph ; save string pointer high byte - TAY ; get string length back - -UC_loop - DEY ; decrement index - LDA (ut1_pl),Y ; get byte from string - JSR LAB_CASC ; is character "a" to "z" (or "A" to "Z") - BCC NoLcase ; branch if not alpha - - AND #$DF ; convert lower to upper case -NoLcase - STA (Sutill),Y ; save byte back to string - TYA ; test index - BNE UC_loop ; loop if not all done - -NoString - JMP LAB_RTST ; check for space on descriptor stack then put string - ; address and length on descriptor stack and update stack - ; pointers - -; perform SADD() - -LAB_SADD - JSR LAB_IGBY ; increment and scan memory - JSR LAB_GVAR ; get var address - - JSR LAB_1BFB ; scan for ")", else do syntax error then warm start - JSR LAB_CTST ; check if source is string, else do type mismatch - - LDY #$02 ; index to string pointer high byte - LDA (Cvaral),Y ; get string pointer high byte - TAX ; copy string pointer high byte to X - DEY ; index to string pointer low byte - LDA (Cvaral),Y ; get string pointer low byte - TAY ; copy string pointer low byte to Y - TXA ; copy string pointer high byte to A - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform LEN() - -LAB_LENS - JSR LAB_ESGL ; evaluate string, get length in A (and Y) - JMP LAB_1FD0 ; convert Y to byte in FAC1 and return - -; evaluate string, get length in Y - -LAB_ESGL - JSR LAB_EVST ; evaluate string - TAY ; copy length to Y - RTS - -; perform ASC() - -LAB_ASC - JSR LAB_ESGL ; evaluate string, get length in A (and Y) - BEQ LAB_23A8 ; if null do function call error then warm start - - LDY #$00 ; set index to first character - LDA (ut1_pl),Y ; get byte - TAY ; copy to Y - JMP LAB_1FD0 ; convert Y to byte in FAC1 and return - -; do function call error then warm start - -LAB_23A8 - JMP LAB_FCER ; do function call error then warm start - -; scan and get byte parameter - -LAB_SGBY - JSR LAB_IGBY ; increment and scan memory - -; get byte parameter - -LAB_GTBY - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - -; evaluate byte expression, result in X - -LAB_EVBY - JSR LAB_EVPI ; evaluate integer expression (no check) - - LDY FAC1_2 ; get FAC1 mantissa2 - BNE LAB_23A8 ; if top byte <> 0 do function call error then warm start - - LDX FAC1_3 ; get FAC1 mantissa3 - JMP LAB_GBYT ; scan memory and return - -; perform VAL() - -LAB_VAL - JSR LAB_ESGL ; evaluate string, get length in A (and Y) - BNE LAB_23C5 ; branch if not null string - - ; string was null so set result = $00 - JMP LAB_24F1 ; clear FAC1 exponent and sign and return - -LAB_23C5 - LDX Bpntrl ; get BASIC execute pointer low byte - LDY Bpntrh ; get BASIC execute pointer high byte - STX Btmpl ; save BASIC execute pointer low byte - STY Btmph ; save BASIC execute pointer high byte - LDX ut1_pl ; get string pointer low byte - STX Bpntrl ; save as BASIC execute pointer low byte - CLC ; clear carry - ADC ut1_pl ; add string length - STA ut2_pl ; save string end low byte - LDA ut1_ph ; get string pointer high byte - STA Bpntrh ; save as BASIC execute pointer high byte - ADC #$00 ; add carry to high byte - STA ut2_ph ; save string end high byte - LDY #$00 ; set index to $00 - LDA (ut2_pl),Y ; get string end +1 byte - PHA ; push it - TYA ; clear A - STA (ut2_pl),Y ; terminate string with $00 - JSR LAB_GBYT ; scan memory - JSR LAB_2887 ; get FAC1 from string - PLA ; restore string end +1 byte - LDY #$00 ; set index to zero - STA (ut2_pl),Y ; put string end byte back - -; restore BASIC execute pointer from temp (Btmpl/Btmph) - -LAB_23F3 - LDX Btmpl ; get BASIC execute pointer low byte back - LDY Btmph ; get BASIC execute pointer high byte back - STX Bpntrl ; save BASIC execute pointer low byte - STY Bpntrh ; save BASIC execute pointer high byte - RTS - -; get two parameters for POKE or WAIT - -LAB_GADB - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - JSR LAB_F2FX ; save integer part of FAC1 in temporary integer - -; scan for "," and get byte, else do Syntax error then warm start - -LAB_SCGB - JSR LAB_1C01 ; scan for "," , else do syntax error then warm start - LDA Itemph ; save temporary integer high byte - PHA ; on stack - LDA Itempl ; save temporary integer low byte - PHA ; on stack - JSR LAB_GTBY ; get byte parameter - PLA ; pull low byte - STA Itempl ; restore temporary integer low byte - PLA ; pull high byte - STA Itemph ; restore temporary integer high byte - RTS - -; convert float to fixed routine. accepts any value that fits in 24 bits, +ve or -; -ve and converts it into a right truncated integer in Itempl and Itemph - -; save unsigned 16 bit integer part of FAC1 in temporary integer - -LAB_F2FX - LDA FAC1_e ; get FAC1 exponent - CMP #$98 ; compare with exponent = 2^24 - BCS LAB_23A8 ; if >= do function call error then warm start - -LAB_F2FU - JSR LAB_2831 ; convert FAC1 floating-to-fixed - LDA FAC1_2 ; get FAC1 mantissa2 - LDY FAC1_3 ; get FAC1 mantissa3 - STY Itempl ; save temporary integer low byte - STA Itemph ; save temporary integer high byte - RTS - -; perform PEEK() - -LAB_PEEK - JSR LAB_F2FX ; save integer part of FAC1 in temporary integer - LDX #$00 ; clear index - LDA (Itempl,X) ; get byte via temporary integer (addr) - TAY ; copy byte to Y - JMP LAB_1FD0 ; convert Y to byte in FAC1 and return - -; perform POKE - -LAB_POKE - JSR LAB_GADB ; get two parameters for POKE or WAIT - TXA ; copy byte argument to A - LDX #$00 ; clear index - STA (Itempl,X) ; save byte via temporary integer (addr) - RTS - -; perform DEEK() - -LAB_DEEK - JSR LAB_F2FX ; save integer part of FAC1 in temporary integer - LDX #$00 ; clear index - LDA (Itempl,X) ; PEEK low byte - TAY ; copy to Y - INC Itempl ; increment pointer low byte - BNE Deekh ; skip high increment if no rollover - - INC Itemph ; increment pointer high byte -Deekh - LDA (Itempl,X) ; PEEK high byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform DOKE - -LAB_DOKE - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - JSR LAB_F2FX ; convert floating-to-fixed - - STY Frnxtl ; save pointer low byte (float to fixed returns word in AY) - STA Frnxth ; save pointer high byte - - JSR LAB_1C01 ; scan for "," , else do syntax error then warm start - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - JSR LAB_F2FX ; convert floating-to-fixed - - TYA ; copy value low byte (float to fixed returns word in AY) - LDX #$00 ; clear index - STA (Frnxtl,X) ; POKE low byte - INC Frnxtl ; increment pointer low byte - BNE Dokeh ; skip high increment if no rollover - - INC Frnxth ; increment pointer high byte -Dokeh - LDA Itemph ; get value high byte - STA (Frnxtl,X) ; POKE high byte - JMP LAB_GBYT ; scan memory and return - -; perform SWAP - -LAB_SWAP - JSR LAB_GVAR ; get var1 address - STA Lvarpl ; save var1 address low byte - STY Lvarph ; save var1 address high byte - LDA Dtypef ; get data type flag, $FF=string, $00=numeric - PHA ; save data type flag - - JSR LAB_1C01 ; scan for "," , else do syntax error then warm start - JSR LAB_GVAR ; get var2 address (pointer in Cvaral/h) - PLA ; pull var1 data type flag - EOR Dtypef ; compare with var2 data type - BPL SwapErr ; exit if not both the same type - - LDY #$03 ; four bytes to swap (either value or descriptor+1) -SwapLp - LDA (Lvarpl),Y ; get byte from var1 - TAX ; save var1 byte - LDA (Cvaral),Y ; get byte from var2 - STA (Lvarpl),Y ; save byte to var1 - TXA ; restore var1 byte - STA (Cvaral),Y ; save byte to var2 - DEY ; decrement index - BPL SwapLp ; loop until done - - RTS - -SwapErr - JMP LAB_1ABC ; do "Type mismatch" error then warm start - -; perform CALL - -LAB_CALL - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - JSR LAB_F2FX ; convert floating-to-fixed - LDA #>CallExit ; set return address high byte - PHA ; put on stack - LDA #8 shifts) - BCC LAB_24A8 ;.go subtract mantissas - -; add 0.5 to FAC1 - -LAB_244E - LDA #LAB_2A96 ; set 0.5 pointer high byte - -; add (AY) to FAC1 - -LAB_246C - JSR LAB_264D ; unpack memory (AY) into FAC2 - -; add FAC2 to FAC1 - -LAB_ADD - BNE LAB_2474 ; branch if FAC1 was not zero - -; copy FAC2 to FAC1 - -LAB_279B - LDA FAC2_s ; get FAC2 sign (b7) - -; save FAC1 sign and copy ABS(FAC2) to FAC1 - -LAB_279D - STA FAC1_s ; save FAC1 sign (b7) - LDX #$04 ; 4 bytes to copy -LAB_27A1 - LDA FAC1_o,X ; get byte from FAC2,X - STA FAC1_e-1,X ; save byte at FAC1,X - DEX ; decrement count - BNE LAB_27A1 ; loop if not all done - - STX FAC1_r ; clear FAC1 rounding byte - RTS - - ; FAC1 is non zero -LAB_2474 - LDX FAC1_r ; get FAC1 rounding byte - STX FAC2_r ; save as FAC2 rounding byte - LDX #FAC2_e ; set index to FAC2 exponent addr - LDA FAC2_e ; get FAC2 exponent -LAB_247C - TAY ; copy exponent - BEQ LAB_244D ; exit if zero - - SEC ; set carry for subtract - SBC FAC1_e ; subtract FAC1 exponent - BEQ LAB_24A8 ; branch if = (go add mantissa) - - BCC LAB_2498 ; branch if < - - ; FAC2>FAC1 - STY FAC1_e ; save FAC1 exponent - LDY FAC2_s ; get FAC2 sign (b7) - STY FAC1_s ; save FAC1 sign (b7) - EOR #$FF ; complement A - ADC #$00 ; +1 (twos complement, carry is set) - LDY #$00 ; clear Y - STY FAC2_r ; clear FAC2 rounding byte - LDX #FAC1_e ; set index to FAC1 exponent addr - BNE LAB_249C ; branch always - -LAB_2498 - LDY #$00 ; clear Y - STY FAC1_r ; clear FAC1 rounding byte -LAB_249C - CMP #$F9 ; compare exponent diff with $F9 - BMI LAB_2467 ; branch if range $79-$F8 - - TAY ; copy exponent difference to Y - LDA FAC1_r ; get FAC1 rounding byte - LSR PLUS_1,X ; shift FAC? mantissa1 - JSR LAB_2592 ; shift FACX Y times right - - ; exponents are equal now do mantissa subtract -LAB_24A8 - BIT FAC_sc ; test sign compare (FAC1 EOR FAC2) - BPL LAB_24F8 ; if = add FAC2 mantissa to FAC1 mantissa and return - - LDY #FAC1_e ; set index to FAC1 exponent addr - CPX #FAC2_e ; compare X to FAC2 exponent addr - BEQ LAB_24B4 ; branch if = - - LDY #FAC2_e ; else set index to FAC2 exponent addr - - ; subtract smaller from bigger (take sign of bigger) -LAB_24B4 - SEC ; set carry for subtract - EOR #$FF ; ones complement A - ADC FAC2_r ; add FAC2 rounding byte - STA FAC1_r ; save FAC1 rounding byte - LDA PLUS_3,Y ; get FACY mantissa3 - SBC PLUS_3,X ; subtract FACX mantissa3 - STA FAC1_3 ; save FAC1 mantissa3 - LDA PLUS_2,Y ; get FACY mantissa2 - SBC PLUS_2,X ; subtract FACX mantissa2 - STA FAC1_2 ; save FAC1 mantissa2 - LDA PLUS_1,Y ; get FACY mantissa1 - SBC PLUS_1,X ; subtract FACX mantissa1 - STA FAC1_1 ; save FAC1 mantissa1 - -; do ABS and normalise FAC1 - -LAB_24D0 - BCS LAB_24D5 ; branch if number is +ve - - JSR LAB_2537 ; negate FAC1 - -; normalise FAC1 - -LAB_24D5 - LDY #$00 ; clear Y - TYA ; clear A - CLC ; clear carry for add -LAB_24D9 - LDX FAC1_1 ; get FAC1 mantissa1 - BNE LAB_251B ; if not zero normalise FAC1 - - LDX FAC1_2 ; get FAC1 mantissa2 - STX FAC1_1 ; save FAC1 mantissa1 - LDX FAC1_3 ; get FAC1 mantissa3 - STX FAC1_2 ; save FAC1 mantissa2 - LDX FAC1_r ; get FAC1 rounding byte - STX FAC1_3 ; save FAC1 mantissa3 - STY FAC1_r ; clear FAC1 rounding byte - ADC #$08 ; add x to exponent offset - CMP #$18 ; compare with $18 (max offset, all bits would be =0) - BNE LAB_24D9 ; loop if not max - -; clear FAC1 exponent and sign - -LAB_24F1 - LDA #$00 ; clear A -LAB_24F3 - STA FAC1_e ; set FAC1 exponent - -; save FAC1 sign - -LAB_24F5 - STA FAC1_s ; save FAC1 sign (b7) - RTS - -; add FAC2 mantissa to FAC1 mantissa - -LAB_24F8 - ADC FAC2_r ; add FAC2 rounding byte - STA FAC1_r ; save FAC1 rounding byte - LDA FAC1_3 ; get FAC1 mantissa3 - ADC FAC2_3 ; add FAC2 mantissa3 - STA FAC1_3 ; save FAC1 mantissa3 - LDA FAC1_2 ; get FAC1 mantissa2 - ADC FAC2_2 ; add FAC2 mantissa2 - STA FAC1_2 ; save FAC1 mantissa2 - LDA FAC1_1 ; get FAC1 mantissa1 - ADC FAC2_1 ; add FAC2 mantissa1 - STA FAC1_1 ; save FAC1 mantissa1 - BCS LAB_252A ; if carry then normalise FAC1 for C=1 - - RTS ; else just exit - -LAB_2511 - ADC #$01 ; add 1 to exponent offset - ASL FAC1_r ; shift FAC1 rounding byte - ROL FAC1_3 ; shift FAC1 mantissa3 - ROL FAC1_2 ; shift FAC1 mantissa2 - ROL FAC1_1 ; shift FAC1 mantissa1 - -; normalise FAC1 - -LAB_251B - BPL LAB_2511 ; loop if not normalised - - SEC ; set carry for subtract - SBC FAC1_e ; subtract FAC1 exponent - BCS LAB_24F1 ; branch if underflow (set result = $0) - - EOR #$FF ; complement exponent - ADC #$01 ; +1 (twos complement) - STA FAC1_e ; save FAC1 exponent - -; test and normalise FAC1 for C=0/1 - -LAB_2528 - BCC LAB_2536 ; exit if no overflow - -; normalise FAC1 for C=1 - -LAB_252A - INC FAC1_e ; increment FAC1 exponent - BEQ LAB_2564 ; if zero do overflow error and warm start - - ROR FAC1_1 ; shift FAC1 mantissa1 - ROR FAC1_2 ; shift FAC1 mantissa2 - ROR FAC1_3 ; shift FAC1 mantissa3 - ROR FAC1_r ; shift FAC1 rounding byte -LAB_2536 - RTS - -; negate FAC1 - -LAB_2537 - LDA FAC1_s ; get FAC1 sign (b7) - EOR #$FF ; complement it - STA FAC1_s ; save FAC1 sign (b7) - -; twos complement FAC1 mantissa - -LAB_253D - LDA FAC1_1 ; get FAC1 mantissa1 - EOR #$FF ; complement it - STA FAC1_1 ; save FAC1 mantissa1 - LDA FAC1_2 ; get FAC1 mantissa2 - EOR #$FF ; complement it - STA FAC1_2 ; save FAC1 mantissa2 - LDA FAC1_3 ; get FAC1 mantissa3 - EOR #$FF ; complement it - STA FAC1_3 ; save FAC1 mantissa3 - LDA FAC1_r ; get FAC1 rounding byte - EOR #$FF ; complement it - STA FAC1_r ; save FAC1 rounding byte - INC FAC1_r ; increment FAC1 rounding byte - BNE LAB_2563 ; exit if no overflow - -; increment FAC1 mantissa - -LAB_2559 - INC FAC1_3 ; increment FAC1 mantissa3 - BNE LAB_2563 ; finished if no rollover - - INC FAC1_2 ; increment FAC1 mantissa2 - BNE LAB_2563 ; finished if no rollover - - INC FAC1_1 ; increment FAC1 mantissa1 -LAB_2563 - RTS - -; do overflow error (overflow exit) - -LAB_2564 - LDX #$0A ; error code $0A ("Overflow" error) - JMP LAB_XERR ; do error #X, then warm start - -; shift FCAtemp << A+8 times - -LAB_2569 - LDX #FACt_1-1 ; set offset to FACtemp -LAB_256B - LDY PLUS_3,X ; get FACX mantissa3 - STY FAC1_r ; save as FAC1 rounding byte - LDY PLUS_2,X ; get FACX mantissa2 - STY PLUS_3,X ; save FACX mantissa3 - LDY PLUS_1,X ; get FACX mantissa1 - STY PLUS_2,X ; save FACX mantissa2 - LDY FAC1_o ; get FAC1 overflow byte - STY PLUS_1,X ; save FACX mantissa1 - -; shift FACX -A times right (> 8 shifts) - -LAB_257B - ADC #$08 ; add 8 to shift count - BMI LAB_256B ; go do 8 shift if still -ve - - BEQ LAB_256B ; go do 8 shift if zero - - SBC #$08 ; else subtract 8 again - TAY ; save count to Y - LDA FAC1_r ; get FAC1 rounding byte - BCS LAB_259A ;. - -LAB_2588 - ASL PLUS_1,X ; shift FACX mantissa1 - BCC LAB_258E ; branch if +ve - - INC PLUS_1,X ; this sets b7 eventually -LAB_258E - ROR PLUS_1,X ; shift FACX mantissa1 (correct for ASL) - ROR PLUS_1,X ; shift FACX mantissa1 (put carry in b7) - -; shift FACX Y times right - -LAB_2592 - ROR PLUS_2,X ; shift FACX mantissa2 - ROR PLUS_3,X ; shift FACX mantissa3 - ROR ; shift FACX rounding byte - INY ; increment exponent diff - BNE LAB_2588 ; branch if range adjust not complete - -LAB_259A - CLC ; just clear it - RTS - -; perform LOG() - -LAB_LOG - JSR LAB_27CA ; test sign and zero - BEQ LAB_25C4 ; if zero do function call error then warm start - - BPL LAB_25C7 ; skip error if +ve - -LAB_25C4 - JMP LAB_FCER ; do function call error then warm start (-ve) - -LAB_25C7 - LDA FAC1_e ; get FAC1 exponent - SBC #$7F ; normalise it - PHA ; save it - LDA #$80 ; set exponent to zero - STA FAC1_e ; save FAC1 exponent - LDA #LAB_25AD ; set 1/root2 pointer high byte - JSR LAB_246C ; add (AY) to FAC1 (1/root2) - LDA #LAB_25B1 ; set root2 pointer high byte - JSR LAB_26CA ; convert AY and do (AY)/FAC1 (root2/(x+(1/root2))) - LDA #LAB_259C ; set 1 pointer high byte - JSR LAB_2455 ; subtract (AY) from FAC1 ((root2/(x+(1/root2)))-1) - LDA #LAB_25A0 ; set pointer high byte to counter - JSR LAB_2B6E ; ^2 then series evaluation - LDA #LAB_25B5 ; set -0.5 pointer high byte - JSR LAB_246C ; add (AY) to FAC1 - PLA ; restore FAC1 exponent - JSR LAB_2912 ; evaluate new ASCII digit - LDA #LAB_25B9 ; set LOG(2) pointer high byte - -; do convert AY, FCA1*(AY) - -LAB_25FB - JSR LAB_264D ; unpack memory (AY) into FAC2 -LAB_MULTIPLY - BEQ LAB_264C ; exit if zero - - JSR LAB_2673 ; test and adjust accumulators - LDA #$00 ; clear A - STA FACt_1 ; clear temp mantissa1 - STA FACt_2 ; clear temp mantissa2 - STA FACt_3 ; clear temp mantissa3 - LDA FAC1_r ; get FAC1 rounding byte - JSR LAB_2622 ; go do shift/add FAC2 - LDA FAC1_3 ; get FAC1 mantissa3 - JSR LAB_2622 ; go do shift/add FAC2 - LDA FAC1_2 ; get FAC1 mantissa2 - JSR LAB_2622 ; go do shift/add FAC2 - LDA FAC1_1 ; get FAC1 mantissa1 - JSR LAB_2627 ; go do shift/add FAC2 - JMP LAB_273C ; copy temp to FAC1, normalise and return - -LAB_2622 - BNE LAB_2627 ; branch if byte <> zero - - JMP LAB_2569 ; shift FCAtemp << A+8 times - - ; else do shift and add -LAB_2627 - LSR ; shift byte - ORA #$80 ; set top bit (mark for 8 times) -LAB_262A - TAY ; copy result - BCC LAB_2640 ; skip next if bit was zero - - CLC ; clear carry for add - LDA FACt_3 ; get temp mantissa3 - ADC FAC2_3 ; add FAC2 mantissa3 - STA FACt_3 ; save temp mantissa3 - LDA FACt_2 ; get temp mantissa2 - ADC FAC2_2 ; add FAC2 mantissa2 - STA FACt_2 ; save temp mantissa2 - LDA FACt_1 ; get temp mantissa1 - ADC FAC2_1 ; add FAC2 mantissa1 - STA FACt_1 ; save temp mantissa1 -LAB_2640 - ROR FACt_1 ; shift temp mantissa1 - ROR FACt_2 ; shift temp mantissa2 - ROR FACt_3 ; shift temp mantissa3 - ROR FAC1_r ; shift temp rounding byte - TYA ; get byte back - LSR ; shift byte - BNE LAB_262A ; loop if all bits not done - -LAB_264C - RTS - -; unpack memory (AY) into FAC2 - -LAB_264D - STA ut1_pl ; save pointer low byte - STY ut1_ph ; save pointer high byte - LDY #$03 ; 4 bytes to get (0-3) - LDA (ut1_pl),Y ; get mantissa3 - STA FAC2_3 ; save FAC2 mantissa3 - DEY ; decrement index - LDA (ut1_pl),Y ; get mantissa2 - STA FAC2_2 ; save FAC2 mantissa2 - DEY ; decrement index - LDA (ut1_pl),Y ; get mantissa1+sign - STA FAC2_s ; save FAC2 sign (b7) - EOR FAC1_s ; EOR with FAC1 sign (b7) - STA FAC_sc ; save sign compare (FAC1 EOR FAC2) - LDA FAC2_s ; recover FAC2 sign (b7) - ORA #$80 ; set 1xxx xxx (set normal bit) - STA FAC2_1 ; save FAC2 mantissa1 - DEY ; decrement index - LDA (ut1_pl),Y ; get exponent byte - STA FAC2_e ; save FAC2 exponent - LDA FAC1_e ; get FAC1 exponent - RTS - -; test and adjust accumulators - -LAB_2673 - LDA FAC2_e ; get FAC2 exponent -LAB_2675 - BEQ LAB_2696 ; branch if FAC2 = $00 (handle underflow) - - CLC ; clear carry for add - ADC FAC1_e ; add FAC1 exponent - BCC LAB_2680 ; branch if sum of exponents <$0100 - - BMI LAB_269B ; do overflow error - - CLC ; clear carry for the add - .byte $2C ; makes next line BIT $1410 -LAB_2680 - BPL LAB_2696 ; if +ve go handle underflow - - ADC #$80 ; adjust exponent - STA FAC1_e ; save FAC1 exponent - BNE LAB_268B ; branch if not zero - - JMP LAB_24F5 ; save FAC1 sign and return - -LAB_268B - LDA FAC_sc ; get sign compare (FAC1 EOR FAC2) - STA FAC1_s ; save FAC1 sign (b7) -LAB_268F - RTS - -; handle overflow and underflow - -LAB_2690 - LDA FAC1_s ; get FAC1 sign (b7) - BPL LAB_269B ; do overflow error - - ; handle underflow -LAB_2696 - PLA ; pop return address low byte - PLA ; pop return address high byte - JMP LAB_24F1 ; clear FAC1 exponent and sign and return - -; multiply by 10 - -LAB_269E - JSR LAB_27AB ; round and copy FAC1 to FAC2 - TAX ; copy exponent (set the flags) - BEQ LAB_268F ; exit if zero - - CLC ; clear carry for add - ADC #$02 ; add two to exponent (*4) - BCS LAB_269B ; do overflow error if > $FF - - LDX #$00 ; clear byte - STX FAC_sc ; clear sign compare (FAC1 EOR FAC2) - JSR LAB_247C ; add FAC2 to FAC1 (*5) - INC FAC1_e ; increment FAC1 exponent (*10) - BNE LAB_268F ; if non zero just do RTS - -LAB_269B - JMP LAB_2564 ; do overflow error and warm start - -; divide by 10 - -LAB_26B9 - JSR LAB_27AB ; round and copy FAC1 to FAC2 - LDA #LAB_26B5 ; set pointer to 10d high addr - LDX #$00 ; clear sign - -; divide by (AY) (X=sign) - -LAB_26C2 - STX FAC_sc ; save sign compare (FAC1 EOR FAC2) - JSR LAB_UFAC ; unpack memory (AY) into FAC1 - JMP LAB_DIVIDE ; do FAC2/FAC1 - - ; Perform divide-by -; convert AY and do (AY)/FAC1 - -LAB_26CA - JSR LAB_264D ; unpack memory (AY) into FAC2 - - ; Perform divide-into -LAB_DIVIDE - BEQ LAB_2737 ; if zero go do /0 error - - JSR LAB_27BA ; round FAC1 - LDA #$00 ; clear A - SEC ; set carry for subtract - SBC FAC1_e ; subtract FAC1 exponent (2s complement) - STA FAC1_e ; save FAC1 exponent - JSR LAB_2673 ; test and adjust accumulators - INC FAC1_e ; increment FAC1 exponent - BEQ LAB_269B ; if zero do overflow error - - LDX #$FF ; set index for pre increment - LDA #$01 ; set bit to flag byte save -LAB_26E4 - LDY FAC2_1 ; get FAC2 mantissa1 - CPY FAC1_1 ; compare FAC1 mantissa1 - BNE LAB_26F4 ; branch if <> - - LDY FAC2_2 ; get FAC2 mantissa2 - CPY FAC1_2 ; compare FAC1 mantissa2 - BNE LAB_26F4 ; branch if <> - - LDY FAC2_3 ; get FAC2 mantissa3 - CPY FAC1_3 ; compare FAC1 mantissa3 -LAB_26F4 - PHP ; save FAC2-FAC1 compare status - ROL ; shift the result byte - BCC LAB_2702 ; if no carry skip the byte save - - LDY #$01 ; set bit to flag byte save - INX ; else increment the index to FACt - CPX #$02 ; compare with the index to FACt_3 - BMI LAB_2701 ; if not last byte just go save it - - BNE LAB_272B ; if all done go save FAC1 rounding byte, normalise and - ; return - - LDY #$40 ; set bit to flag byte save for the rounding byte -LAB_2701 - STA FACt_1,X ; write result byte to FACt_1 + index - TYA ; copy the next save byte flag -LAB_2702 - PLP ; restore FAC2-FAC1 compare status - BCC LAB_2704 ; if FAC2 < FAC1 then skip the subtract - - TAY ; save FAC2-FAC1 compare status - LDA FAC2_3 ; get FAC2 mantissa3 - SBC FAC1_3 ; subtract FAC1 mantissa3 - STA FAC2_3 ; save FAC2 mantissa3 - LDA FAC2_2 ; get FAC2 mantissa2 - SBC FAC1_2 ; subtract FAC1 mantissa2 - STA FAC2_2 ; save FAC2 mantissa2 - LDA FAC2_1 ; get FAC2 mantissa1 - SBC FAC1_1 ; subtract FAC1 mantissa1 - STA FAC2_1 ; save FAC2 mantissa1 - TYA ; restore FAC2-FAC1 compare status - - ; FAC2 = FAC2*2 -LAB_2704 - ASL FAC2_3 ; shift FAC2 mantissa3 - ROL FAC2_2 ; shift FAC2 mantissa2 - ROL FAC2_1 ; shift FAC2 mantissa1 - BCS LAB_26F4 ; loop with no compare - - BMI LAB_26E4 ; loop with compare - - BPL LAB_26F4 ; loop always with no compare - -; do A<<6, save as FAC1 rounding byte, normalise and return - -LAB_272B - LSR ; shift b1 - b0 .. - ROR ; .. - ROR ; .. to b7 - b6 - STA FAC1_r ; save FAC1 rounding byte - PLP ; dump FAC2-FAC1 compare status - JMP LAB_273C ; copy temp to FAC1, normalise and return - -; do "Divide by zero" error - -LAB_2737 - LDX #$14 ; error code $14 ("Divide by zero" error) - JMP LAB_XERR ; do error #X, then warm start - -; copy temp to FAC1 and normalise - -LAB_273C - LDA FACt_1 ; get temp mantissa1 - STA FAC1_1 ; save FAC1 mantissa1 - LDA FACt_2 ; get temp mantissa2 - STA FAC1_2 ; save FAC1 mantissa2 - LDA FACt_3 ; get temp mantissa3 - STA FAC1_3 ; save FAC1 mantissa3 - JMP LAB_24D5 ; normalise FAC1 and return - -; unpack memory (AY) into FAC1 - -LAB_UFAC - STA ut1_pl ; save pointer low byte - STY ut1_ph ; save pointer high byte - LDY #$03 ; 4 bytes to do - LDA (ut1_pl),Y ; get last byte - STA FAC1_3 ; save FAC1 mantissa3 - DEY ; decrement index - LDA (ut1_pl),Y ; get last-1 byte - STA FAC1_2 ; save FAC1 mantissa2 - DEY ; decrement index - LDA (ut1_pl),Y ; get second byte - STA FAC1_s ; save FAC1 sign (b7) - ORA #$80 ; set 1xxx xxxx (add normal bit) - STA FAC1_1 ; save FAC1 mantissa1 - DEY ; decrement index - LDA (ut1_pl),Y ; get first byte (exponent) - STA FAC1_e ; save FAC1 exponent - STY FAC1_r ; clear FAC1 rounding byte - RTS - -; pack FAC1 into Adatal - -LAB_276E - LDX #Adatal ; set pointer high byte - BEQ LAB_2778 ; pack FAC1 into (XY) and return - -; pack FAC1 into (Lvarpl) - -LAB_PFAC - LDX Lvarpl ; get destination pointer low byte - LDY Lvarph ; get destination pointer high byte - -; pack FAC1 into (XY) - -LAB_2778 - JSR LAB_27BA ; round FAC1 - STX ut1_pl ; save pointer low byte - STY ut1_ph ; save pointer high byte - LDY #$03 ; set index - LDA FAC1_3 ; get FAC1 mantissa3 - STA (ut1_pl),Y ; store in destination - DEY ; decrement index - LDA FAC1_2 ; get FAC1 mantissa2 - STA (ut1_pl),Y ; store in destination - DEY ; decrement index - LDA FAC1_s ; get FAC1 sign (b7) - ORA #$7F ; set bits x111 1111 - AND FAC1_1 ; AND in FAC1 mantissa1 - STA (ut1_pl),Y ; store in destination - DEY ; decrement index - LDA FAC1_e ; get FAC1 exponent - STA (ut1_pl),Y ; store in destination - STY FAC1_r ; clear FAC1 rounding byte - RTS - -; round and copy FAC1 to FAC2 - -LAB_27AB - JSR LAB_27BA ; round FAC1 - -; copy FAC1 to FAC2 - -LAB_27AE - LDX #$05 ; 5 bytes to copy -LAB_27B0 - LDA FAC1_e-1,X ; get byte from FAC1,X - STA FAC1_o,X ; save byte at FAC2,X - DEX ; decrement count - BNE LAB_27B0 ; loop if not all done - - STX FAC1_r ; clear FAC1 rounding byte -LAB_27B9 - RTS - -; round FAC1 - -LAB_27BA - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_27B9 ; exit if zero - - ASL FAC1_r ; shift FAC1 rounding byte - BCC LAB_27B9 ; exit if no overflow - -; round FAC1 (no check) - -LAB_27C2 - JSR LAB_2559 ; increment FAC1 mantissa - BNE LAB_27B9 ; branch if no overflow - - JMP LAB_252A ; normalise FAC1 for C=1 and return - -; get FAC1 sign -; return A=FF,C=1/-ve A=01,C=0/+ve - -LAB_27CA - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_27D7 ; exit if zero (already correct SGN(0)=0) - -; return A=FF,C=1/-ve A=01,C=0/+ve -; no = 0 check - -LAB_27CE - LDA FAC1_s ; else get FAC1 sign (b7) - -; return A=FF,C=1/-ve A=01,C=0/+ve -; no = 0 check, sign in A - -LAB_27D0 - ROL ; move sign bit to carry - LDA #$FF ; set byte for -ve result - BCS LAB_27D7 ; return if sign was set (-ve) - - LDA #$01 ; else set byte for +ve result -LAB_27D7 - RTS - -; perform SGN() - -LAB_SGN - JSR LAB_27CA ; get FAC1 sign - ; return A=$FF/-ve A=$01/+ve -; save A as integer byte - -LAB_27DB - STA FAC1_1 ; save FAC1 mantissa1 - LDA #$00 ; clear A - STA FAC1_2 ; clear FAC1 mantissa2 - LDX #$88 ; set exponent - -; set exp=X, clearFAC1 mantissa3 and normalise - -LAB_27E3 - LDA FAC1_1 ; get FAC1 mantissa1 - EOR #$FF ; complement it - ROL ; sign bit into carry - -; set exp=X, clearFAC1 mantissa3 and normalise - -LAB_STFA - LDA #$00 ; clear A - STA FAC1_3 ; clear FAC1 mantissa3 - STX FAC1_e ; set FAC1 exponent - STA FAC1_r ; clear FAC1 rounding byte - STA FAC1_s ; clear FAC1 sign (b7) - JMP LAB_24D0 ; do ABS and normalise FAC1 - -; perform ABS() - -LAB_ABS - LSR FAC1_s ; clear FAC1 sign (put zero in b7) - RTS - -; compare FAC1 with (AY) -; returns A=$00 if FAC1 = (AY) -; returns A=$01 if FAC1 > (AY) -; returns A=$FF if FAC1 < (AY) - -LAB_27F8 - STA ut2_pl ; save pointer low byte -LAB_27FA - STY ut2_ph ; save pointer high byte - LDY #$00 ; clear index - LDA (ut2_pl),Y ; get exponent - INY ; increment index - TAX ; copy (AY) exponent to X - BEQ LAB_27CA ; branch if (AY) exponent=0 and get FAC1 sign - ; A=FF,C=1/-ve A=01,C=0/+ve - - LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign) - EOR FAC1_s ; EOR FAC1 sign (b7) - BMI LAB_27CE ; if signs <> do return A=FF,C=1/-ve - ; A=01,C=0/+ve and return - - CPX FAC1_e ; compare (AY) exponent with FAC1 exponent - BNE LAB_2828 ; branch if different - - LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign) - ORA #$80 ; normalise top bit - CMP FAC1_1 ; compare with FAC1 mantissa1 - BNE LAB_2828 ; branch if different - - INY ; increment index - LDA (ut2_pl),Y ; get mantissa2 - CMP FAC1_2 ; compare with FAC1 mantissa2 - BNE LAB_2828 ; branch if different - - INY ; increment index - LDA #$7F ; set for 1/2 value rounding byte - CMP FAC1_r ; compare with FAC1 rounding byte (set carry) - LDA (ut2_pl),Y ; get mantissa3 - SBC FAC1_3 ; subtract FAC1 mantissa3 - BEQ LAB_2850 ; exit if mantissa3 equal - -; gets here if number <> FAC1 - -LAB_2828 - LDA FAC1_s ; get FAC1 sign (b7) - BCC LAB_282E ; branch if FAC1 > (AY) - - EOR #$FF ; else toggle FAC1 sign -LAB_282E - JMP LAB_27D0 ; return A=FF,C=1/-ve A=01,C=0/+ve - -; convert FAC1 floating-to-fixed - -LAB_2831 - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_287F ; if zero go clear FAC1 and return - - SEC ; set carry for subtract - SBC #$98 ; subtract maximum integer range exponent - BIT FAC1_s ; test FAC1 sign (b7) - BPL LAB_2845 ; branch if FAC1 +ve - - ; FAC1 was -ve - TAX ; copy subtracted exponent - LDA #$FF ; overflow for -ve number - STA FAC1_o ; set FAC1 overflow byte - JSR LAB_253D ; twos complement FAC1 mantissa - TXA ; restore subtracted exponent -LAB_2845 - LDX #FAC1_e ; set index to FAC1 - CMP #$F9 ; compare exponent result - BPL LAB_2851 ; if < 8 shifts shift FAC1 A times right and return - - JSR LAB_257B ; shift FAC1 A times right (> 8 shifts) - STY FAC1_o ; clear FAC1 overflow byte -LAB_2850 - RTS - -; shift FAC1 A times right - -LAB_2851 - TAY ; copy shift count - LDA FAC1_s ; get FAC1 sign (b7) - AND #$80 ; mask sign bit only (x000 0000) - LSR FAC1_1 ; shift FAC1 mantissa1 - ORA FAC1_1 ; OR sign in b7 FAC1 mantissa1 - STA FAC1_1 ; save FAC1 mantissa1 - JSR LAB_2592 ; shift FAC1 Y times right - STY FAC1_o ; clear FAC1 overflow byte - RTS - -; perform INT() - -LAB_INT - LDA FAC1_e ; get FAC1 exponent - CMP #$98 ; compare with max int - BCS LAB_2886 ; exit if >= (already int, too big for fractional part!) - - JSR LAB_2831 ; convert FAC1 floating-to-fixed - STY FAC1_r ; save FAC1 rounding byte - LDA FAC1_s ; get FAC1 sign (b7) - STY FAC1_s ; save FAC1 sign (b7) - EOR #$80 ; toggle FAC1 sign - ROL ; shift into carry - LDA #$98 ; set new exponent - STA FAC1_e ; save FAC1 exponent - LDA FAC1_3 ; get FAC1 mantissa3 - STA Temp3 ; save for EXP() function - JMP LAB_24D0 ; do ABS and normalise FAC1 - -; clear FAC1 and return - -LAB_287F - STA FAC1_1 ; clear FAC1 mantissa1 - STA FAC1_2 ; clear FAC1 mantissa2 - STA FAC1_3 ; clear FAC1 mantissa3 - TAY ; clear Y -LAB_2886 - RTS - -; get FAC1 from string -; this routine now handles hex and binary values from strings -; starting with "$" and "%" respectively - -LAB_2887 - LDY #$00 ; clear Y - STY Dtypef ; clear data type flag, $FF=string, $00=numeric - LDX #$09 ; set index -LAB_288B - STY numexp,X ; clear byte - DEX ; decrement index - BPL LAB_288B ; loop until numexp to negnum (and FAC1) = $00 - - BCC LAB_28FE ; branch if 1st character numeric - -; get FAC1 from string .. first character wasn't numeric - - CMP #'-' ; else compare with "-" - BNE LAB_289A ; branch if not "-" - - STX negnum ; set flag for -ve number (X = $FF) - BEQ LAB_289C ; branch always (go scan and check for hex/bin) - -; get FAC1 from string .. first character wasn't numeric or - - -LAB_289A - CMP #'+' ; else compare with "+" - BNE LAB_289D ; branch if not "+" (go check for hex/bin) - -; was "+" or "-" to start, so get next character - -LAB_289C - JSR LAB_IGBY ; increment and scan memory - BCC LAB_28FE ; branch if numeric character - -; code here for hex and binary numbers - -LAB_289D - CMP #'$' ; else compare with "$" - BNE LAB_NHEX ; branch if not "$" - - JMP LAB_CHEX ; branch if "$" - -LAB_NHEX - CMP #'%' ; else compare with "%" - BNE LAB_28A3 ; branch if not "%" (continue original code) - - JMP LAB_CBIN ; branch if "%" - -LAB_289E - JSR LAB_IGBY ; increment and scan memory (ignore + or get next number) -LAB_28A1 - BCC LAB_28FE ; branch if numeric character - -; get FAC1 from string .. character wasn't numeric, -, +, hex or binary - -LAB_28A3 - CMP #'.' ; else compare with "." - BEQ LAB_28D5 ; branch if "." - -; get FAC1 from string .. character wasn't numeric, -, + or . - - CMP #'E' ; else compare with "E" - BNE LAB_28DB ; branch if not "E" - - ; was "E" so evaluate exponential part - JSR LAB_IGBY ; increment and scan memory - BCC LAB_28C7 ; branch if numeric character - - CMP #TK_MINUS ; else compare with token for - - BEQ LAB_28C2 ; branch if token for - - - CMP #'-' ; else compare with "-" - BEQ LAB_28C2 ; branch if "-" - - CMP #TK_PLUS ; else compare with token for + - BEQ LAB_28C4 ; branch if token for + - - CMP #'+' ; else compare with "+" - BEQ LAB_28C4 ; branch if "+" - - BNE LAB_28C9 ; branch always - -LAB_28C2 - ROR expneg ; set exponent -ve flag (C, which=1, into b7) -LAB_28C4 - JSR LAB_IGBY ; increment and scan memory -LAB_28C7 - BCC LAB_2925 ; branch if numeric character - -LAB_28C9 - BIT expneg ; test exponent -ve flag - BPL LAB_28DB ; if +ve go evaluate exponent - - ; else do exponent = -exponent - LDA #$00 ; clear result - SEC ; set carry for subtract - SBC expcnt ; subtract exponent byte - JMP LAB_28DD ; go evaluate exponent - -LAB_28D5 - ROR numdpf ; set decimal point flag - BIT numdpf ; test decimal point flag - BVC LAB_289E ; branch if only one decimal point so far - - ; evaluate exponent -LAB_28DB - LDA expcnt ; get exponent count byte -LAB_28DD - SEC ; set carry for subtract - SBC numexp ; subtract numerator exponent - STA expcnt ; save exponent count byte - BEQ LAB_28F6 ; branch if no adjustment - - BPL LAB_28EF ; else if +ve go do FAC1*10^expcnt - - ; else go do FAC1/10^(0-expcnt) -LAB_28E6 - JSR LAB_26B9 ; divide by 10 - INC expcnt ; increment exponent count byte - BNE LAB_28E6 ; loop until all done - - BEQ LAB_28F6 ; branch always - -LAB_28EF - JSR LAB_269E ; multiply by 10 - DEC expcnt ; decrement exponent count byte - BNE LAB_28EF ; loop until all done - -LAB_28F6 - LDA negnum ; get -ve flag - BMI LAB_28FB ; if -ve do - FAC1 and return - - RTS - -; do - FAC1 and return - -LAB_28FB - JMP LAB_GTHAN ; do - FAC1 and return - -; do unsigned FAC1*10+number - -LAB_28FE - PHA ; save character - BIT numdpf ; test decimal point flag - BPL LAB_2905 ; skip exponent increment if not set - - INC numexp ; else increment number exponent -LAB_2905 - JSR LAB_269E ; multiply FAC1 by 10 - PLA ; restore character - AND #$0F ; convert to binary - JSR LAB_2912 ; evaluate new ASCII digit - JMP LAB_289E ; go do next character - -; evaluate new ASCII digit - -LAB_2912 - PHA ; save digit - JSR LAB_27AB ; round and copy FAC1 to FAC2 - PLA ; restore digit - JSR LAB_27DB ; save A as integer byte - LDA FAC2_s ; get FAC2 sign (b7) - EOR FAC1_s ; toggle with FAC1 sign (b7) - STA FAC_sc ; save sign compare (FAC1 EOR FAC2) - LDX FAC1_e ; get FAC1 exponent - JMP LAB_ADD ; add FAC2 to FAC1 and return - -; evaluate next character of exponential part of number - -LAB_2925 - LDA expcnt ; get exponent count byte - CMP #$0A ; compare with 10 decimal - BCC LAB_2934 ; branch if less - - LDA #$64 ; make all -ve exponents = -100 decimal (causes underflow) - BIT expneg ; test exponent -ve flag - BMI LAB_2942 ; branch if -ve - - JMP LAB_2564 ; else do overflow error - -LAB_2934 - ASL ; * 2 - ASL ; * 4 - ADC expcnt ; * 5 - ASL ; * 10 - LDY #$00 ; set index - ADC (Bpntrl),Y ; add character (will be $30 too much!) - SBC #'0'-1 ; convert character to binary -LAB_2942 - STA expcnt ; save exponent count byte - JMP LAB_28C4 ; go get next character - -; print " in line [LINE #]" - -LAB_2953 - LDA #LAB_LMSG ; point to " in line " message high byte - JSR LAB_18C3 ; print null terminated string from memory - - ; print Basic line # - LDA Clineh ; get current line high byte - LDX Clinel ; get current line low byte - -; print XA as unsigned integer - -LAB_295E - STA FAC1_1 ; save low byte as FAC1 mantissa1 - STX FAC1_2 ; save high byte as FAC1 mantissa2 - LDX #$90 ; set exponent to 16d bits - SEC ; set integer is +ve flag - JSR LAB_STFA ; set exp=X, clearFAC1 mantissa3 and normalise - LDY #$00 ; clear index - TYA ; clear A - JSR LAB_297B ; convert FAC1 to string, skip sign character save - JMP LAB_18C3 ; print null terminated string from memory and return - -; convert FAC1 to ASCII string result in (AY) -; not any more, moved scratchpad to page 0 - -LAB_296E - LDY #$01 ; set index = 1 - LDA #$20 ; character = " " (assume +ve) - BIT FAC1_s ; test FAC1 sign (b7) - BPL LAB_2978 ; branch if +ve - - LDA #$2D ; else character = "-" -LAB_2978 - STA Decss,Y ; save leading character (" " or "-") -LAB_297B - STA FAC1_s ; clear FAC1 sign (b7) - STY Sendl ; save index - INY ; increment index - LDX FAC1_e ; get FAC1 exponent - BNE LAB_2989 ; branch if FAC1<>0 - - ; exponent was $00 so FAC1 is 0 - LDA #'0' ; set character = "0" - JMP LAB_2A89 ; save last character, [EOT] and exit - - ; FAC1 is some non zero value -LAB_2989 - LDA #$00 ; clear (number exponent count) - CPX #$81 ; compare FAC1 exponent with $81 (>1.00000) - - BCS LAB_299A ; branch if FAC1=>1 - - ; FAC1<1 - LDA #LAB_294F ; set pointer high byte to 1,000,000 - JSR LAB_25FB ; do convert AY, FCA1*(AY) - LDA #$FA ; set number exponent count (-6) -LAB_299A - STA numexp ; save number exponent count -LAB_299C - LDA #LAB_294B ; set pointer high byte to 999999.4375 - JSR LAB_27F8 ; compare FAC1 with (AY) - BEQ LAB_29C3 ; exit if FAC1 = (AY) - - BPL LAB_29B9 ; go do /10 if FAC1 > (AY) - - ; FAC1 < (AY) -LAB_29A7 - LDA #LAB_2947 ; set pointer high byte to 99999.9375 - JSR LAB_27F8 ; compare FAC1 with (AY) - BEQ LAB_29B2 ; branch if FAC1 = (AY) (allow decimal places) - - BPL LAB_29C0 ; branch if FAC1 > (AY) (no decimal places) - - ; FAC1 <= (AY) -LAB_29B2 - JSR LAB_269E ; multiply by 10 - DEC numexp ; decrement number exponent count - BNE LAB_29A7 ; go test again (branch always) - -LAB_29B9 - JSR LAB_26B9 ; divide by 10 - INC numexp ; increment number exponent count - BNE LAB_299C ; go test again (branch always) - -; now we have just the digits to do - -LAB_29C0 - JSR LAB_244E ; add 0.5 to FAC1 (round FAC1) -LAB_29C3 - JSR LAB_2831 ; convert FAC1 floating-to-fixed - LDX #$01 ; set default digits before dp = 1 - LDA numexp ; get number exponent count - CLC ; clear carry for add - ADC #$07 ; up to 6 digits before point - BMI LAB_29D8 ; if -ve then 1 digit before dp - - CMP #$08 ; A>=8 if n>=1E6 - BCS LAB_29D9 ; branch if >= $08 - - ; carry is clear - ADC #$FF ; take 1 from digit count - TAX ; copy to A - LDA #$02 ;.set exponent adjust -LAB_29D8 - SEC ; set carry for subtract -LAB_29D9 - SBC #$02 ; -2 - STA expcnt ;.save exponent adjust - STX numexp ; save digits before dp count - TXA ; copy to A - BEQ LAB_29E4 ; branch if no digits before dp - - BPL LAB_29F7 ; branch if digits before dp - -LAB_29E4 - LDY Sendl ; get output string index - LDA #$2E ; character "." - INY ; increment index - STA Decss,Y ; save to output string - TXA ;. - BEQ LAB_29F5 ;. - - LDA #'0' ; character "0" - INY ; increment index - STA Decss,Y ; save to output string -LAB_29F5 - STY Sendl ; save output string index -LAB_29F7 - LDY #$00 ; clear index (point to 100,000) - LDX #$80 ; -LAB_29FB - LDA FAC1_3 ; get FAC1 mantissa3 - CLC ; clear carry for add - ADC LAB_2A9C,Y ; add -ve LSB - STA FAC1_3 ; save FAC1 mantissa3 - LDA FAC1_2 ; get FAC1 mantissa2 - ADC LAB_2A9B,Y ; add -ve NMSB - STA FAC1_2 ; save FAC1 mantissa2 - LDA FAC1_1 ; get FAC1 mantissa1 - ADC LAB_2A9A,Y ; add -ve MSB - STA FAC1_1 ; save FAC1 mantissa1 - INX ; - BCS LAB_2A18 ; - - BPL LAB_29FB ; not -ve so try again - - BMI LAB_2A1A ; - -LAB_2A18 - BMI LAB_29FB ; - -LAB_2A1A - TXA ; - BCC LAB_2A21 ; - - EOR #$FF ; - ADC #$0A ; -LAB_2A21 - ADC #'0'-1 ; add "0"-1 to result - INY ; increment index .. - INY ; .. to next less .. - INY ; .. power of ten - STY Cvaral ; save as current var address low byte - LDY Sendl ; get output string index - INY ; increment output string index - TAX ; copy character to X - AND #$7F ; mask out top bit - STA Decss,Y ; save to output string - DEC numexp ; decrement # of characters before the dp - BNE LAB_2A3B ; branch if still characters to do - - ; else output the point - LDA #$2E ; character "." - INY ; increment output string index - STA Decss,Y ; save to output string -LAB_2A3B - STY Sendl ; save output string index - LDY Cvaral ; get current var address low byte - TXA ; get character back - EOR #$FF ; - AND #$80 ; - TAX ; - CPY #$12 ; compare index with max - BNE LAB_29FB ; loop if not max - - ; now remove trailing zeroes - LDY Sendl ; get output string index -LAB_2A4B - LDA Decss,Y ; get character from output string - DEY ; decrement output string index - CMP #'0' ; compare with "0" - BEQ LAB_2A4B ; loop until non "0" character found - - CMP #'.' ; compare with "." - BEQ LAB_2A58 ; branch if was dp - - ; restore last character - INY ; increment output string index -LAB_2A58 - LDA #$2B ; character "+" - LDX expcnt ; get exponent count - BEQ LAB_2A8C ; if zero go set null terminator and exit - - ; exponent isn't zero so write exponent - BPL LAB_2A68 ; branch if exponent count +ve - - LDA #$00 ; clear A - SEC ; set carry for subtract - SBC expcnt ; subtract exponent count adjust (convert -ve to +ve) - TAX ; copy exponent count to X - LDA #'-' ; character "-" -LAB_2A68 - STA Decss+2,Y ; save to output string - LDA #$45 ; character "E" - STA Decss+1,Y ; save exponent sign to output string - TXA ; get exponent count back - LDX #'0'-1 ; one less than "0" character - SEC ; set carry for subtract -LAB_2A74 - INX ; increment 10's character - SBC #$0A ;.subtract 10 from exponent count - BCS LAB_2A74 ; loop while still >= 0 - - ADC #':' ; add character ":" ($30+$0A, result is 10 less that value) - STA Decss+4,Y ; save to output string - TXA ; copy 10's character - STA Decss+3,Y ; save to output string - LDA #$00 ; set null terminator - STA Decss+5,Y ; save to output string - BEQ LAB_2A91 ; go set string pointer (AY) and exit (branch always) - - ; save last character, [EOT] and exit -LAB_2A89 - STA Decss,Y ; save last character to output string - - ; set null terminator and exit -LAB_2A8C - LDA #$00 ; set null terminator - STA Decss+1,Y ; save after last character - - ; set string pointer (AY) and exit -LAB_2A91 - LDA #Decssp1 ; set result string high pointer - RTS - -; perform power function - -LAB_POWER - BEQ LAB_EXP ; go do EXP() - - LDA FAC2_e ; get FAC2 exponent - BNE LAB_2ABF ; branch if FAC2<>0 - - JMP LAB_24F3 ; clear FAC1 exponent and sign and return - -LAB_2ABF - LDX #func_l ; set destination pointer high byte - JSR LAB_2778 ; pack FAC1 into (XY) - LDA FAC2_s ; get FAC2 sign (b7) - BPL LAB_2AD9 ; branch if FAC2>0 - - ; else FAC2 is -ve and can only be raised to an - ; integer power which gives an x +j0 result - JSR LAB_INT ; perform INT - LDA #func_l ; set source pointer high byte - JSR LAB_27F8 ; compare FAC1 with (AY) - BNE LAB_2AD9 ; branch if FAC1 <> (AY) to allow Function Call error - ; this will leave FAC1 -ve and cause a Function Call - ; error when LOG() is called - - TYA ; clear sign b7 - LDY Temp3 ; save mantissa 3 from INT() function as sign in Y - ; for possible later negation, b0 -LAB_2AD9 - JSR LAB_279D ; save FAC1 sign and copy ABS(FAC2) to FAC1 - TYA ; copy sign back .. - PHA ; .. and save it - JSR LAB_LOG ; do LOG(n) - LDA #garb_l ; set pointer high byte - JSR LAB_25FB ; do convert AY, FCA1*(AY) (square the value) - JSR LAB_EXP ; go do EXP(n) - PLA ; pull sign from stack - LSR ; b0 is to be tested, shift to Cb - BCC LAB_2AF9 ; if no bit then exit - - ; Perform negation -; do - FAC1 - -LAB_GTHAN - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_2AF9 ; exit if FAC1_e = $00 - - LDA FAC1_s ; get FAC1 sign (b7) - EOR #$FF ; complement it - STA FAC1_s ; save FAC1 sign (b7) -LAB_2AF9 - RTS - -; perform EXP() (x^e) - -LAB_EXP - LDA #LAB_2AFA ; set 1.443 pointer high byte - JSR LAB_25FB ; do convert AY, FCA1*(AY) - LDA FAC1_r ; get FAC1 rounding byte - ADC #$50 ; +$50/$100 - BCC LAB_2B2B ; skip rounding if no carry - - JSR LAB_27C2 ; round FAC1 (no check) -LAB_2B2B - STA FAC2_r ; save FAC2 rounding byte - JSR LAB_27AE ; copy FAC1 to FAC2 - LDA FAC1_e ; get FAC1 exponent - CMP #$88 ; compare with EXP limit (256d) - BCC LAB_2B39 ; branch if less - -LAB_2B36 - JSR LAB_2690 ; handle overflow and underflow -LAB_2B39 - JSR LAB_INT ; perform INT - LDA Temp3 ; get mantissa 3 from INT() function - CLC ; clear carry for add - ADC #$81 ; normalise +1 - BEQ LAB_2B36 ; if $00 go handle overflow - - SEC ; set carry for subtract - SBC #$01 ; now correct for exponent - PHA ; save FAC2 exponent - - ; swap FAC1 and FAC2 - LDX #$04 ; 4 bytes to do -LAB_2B49 - LDA FAC2_e,X ; get FAC2,X - LDY FAC1_e,X ; get FAC1,X - STA FAC1_e,X ; save FAC1,X - STY FAC2_e,X ; save FAC2,X - DEX ; decrement count/index - BPL LAB_2B49 ; loop if not all done - - LDA FAC2_r ; get FAC2 rounding byte - STA FAC1_r ; save as FAC1 rounding byte - JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1 - JSR LAB_GTHAN ; do - FAC1 - LDA #LAB_2AFE ; set counter pointer high byte - JSR LAB_2B84 ; go do series evaluation - LDA #$00 ; clear A - STA FAC_sc ; clear sign compare (FAC1 EOR FAC2) - PLA ;.get saved FAC2 exponent - JMP LAB_2675 ; test and adjust accumulators and return - -; ^2 then series evaluation - -LAB_2B6E - STA Cptrl ; save count pointer low byte - STY Cptrh ; save count pointer high byte - JSR LAB_276E ; pack FAC1 into Adatal - LDA #Adatal ; pointer to original # high byte - JMP LAB_25FB ; do convert AY, FCA1*(AY) and return - -; series evaluation - -LAB_2B84 - STA Cptrl ; save count pointer low byte - STY Cptrh ; save count pointer high byte -LAB_2B88 - LDX #numexp ; set pointer high byte to partial @ numexp - DEC numcon ; decrement constants count - BNE LAB_2B9B ; loop until all done - - RTS - -; RND(n), 32 bit Galoise version. make n=0 for 19th next number in sequence or n<>0 -; to get 19th next number in sequence after seed n. This version of the PRNG uses -; the Galois method and a sample of 65536 bytes produced gives the following values. - -; Entropy = 7.997442 bits per byte -; Optimum compression would reduce these 65536 bytes by 0 percent - -; Chi square distribution for 65536 samples is 232.01, and -; randomly would exceed this value 75.00 percent of the time - -; Arithmetic mean value of data bytes is 127.6724, 127.5 would be random -; Monte Carlo value for Pi is 3.122871269, error 0.60 percent -; Serial correlation coefficient is -0.000370, totally uncorrelated would be 0.0 - -LAB_RND - LDA FAC1_e ; get FAC1 exponent - BEQ NextPRN ; do next random # if zero - - ; else get seed into random number store - LDX #Rbyte4 ; set PRNG pointer low byte - LDY #$00 ; set PRNG pointer high byte - JSR LAB_2778 ; pack FAC1 into (XY) -NextPRN - LDX #$AF ; set EOR byte - LDY #$13 ; do this nineteen times -LoopPRN - ASL Rbyte1 ; shift PRNG most significant byte - ROL Rbyte2 ; shift PRNG middle byte - ROL Rbyte3 ; shift PRNG least significant byte - ROL Rbyte4 ; shift PRNG extra byte - BCC Ninc1 ; branch if bit 32 clear - - TXA ; set EOR byte - EOR Rbyte1 ; EOR PRNG extra byte - STA Rbyte1 ; save new PRNG extra byte -Ninc1 - DEY ; decrement loop count - BNE LoopPRN ; loop if not all done - - LDX #$02 ; three bytes to copy -CopyPRNG - LDA Rbyte1,X ; get PRNG byte - STA FAC1_1,X ; save FAC1 byte - DEX - BPL CopyPRNG ; loop if not complete - - LDA #$80 ; set the exponent - STA FAC1_e ; save FAC1 exponent - - ASL ; clear A - STA FAC1_s ; save FAC1 sign - - JMP LAB_24D5 ; normalise FAC1 and return - -; perform COS() - -LAB_COS - LDA #LAB_2C78 ; set (pi/2) pointer high byte - JSR LAB_246C ; add (AY) to FAC1 - -; perform SIN() - -LAB_SIN - JSR LAB_27AB ; round and copy FAC1 to FAC2 - LDA #LAB_2C7C ; set (2*pi) pointer high byte - LDX FAC2_s ; get FAC2 sign (b7) - JSR LAB_26C2 ; divide by (AY) (X=sign) - JSR LAB_27AB ; round and copy FAC1 to FAC2 - JSR LAB_INT ; perform INT - LDA #$00 ; clear byte - STA FAC_sc ; clear sign compare (FAC1 EOR FAC2) - JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1 - LDA #LAB_2C80 ; set 0.25 pointer high byte - JSR LAB_2455 ; perform subtraction, (AY) from FAC1 - LDA FAC1_s ; get FAC1 sign (b7) - PHA ; save FAC1 sign - BPL LAB_2C35 ; branch if +ve - - ; FAC1 sign was -ve - JSR LAB_244E ; add 0.5 to FAC1 - LDA FAC1_s ; get FAC1 sign (b7) - BMI LAB_2C38 ; branch if -ve - - LDA Cflag ; get comparison evaluation flag - EOR #$FF ; toggle flag - STA Cflag ; save comparison evaluation flag -LAB_2C35 - JSR LAB_GTHAN ; do - FAC1 -LAB_2C38 - LDA #LAB_2C80 ; set 0.25 pointer high byte - JSR LAB_246C ; add (AY) to FAC1 - PLA ; restore FAC1 sign - BPL LAB_2C45 ; branch if was +ve - - ; else correct FAC1 - JSR LAB_GTHAN ; do - FAC1 -LAB_2C45 - LDA #LAB_2C84 ; set pointer high byte to counter - JMP LAB_2B6E ; ^2 then series evaluation and return - -; perform TAN() - -LAB_TAN - JSR LAB_276E ; pack FAC1 into Adatal - LDA #$00 ; clear byte - STA Cflag ; clear comparison evaluation flag - JSR LAB_SIN ; go do SIN(n) - LDX #func_l ; set sin(n) pointer high byte - JSR LAB_2778 ; pack FAC1 into (XY) - LDA #Adatal ; set n pointer high addr - JSR LAB_UFAC ; unpack memory (AY) into FAC1 - LDA #$00 ; clear byte - STA FAC1_s ; clear FAC1 sign (b7) - LDA Cflag ; get comparison evaluation flag - JSR LAB_2C74 ; save flag and go do series evaluation - - LDA #func_l ; set sin(n) pointer high byte - JMP LAB_26CA ; convert AY and do (AY)/FAC1 - -LAB_2C74 - PHA ; save comparison evaluation flag - JMP LAB_2C35 ; go do series evaluation - -; perform USR() - -LAB_USR - JSR Usrjmp ; call user code - JMP LAB_1BFB ; scan for ")", else do syntax error then warm start - -; perform ATN() - -LAB_ATN - LDA FAC1_s ; get FAC1 sign (b7) - PHA ; save sign - BPL LAB_2CA1 ; branch if +ve - - JSR LAB_GTHAN ; else do - FAC1 -LAB_2CA1 - LDA FAC1_e ; get FAC1 exponent - PHA ; push exponent - CMP #$81 ; compare with 1 - BCC LAB_2CAF ; branch if FAC1<1 - - LDA #LAB_259C ; set 1 pointer high byte - JSR LAB_26CA ; convert AY and do (AY)/FAC1 -LAB_2CAF - LDA #LAB_2CC9 ; set pointer high byte to counter - JSR LAB_2B6E ; ^2 then series evaluation - PLA ; restore old FAC1 exponent - CMP #$81 ; compare with 1 - BCC LAB_2CC2 ; branch if FAC1<1 - - LDA #LAB_2C78 ; set (pi/2) pointer high byte - JSR LAB_2455 ; perform subtraction, (AY) from FAC1 -LAB_2CC2 - PLA ; restore FAC1 sign - BPL LAB_2D04 ; exit if was +ve - - JMP LAB_GTHAN ; else do - FAC1 and return - -; perform BITSET - -LAB_BITSET - JSR LAB_GADB ; get two parameters for POKE or WAIT - CPX #$08 ; only 0 to 7 are allowed - BCS FCError ; branch if > 7 - - LDA #$00 ; clear A - SEC ; set the carry -S_Bits - ROL ; shift bit - DEX ; decrement bit number - BPL S_Bits ; loop if still +ve - - INX ; make X = $00 - ORA (Itempl,X) ; or with byte via temporary integer (addr) - STA (Itempl,X) ; save byte via temporary integer (addr) -LAB_2D04 - RTS - -; perform BITCLR - -LAB_BITCLR - JSR LAB_GADB ; get two parameters for POKE or WAIT - CPX #$08 ; only 0 to 7 are allowed - BCS FCError ; branch if > 7 - - LDA #$FF ; set A -S_Bitc - ROL ; shift bit - DEX ; decrement bit number - BPL S_Bitc ; loop if still +ve - - INX ; make X = $00 - AND (Itempl,X) ; and with byte via temporary integer (addr) - STA (Itempl,X) ; save byte via temporary integer (addr) - RTS - -FCError - JMP LAB_FCER ; do function call error then warm start - -; perform BITTST() - -LAB_BTST - JSR LAB_IGBY ; increment BASIC pointer - JSR LAB_GADB ; get two parameters for POKE or WAIT - CPX #$08 ; only 0 to 7 are allowed - BCS FCError ; branch if > 7 - - JSR LAB_GBYT ; get next BASIC byte - CMP #')' ; is next character ")" - BEQ TST_OK ; if ")" go do rest of function - - JMP LAB_SNER ; do syntax error then warm start - -TST_OK - JSR LAB_IGBY ; update BASIC execute pointer (to character past ")") - LDA #$00 ; clear A - SEC ; set the carry -T_Bits - ROL ; shift bit - DEX ; decrement bit number - BPL T_Bits ; loop if still +ve - - INX ; make X = $00 - AND (Itempl,X) ; AND with byte via temporary integer (addr) - BEQ LAB_NOTT ; branch if zero (already correct) - - LDA #$FF ; set for -1 result -LAB_NOTT - JMP LAB_27DB ; go do SGN tail - -; perform BIN$() - -LAB_BINS - CPX #$19 ; max + 1 - BCS BinFErr ; exit if too big ( > or = ) - - STX TempB ; save # of characters ($00 = leading zero remove) - LDA #$18 ; need A byte long space - JSR LAB_MSSP ; make string space A bytes long - LDY #$17 ; set index - LDX #$18 ; character count -NextB1 - LSR nums_1 ; shift highest byte - ROR nums_2 ; shift middle byte - ROR nums_3 ; shift lowest byte bit 0 to carry - TXA ; load with "0"/2 - ROL ; shift in carry - STA (str_pl),Y ; save to temp string + index - DEY ; decrement index - BPL NextB1 ; loop if not done - - LDA TempB ; get # of characters - BEQ EndBHS ; branch if truncate - - TAX ; copy length to X - SEC ; set carry for add ! - EOR #$FF ; 1's complement - ADC #$18 ; add 24d - BEQ GoPr2 ; if zero print whole string - - BNE GoPr1 ; else go make output string - -; this is the exit code and is also used by HEX$() -; truncate string to remove leading "0"s - -EndBHS - TAY ; clear index (A=0, X=length here) -NextB2 - LDA (str_pl),Y ; get character from string - CMP #'0' ; compare with "0" - BNE GoPr ; if not "0" then go print string from here - - DEX ; decrement character count - BEQ GoPr3 ; if zero then end of string so go print it - - INY ; else increment index - BPL NextB2 ; loop always - -; make fixed length output string - ignore overflows! - -GoPr3 - INX ; need at least 1 character -GoPr - TYA ; copy result -GoPr1 - CLC ; clear carry for add - ADC str_pl ; add low address - STA str_pl ; save low address - LDA #$00 ; do high byte - ADC str_ph ; add high address - STA str_ph ; save high address -GoPr2 - STX str_ln ; X holds string length - JSR LAB_IGBY ; update BASIC execute pointer (to character past ")") - JMP LAB_RTST ; check for space on descriptor stack then put address - ; and length on descriptor stack and update stack pointers - -BinFErr - JMP LAB_FCER ; do function call error then warm start - -; perform HEX$() - -LAB_HEXS - CPX #$07 ; max + 1 - BCS BinFErr ; exit if too big ( > or = ) - - STX TempB ; save # of characters - - LDA #$06 ; need 6 bytes for string - JSR LAB_MSSP ; make string space A bytes long - LDY #$05 ; set string index - - SED ; need decimal mode for nibble convert - LDA nums_3 ; get lowest byte - JSR LAB_A2HX ; convert A to ASCII hex byte and output - LDA nums_2 ; get middle byte - JSR LAB_A2HX ; convert A to ASCII hex byte and output - LDA nums_1 ; get highest byte - JSR LAB_A2HX ; convert A to ASCII hex byte and output - CLD ; back to binary - - LDX #$06 ; character count - LDA TempB ; get # of characters - BEQ EndBHS ; branch if truncate - - TAX ; copy length to X - SEC ; set carry for add ! - EOR #$FF ; 1's complement - ADC #$06 ; add 6d - BEQ GoPr2 ; if zero print whole string - - BNE GoPr1 ; else go make output string (branch always) - -; convert A to ASCII hex byte and output .. note set decimal mode before calling - -LAB_A2HX - TAX ; save byte - AND #$0F ; mask off top bits - JSR LAB_AL2X ; convert low nibble to ASCII and output - TXA ; get byte back - LSR ; /2 shift high nibble to low nibble - LSR ; /4 - LSR ; /8 - LSR ; /16 -LAB_AL2X - CMP #$0A ; set carry for +1 if >9 - ADC #'0' ; add ASCII "0" - STA (str_pl),Y ; save to temp string - DEY ; decrement counter - RTS - -LAB_NLTO - STA FAC1_e ; save FAC1 exponent - LDA #$00 ; clear sign compare -LAB_MLTE - STA FAC_sc ; save sign compare (FAC1 EOR FAC2) - TXA ; restore character - JSR LAB_2912 ; evaluate new ASCII digit - -; gets here if the first character was "$" for hex -; get hex number - -LAB_CHEX - JSR LAB_IGBY ; increment and scan memory - BCC LAB_ISHN ; branch if numeric character - - ORA #$20 ; case convert, allow "A" to "F" and "a" to "f" - SBC #'a' ; subtract "a" (carry set here) - CMP #$06 ; compare normalised with $06 (max+1) - BCS LAB_EXCH ; exit if >"f" or <"0" - - ADC #$0A ; convert to nibble -LAB_ISHN - AND #$0F ; convert to binary - TAX ; save nibble - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_MLTE ; skip multiply if zero - - ADC #$04 ; add four to exponent (*16 - carry clear here) - BCC LAB_NLTO ; if no overflow do evaluate digit - -LAB_MLTO - JMP LAB_2564 ; do overflow error and warm start - -LAB_NXCH - TAX ; save bit - LDA FAC1_e ; get FAC1 exponent - BEQ LAB_MLBT ; skip multiply if zero - - INC FAC1_e ; increment FAC1 exponent (*2) - BEQ LAB_MLTO ; do overflow error if = $00 - - LDA #$00 ; clear sign compare -LAB_MLBT - STA FAC_sc ; save sign compare (FAC1 EOR FAC2) - TXA ; restore bit - JSR LAB_2912 ; evaluate new ASCII digit - -; gets here if the first character was "%" for binary -; get binary number - -LAB_CBIN - JSR LAB_IGBY ; increment and scan memory - EOR #'0' ; convert "0" to 0 etc. - CMP #$02 ; compare with max+1 - BCC LAB_NXCH ; branch exit if < 2 - -LAB_EXCH - JMP LAB_28F6 ; evaluate -ve flag and return - -; ctrl-c check routine. includes limited "life" byte save for INGET routine -; now also the code that checks to see if an interrupt has occurred - -CTRLC - LDA ccflag ; get [CTRL-C] check flag - BNE LAB_FBA2 ; exit if inhibited - - JSR V_INPT ; scan input device - BCC LAB_FBA0 ; exit if buffer empty - - STA ccbyte ; save received byte - LDX #$20 ; "life" timer for bytes - STX ccnull ; set countdown - JMP LAB_1636 ; return to BASIC - -LAB_FBA0 - LDX ccnull ; get countdown byte - BEQ LAB_FBA2 ; exit if finished - - DEC ccnull ; else decrement countdown -LAB_FBA2 - LDX #NmiBase ; set pointer to NMI values - JSR LAB_CKIN ; go check interrupt - LDX #IrqBase ; set pointer to IRQ values - JSR LAB_CKIN ; go check interrupt -LAB_CRTS - RTS - -; check whichever interrupt is indexed by X - -LAB_CKIN - LDA PLUS_0,X ; get interrupt flag byte - BPL LAB_CRTS ; branch if interrupt not enabled - -; we disable the interrupt here and make two new commands RETIRQ and RETNMI to -; automatically enable the interrupt when we exit - - ASL ; move happened bit to setup bit - AND #$40 ; mask happened bits - BEQ LAB_CRTS ; if no interrupt then exit - - STA PLUS_0,X ; save interrupt flag byte - - TXA ; copy index .. - TAY ; .. to Y - - PLA ; dump return address low byte, call from CTRL-C - PLA ; dump return address high byte - - LDA #$05 ; need 5 bytes for GOSUB - JSR LAB_1212 ; check room on stack for A bytes - LDA Bpntrh ; get BASIC execute pointer high byte - PHA ; push on stack - LDA Bpntrl ; get BASIC execute pointer low byte - PHA ; push on stack - LDA Clineh ; get current line high byte - PHA ; push on stack - LDA Clinel ; get current line low byte - PHA ; push on stack - LDA #TK_GOSUB ; token for GOSUB - PHA ; push on stack - - LDA PLUS_1,Y ; get interrupt code pointer low byte - STA Bpntrl ; save as BASIC execute pointer low byte - LDA PLUS_2,Y ; get interrupt code pointer high byte - STA Bpntrh ; save as BASIC execute pointer high byte - - JMP LAB_15C2 ; go do interpreter inner loop - ; can't RTS, we used the stack! the RTS from the ctrl-c - ; check will be taken when the RETIRQ/RETNMI/RETURN is - ; executed at the end of the subroutine - -; get byte from input device, no waiting -; returns with carry set if byte in A - -INGET - JSR V_INPT ; call scan input device - BCS LAB_FB95 ; if byte go reset timer - - LDA ccnull ; get countdown - BEQ LAB_FB96 ; exit if empty - - LDA ccbyte ; get last received byte - SEC ; flag we got a byte -LAB_FB95 - LDX #$00 ; clear X - STX ccnull ; clear timer because we got a byte -LAB_FB96 - RTS - -; these routines only enable the interrupts if the set-up flag is set -; if not they have no effect - -; perform IRQ {ON|OFF|CLEAR} - -LAB_IRQ - LDX #IrqBase ; set pointer to IRQ values - .byte $2C ; make next line BIT abs. - -; perform NMI {ON|OFF|CLEAR} - -LAB_NMI - LDX #NmiBase ; set pointer to NMI values - CMP #TK_ON ; compare with token for ON - BEQ LAB_INON ; go turn on interrupt - - CMP #TK_OFF ; compare with token for OFF - BEQ LAB_IOFF ; go turn off interrupt - - EOR #TK_CLEAR ; compare with token for CLEAR, A = $00 if = TK_CLEAR - BEQ LAB_INEX ; go clear interrupt flags and return - - JMP LAB_SNER ; do syntax error then warm start - -LAB_IOFF - LDA #$7F ; clear A - AND PLUS_0,X ; AND with interrupt setup flag - BPL LAB_INEX ; go clear interrupt enabled flag and return - -LAB_INON - LDA PLUS_0,X ; get interrupt setup flag - ASL ; Shift bit to enabled flag - ORA PLUS_0,X ; OR with flag byte -LAB_INEX - STA PLUS_0,X ; save interrupt flag byte - JMP LAB_IGBY ; update BASIC execute pointer and return - -; these routines set up the pointers and flags for the interrupt routines -; note that the interrupts are also enabled by these commands - -; perform ON IRQ - -LAB_SIRQ - CLI ; enable interrupts - LDX #IrqBase ; set pointer to IRQ values - .byte $2C ; make next line BIT abs. - -; perform ON NMI - -LAB_SNMI - LDX #NmiBase ; set pointer to NMI values - - STX TempB ; save interrupt pointer - JSR LAB_IGBY ; increment and scan memory (past token) - JSR LAB_GFPN ; get fixed-point number into temp integer - LDA Smeml ; get start of mem low byte - LDX Smemh ; get start of mem high byte - JSR LAB_SHLN ; search Basic for temp integer line number from AX - BCS LAB_LFND ; if carry set go set-up interrupt - - JMP LAB_16F7 ; else go do "Undefined statement" error and warm start - -LAB_LFND - LDX TempB ; get interrupt pointer - LDA Baslnl ; get pointer low byte - SBC #$01 ; -1 (carry already set for subtract) - STA PLUS_1,X ; save as interrupt pointer low byte - LDA Baslnh ; get pointer high byte - SBC #$00 ; subtract carry - STA PLUS_2,X ; save as interrupt pointer high byte - - LDA #$C0 ; set interrupt enabled/setup bits - STA PLUS_0,X ; set interrupt flags -LAB_IRTS - RTS - -; return from IRQ service, restores the enabled flag. - -; perform RETIRQ - -LAB_RETIRQ - BNE LAB_IRTS ; exit if following token (to allow syntax error) - - LDA IrqBase ; get interrupt flags - ASL ; copy setup to enabled (b7) - ORA IrqBase ; OR in setup flag - STA IrqBase ; save enabled flag - JMP LAB_16E8 ; go do rest of RETURN - -; return from NMI service, restores the enabled flag. - -; perform RETNMI - -LAB_RETNMI - BNE LAB_IRTS ; exit if following token (to allow syntax error) - - LDA NmiBase ; get set-up flag - ASL ; copy setup to enabled (b7) - ORA NmiBase ; OR in setup flag - STA NmiBase ; save enabled flag - JMP LAB_16E8 ; go do rest of RETURN - -; MAX() MIN() pre process - -LAB_MMPP - JSR LAB_EVEZ ; process expression - JMP LAB_CTNM ; check if source is numeric, else do type mismatch - -; perform MAX() - -LAB_MAX - JSR LAB_PHFA ; push FAC1, evaluate expression, - ; pull FAC2 and compare with FAC1 - BPL LAB_MAX ; branch if no swap to do - - LDA FAC2_1 ; get FAC2 mantissa1 - ORA #$80 ; set top bit (clear sign from compare) - STA FAC2_1 ; save FAC2 mantissa1 - JSR LAB_279B ; copy FAC2 to FAC1 - BEQ LAB_MAX ; go do next (branch always) - -; perform MIN() - -LAB_MIN - JSR LAB_PHFA ; push FAC1, evaluate expression, - ; pull FAC2 and compare with FAC1 - BMI LAB_MIN ; branch if no swap to do - - BEQ LAB_MIN ; branch if no swap to do - - LDA FAC2_1 ; get FAC2 mantissa1 - ORA #$80 ; set top bit (clear sign from compare) - STA FAC2_1 ; save FAC2 mantissa1 - JSR LAB_279B ; copy FAC2 to FAC1 - BEQ LAB_MIN ; go do next (branch always) - -; exit routine. don't bother returning to the loop code -; check for correct exit, else so syntax error - -LAB_MMEC - CMP #')' ; is it end of function? - BNE LAB_MMSE ; if not do MAX MIN syntax error - - PLA ; dump return address low byte - PLA ; dump return address high byte - JMP LAB_IGBY ; update BASIC execute pointer (to chr past ")") - -LAB_MMSE - JMP LAB_SNER ; do syntax error then warm start - -; check for next, evaluate and return or exit -; this is the routine that does most of the work - -LAB_PHFA - JSR LAB_GBYT ; get next BASIC byte - CMP #',' ; is there more ? - BNE LAB_MMEC ; if not go do end check - - ; push FAC1 - JSR LAB_27BA ; round FAC1 - LDA FAC1_s ; get FAC1 sign - ORA #$7F ; set all non sign bits - AND FAC1_1 ; AND FAC1 mantissa1 (AND in sign bit) - PHA ; push on stack - LDA FAC1_2 ; get FAC1 mantissa2 - PHA ; push on stack - LDA FAC1_3 ; get FAC1 mantissa3 - PHA ; push on stack - LDA FAC1_e ; get FAC1 exponent - PHA ; push on stack - - JSR LAB_IGBY ; scan and get next BASIC byte (after ",") - JSR LAB_EVNM ; evaluate expression and check is numeric, - ; else do type mismatch - - ; pop FAC2 (MAX/MIN expression so far) - PLA ; pop exponent - STA FAC2_e ; save FAC2 exponent - PLA ; pop mantissa3 - STA FAC2_3 ; save FAC2 mantissa3 - PLA ; pop mantissa1 - STA FAC2_2 ; save FAC2 mantissa2 - PLA ; pop sign/mantissa1 - STA FAC2_1 ; save FAC2 sign/mantissa1 - STA FAC2_s ; save FAC2 sign - - ; compare FAC1 with (packed) FAC2 - LDA #FAC2_e ; set pointer high byte to FAC2 - JMP LAB_27F8 ; compare FAC1 with FAC2 (AY) and return - ; returns A=$00 if FAC1 = (AY) - ; returns A=$01 if FAC1 > (AY) - ; returns A=$FF if FAC1 < (AY) - -; perform WIDTH - -LAB_WDTH - CMP #',' ; is next byte "," - BEQ LAB_TBSZ ; if so do tab size - - JSR LAB_GTBY ; get byte parameter - TXA ; copy width to A - BEQ LAB_NSTT ; branch if set for infinite line - - CPX #$10 ; else make min width = 16d - BCC TabErr ; if less do function call error and exit - -; this next compare ensures that we can't exit WIDTH via an error leaving the -; tab size greater than the line length. - - CPX TabSiz ; compare with tab size - BCS LAB_NSTT ; branch if >= tab size - - STX TabSiz ; else make tab size = terminal width -LAB_NSTT - STX TWidth ; set the terminal width - JSR LAB_GBYT ; get BASIC byte back - BEQ WExit ; exit if no following - - CMP #',' ; else is it "," - BNE LAB_MMSE ; if not do syntax error - -LAB_TBSZ - JSR LAB_SGBY ; scan and get byte parameter - TXA ; copy TAB size - BMI TabErr ; if >127 do function call error and exit - - CPX #$01 ; compare with min-1 - BCC TabErr ; if <=1 do function call error and exit - - LDA TWidth ; set flags for width - BEQ LAB_SVTB ; skip check if infinite line - - CPX TWidth ; compare TAB with width - BEQ LAB_SVTB ; ok if = - - BCS TabErr ; branch if too big - -LAB_SVTB - STX TabSiz ; save TAB size - -; calculate tab column limit from TAB size. The Iclim is set to the last tab -; position on a line that still has at least one whole tab width between it -; and the end of the line. - -WExit - LDA TWidth ; get width - BEQ LAB_SULP ; branch if infinite line - - CMP TabSiz ; compare with tab size - BCS LAB_WDLP ; branch if >= tab size - - STA TabSiz ; else make tab size = terminal width -LAB_SULP - SEC ; set carry for subtract -LAB_WDLP - SBC TabSiz ; subtract tab size - BCS LAB_WDLP ; loop while no borrow - - ADC TabSiz ; add tab size back - CLC ; clear carry for add - ADC TabSiz ; add tab size back again - STA Iclim ; save for now - LDA TWidth ; get width back - SEC ; set carry for subtract - SBC Iclim ; subtract remainder - STA Iclim ; save tab column limit -LAB_NOSQ - RTS - -TabErr - JMP LAB_FCER ; do function call error then warm start - -; perform SQR() - -LAB_SQR - LDA FAC1_s ; get FAC1 sign - BMI TabErr ; if -ve do function call error - - LDA FAC1_e ; get exponent - BEQ LAB_NOSQ ; if zero just return - - ; else do root - JSR LAB_27AB ; round and copy FAC1 to FAC2 - LDA #$00 ; clear A - - STA FACt_3 ; clear remainder - STA FACt_2 ; .. - STA FACt_1 ; .. - STA TempB ; .. - - STA FAC1_3 ; clear root - STA FAC1_2 ; .. - STA FAC1_1 ; .. - - LDX #$18 ; 24 pairs of bits to do - LDA FAC2_e ; get exponent - LSR ; check odd/even - BCS LAB_SQE2 ; if odd only 1 shift first time - -LAB_SQE1 - ASL FAC2_3 ; shift highest bit of number .. - ROL FAC2_2 ; .. - ROL FAC2_1 ; .. - ROL FACt_3 ; .. into remainder - ROL FACt_2 ; .. - ROL FACt_1 ; .. - ROL TempB ; .. never overflows -LAB_SQE2 - ASL FAC2_3 ; shift highest bit of number .. - ROL FAC2_2 ; .. - ROL FAC2_1 ; .. - ROL FACt_3 ; .. into remainder - ROL FACt_2 ; .. - ROL FACt_1 ; .. - ROL TempB ; .. never overflows - - ASL FAC1_3 ; root = root * 2 - ROL FAC1_2 ; .. - ROL FAC1_1 ; .. never overflows - - LDA FAC1_3 ; get root low byte - ROL ; *2 - STA Temp3 ; save partial low byte - LDA FAC1_2 ; get root low mid byte - ROL ; *2 - STA Temp3+1 ; save partial low mid byte - LDA FAC1_1 ; get root high mid byte - ROL ; *2 - STA Temp3+2 ; save partial high mid byte - LDA #$00 ; get root high byte (always $00) - ROL ; *2 - STA Temp3+3 ; save partial high byte - - ; carry clear for subtract +1 - LDA FACt_3 ; get remainder low byte - SBC Temp3 ; subtract partial low byte - STA Temp3 ; save partial low byte - - LDA FACt_2 ; get remainder low mid byte - SBC Temp3+1 ; subtract partial low mid byte - STA Temp3+1 ; save partial low mid byte - - LDA FACt_1 ; get remainder high mid byte - SBC Temp3+2 ; subtract partial high mid byte - TAY ; copy partial high mid byte - - LDA TempB ; get remainder high byte - SBC Temp3+3 ; subtract partial high byte - BCC LAB_SQNS ; skip sub if remainder smaller - - STA TempB ; save remainder high byte - - STY FACt_1 ; save remainder high mid byte - - LDA Temp3+1 ; get remainder low mid byte - STA FACt_2 ; save remainder low mid byte - - LDA Temp3 ; get partial low byte - STA FACt_3 ; save remainder low byte - - INC FAC1_3 ; increment root low byte (never any rollover) -LAB_SQNS - DEX ; decrement bit pair count - BNE LAB_SQE1 ; loop if not all done - - SEC ; set carry for subtract - LDA FAC2_e ; get exponent - SBC #$80 ; normalise - ROR ; /2 and re-bias to $80 - ADC #$00 ; add bit zero back in (allow for half shift) - STA FAC1_e ; save it - JMP LAB_24D5 ; normalise FAC1 and return - -; perform VARPTR() - -LAB_VARPTR - JSR LAB_IGBY ; increment and scan memory - JSR LAB_GVAR ; get var address - JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start - LDY Cvaral ; get var address low byte - LDA Cvarah ; get var address high byte - JMP LAB_AYFC ; save and convert integer AY to FAC1 and return - -; perform PI - -LAB_PI - LDA #LAB_2C7C ; set (2*pi) pointer high byte - JSR LAB_UFAC ; unpack memory (AY) into FAC1 - DEC FAC1_e ; make result = PI - RTS - -; perform TWOPI - -LAB_TWOPI - LDA #LAB_2C7C ; set (2*pi) pointer high byte - JMP LAB_UFAC ; unpack memory (AY) into FAC1 and return - -; system dependant i/o vectors -; these are in RAM and are set by the monitor at start-up - -V_INPT - JMP (VEC_IN) ; non halting scan input device -V_OUTP - JMP (VEC_OUT) ; send byte to output device -V_LOAD - JMP (VEC_LD) ; load BASIC program -V_SAVE - JMP (VEC_SV) ; save BASIC program - -; The rest are tables messages and code for RAM - -; the rest of the code is tables and BASIC start-up code - -PG2_TABS - .byte $FF ; ctrl-c flag - $00 = enabled - .byte $00 ; ctrl-c byte - GET needs this - .byte $00 ; ctrl-c byte timeout - GET needs this - .word CTRLC ; ctrl c check vector - .word CHRIN ; non halting key input - monitor to set this - .word CHROUT ; output vector - monitor to set this -; .word xxxx ; load vector - monitor to set this -; .word xxxx ; save vector - monitor to set this -PG2_TABE - -; character get subroutine for zero page - -; For a 1.8432MHz 6502 including the JSR and RTS -; fastest (>=":") = 29 cycles = 15.7uS -; slowest (<":") = 40 cycles = 21.7uS -; space skip = +21 cycles = +11.4uS -; inc across page = +4 cycles = +2.2uS - -; the target address for the LDA at LAB_2CF4 becomes the BASIC execute pointer once the -; block is copied to it's destination, any non zero page address will do at assembly -; time, to assemble a three byte instruction. - -; page 0 initialisation table from $BC -; increment and scan memory - -LAB_2CEE - INC Bpntrl ; increment BASIC execute pointer low byte - BNE LAB_2CF4 ; branch if no carry - ; else - INC Bpntrh ; increment BASIC execute pointer high byte - -; page 0 initialisation table from $C2 -; scan memory - -LAB_2CF4 - LDA $FFFF ; get byte to scan (addr set by call routine) - CMP #TK_ELSE ; compare with the token for ELSE - BEQ LAB_2D05 ; exit if ELSE, not numeric, carry set - - CMP #':' ; compare with ":" - BCS LAB_2D05 ; exit if >= ":", not numeric, carry set - - CMP #' ' ; compare with " " - BEQ LAB_2CEE ; if " " go do next - - SEC ; set carry for SBC - SBC #'0' ; subtract "0" - SEC ; set carry for SBC - SBC #$D0 ; subtract -"0" - ; clear carry if byte = "0"-"9" -LAB_2D05 - RTS - -; page zero initialisation table $00-$12 inclusive - -StrTab - .byte $4C ; JMP opcode - .word LAB_COLD ; initial warm start vector (cold start) - - .byte $00 ; these bytes are not used by BASIC - .word $0000 ; - .word $0000 ; - .word $0000 ; - - .byte $4C ; JMP opcode - .word LAB_FCER ; initial user function vector ("Function call" error) - .byte $00 ; default NULL count - .byte $00 ; clear terminal position - .byte $00 ; default terminal width byte - .byte $F2 ; default limit for TAB = 14 - .word Ram_base ; start of user RAM -EndTab - -LAB_MSZM - .byte $0D,$0A,"Memory size ",$00 - -LAB_SMSG - .byte " Bytes free",$0D,$0A,$0A - .byte "Enhanced BASIC 2.22",$0A,$00 - -; numeric constants and series - - ; constants and series for LOG(n) -LAB_25A0 - .byte $02 ; counter - .byte $80,$19,$56,$62 ; 0.59898 - .byte $80,$76,$22,$F3 ; 0.96147 -;## .byte $80,$76,$22,$F1 ; 0.96147 - .byte $82,$38,$AA,$40 ; 2.88539 -;## .byte $82,$38,$AA,$45 ; 2.88539 - -LAB_25AD - .byte $80,$35,$04,$F3 ; 0.70711 1/root 2 -LAB_25B1 - .byte $81,$35,$04,$F3 ; 1.41421 root 2 -LAB_25B5 - .byte $80,$80,$00,$00 ; -0.5 -LAB_25B9 - .byte $80,$31,$72,$18 ; 0.69315 LOG(2) - - ; numeric PRINT constants -LAB_2947 - .byte $91,$43,$4F,$F8 ; 99999.9375 (max value with at least one decimal) -LAB_294B - .byte $94,$74,$23,$F7 ; 999999.4375 (max value before scientific notation) -LAB_294F - .byte $94,$74,$24,$00 ; 1000000 - - ; EXP(n) constants and series -LAB_2AFA - .byte $81,$38,$AA,$3B ; 1.4427 (1/LOG base 2 e) -LAB_2AFE - .byte $06 ; counter - .byte $74,$63,$90,$8C ; 2.17023e-4 - .byte $77,$23,$0C,$AB ; 0.00124 - .byte $7A,$1E,$94,$00 ; 0.00968 - .byte $7C,$63,$42,$80 ; 0.05548 - .byte $7E,$75,$FE,$D0 ; 0.24023 - .byte $80,$31,$72,$15 ; 0.69315 - .byte $81,$00,$00,$00 ; 1.00000 - -;## .byte $07 ; counter -;## .byte $74,$94,$2E,$40 ; -1/7! (-1/5040) -;## .byte $77,$2E,$4F,$70 ; 1/6! ( 1/720) -;## .byte $7A,$88,$02,$6E ; -1/5! (-1/120) -;## .byte $7C,$2A,$A0,$E6 ; 1/4! ( 1/24) -;## .byte $7E,$AA,$AA,$50 ; -1/3! (-1/6) -;## .byte $7F,$7F,$FF,$FF ; 1/2! ( 1/2) -;## .byte $81,$80,$00,$00 ; -1/1! (-1/1) -;## .byte $81,$00,$00,$00 ; 1/0! ( 1/1) - - ; trigonometric constants and series -LAB_2C78 - .byte $81,$49,$0F,$DB ; 1.570796371 (pi/2) as floating # -LAB_2C84 - .byte $04 ; counter - .byte $86,$1E,$D7,$FB ; 39.7109 -;## .byte $86,$1E,$D7,$BA ; 39.7109 - .byte $87,$99,$26,$65 ;-76.575 -;## .byte $87,$99,$26,$64 ;-76.575 - .byte $87,$23,$34,$58 ; 81.6022 - .byte $86,$A5,$5D,$E1 ;-41.3417 -;## .byte $86,$A5,$5D,$E0 ;-41.3417 -LAB_2C7C - .byte $83,$49,$0F,$DB ; 6.28319 (2*pi) as floating # -;## .byte $83,$49,$0F,$DA ; 6.28319 (2*pi) as floating # - -LAB_2CC9 - .byte $08 ; counter - .byte $78,$3A,$C5,$37 ; 0.00285 - .byte $7B,$83,$A2,$5C ;-0.0160686 - .byte $7C,$2E,$DD,$4D ; 0.0426915 - .byte $7D,$99,$B0,$1E ;-0.0750429 - .byte $7D,$59,$ED,$24 ; 0.106409 - .byte $7E,$91,$72,$00 ;-0.142036 - .byte $7E,$4C,$B9,$73 ; 0.199926 - .byte $7F,$AA,$AA,$53 ;-0.333331 - -;## .byte $08 ; counter -;## .byte $78,$3B,$D7,$4A ; 1/17 -;## .byte $7B,$84,$6E,$02 ;-1/15 -;## .byte $7C,$2F,$C1,$FE ; 1/13 -;## .byte $7D,$9A,$31,$74 ;-1/11 -;## .byte $7D,$5A,$3D,$84 ; 1/9 -;## .byte $7E,$91,$7F,$C8 ;-1/7 -;## .byte $7E,$4C,$BB,$E4 ; 1/5 -;## .byte $7F,$AA,$AA,$6C ;-1/3 - -LAB_1D96 = *+1 ; $00,$00 used for undefined variables -LAB_259C - .byte $81,$00,$00,$00 ; 1.000000, used for INC -LAB_2AFD - .byte $81,$80,$00,$00 ; -1.00000, used for DEC. must be on the same page as +1.00 - - ; misc constants -LAB_1DF7 - .byte $90 ;-32768 (uses first three bytes from 0.5) -LAB_2A96 - .byte $80,$00,$00,$00 ; 0.5 -LAB_2C80 - .byte $7F,$00,$00,$00 ; 0.25 -LAB_26B5 - .byte $84,$20,$00,$00 ; 10.0000 divide by 10 constant - -; This table is used in converting numbers to ASCII. - -LAB_2A9A -LAB_2A9B = LAB_2A9A+1 -LAB_2A9C = LAB_2A9B+1 - .byte $FE,$79,$60 ; -100000 - .byte $00,$27,$10 ; 10000 - .byte $FF,$FC,$18 ; -1000 - .byte $00,$00,$64 ; 100 - .byte $FF,$FF,$F6 ; -10 - .byte $00,$00,$01 ; 1 - -LAB_CTBL - .word LAB_END-1 ; END - .word LAB_FOR-1 ; FOR - .word LAB_NEXT-1 ; NEXT - .word LAB_DATA-1 ; DATA - .word LAB_INPUT-1 ; INPUT - .word LAB_DIM-1 ; DIM - .word LAB_READ-1 ; READ - .word LAB_LET-1 ; LET - .word LAB_DEC-1 ; DEC new command - .word LAB_GOTO-1 ; GOTO - .word LAB_RUN-1 ; RUN - .word LAB_IF-1 ; IF - .word LAB_RESTORE-1 ; RESTORE modified command - .word LAB_GOSUB-1 ; GOSUB - .word LAB_RETIRQ-1 ; RETIRQ new command - .word LAB_RETNMI-1 ; RETNMI new command - .word LAB_RETURN-1 ; RETURN - .word LAB_REM-1 ; REM - .word LAB_STOP-1 ; STOP - .word LAB_ON-1 ; ON modified command - .word LAB_NULL-1 ; NULL modified command - .word LAB_INC-1 ; INC new command - .word LAB_WAIT-1 ; WAIT - .word V_LOAD-1 ; LOAD - .word V_SAVE-1 ; SAVE - .word LAB_DEF-1 ; DEF - .word LAB_POKE-1 ; POKE - .word LAB_DOKE-1 ; DOKE new command - .word LAB_CALL-1 ; CALL new command - .word LAB_DO-1 ; DO new command - .word LAB_LOOP-1 ; LOOP new command - .word LAB_PRINT-1 ; PRINT - .word LAB_CONT-1 ; CONT - .word LAB_LIST-1 ; LIST - .word LAB_CLEAR-1 ; CLEAR - .word LAB_NEW-1 ; NEW - .word LAB_WDTH-1 ; WIDTH new command - .word LAB_GET-1 ; GET new command - .word LAB_SWAP-1 ; SWAP new command - .word LAB_BITSET-1 ; BITSET new command - .word LAB_BITCLR-1 ; BITCLR new command - .word LAB_IRQ-1 ; IRQ new command - .word LAB_NMI-1 ; NMI new command - -; function pre process routine table - -LAB_FTPL -LAB_FTPM = LAB_FTPL+$01 - .word LAB_PPFN-1 ; SGN(n) process numeric expression in () - .word LAB_PPFN-1 ; INT(n) " - .word LAB_PPFN-1 ; ABS(n) " - .word LAB_EVEZ-1 ; USR(x) process any expression - .word LAB_1BF7-1 ; FRE(x) " - .word LAB_1BF7-1 ; POS(x) " - .word LAB_PPFN-1 ; SQR(n) process numeric expression in () - .word LAB_PPFN-1 ; RND(n) " - .word LAB_PPFN-1 ; LOG(n) " - .word LAB_PPFN-1 ; EXP(n) " - .word LAB_PPFN-1 ; COS(n) " - .word LAB_PPFN-1 ; SIN(n) " - .word LAB_PPFN-1 ; TAN(n) " - .word LAB_PPFN-1 ; ATN(n) " - .word LAB_PPFN-1 ; PEEK(n) " - .word LAB_PPFN-1 ; DEEK(n) " - .word $0000 ; SADD() none - .word LAB_PPFS-1 ; LEN($) process string expression in () - .word LAB_PPFN-1 ; STR$(n) process numeric expression in () - .word LAB_PPFS-1 ; VAL($) process string expression in () - .word LAB_PPFS-1 ; ASC($) " - .word LAB_PPFS-1 ; UCASE$($) " - .word LAB_PPFS-1 ; LCASE$($) " - .word LAB_PPFN-1 ; CHR$(n) process numeric expression in () - .word LAB_BHSS-1 ; HEX$(n) " - .word LAB_BHSS-1 ; BIN$(n) " - .word $0000 ; BITTST() none - .word LAB_MMPP-1 ; MAX() process numeric expression - .word LAB_MMPP-1 ; MIN() " - .word LAB_PPBI-1 ; PI advance pointer - .word LAB_PPBI-1 ; TWOPI " - .word $0000 ; VARPTR() none - .word LAB_LRMS-1 ; LEFT$() process string expression - .word LAB_LRMS-1 ; RIGHT$() " - .word LAB_LRMS-1 ; MID$() " - -; action addresses for functions - -LAB_FTBL -LAB_FTBM = LAB_FTBL+$01 - .word LAB_SGN-1 ; SGN() - .word LAB_INT-1 ; INT() - .word LAB_ABS-1 ; ABS() - .word LAB_USR-1 ; USR() - .word LAB_FRE-1 ; FRE() - .word LAB_POS-1 ; POS() - .word LAB_SQR-1 ; SQR() - .word LAB_RND-1 ; RND() modified function - .word LAB_LOG-1 ; LOG() - .word LAB_EXP-1 ; EXP() - .word LAB_COS-1 ; COS() - .word LAB_SIN-1 ; SIN() - .word LAB_TAN-1 ; TAN() - .word LAB_ATN-1 ; ATN() - .word LAB_PEEK-1 ; PEEK() - .word LAB_DEEK-1 ; DEEK() new function - .word LAB_SADD-1 ; SADD() new function - .word LAB_LENS-1 ; LEN() - .word LAB_STRS-1 ; STR$() - .word LAB_VAL-1 ; VAL() - .word LAB_ASC-1 ; ASC() - .word LAB_UCASE-1 ; UCASE$() new function - .word LAB_LCASE-1 ; LCASE$() new function - .word LAB_CHRS-1 ; CHR$() - .word LAB_HEXS-1 ; HEX$() new function - .word LAB_BINS-1 ; BIN$() new function - .word LAB_BTST-1 ; BITTST() new function - .word LAB_MAX-1 ; MAX() new function - .word LAB_MIN-1 ; MIN() new function - .word LAB_PI-1 ; PI new function - .word LAB_TWOPI-1 ; TWOPI new function - .word LAB_VARPTR-1 ; VARPTR() new function - .word LAB_LEFT-1 ; LEFT$() - .word LAB_RIGHT-1 ; RIGHT$() - .word LAB_MIDS-1 ; MID$() - -; hierarchy and action addresses for operator - -LAB_OPPT - .byte $79 ; + - .word LAB_ADD-1 - .byte $79 ; - - .word LAB_SUBTRACT-1 - .byte $7B ; * - .word LAB_MULTIPLY-1 - .byte $7B ; / - .word LAB_DIVIDE-1 - .byte $7F ; ^ - .word LAB_POWER-1 - .byte $50 ; AND - .word LAB_AND-1 - .byte $46 ; EOR new operator - .word LAB_EOR-1 - .byte $46 ; OR - .word LAB_OR-1 - .byte $56 ; >> new operator - .word LAB_RSHIFT-1 - .byte $56 ; << new operator - .word LAB_LSHIFT-1 - .byte $7D ; > - .word LAB_GTHAN-1 - .byte $5A ; = - .word LAB_EQUAL-1 - .byte $64 ; < - .word LAB_LTHAN-1 - -; keywords start with .. -; this is the first character table and must be in alphabetic order - -TAB_1STC - .byte "*" - .byte "+" - .byte "-" - .byte "/" - .byte "<" - .byte "=" - .byte ">" - .byte "?" - .byte "A" - .byte "B" - .byte "C" - .byte "D" - .byte "E" - .byte "F" - .byte "G" - .byte "H" - .byte "I" - .byte "L" - .byte "M" - .byte "N" - .byte "O" - .byte "P" - .byte "R" - .byte "S" - .byte "T" - .byte "U" - .byte "V" - .byte "W" - .byte "^" - .byte $00 ; table terminator - -; pointers to keyword tables - -TAB_CHRT - .word TAB_STAR ; table for "*" - .word TAB_PLUS ; table for "+" - .word TAB_MNUS ; table for "-" - .word TAB_SLAS ; table for "/" - .word TAB_LESS ; table for "<" - .word TAB_EQUL ; table for "=" - .word TAB_MORE ; table for ">" - .word TAB_QEST ; table for "?" - .word TAB_ASCA ; table for "A" - .word TAB_ASCB ; table for "B" - .word TAB_ASCC ; table for "C" - .word TAB_ASCD ; table for "D" - .word TAB_ASCE ; table for "E" - .word TAB_ASCF ; table for "F" - .word TAB_ASCG ; table for "G" - .word TAB_ASCH ; table for "H" - .word TAB_ASCI ; table for "I" - .word TAB_ASCL ; table for "L" - .word TAB_ASCM ; table for "M" - .word TAB_ASCN ; table for "N" - .word TAB_ASCO ; table for "O" - .word TAB_ASCP ; table for "P" - .word TAB_ASCR ; table for "R" - .word TAB_ASCS ; table for "S" - .word TAB_ASCT ; table for "T" - .word TAB_ASCU ; table for "U" - .word TAB_ASCV ; table for "V" - .word TAB_ASCW ; table for "W" - .word TAB_POWR ; table for "^" - -; tables for each start character, note if a longer keyword with the same start -; letters as a shorter one exists then it must come first, else the list is in -; alphabetical order as follows .. - -; [keyword,token -; [keyword,token]] -; end marker (#$00) - -TAB_STAR - .byte TK_MUL,$00 ; * -TAB_PLUS - .byte TK_PLUS,$00 ; + -TAB_MNUS - .byte TK_MINUS,$00 ; - -TAB_SLAS - .byte TK_DIV,$00 ; / -TAB_LESS -LBB_LSHIFT - .byte "<",TK_LSHIFT ; << note - "<<" must come before "<" - .byte TK_LT ; < - .byte $00 -TAB_EQUL - .byte TK_EQUAL,$00 ; = -TAB_MORE -LBB_RSHIFT - .byte ">",TK_RSHIFT ; >> note - ">>" must come before ">" - .byte TK_GT ; > - .byte $00 -TAB_QEST - .byte TK_PRINT,$00 ; ? -TAB_ASCA -LBB_ABS - .byte "BS(",TK_ABS ; ABS( -LBB_AND - .byte "ND",TK_AND ; AND -LBB_ASC - .byte "SC(",TK_ASC ; ASC( -LBB_ATN - .byte "TN(",TK_ATN ; ATN( - .byte $00 -TAB_ASCB -LBB_BINS - .byte "IN$(",TK_BINS ; BIN$( -LBB_BITCLR - .byte "ITCLR",TK_BITCLR ; BITCLR -LBB_BITSET - .byte "ITSET",TK_BITSET ; BITSET -LBB_BITTST - .byte "ITTST(",TK_BITTST - ; BITTST( - .byte $00 -TAB_ASCC -LBB_CALL - .byte "ALL",TK_CALL ; CALL -LBB_CHRS - .byte "HR$(",TK_CHRS ; CHR$( -LBB_CLEAR - .byte "LEAR",TK_CLEAR ; CLEAR -LBB_CONT - .byte "ONT",TK_CONT ; CONT -LBB_COS - .byte "OS(",TK_COS ; COS( - .byte $00 -TAB_ASCD -LBB_DATA - .byte "ATA",TK_DATA ; DATA -LBB_DEC - .byte "EC",TK_DEC ; DEC -LBB_DEEK - .byte "EEK(",TK_DEEK ; DEEK( -LBB_DEF - .byte "EF",TK_DEF ; DEF -LBB_DIM - .byte "IM",TK_DIM ; DIM -LBB_DOKE - .byte "OKE",TK_DOKE ; DOKE note - "DOKE" must come before "DO" -LBB_DO - .byte "O",TK_DO ; DO - .byte $00 -TAB_ASCE -LBB_ELSE - .byte "LSE",TK_ELSE ; ELSE -LBB_END - .byte "ND",TK_END ; END -LBB_EOR - .byte "OR",TK_EOR ; EOR -LBB_EXP - .byte "XP(",TK_EXP ; EXP( - .byte $00 -TAB_ASCF -LBB_FN - .byte "N",TK_FN ; FN -LBB_FOR - .byte "OR",TK_FOR ; FOR -LBB_FRE - .byte "RE(",TK_FRE ; FRE( - .byte $00 -TAB_ASCG -LBB_GET - .byte "ET",TK_GET ; GET -LBB_GOSUB - .byte "OSUB",TK_GOSUB ; GOSUB -LBB_GOTO - .byte "OTO",TK_GOTO ; GOTO - .byte $00 -TAB_ASCH -LBB_HEXS - .byte "EX$(",TK_HEXS ; HEX$( - .byte $00 -TAB_ASCI -LBB_IF - .byte "F",TK_IF ; IF -LBB_INC - .byte "NC",TK_INC ; INC -LBB_INPUT - .byte "NPUT",TK_INPUT ; INPUT -LBB_INT - .byte "NT(",TK_INT ; INT( -LBB_IRQ - .byte "RQ",TK_IRQ ; IRQ - .byte $00 -TAB_ASCL -LBB_LCASES - .byte "CASE$(",TK_LCASES - ; LCASE$( -LBB_LEFTS - .byte "EFT$(",TK_LEFTS ; LEFT$( -LBB_LEN - .byte "EN(",TK_LEN ; LEN( -LBB_LET - .byte "ET",TK_LET ; LET -LBB_LIST - .byte "IST",TK_LIST ; LIST -LBB_LOAD - .byte "OAD",TK_LOAD ; LOAD -LBB_LOG - .byte "OG(",TK_LOG ; LOG( -LBB_LOOP - .byte "OOP",TK_LOOP ; LOOP - .byte $00 -TAB_ASCM -LBB_MAX - .byte "AX(",TK_MAX ; MAX( -LBB_MIDS - .byte "ID$(",TK_MIDS ; MID$( -LBB_MIN - .byte "IN(",TK_MIN ; MIN( - .byte $00 -TAB_ASCN -LBB_NEW - .byte "EW",TK_NEW ; NEW -LBB_NEXT - .byte "EXT",TK_NEXT ; NEXT -LBB_NMI - .byte "MI",TK_NMI ; NMI -LBB_NOT - .byte "OT",TK_NOT ; NOT -LBB_NULL - .byte "ULL",TK_NULL ; NULL - .byte $00 -TAB_ASCO -LBB_OFF - .byte "FF",TK_OFF ; OFF -LBB_ON - .byte "N",TK_ON ; ON -LBB_OR - .byte "R",TK_OR ; OR - .byte $00 -TAB_ASCP -LBB_PEEK - .byte "EEK(",TK_PEEK ; PEEK( -LBB_PI - .byte "I",TK_PI ; PI -LBB_POKE - .byte "OKE",TK_POKE ; POKE -LBB_POS - .byte "OS(",TK_POS ; POS( -LBB_PRINT - .byte "RINT",TK_PRINT ; PRINT - .byte $00 -TAB_ASCR -LBB_READ - .byte "EAD",TK_READ ; READ -LBB_REM - .byte "EM",TK_REM ; REM -LBB_RESTORE - .byte "ESTORE",TK_RESTORE - ; RESTORE -LBB_RETIRQ - .byte "ETIRQ",TK_RETIRQ ; RETIRQ -LBB_RETNMI - .byte "ETNMI",TK_RETNMI ; RETNMI -LBB_RETURN - .byte "ETURN",TK_RETURN ; RETURN -LBB_RIGHTS - .byte "IGHT$(",TK_RIGHTS - ; RIGHT$( -LBB_RND - .byte "ND(",TK_RND ; RND( -LBB_RUN - .byte "UN",TK_RUN ; RUN - .byte $00 -TAB_ASCS -LBB_SADD - .byte "ADD(",TK_SADD ; SADD( -LBB_SAVE - .byte "AVE",TK_SAVE ; SAVE -LBB_SGN - .byte "GN(",TK_SGN ; SGN( -LBB_SIN - .byte "IN(",TK_SIN ; SIN( -LBB_SPC - .byte "PC(",TK_SPC ; SPC( -LBB_SQR - .byte "QR(",TK_SQR ; SQR( -LBB_STEP - .byte "TEP",TK_STEP ; STEP -LBB_STOP - .byte "TOP",TK_STOP ; STOP -LBB_STRS - .byte "TR$(",TK_STRS ; STR$( -LBB_SWAP - .byte "WAP",TK_SWAP ; SWAP - .byte $00 -TAB_ASCT -LBB_TAB - .byte "AB(",TK_TAB ; TAB( -LBB_TAN - .byte "AN(",TK_TAN ; TAN( -LBB_THEN - .byte "HEN",TK_THEN ; THEN -LBB_TO - .byte "O",TK_TO ; TO -LBB_TWOPI - .byte "WOPI",TK_TWOPI ; TWOPI - .byte $00 -TAB_ASCU -LBB_UCASES - .byte "CASE$(",TK_UCASES - ; UCASE$( -LBB_UNTIL - .byte "NTIL",TK_UNTIL ; UNTIL -LBB_USR - .byte "SR(",TK_USR ; USR( - .byte $00 -TAB_ASCV -LBB_VAL - .byte "AL(",TK_VAL ; VAL( -LBB_VPTR - .byte "ARPTR(",TK_VPTR ; VARPTR( - .byte $00 -TAB_ASCW -LBB_WAIT - .byte "AIT",TK_WAIT ; WAIT -LBB_WHILE - .byte "HILE",TK_WHILE ; WHILE -LBB_WIDTH - .byte "IDTH",TK_WIDTH ; WIDTH - .byte $00 -TAB_POWR - .byte TK_POWER,$00 ; ^ - -; new decode table for LIST -; Table is .. -; byte - keyword length, keyword first character -; word - pointer to rest of keyword from dictionary - -; note if length is 1 then the pointer is ignored - -LAB_KEYT - .byte 3,'E' - .word LBB_END ; END - .byte 3,'F' - .word LBB_FOR ; FOR - .byte 4,'N' - .word LBB_NEXT ; NEXT - .byte 4,'D' - .word LBB_DATA ; DATA - .byte 5,'I' - .word LBB_INPUT ; INPUT - .byte 3,'D' - .word LBB_DIM ; DIM - .byte 4,'R' - .word LBB_READ ; READ - .byte 3,'L' - .word LBB_LET ; LET - .byte 3,'D' - .word LBB_DEC ; DEC - .byte 4,'G' - .word LBB_GOTO ; GOTO - .byte 3,'R' - .word LBB_RUN ; RUN - .byte 2,'I' - .word LBB_IF ; IF - .byte 7,'R' - .word LBB_RESTORE ; RESTORE - .byte 5,'G' - .word LBB_GOSUB ; GOSUB - .byte 6,'R' - .word LBB_RETIRQ ; RETIRQ - .byte 6,'R' - .word LBB_RETNMI ; RETNMI - .byte 6,'R' - .word LBB_RETURN ; RETURN - .byte 3,'R' - .word LBB_REM ; REM - .byte 4,'S' - .word LBB_STOP ; STOP - .byte 2,'O' - .word LBB_ON ; ON - .byte 4,'N' - .word LBB_NULL ; NULL - .byte 3,'I' - .word LBB_INC ; INC - .byte 4,'W' - .word LBB_WAIT ; WAIT - .byte 4,'L' - .word LBB_LOAD ; LOAD - .byte 4,'S' - .word LBB_SAVE ; SAVE - .byte 3,'D' - .word LBB_DEF ; DEF - .byte 4,'P' - .word LBB_POKE ; POKE - .byte 4,'D' - .word LBB_DOKE ; DOKE - .byte 4,'C' - .word LBB_CALL ; CALL - .byte 2,'D' - .word LBB_DO ; DO - .byte 4,'L' - .word LBB_LOOP ; LOOP - .byte 5,'P' - .word LBB_PRINT ; PRINT - .byte 4,'C' - .word LBB_CONT ; CONT - .byte 4,'L' - .word LBB_LIST ; LIST - .byte 5,'C' - .word LBB_CLEAR ; CLEAR - .byte 3,'N' - .word LBB_NEW ; NEW - .byte 5,'W' - .word LBB_WIDTH ; WIDTH - .byte 3,'G' - .word LBB_GET ; GET - .byte 4,'S' - .word LBB_SWAP ; SWAP - .byte 6,'B' - .word LBB_BITSET ; BITSET - .byte 6,'B' - .word LBB_BITCLR ; BITCLR - .byte 3,'I' - .word LBB_IRQ ; IRQ - .byte 3,'N' - .word LBB_NMI ; NMI - -; secondary commands (can't start a statement) - - .byte 4,'T' - .word LBB_TAB ; TAB - .byte 4,'E' - .word LBB_ELSE ; ELSE - .byte 2,'T' - .word LBB_TO ; TO - .byte 2,'F' - .word LBB_FN ; FN - .byte 4,'S' - .word LBB_SPC ; SPC - .byte 4,'T' - .word LBB_THEN ; THEN - .byte 3,'N' - .word LBB_NOT ; NOT - .byte 4,'S' - .word LBB_STEP ; STEP - .byte 5,'U' - .word LBB_UNTIL ; UNTIL - .byte 5,'W' - .word LBB_WHILE ; WHILE - .byte 3,'O' - .word LBB_OFF ; OFF - -; opperators - - .byte 1,'+' - .word $0000 ; + - .byte 1,'-' - .word $0000 ; - - .byte 1,'*' - .word $0000 ; * - .byte 1,'/' - .word $0000 ; / - .byte 1,'^' - .word $0000 ; ^ - .byte 3,'A' - .word LBB_AND ; AND - .byte 3,'E' - .word LBB_EOR ; EOR - .byte 2,'O' - .word LBB_OR ; OR - .byte 2,'>' - .word LBB_RSHIFT ; >> - .byte 2,'<' - .word LBB_LSHIFT ; << - .byte 1,'>' - .word $0000 ; > - .byte 1,'=' - .word $0000 ; = - .byte 1,'<' - .word $0000 ; < - -; functions - - .byte 4,'S' ; - .word LBB_SGN ; SGN - .byte 4,'I' ; - .word LBB_INT ; INT - .byte 4,'A' ; - .word LBB_ABS ; ABS - .byte 4,'U' ; - .word LBB_USR ; USR - .byte 4,'F' ; - .word LBB_FRE ; FRE - .byte 4,'P' ; - .word LBB_POS ; POS - .byte 4,'S' ; - .word LBB_SQR ; SQR - .byte 4,'R' ; - .word LBB_RND ; RND - .byte 4,'L' ; - .word LBB_LOG ; LOG - .byte 4,'E' ; - .word LBB_EXP ; EXP - .byte 4,'C' ; - .word LBB_COS ; COS - .byte 4,'S' ; - .word LBB_SIN ; SIN - .byte 4,'T' ; - .word LBB_TAN ; TAN - .byte 4,'A' ; - .word LBB_ATN ; ATN - .byte 5,'P' ; - .word LBB_PEEK ; PEEK - .byte 5,'D' ; - .word LBB_DEEK ; DEEK - .byte 5,'S' ; - .word LBB_SADD ; SADD - .byte 4,'L' ; - .word LBB_LEN ; LEN - .byte 5,'S' ; - .word LBB_STRS ; STR$ - .byte 4,'V' ; - .word LBB_VAL ; VAL - .byte 4,'A' ; - .word LBB_ASC ; ASC - .byte 7,'U' ; - .word LBB_UCASES ; UCASE$ - .byte 7,'L' ; - .word LBB_LCASES ; LCASE$ - .byte 5,'C' ; - .word LBB_CHRS ; CHR$ - .byte 5,'H' ; - .word LBB_HEXS ; HEX$ - .byte 5,'B' ; - .word LBB_BINS ; BIN$ - .byte 7,'B' ; - .word LBB_BITTST ; BITTST - .byte 4,'M' ; - .word LBB_MAX ; MAX - .byte 4,'M' ; - .word LBB_MIN ; MIN - .byte 2,'P' ; - .word LBB_PI ; PI - .byte 5,'T' ; - .word LBB_TWOPI ; TWOPI - .byte 7,'V' ; - .word LBB_VPTR ; VARPTR - .byte 6,'L' ; - .word LBB_LEFTS ; LEFT$ - .byte 7,'R' ; - .word LBB_RIGHTS ; RIGHT$ - .byte 5,'M' ; - .word LBB_MIDS ; MID$ - -; BASIC messages, mostly error messages - -LAB_BAER - .word ERR_NF ;$00 NEXT without FOR - .word ERR_SN ;$02 syntax - .word ERR_RG ;$04 RETURN without GOSUB - .word ERR_OD ;$06 out of data - .word ERR_FC ;$08 function call - .word ERR_OV ;$0A overflow - .word ERR_OM ;$0C out of memory - .word ERR_US ;$0E undefined statement - .word ERR_BS ;$10 array bounds - .word ERR_DD ;$12 double dimension array - .word ERR_D0 ;$14 divide by 0 - .word ERR_ID ;$16 illegal direct - .word ERR_TM ;$18 type mismatch - .word ERR_LS ;$1A long string - .word ERR_ST ;$1C string too complex - .word ERR_CN ;$1E continue error - .word ERR_UF ;$20 undefined function - .word ERR_LD ;$22 LOOP without DO - -; I may implement these two errors to force definition of variables and -; dimensioning of arrays before use. - -; .word ERR_UV ;$24 undefined variable - -; the above error has been tested and works (see code and comments below LAB_1D8B) - -; .word ERR_UA ;$26 undimensioned array - -ERR_NF .byte "NEXT without FOR",$00 -ERR_SN .byte "Syntax",$00 -ERR_RG .byte "RETURN without GOSUB",$00 -ERR_OD .byte "Out of DATA",$00 -ERR_FC .byte "Function call",$00 -ERR_OV .byte "Overflow",$00 -ERR_OM .byte "Out of memory",$00 -ERR_US .byte "Undefined statement",$00 -ERR_BS .byte "Array bounds",$00 -ERR_DD .byte "Double dimension",$00 -ERR_D0 .byte "Divide by zero",$00 -ERR_ID .byte "Illegal direct",$00 -ERR_TM .byte "Type mismatch",$00 -ERR_LS .byte "String too long",$00 -ERR_ST .byte "String too complex",$00 -ERR_CN .byte "Can't continue",$00 -ERR_UF .byte "Undefined function",$00 -ERR_LD .byte "LOOP without DO",$00 - -;ERR_UV .byte "Undefined variable",$00 - -; the above error has been tested and works (see code and comments below LAB_1D8B) - -;ERR_UA .byte "Undimensioned array",$00 - -LAB_BMSG .byte $0D,$0A,"Break",$00 -LAB_EMSG .byte " Error",$00 -LAB_LMSG .byte " in line ",$00 -LAB_RMSG .byte $0D,$0A,"Ready",$0D,$0A,$00 - -LAB_IMSG .byte " Extra ignored",$0D,$0A,$00 -LAB_REDO .byte " Redo from start",$0D,$0A,$00 - -AA_end_basic + +; The code below was copied and adapted from Lee Davison’s +; code of EhBasic to be ran in Michal Kowalski's 6502 emulator. +; Original comments and credits follow: +; +; Enhanced BASIC to assemble under 6502 simulator, $ver 2.22 + +; $E7E1 $E7CF $E7C6 $E7D3 $E7D1 $E7D5 $E7CF $E81E $E825 + +; 2.00 new revision numbers start here +; 2.01 fixed LCASE$() and UCASE$() +; 2.02 new get value routine done +; 2.03 changed RND() to galoise method +; 2.04 fixed SPC() +; 2.05 new get value routine fixed +; 2.06 changed USR() code +; 2.07 fixed STR$() +; 2.08 changed INPUT and READ to remove need for $00 start to input buffer +; 2.09 fixed RND() +; 2.10 integrated missed changes from an earlier version +; 2.20 added ELSE to IF .. THEN and fixed IF .. GOTO to cause error +; 2.21 fixed IF .. THEN RETURN to not cause error +; 2.22 fixed RND() breaking the get byte routine + +; zero page use .. + +LAB_WARM = $00 ; BASIC warm start entry point +Wrmjpl = LAB_WARM+1; BASIC warm start vector jump low byte +Wrmjph = LAB_WARM+2; BASIC warm start vector jump high byte + +Usrjmp = $0A ; USR function JMP address +Usrjpl = Usrjmp+1 ; USR function JMP vector low byte +Usrjph = Usrjmp+2 ; USR function JMP vector high byte +Nullct = $0D ; nulls output after each line +TPos = $0E ; BASIC terminal position byte +TWidth = $0F ; BASIC terminal width byte +Iclim = $10 ; input column limit +Itempl = $11 ; temporary integer low byte +Itemph = Itempl+1 ; temporary integer high byte + +nums_1 = Itempl ; number to bin/hex string convert MSB +nums_2 = nums_1+1 ; number to bin/hex string convert +nums_3 = nums_1+2 ; number to bin/hex string convert LSB + +Srchc = $5B ; search character +Temp3 = Srchc ; temp byte used in number routines +Scnquo = $5C ; scan-between-quotes flag +Asrch = Scnquo ; alt search character + +XOAw_l = Srchc ; eXclusive OR, OR and AND word low byte +XOAw_h = Scnquo ; eXclusive OR, OR and AND word high byte + +Ibptr = $5D ; input buffer pointer +Dimcnt = Ibptr ; # of dimensions +Tindx = Ibptr ; token index + +Defdim = $5E ; default DIM flag +Dtypef = $5F ; data type flag, $FF=string, $00=numeric +Oquote = $60 ; open quote flag (b7) (Flag: DATA scan; LIST quote; memory) +Gclctd = $60 ; garbage collected flag +Sufnxf = $61 ; subscript/FNX flag, 1xxx xxx = FN(0xxx xxx) +Imode = $62 ; input mode flag, $00=INPUT, $80=READ + +Cflag = $63 ; comparison evaluation flag + +TabSiz = $64 ; TAB step size (was input flag) + +next_s = $65 ; next descriptor stack address + + ; these two bytes form a word pointer to the item + ; currently on top of the descriptor stack +last_sl = $66 ; last descriptor stack address low byte +last_sh = $67 ; last descriptor stack address high byte (always $00) + +des_sk = $68 ; descriptor stack start address (temp strings) + +; = $70 ; End of descriptor stack + +ut1_pl = $71 ; utility pointer 1 low byte +ut1_ph = ut1_pl+1 ; utility pointer 1 high byte +ut2_pl = $73 ; utility pointer 2 low byte +ut2_ph = ut2_pl+1 ; utility pointer 2 high byte + +Temp_2 = ut1_pl ; temp byte for block move + +FACt_1 = $75 ; FAC temp mantissa1 +FACt_2 = FACt_1+1 ; FAC temp mantissa2 +FACt_3 = FACt_2+1 ; FAC temp mantissa3 + +dims_l = FACt_2 ; array dimension size low byte +dims_h = FACt_3 ; array dimension size high byte + +TempB = $78 ; temp page 0 byte + +Smeml = $79 ; start of mem low byte (Start-of-Basic) +Smemh = Smeml+1 ; start of mem high byte (Start-of-Basic) +Svarl = $7B ; start of vars low byte (Start-of-Variables) +Svarh = Svarl+1 ; start of vars high byte (Start-of-Variables) +Sarryl = $7D ; var mem end low byte (Start-of-Arrays) +Sarryh = Sarryl+1 ; var mem end high byte (Start-of-Arrays) +Earryl = $7F ; array mem end low byte (End-of-Arrays) +Earryh = Earryl+1 ; array mem end high byte (End-of-Arrays) +Sstorl = $81 ; string storage low byte (String storage (moving down)) +Sstorh = Sstorl+1 ; string storage high byte (String storage (moving down)) +Sutill = $83 ; string utility ptr low byte +Sutilh = Sutill+1 ; string utility ptr high byte +Ememl = $85 ; end of mem low byte (Limit-of-memory) +Ememh = Ememl+1 ; end of mem high byte (Limit-of-memory) +Clinel = $87 ; current line low byte (Basic line number) +Clineh = Clinel+1 ; current line high byte (Basic line number) +Blinel = $89 ; break line low byte (Previous Basic line number) +Blineh = Blinel+1 ; break line high byte (Previous Basic line number) + +Cpntrl = $8B ; continue pointer low byte +Cpntrh = Cpntrl+1 ; continue pointer high byte + +Dlinel = $8D ; current DATA line low byte +Dlineh = Dlinel+1 ; current DATA line high byte + +Dptrl = $8F ; DATA pointer low byte +Dptrh = Dptrl+1 ; DATA pointer high byte + +Rdptrl = $91 ; read pointer low byte +Rdptrh = Rdptrl+1 ; read pointer high byte + +Varnm1 = $93 ; current var name 1st byte +Varnm2 = Varnm1+1 ; current var name 2nd byte + +Cvaral = $95 ; current var address low byte +Cvarah = Cvaral+1 ; current var address high byte + +Frnxtl = $97 ; var pointer for FOR/NEXT low byte +Frnxth = Frnxtl+1 ; var pointer for FOR/NEXT high byte + +Tidx1 = Frnxtl ; temp line index + +Lvarpl = Frnxtl ; let var pointer low byte +Lvarph = Frnxth ; let var pointer high byte + +prstk = $99 ; precedence stacked flag + +comp_f = $9B ; compare function flag, bits 0,1 and 2 used + ; bit 2 set if > + ; bit 1 set if = + ; bit 0 set if < + +func_l = $9C ; function pointer low byte +func_h = func_l+1 ; function pointer high byte + +garb_l = func_l ; garbage collection working pointer low byte +garb_h = func_h ; garbage collection working pointer high byte + +des_2l = $9E ; string descriptor_2 pointer low byte +des_2h = des_2l+1 ; string descriptor_2 pointer high byte + +g_step = $A0 ; garbage collect step size + +Fnxjmp = $A1 ; jump vector for functions +Fnxjpl = Fnxjmp+1 ; functions jump vector low byte +Fnxjph = Fnxjmp+2 ; functions jump vector high byte + +g_indx = Fnxjpl ; garbage collect temp index + +FAC2_r = $A3 ; FAC2 rounding byte + +Adatal = $A4 ; array data pointer low byte +Adatah = Adatal+1 ; array data pointer high byte + +Nbendl = Adatal ; new block end pointer low byte +Nbendh = Adatah ; new block end pointer high byte + +Obendl = $A6 ; old block end pointer low byte +Obendh = Obendl+1 ; old block end pointer high byte + +numexp = $A8 ; string to float number exponent count +expcnt = $A9 ; string to float exponent count + +numbit = numexp ; bit count for array element calculations + +numdpf = $AA ; string to float decimal point flag +expneg = $AB ; string to float eval exponent -ve flag + +Astrtl = numdpf ; array start pointer low byte +Astrth = expneg ; array start pointer high byte + +Histrl = numdpf ; highest string low byte +Histrh = expneg ; highest string high byte + +Baslnl = numdpf ; BASIC search line pointer low byte +Baslnh = expneg ; BASIC search line pointer high byte + +Fvar_l = numdpf ; find/found variable pointer low byte +Fvar_h = expneg ; find/found variable pointer high byte + +Ostrtl = numdpf ; old block start pointer low byte +Ostrth = expneg ; old block start pointer high byte + +Vrschl = numdpf ; variable search pointer low byte +Vrschh = expneg ; variable search pointer high byte + +FAC1_e = $AC ; FAC1 exponent +FAC1_1 = FAC1_e+1 ; FAC1 mantissa1 +FAC1_2 = FAC1_e+2 ; FAC1 mantissa2 +FAC1_3 = FAC1_e+3 ; FAC1 mantissa3 +FAC1_s = FAC1_e+4 ; FAC1 sign (b7) + +str_ln = FAC1_e ; string length +str_pl = FAC1_1 ; string pointer low byte +str_ph = FAC1_2 ; string pointer high byte + +des_pl = FAC1_2 ; string descriptor pointer low byte +des_ph = FAC1_3 ; string descriptor pointer high byte + +mids_l = FAC1_3 ; MID$ string temp length byte + +negnum = $B1 ; string to float eval -ve flag +numcon = $B1 ; series evaluation constant count + +FAC1_o = $B2 ; FAC1 overflow byte + +FAC2_e = $B3 ; FAC2 exponent +FAC2_1 = FAC2_e+1 ; FAC2 mantissa1 +FAC2_2 = FAC2_e+2 ; FAC2 mantissa2 +FAC2_3 = FAC2_e+3 ; FAC2 mantissa3 +FAC2_s = FAC2_e+4 ; FAC2 sign (b7) + +FAC_sc = $B8 ; FAC sign comparison, Acc#1 vs #2 +FAC1_r = $B9 ; FAC1 rounding byte + +ssptr_l = FAC_sc ; string start pointer low byte +ssptr_h = FAC1_r ; string start pointer high byte + +sdescr = FAC_sc ; string descriptor pointer + +csidx = $BA ; line crunch save index +Asptl = csidx ; array size/pointer low byte +Aspth = $BB ; array size/pointer high byte + +Btmpl = Asptl ; BASIC pointer temp low byte +Btmph = Aspth ; BASIC pointer temp low byte + +Cptrl = Asptl ; BASIC pointer temp low byte +Cptrh = Aspth ; BASIC pointer temp low byte + +Sendl = Asptl ; BASIC pointer temp low byte +Sendh = Aspth ; BASIC pointer temp low byte + +LAB_IGBY = $BC ; get next BASIC byte subroutine + +LAB_GBYT = $C2 ; get current BASIC byte subroutine +Bpntrl = $C3 ; BASIC execute (get byte) pointer low byte +Bpntrh = Bpntrl+1 ; BASIC execute (get byte) pointer high byte + +; = $D7 ; end of get BASIC char subroutine + +Rbyte4 = $D8 ; extra PRNG byte +Rbyte1 = Rbyte4+1 ; most significant PRNG byte +Rbyte2 = Rbyte4+2 ; middle PRNG byte +Rbyte3 = Rbyte4+3 ; least significant PRNG byte + +NmiBase = $DC ; NMI handler enabled/setup/triggered flags + ; bit function + ; === ======== + ; 7 interrupt enabled + ; 6 interrupt setup + ; 5 interrupt happened +; = $DD ; NMI handler addr low byte +; = $DE ; NMI handler addr high byte +IrqBase = $DF ; IRQ handler enabled/setup/triggered flags +; = $E0 ; IRQ handler addr low byte +; = $E1 ; IRQ handler addr high byte + +; = $DE ; unused +; = $DF ; unused +; = $E0 ; unused +; = $E1 ; unused +; = $E2 ; unused +; = $E3 ; unused +; = $E4 ; unused +; = $E5 ; unused +; = $E6 ; unused +; = $E7 ; unused +; = $E8 ; unused +; = $E9 ; unused +; = $EA ; unused +; = $EB ; unused +; = $EC ; unused +; = $ED ; unused +; = $EE ; unused + +Decss = $EF ; number to decimal string start +Decssp1 = Decss+1 ; number to decimal string start + +; = $FF ; decimal string end + +; token values needed for BASIC + +; primary command tokens (can start a statement) + +TK_END = $80 ; END token +TK_FOR = TK_END+1 ; FOR token +TK_NEXT = TK_FOR+1 ; NEXT token +TK_DATA = TK_NEXT+1 ; DATA token +TK_INPUT = TK_DATA+1 ; INPUT token +TK_DIM = TK_INPUT+1 ; DIM token +TK_READ = TK_DIM+1 ; READ token +TK_LET = TK_READ+1 ; LET token +TK_DEC = TK_LET+1 ; DEC token +TK_GOTO = TK_DEC+1 ; GOTO token +TK_RUN = TK_GOTO+1 ; RUN token +TK_IF = TK_RUN+1 ; IF token +TK_RESTORE = TK_IF+1 ; RESTORE token +TK_GOSUB = TK_RESTORE+1 ; GOSUB token +TK_RETIRQ = TK_GOSUB+1 ; RETIRQ token +TK_RETNMI = TK_RETIRQ+1 ; RETNMI token +TK_RETURN = TK_RETNMI+1 ; RETURN token +TK_REM = TK_RETURN+1 ; REM token +TK_STOP = TK_REM+1 ; STOP token +TK_ON = TK_STOP+1 ; ON token +TK_NULL = TK_ON+1 ; NULL token +TK_INC = TK_NULL+1 ; INC token +TK_WAIT = TK_INC+1 ; WAIT token +TK_LOAD = TK_WAIT+1 ; LOAD token +TK_SAVE = TK_LOAD+1 ; SAVE token +TK_DEF = TK_SAVE+1 ; DEF token +TK_POKE = TK_DEF+1 ; POKE token +TK_DOKE = TK_POKE+1 ; DOKE token +TK_CALL = TK_DOKE+1 ; CALL token +TK_DO = TK_CALL+1 ; DO token +TK_LOOP = TK_DO+1 ; LOOP token +TK_PRINT = TK_LOOP+1 ; PRINT token +TK_CONT = TK_PRINT+1 ; CONT token +TK_LIST = TK_CONT+1 ; LIST token +TK_CLEAR = TK_LIST+1 ; CLEAR token +TK_NEW = TK_CLEAR+1 ; NEW token +TK_WIDTH = TK_NEW+1 ; WIDTH token +TK_GET = TK_WIDTH+1 ; GET token +TK_SWAP = TK_GET+1 ; SWAP token +TK_BITSET = TK_SWAP+1 ; BITSET token +TK_BITCLR = TK_BITSET+1 ; BITCLR token +TK_IRQ = TK_BITCLR+1 ; IRQ token +TK_NMI = TK_IRQ+1 ; NMI token + +; secondary command tokens, can't start a statement + +TK_TAB = TK_NMI+1 ; TAB token +TK_ELSE = TK_TAB+1 ; ELSE token +TK_TO = TK_ELSE+1 ; TO token +TK_FN = TK_TO+1 ; FN token +TK_SPC = TK_FN+1 ; SPC token +TK_THEN = TK_SPC+1 ; THEN token +TK_NOT = TK_THEN+1 ; NOT token +TK_STEP = TK_NOT+1 ; STEP token +TK_UNTIL = TK_STEP+1 ; UNTIL token +TK_WHILE = TK_UNTIL+1 ; WHILE token +TK_OFF = TK_WHILE+1 ; OFF token + +; opperator tokens + +TK_PLUS = TK_OFF+1 ; + token +TK_MINUS = TK_PLUS+1 ; - token +TK_MUL = TK_MINUS+1 ; * token +TK_DIV = TK_MUL+1 ; / token +TK_POWER = TK_DIV+1 ; ^ token +TK_AND = TK_POWER+1 ; AND token +TK_EOR = TK_AND+1 ; EOR token +TK_OR = TK_EOR+1 ; OR token +TK_RSHIFT = TK_OR+1 ; RSHIFT token +TK_LSHIFT = TK_RSHIFT+1 ; LSHIFT token +TK_GT = TK_LSHIFT+1 ; > token +TK_EQUAL = TK_GT+1 ; = token +TK_LT = TK_EQUAL+1 ; < token + +; functions tokens + +TK_SGN = TK_LT+1 ; SGN token +TK_INT = TK_SGN+1 ; INT token +TK_ABS = TK_INT+1 ; ABS token +TK_USR = TK_ABS+1 ; USR token +TK_FRE = TK_USR+1 ; FRE token +TK_POS = TK_FRE+1 ; POS token +TK_SQR = TK_POS+1 ; SQR token +TK_RND = TK_SQR+1 ; RND token +TK_LOG = TK_RND+1 ; LOG token +TK_EXP = TK_LOG+1 ; EXP token +TK_COS = TK_EXP+1 ; COS token +TK_SIN = TK_COS+1 ; SIN token +TK_TAN = TK_SIN+1 ; TAN token +TK_ATN = TK_TAN+1 ; ATN token +TK_PEEK = TK_ATN+1 ; PEEK token +TK_DEEK = TK_PEEK+1 ; DEEK token +TK_SADD = TK_DEEK+1 ; SADD token +TK_LEN = TK_SADD+1 ; LEN token +TK_STRS = TK_LEN+1 ; STR$ token +TK_VAL = TK_STRS+1 ; VAL token +TK_ASC = TK_VAL+1 ; ASC token +TK_UCASES = TK_ASC+1 ; UCASE$ token +TK_LCASES = TK_UCASES+1 ; LCASE$ token +TK_CHRS = TK_LCASES+1 ; CHR$ token +TK_HEXS = TK_CHRS+1 ; HEX$ token +TK_BINS = TK_HEXS+1 ; BIN$ token +TK_BITTST = TK_BINS+1 ; BITTST token +TK_MAX = TK_BITTST+1 ; MAX token +TK_MIN = TK_MAX+1 ; MIN token +TK_PI = TK_MIN+1 ; PI token +TK_TWOPI = TK_PI+1 ; TWOPI token +TK_VPTR = TK_TWOPI+1 ; VARPTR token +TK_LEFTS = TK_VPTR+1 ; LEFT$ token +TK_RIGHTS = TK_LEFTS+1 ; RIGHT$ token +TK_MIDS = TK_RIGHTS+1 ; MID$ token + +; offsets from a base of X or Y + +PLUS_0 = $00 ; X or Y plus 0 +PLUS_1 = $01 ; X or Y plus 1 +PLUS_2 = $02 ; X or Y plus 2 +PLUS_3 = $03 ; X or Y plus 3 + +LAB_STAK = $0100 ; stack bottom, no offset + +LAB_SKFE = LAB_STAK+$FE + ; flushed stack address +LAB_SKFF = LAB_STAK+$FF + ; flushed stack address + +ccflag = $0200 ; BASIC CTRL-C flag, 00 = enabled, 01 = dis +ccbyte = ccflag+1 ; BASIC CTRL-C byte +ccnull = ccbyte+1 ; BASIC CTRL-C byte timeout + +VEC_CC = ccnull+1 ; ctrl c check vector + +VEC_IN = VEC_CC+2 ; input vector +VEC_OUT = VEC_IN+2 ; output vector +VEC_LD = VEC_OUT+2 ; load vector +VEC_SV = VEC_LD+2 ; save vector + +; Ibuffs can now be anywhere in RAM, ensure that the max length is < $80 + +IRQ_vec = VEC_SV+2 + +Ibuffs = IRQ_vec+$14 ; start of input buffer after IRQ/NMI code +Ibuffe = Ibuffs+$47 ; end of input buffer + + .ORG $FFC0 + +; I/O routines for Michal Kowalski's 6502 emulator. + +CHRIN + LDA $E004 ; Read from char IO address, non-blocking + BEQ ECHRIN ; if null, assume no character in buffer + CMP #'a' ; < 'a'? + BCC DCHRIN ; yes, done + CMP #'{' ; >= '{'? + BCS DCHRIN ; yes, done + AND #$5F ; no, convert to upper case +DCHRIN + SEC ; These is character waiting, set CARRY flag + RTS +ECHRIN + CLC ; no character in buffer, clear CARRY + RTS + +CHROUT + STA $E001 ; write to char IO address + AND #$FF ; set flags + RTS + + +Ram_base = $0300 ; start of user RAM (set as needed, should be page aligned) +Ram_top = $C000 ; end of user RAM+1 (set as needed, should be page aligned) + +; This start can be changed to suit your system + + *= $C000 + +; BASIC cold start entry point + +; new page 2 initialisation, copy block to ccflag on + +LAB_COLD + CLD + LDY #PG2_TABE-PG2_TABS-1 + ; byte count-1 +LAB_2D13 + LDA PG2_TABS,Y ; get byte + STA ccflag,Y ; store in page 2 + DEY ; decrement count + BPL LAB_2D13 ; loop if not done + + LDX #$FF ; set byte + STX Ibuffs + STX Clineh ; set current line high byte (set immediate mode) + TXS ; reset stack pointer + + LDA #$4C ; code for JMP + STA Fnxjmp ; save for jump vector for functions + +; copy block from LAB_2CEE to $00BC - $00D3 + + LDX #StrTab-LAB_2CEE ; set byte count +LAB_2D4E + LDA LAB_2CEE-1,X ; get byte from table + STA LAB_IGBY-1,X ; save byte in page zero + DEX ; decrement count + BNE LAB_2D4E ; loop if not all done + +; copy block from StrTab to $0000 - $0012 + +LAB_GMEM + LDX #EndTab-StrTab-1 ; set byte count-1 +TabLoop + LDA StrTab,X ; get byte from table + STA PLUS_0,X ; save byte in page zero + DEX ; decrement count + BPL TabLoop ; loop if not all done + +; set-up start values + + LDA #$00 ; clear A + STA NmiBase ; clear NMI handler enabled flag + STA IrqBase ; clear IRQ handler enabled flag + STA FAC1_o ; clear FAC1 overflow byte + STA last_sh ; clear descriptor stack top item pointer high byte + + LDA #$0E ; set default tab size + STA TabSiz ; save it + LDA #$03 ; set garbage collect step size for descriptor stack + STA g_step ; save it + LDX #des_sk ; descriptor stack start + STX next_s ; set descriptor stack pointer + JSR LAB_CRLF ; print CR/LF + LDA #LAB_MSZM ; point to memory size message (high addr) + JSR LAB_18C3 ; print null terminated string from memory + JSR LAB_INLN ; print "? " and get BASIC input + STX Bpntrl ; set BASIC execute pointer low byte + STY Bpntrh ; set BASIC execute pointer high byte + JSR LAB_GBYT ; get last byte back + + BNE LAB_2DAA ; branch if not null (user typed something) + + LDY #$00 ; else clear Y + ; character was null so get memory size the hard way + ; we get here with Y=0 and Itempl/h = Ram_base +LAB_2D93 + INC Itempl ; increment temporary integer low byte + BNE LAB_2D99 ; branch if no overflow + + INC Itemph ; increment temporary integer high byte + LDA Itemph ; get high byte + CMP #>Ram_top ; compare with top of RAM+1 + BEQ LAB_2DB6 ; branch if match (end of user RAM) + +LAB_2D99 + LDA #$55 ; set test byte + STA (Itempl),Y ; save via temporary integer + CMP (Itempl),Y ; compare via temporary integer + BNE LAB_2DB6 ; branch if fail + + ASL ; shift test byte left (now $AA) + STA (Itempl),Y ; save via temporary integer + CMP (Itempl),Y ; compare via temporary integer + BEQ LAB_2D93 ; if ok go do next byte + + BNE LAB_2DB6 ; branch if fail + +LAB_2DAA + JSR LAB_2887 ; get FAC1 from string + LDA FAC1_e ; get FAC1 exponent + CMP #$98 ; compare with exponent = 2^24 + BCS LAB_GMEM ; if too large go try again + + JSR LAB_F2FU ; save integer part of FAC1 in temporary integer + ; (no range check) + +LAB_2DB6 + LDA Itempl ; get temporary integer low byte + LDY Itemph ; get temporary integer high byte + CPY #Ram_top ; compare with top of RAM high byte +; BCC MEM_OK ; branch if < RAM top + +; BNE LAB_GMEM ; if too large go try again + ; else was = so compare low bytes +; CMP #Ram_base ; set start addr high byte + STY Smeml ; save start of mem low byte + STX Smemh ; save start of mem high byte + +; this line is only needed if Ram_base is not $xx00 + +; LDY #$00 ; clear Y + TYA ; clear A + STA (Smeml),Y ; clear first byte + INC Smeml ; increment start of mem low byte + +; these two lines are only needed if Ram_base is $xxFF + +; BNE LAB_2E05 ; branch if no rollover + +; INC Smemh ; increment start of mem high byte +LAB_2E05 + JSR LAB_CRLF ; print CR/LF + JSR LAB_1463 ; do "NEW" and "CLEAR" + LDA Ememl ; get end of mem low byte + SEC ; set carry for subtract + SBC Smeml ; subtract start of mem low byte + TAX ; copy to X + LDA Ememh ; get end of mem high byte + SBC Smemh ; subtract start of mem high byte + JSR LAB_295E ; print XA as unsigned integer (bytes free) + LDA #LAB_SMSG ; point to sign-on message (high addr) + JSR LAB_18C3 ; print null terminated string from memory + LDA #LAB_1274 ; warm start vector high byte + STA Wrmjpl ; save warm start vector low byte + STY Wrmjph ; save warm start vector high byte + JMP (Wrmjpl) ; go do warm start + +; open up space in memory +; move (Ostrtl)-(Obendl) to new block ending at (Nbendl) + +; Nbendl,Nbendh - new block end address (A/Y) +; Obendl,Obendh - old block end address +; Ostrtl,Ostrth - old block start address + +; returns with .. + +; Nbendl,Nbendh - new block start address (high byte - $100) +; Obendl,Obendh - old block start address (high byte - $100) +; Ostrtl,Ostrth - old block start address (unchanged) + +LAB_11CF + JSR LAB_121F ; check available memory, "Out of memory" error if no room + ; addr to check is in AY (low/high) + STA Earryl ; save new array mem end low byte + STY Earryh ; save new array mem end high byte + +; open up space in memory +; move (Ostrtl)-(Obendl) to new block ending at (Nbendl) +; don't set array end + +LAB_11D6 + SEC ; set carry for subtract + LDA Obendl ; get block end low byte + SBC Ostrtl ; subtract block start low byte + TAY ; copy MOD(block length/$100) byte to Y + LDA Obendh ; get block end high byte + SBC Ostrth ; subtract block start high byte + TAX ; copy block length high byte to X + INX ; +1 to allow for count=0 exit + TYA ; copy block length low byte to A + BEQ LAB_120A ; branch if length low byte=0 + + ; block is (X-1)*256+Y bytes, do the Y bytes first + + SEC ; set carry for add + 1, two's complement + EOR #$FF ; invert low byte for subtract + ADC Obendl ; add block end low byte + + STA Obendl ; save corrected old block end low byte + BCS LAB_11F3 ; branch if no underflow + + DEC Obendh ; else decrement block end high byte + SEC ; set carry for add + 1, two's complement +LAB_11F3 + TYA ; get MOD(block length/$100) byte + EOR #$FF ; invert low byte for subtract + ADC Nbendl ; add destination end low byte + STA Nbendl ; save modified new block end low byte + BCS LAB_1203 ; branch if no underflow + + DEC Nbendh ; else decrement block end high byte + BCC LAB_1203 ; branch always + +LAB_11FF + LDA (Obendl),Y ; get byte from source + STA (Nbendl),Y ; copy byte to destination +LAB_1203 + DEY ; decrement index + BNE LAB_11FF ; loop until Y=0 + + ; now do Y=0 indexed byte + LDA (Obendl),Y ; get byte from source + STA (Nbendl),Y ; save byte to destination +LAB_120A + DEC Obendh ; decrement source pointer high byte + DEC Nbendh ; decrement destination pointer high byte + DEX ; decrement block count + BNE LAB_1203 ; loop until count = $0 + + RTS + +; check room on stack for A bytes +; stack too deep? do OM error + +LAB_1212 + STA TempB ; save result in temp byte + TSX ; copy stack + CPX TempB ; compare new "limit" with stack + BCC LAB_OMER ; if stack < limit do "Out of memory" error then warm start + + RTS + +; check available memory, "Out of memory" error if no room +; addr to check is in AY (low/high) + +LAB_121F + CPY Sstorh ; compare bottom of string mem high byte + BCC LAB_124B ; if less then exit (is ok) + + BNE LAB_1229 ; skip next test if greater (tested <) + + ; high byte was =, now do low byte + CMP Sstorl ; compare with bottom of string mem low byte + BCC LAB_124B ; if less then exit (is ok) + + ; addr is > string storage ptr (oops!) +LAB_1229 + PHA ; push addr low byte + LDX #$08 ; set index to save Adatal to expneg inclusive + TYA ; copy addr high byte (to push on stack) + + ; save misc numeric work area +LAB_122D + PHA ; push byte + LDA Adatal-1,X ; get byte from Adatal to expneg ( ,$00 not pushed) + DEX ; decrement index + BPL LAB_122D ; loop until all done + + JSR LAB_GARB ; garbage collection routine + + ; restore misc numeric work area + LDX #$00 ; clear the index to restore bytes +LAB_1238 + PLA ; pop byte + STA Adatal,X ; save byte to Adatal to expneg + INX ; increment index + CPX #$08 ; compare with end + 1 + BMI LAB_1238 ; loop if more to do + + PLA ; pop addr high byte + TAY ; copy back to Y + PLA ; pop addr low byte + CPY Sstorh ; compare bottom of string mem high byte + BCC LAB_124B ; if less then exit (is ok) + + BNE LAB_OMER ; if greater do "Out of memory" error then warm start + + ; high byte was =, now do low byte + CMP Sstorl ; compare with bottom of string mem low byte + BCS LAB_OMER ; if >= do "Out of memory" error then warm start + + ; ok exit, carry clear +LAB_124B + RTS + +; do "Out of memory" error then warm start + +LAB_OMER + LDX #$0C ; error code $0C ("Out of memory" error) + +; do error #X, then warm start + +LAB_XERR + JSR LAB_CRLF ; print CR/LF + + LDA LAB_BAER,X ; get error message pointer low byte + LDY LAB_BAER+1,X ; get error message pointer high byte + JSR LAB_18C3 ; print null terminated string from memory + + JSR LAB_1491 ; flush stack and clear continue flag + LDA #LAB_EMSG ; point to " Error" high addr +LAB_1269 + JSR LAB_18C3 ; print null terminated string from memory + LDY Clineh ; get current line high byte + INY ; increment it + BEQ LAB_1274 ; go do warm start (was immediate mode) + + ; else print line number + JSR LAB_2953 ; print " in line [LINE #]" + +; BASIC warm start entry point +; wait for Basic command + +LAB_1274 + ; clear ON IRQ/NMI bytes + LDA #$00 ; clear A + STA IrqBase ; clear enabled byte + STA NmiBase ; clear enabled byte + LDA #LAB_RMSG ; point to "Ready" message high byte + + JSR LAB_18C3 ; go do print string + CLC + +; wait for Basic command (no "Ready") + +LAB_127D + JSR LAB_1357 ; call for BASIC input +LAB_1280 + STX Bpntrl ; set BASIC execute pointer low byte + STY Bpntrh ; set BASIC execute pointer high byte + JSR LAB_GBYT ; scan memory + BEQ LAB_127D ; loop while null + +; got to interpret input line now .. + + LDX #$FF ; current line to null value + STX Clineh ; set current line high byte + BCC LAB_1295 ; branch if numeric character (handle new BASIC line) + + ; no line number .. immediate mode + JSR LAB_13A6 ; crunch keywords into Basic tokens + JMP LAB_15F6 ; go scan and interpret code + +; handle new BASIC line + +LAB_1295 + JSR LAB_GFPN ; get fixed-point number into temp integer + JSR LAB_13A6 ; crunch keywords into Basic tokens + STY Ibptr ; save index pointer to end of crunched line + JSR LAB_SSLN ; search BASIC for temp integer line number + BCC LAB_12E6 ; branch if not found + + ; aroooogah! line # already exists! delete it + LDY #$01 ; set index to next line pointer high byte + LDA (Baslnl),Y ; get next line pointer high byte + STA ut1_ph ; save it + LDA Svarl ; get start of vars low byte + STA ut1_pl ; save it + LDA Baslnh ; get found line pointer high byte + STA ut2_ph ; save it + LDA Baslnl ; get found line pointer low byte + DEY ; decrement index + SBC (Baslnl),Y ; subtract next line pointer low byte + CLC ; clear carry for add + ADC Svarl ; add start of vars low byte + STA Svarl ; save new start of vars low byte + STA ut2_pl ; save destination pointer low byte + LDA Svarh ; get start of vars high byte + ADC #$FF ; -1 + carry + STA Svarh ; save start of vars high byte + SBC Baslnh ; subtract found line pointer high byte + TAX ; copy to block count + SEC ; set carry for subtract + LDA Baslnl ; get found line pointer low byte + SBC Svarl ; subtract start of vars low byte + TAY ; copy to bytes in first block count + BCS LAB_12D0 ; branch if overflow + + INX ; increment block count (correct for =0 loop exit) + DEC ut2_ph ; decrement destination high byte +LAB_12D0 + CLC ; clear carry for add + ADC ut1_pl ; add source pointer low byte + BCC LAB_12D8 ; branch if no overflow + + DEC ut1_ph ; else decrement source pointer high byte + CLC ; clear carry + + ; close up memory to delete old line +LAB_12D8 + LDA (ut1_pl),Y ; get byte from source + STA (ut2_pl),Y ; copy to destination + INY ; increment index + BNE LAB_12D8 ; while <> 0 do this block + + INC ut1_ph ; increment source pointer high byte + INC ut2_ph ; increment destination pointer high byte + DEX ; decrement block count + BNE LAB_12D8 ; loop until all done + + ; got new line in buffer and no existing same # +LAB_12E6 + LDA Ibuffs ; get byte from start of input buffer + BEQ LAB_1319 ; if null line just go flush stack/vars and exit + + ; got new line and it isn't empty line + LDA Ememl ; get end of mem low byte + LDY Ememh ; get end of mem high byte + STA Sstorl ; set bottom of string space low byte + STY Sstorh ; set bottom of string space high byte + LDA Svarl ; get start of vars low byte (end of BASIC) + STA Obendl ; save old block end low byte + LDY Svarh ; get start of vars high byte (end of BASIC) + STY Obendh ; save old block end high byte + ADC Ibptr ; add input buffer pointer (also buffer length) + BCC LAB_1301 ; branch if no overflow from add + + INY ; else increment high byte +LAB_1301 + STA Nbendl ; save new block end low byte (move to, low byte) + STY Nbendh ; save new block end high byte + JSR LAB_11CF ; open up space in memory + ; old start pointer Ostrtl,Ostrth set by the find line call + LDA Earryl ; get array mem end low byte + LDY Earryh ; get array mem end high byte + STA Svarl ; save start of vars low byte + STY Svarh ; save start of vars high byte + LDY Ibptr ; get input buffer pointer (also buffer length) + DEY ; adjust for loop type +LAB_1311 + LDA Ibuffs-4,Y ; get byte from crunched line + STA (Baslnl),Y ; save it to program memory + DEY ; decrement count + CPY #$03 ; compare with first byte-1 + BNE LAB_1311 ; continue while count <> 3 + + LDA Itemph ; get line # high byte + STA (Baslnl),Y ; save it to program memory + DEY ; decrement count + LDA Itempl ; get line # low byte + STA (Baslnl),Y ; save it to program memory + DEY ; decrement count + LDA #$FF ; set byte to allow chain rebuild. if you didn't set this + ; byte then a zero already here would stop the chain rebuild + ; as it would think it was the [EOT] marker. + STA (Baslnl),Y ; save it to program memory + +LAB_1319 + JSR LAB_1477 ; reset execution to start, clear vars and flush stack + LDX Smeml ; get start of mem low byte + LDA Smemh ; get start of mem high byte + LDY #$01 ; index to high byte of next line pointer +LAB_1325 + STX ut1_pl ; set line start pointer low byte + STA ut1_ph ; set line start pointer high byte + LDA (ut1_pl),Y ; get it + BEQ LAB_133E ; exit if end of program + +; rebuild chaining of Basic lines + + LDY #$04 ; point to first code byte of line + ; there is always 1 byte + [EOL] as null entries are deleted +LAB_1330 + INY ; next code byte + LDA (ut1_pl),Y ; get byte + BNE LAB_1330 ; loop if not [EOL] + + SEC ; set carry for add + 1 + TYA ; copy end index + ADC ut1_pl ; add to line start pointer low byte + TAX ; copy to X + LDY #$00 ; clear index, point to this line's next line pointer + STA (ut1_pl),Y ; set next line pointer low byte + TYA ; clear A + ADC ut1_ph ; add line start pointer high byte + carry + INY ; increment index to high byte + STA (ut1_pl),Y ; save next line pointer low byte + BCC LAB_1325 ; go do next line, branch always, carry clear + + +LAB_133E + JMP LAB_127D ; else we just wait for Basic command, no "Ready" + +; print "? " and get BASIC input + +LAB_INLN + JSR LAB_18E3 ; print "?" character + JSR LAB_18E0 ; print " " + BNE LAB_1357 ; call for BASIC input and return + +; receive line from keyboard + + ; $08 as delete key (BACKSPACE on standard keyboard) +LAB_134B + JSR LAB_PRNA ; go print the character + DEX ; decrement the buffer counter (delete) + .byte $2C ; make LDX into BIT abs + +; call for BASIC input (main entry point) + +LAB_1357 + LDX #$00 ; clear BASIC line buffer pointer +LAB_1359 + JSR V_INPT ; call scan input device + BCC LAB_1359 ; loop if no byte + + BEQ LAB_1359 ; loop until valid input (ignore NULLs) + + CMP #$07 ; compare with [BELL] + BEQ LAB_1378 ; branch if [BELL] + + CMP #$0D ; compare with [CR] + BEQ LAB_1384 ; do CR/LF exit if [CR] + + CPX #$00 ; compare pointer with $00 + BNE LAB_1374 ; branch if not empty + +; next two lines ignore any non print character and [SPACE] if input buffer empty + + CMP #$21 ; compare with [SP]+1 + BCC LAB_1359 ; if < ignore character + +LAB_1374 + CMP #$08 ; compare with [BACKSPACE] (delete last character) + BEQ LAB_134B ; go delete last character + +LAB_1378 + CPX #Ibuffe-Ibuffs ; compare character count with max + BCS LAB_138E ; skip store and do [BELL] if buffer full + + STA Ibuffs,X ; else store in buffer + INX ; increment pointer +LAB_137F + JSR LAB_PRNA ; go print the character + BNE LAB_1359 ; always loop for next character + +LAB_1384 + JMP LAB_1866 ; do CR/LF exit to BASIC + +; announce buffer full + +LAB_138E + LDA #$07 ; [BELL] character into A + BNE LAB_137F ; go print the [BELL] but ignore input character + ; branch always + +; crunch keywords into Basic tokens +; position independent buffer version .. +; faster, dictionary search version .... + +LAB_13A6 + LDY #$FF ; set save index (makes for easy math later) + + SEC ; set carry for subtract + LDA Bpntrl ; get basic execute pointer low byte + SBC #= go save byte then continue crunching + + CMP #'<' ; compare with "<" + BCS LAB_13CC ; if >= go crunch now + + CMP #'0' ; compare with "0" + BCS LAB_13EC ; if >= go save byte then continue crunching + + STA Scnquo ; save buffer byte as search character + CMP #$22 ; is it quote character? + BEQ LAB_1410 ; branch if so (copy quoted string) + + CMP #'*' ; compare with "*" + BCC LAB_13EC ; if < go save byte then continue crunching + + ; else crunch now +LAB_13CC + BIT Oquote ; get open quote/DATA token flag + BVS LAB_13EC ; branch if b6 of Oquote set (was DATA) + ; go save byte then continue crunching + + STX TempB ; save buffer read index + STY csidx ; copy buffer save index + LDY #TAB_1STC ; get keyword first character table high address + STY ut2_ph ; save pointer high byte + LDY #$00 ; clear table pointer + +LAB_13D0 + CMP (ut2_pl),Y ; compare with keyword first character table byte + BEQ LAB_13D1 ; go do word_table_chr if match + + BCC LAB_13EA ; if < keyword first character table byte go restore + ; Y and save to crunched + + INY ; else increment pointer + BNE LAB_13D0 ; and loop (branch always) + +; have matched first character of some keyword + +LAB_13D1 + TYA ; copy matching index + ASL ; *2 (bytes per pointer) + TAX ; copy to new index + LDA TAB_CHRT,X ; get keyword table pointer low byte + STA ut2_pl ; save pointer low byte + LDA TAB_CHRT+1,X ; get keyword table pointer high byte + STA ut2_ph ; save pointer high byte + + LDY #$FF ; clear table pointer (make -1 for start) + + LDX TempB ; restore buffer read index + +LAB_13D6 + INY ; next table byte + LDA (ut2_pl),Y ; get byte from table +LAB_13D8 + BMI LAB_13EA ; all bytes matched so go save token + + INX ; next buffer byte + CMP Ibuffs,X ; compare with byte from input buffer + BEQ LAB_13D6 ; go compare next if match + + BNE LAB_1417 ; branch if >< (not found keyword) + +LAB_13EA + LDY csidx ; restore save index + + ; save crunched to output +LAB_13EC + INX ; increment buffer index (to next input byte) + INY ; increment save index (to next output byte) + STA Ibuffs,Y ; save byte to output + CMP #$00 ; set the flags, set carry + BEQ LAB_142A ; do exit if was null [EOL] + + ; A holds token or byte here + SBC #':' ; subtract ":" (carry set by CMP #00) + BEQ LAB_13FF ; branch if it was ":" (is now $00) + + ; A now holds token-$3A + CMP #TK_DATA-$3A ; compare with DATA token - $3A + BNE LAB_1401 ; branch if not DATA + + ; token was : or DATA +LAB_13FF + STA Oquote ; save token-$3A (clear for ":", TK_DATA-$3A for DATA) +LAB_1401 + EOR #TK_REM-$3A ; effectively subtract REM token offset + BNE LAB_13AC ; If wasn't REM then go crunch rest of line + + STA Asrch ; else was REM so set search for [EOL] + + ; loop for REM, "..." etc. +LAB_1408 + LDA Ibuffs,X ; get byte from input buffer + BEQ LAB_13EC ; branch if null [EOL] + + CMP Asrch ; compare with stored character + BEQ LAB_13EC ; branch if match (end quote) + + ; entry for copy string in quotes, don't crunch +LAB_1410 + INY ; increment buffer save index + STA Ibuffs,Y ; save byte to output + INX ; increment buffer read index + BNE LAB_1408 ; loop while <> 0 (should never be 0!) + + ; not found keyword this go +LAB_1417 + LDX TempB ; compare has failed, restore buffer index (start byte!) + + ; now find the end of this word in the table +LAB_141B + LDA (ut2_pl),Y ; get table byte + PHP ; save status + INY ; increment table index + PLP ; restore byte status + BPL LAB_141B ; if not end of keyword go do next + + LDA (ut2_pl),Y ; get byte from keyword table + BNE LAB_13D8 ; go test next word if not zero byte (end of table) + + ; reached end of table with no match + LDA Ibuffs,X ; restore byte from input buffer + BPL LAB_13EA ; branch always (all bytes in buffer are $00-$7F) + ; go save byte in output and continue crunching + + ; reached [EOL] +LAB_142A + INY ; increment pointer + INY ; increment pointer (makes it next line pointer high byte) + STA Ibuffs,Y ; save [EOL] (marks [EOT] in immediate mode) + INY ; adjust for line copy + INY ; adjust for line copy + INY ; adjust for line copy + DEC Bpntrl ; allow for increment (change if buffer starts at $xxFF) + RTS + +; search Basic for temp integer line number from start of mem + +LAB_SSLN + LDA Smeml ; get start of mem low byte + LDX Smemh ; get start of mem high byte + +; search Basic for temp integer line number from AX +; returns carry set if found +; returns Baslnl/Baslnh pointer to found or next higher (not found) line + +; old 541 new 507 + +LAB_SHLN + LDY #$01 ; set index + STA Baslnl ; save low byte as current + STX Baslnh ; save high byte as current + LDA (Baslnl),Y ; get pointer high byte from addr + BEQ LAB_145F ; pointer was zero so we're done, do 'not found' exit + + LDY #$03 ; set index to line # high byte + LDA (Baslnl),Y ; get line # high byte + DEY ; decrement index (point to low byte) + CMP Itemph ; compare with temporary integer high byte + BNE LAB_1455 ; if <> skip low byte check + + LDA (Baslnl),Y ; get line # low byte + CMP Itempl ; compare with temporary integer low byte +LAB_1455 + BCS LAB_145E ; else if temp < this line, exit (passed line#) + +LAB_1456 + DEY ; decrement index to next line ptr high byte + LDA (Baslnl),Y ; get next line pointer high byte + TAX ; copy to X + DEY ; decrement index to next line ptr low byte + LDA (Baslnl),Y ; get next line pointer low byte + BCC LAB_SHLN ; go search for line # in temp (Itempl/Itemph) from AX + ; (carry always clear) + +LAB_145E + BEQ LAB_1460 ; exit if temp = found line #, carry is set + +LAB_145F + CLC ; clear found flag +LAB_1460 + RTS + +; perform NEW + +LAB_NEW + BNE LAB_1460 ; exit if not end of statement (to do syntax error) + +LAB_1463 + LDA #$00 ; clear A + TAY ; clear Y + STA (Smeml),Y ; clear first line, next line pointer, low byte + INY ; increment index + STA (Smeml),Y ; clear first line, next line pointer, high byte + CLC ; clear carry + LDA Smeml ; get start of mem low byte + ADC #$02 ; calculate end of BASIC low byte + STA Svarl ; save start of vars low byte + LDA Smemh ; get start of mem high byte + ADC #$00 ; add any carry + STA Svarh ; save start of vars high byte + +; reset execution to start, clear vars and flush stack + +LAB_1477 + CLC ; clear carry + LDA Smeml ; get start of mem low byte + ADC #$FF ; -1 + STA Bpntrl ; save BASIC execute pointer low byte + LDA Smemh ; get start of mem high byte + ADC #$FF ; -1+carry + STA Bpntrh ; save BASIC execute pointer high byte + +; "CLEAR" command gets here + +LAB_147A + LDA Ememl ; get end of mem low byte + LDY Ememh ; get end of mem high byte + STA Sstorl ; set bottom of string space low byte + STY Sstorh ; set bottom of string space high byte + LDA Svarl ; get start of vars low byte + LDY Svarh ; get start of vars high byte + STA Sarryl ; save var mem end low byte + STY Sarryh ; save var mem end high byte + STA Earryl ; save array mem end low byte + STY Earryh ; save array mem end high byte + JSR LAB_161A ; perform RESTORE command + +; flush stack and clear continue flag + +LAB_1491 + LDX #des_sk ; set descriptor stack pointer + STX next_s ; save descriptor stack pointer + PLA ; pull return address low byte + TAX ; copy return address low byte + PLA ; pull return address high byte + STX LAB_SKFE ; save to cleared stack + STA LAB_SKFF ; save to cleared stack + LDX #$FD ; new stack pointer + TXS ; reset stack + LDA #$00 ; clear byte + STA Cpntrh ; clear continue pointer high byte + STA Sufnxf ; clear subscript/FNX flag +LAB_14A6 + RTS + +; perform CLEAR + +LAB_CLEAR + BEQ LAB_147A ; if no following token go do "CLEAR" + + ; else there was a following token (go do syntax error) + RTS + +; perform LIST [n][-m] +; bigger, faster version (a _lot_ faster) + +LAB_LIST + BCC LAB_14BD ; branch if next character numeric (LIST n..) + + BEQ LAB_14BD ; branch if next character [NULL] (LIST) + + CMP #TK_MINUS ; compare with token for - + BNE LAB_14A6 ; exit if not - (LIST -m) + + ; LIST [[n][-m]] + ; this bit sets the n , if present, as the start and end +LAB_14BD + JSR LAB_GFPN ; get fixed-point number into temp integer + JSR LAB_SSLN ; search BASIC for temp integer line number + ; (pointer in Baslnl/Baslnh) + JSR LAB_GBYT ; scan memory + BEQ LAB_14D4 ; branch if no more characters + + ; this bit checks the - is present + CMP #TK_MINUS ; compare with token for - + BNE LAB_1460 ; return if not "-" (will be Syntax error) + + ; LIST [n]-m + ; the - was there so set m as the end value + JSR LAB_IGBY ; increment and scan memory + JSR LAB_GFPN ; get fixed-point number into temp integer + BNE LAB_1460 ; exit if not ok + +LAB_14D4 + LDA Itempl ; get temporary integer low byte + ORA Itemph ; OR temporary integer high byte + BNE LAB_14E2 ; branch if start set + + LDA #$FF ; set for -1 + STA Itempl ; set temporary integer low byte + STA Itemph ; set temporary integer high byte +LAB_14E2 + LDY #$01 ; set index for line + STY Oquote ; clear open quote flag + JSR LAB_CRLF ; print CR/LF + LDA (Baslnl),Y ; get next line pointer high byte + ; pointer initially set by search at LAB_14BD + BEQ LAB_152B ; if null all done so exit + JSR LAB_1629 ; do CRTL-C check vector + + INY ; increment index for line + LDA (Baslnl),Y ; get line # low byte + TAX ; copy to X + INY ; increment index + LDA (Baslnl),Y ; get line # high byte + CMP Itemph ; compare with temporary integer high byte + BNE LAB_14FF ; branch if no high byte match + + CPX Itempl ; compare with temporary integer low byte + BEQ LAB_1501 ; branch if = last line to do (< will pass next branch) + +LAB_14FF ; else .. + BCS LAB_152B ; if greater all done so exit + +LAB_1501 + STY Tidx1 ; save index for line + JSR LAB_295E ; print XA as unsigned integer + LDA #$20 ; space is the next character +LAB_1508 + LDY Tidx1 ; get index for line + AND #$7F ; mask top out bit of character +LAB_150C + JSR LAB_PRNA ; go print the character + CMP #$22 ; was it " character + BNE LAB_1519 ; branch if not + + ; we are either entering or leaving a pair of quotes + LDA Oquote ; get open quote flag + EOR #$FF ; toggle it + STA Oquote ; save it back +LAB_1519 + INY ; increment index + LDA (Baslnl),Y ; get next byte + BNE LAB_152E ; branch if not [EOL] (go print character) + TAY ; else clear index + LDA (Baslnl),Y ; get next line pointer low byte + TAX ; copy to X + INY ; increment index + LDA (Baslnl),Y ; get next line pointer high byte + STX Baslnl ; set pointer to line low byte + STA Baslnh ; set pointer to line high byte + BNE LAB_14E2 ; go do next line if not [EOT] + ; else .. +LAB_152B + RTS + +LAB_152E + BPL LAB_150C ; just go print it if not token byte + + ; else was token byte so uncrunch it (maybe) + BIT Oquote ; test the open quote flag + BMI LAB_150C ; just go print character if open quote set + + LDX #>LAB_KEYT ; get table address high byte + ASL ; *2 + ASL ; *4 + BCC LAB_152F ; branch if no carry + + INX ; else increment high byte + CLC ; clear carry for add +LAB_152F + ADC #LAB_159F ; set return address high byte + STA ut1_pl ; save return address low byte + STY ut1_ph ; save return address high byte + JMP LAB_1B66 ; round FAC1 and put on stack (returns to next instruction) + +LAB_159F + LDA #LAB_259C ; set 1 pointer high addr + JSR LAB_UFAC ; unpack memory (AY) into FAC1 + JSR LAB_GBYT ; scan memory + CMP #TK_STEP ; compare with STEP token + BNE LAB_15B3 ; jump if not "STEP" + + ;.was step so .. + JSR LAB_IGBY ; increment and scan memory + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch +LAB_15B3 + JSR LAB_27CA ; return A=FF,C=1/-ve A=01,C=0/+ve + STA FAC1_s ; set FAC1 sign (b7) + ; this is +1 for +ve step and -1 for -ve step, in NEXT we + ; compare the FOR value and the TO value and return +1 if + ; FOR > TO, 0 if FOR = TO and -1 if FOR < TO. the value + ; here (+/-1) is then compared to that result and if they + ; are the same (+ve and FOR > TO or -ve and FOR < TO) then + ; the loop is done + JSR LAB_1B5B ; push sign, round FAC1 and put on stack + LDA Frnxth ; get var pointer for FOR/NEXT high byte + PHA ; push on stack + LDA Frnxtl ; get var pointer for FOR/NEXT low byte + PHA ; push on stack + LDA #TK_FOR ; get FOR token + PHA ; push on stack + +; interpreter inner loop + +LAB_15C2 + JSR LAB_1629 ; do CRTL-C check vector + LDA Bpntrl ; get BASIC execute pointer low byte + LDY Bpntrh ; get BASIC execute pointer high byte + + LDX Clineh ; continue line is $FFxx for immediate mode + ; ($00xx for RUN from immediate mode) + INX ; increment it (now $00 if immediate mode) + BEQ LAB_15D1 ; branch if null (immediate mode) + + STA Cpntrl ; save continue pointer low byte + STY Cpntrh ; save continue pointer high byte +LAB_15D1 + LDY #$00 ; clear index + LDA (Bpntrl),Y ; get next byte + BEQ LAB_15DC ; branch if null [EOL] + + CMP #':' ; compare with ":" + BEQ LAB_15F6 ; branch if = (statement separator) + +LAB_15D9 + JMP LAB_SNER ; else syntax error then warm start + + ; have reached [EOL] +LAB_15DC + LDY #$02 ; set index + LDA (Bpntrl),Y ; get next line pointer high byte + CLC ; clear carry for no "BREAK" message + BEQ LAB_1651 ; if null go to immediate mode (was immediate or [EOT] + ; marker) + + INY ; increment index + LDA (Bpntrl),Y ; get line # low byte + STA Clinel ; save current line low byte + INY ; increment index + LDA (Bpntrl),Y ; get line # high byte + STA Clineh ; save current line high byte + TYA ; A now = 4 + ADC Bpntrl ; add BASIC execute pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + BCC LAB_15F6 ; branch if no overflow + + INC Bpntrh ; else increment BASIC execute pointer high byte +LAB_15F6 + JSR LAB_IGBY ; increment and scan memory + +LAB_15F9 + JSR LAB_15FF ; go interpret BASIC code from (Bpntrl) + +LAB_15FC + JMP LAB_15C2 ; loop + +; interpret BASIC code from (Bpntrl) + +LAB_15FF + BEQ LAB_1628 ; exit if zero [EOL] + +LAB_1602 + ASL ; *2 bytes per vector and normalise token + BCS LAB_1609 ; branch if was token + + JMP LAB_LET ; else go do implied LET + +LAB_1609 + CMP #[TK_TAB-$80]*2 ; compare normalised token * 2 with TAB + BCS LAB_15D9 ; branch if A>=TAB (do syntax error then warm start) + ; only tokens before TAB can start a line + TAY ; copy to index + LDA LAB_CTBL+1,Y ; get vector high byte + PHA ; onto stack + LDA LAB_CTBL,Y ; get vector low byte + PHA ; onto stack + JMP LAB_IGBY ; jump to increment and scan memory + ; then "return" to vector + +; CTRL-C check jump. this is called as a subroutine but exits back via a jump if a +; key press is detected. + +LAB_1629 + JMP (VEC_CC) ; ctrl c check vector + +; if there was a key press it gets back here .. + +LAB_1636 + CMP #$03 ; compare with CTRL-C + +; perform STOP + +LAB_STOP + BCS LAB_163B ; branch if token follows STOP + ; else just END +; END + +LAB_END + CLC ; clear the carry, indicate a normal program end +LAB_163B + BNE LAB_167A ; if wasn't CTRL-C or there is a following byte return + + LDA Bpntrh ; get the BASIC execute pointer high byte + EOR #>Ibuffs ; compare with buffer address high byte (Cb unchanged) + BEQ LAB_164F ; branch if the BASIC pointer is in the input buffer + ; (can't continue in immediate mode) + + ; else .. + EOR #>Ibuffs ; correct the bits + LDY Bpntrl ; get BASIC execute pointer low byte + STY Cpntrl ; save continue pointer low byte + STA Cpntrh ; save continue pointer high byte +LAB_1647 + LDA Clinel ; get current line low byte + LDY Clineh ; get current line high byte + STA Blinel ; save break line low byte + STY Blineh ; save break line high byte +LAB_164F + PLA ; pull return address low + PLA ; pull return address high +LAB_1651 + BCC LAB_165E ; if was program end just do warm start + + ; else .. + LDA #LAB_BMSG ; point to "Break" high byte + JMP LAB_1269 ; print "Break" and do warm start + +LAB_165E + JMP LAB_1274 ; go do warm start + +; perform RESTORE + +LAB_RESTORE + BNE LAB_RESTOREn ; branch if next character not null (RESTORE n) + +LAB_161A + SEC ; set carry for subtract + LDA Smeml ; get start of mem low byte + SBC #$01 ; -1 + LDY Smemh ; get start of mem high byte + BCS LAB_1624 ; branch if no underflow + +LAB_uflow + DEY ; else decrement high byte +LAB_1624 + STA Dptrl ; save DATA pointer low byte + STY Dptrh ; save DATA pointer high byte +LAB_1628 + RTS + + ; is RESTORE n +LAB_RESTOREn + JSR LAB_GFPN ; get fixed-point number into temp integer + JSR LAB_SNBL ; scan for next BASIC line + LDA Clineh ; get current line high byte + CMP Itemph ; compare with temporary integer high byte + BCS LAB_reset_search ; branch if >= (start search from beginning) + + TYA ; else copy line index to A + SEC ; set carry (+1) + ADC Bpntrl ; add BASIC execute pointer low byte + LDX Bpntrh ; get BASIC execute pointer high byte + BCC LAB_go_search ; branch if no overflow to high byte + + INX ; increment high byte + BCS LAB_go_search ; branch always (can never be carry clear) + +; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml) + +LAB_reset_search + LDA Smeml ; get start of mem low byte + LDX Smemh ; get start of mem high byte + +; search for line # in temp (Itempl/Itemph) from (AX) + +LAB_go_search + + JSR LAB_SHLN ; search Basic for temp integer line number from AX + BCS LAB_line_found ; if carry set go set pointer + + JMP LAB_16F7 ; else go do "Undefined statement" error + +LAB_line_found + ; carry already set for subtract + LDA Baslnl ; get pointer low byte + SBC #$01 ; -1 + LDY Baslnh ; get pointer high byte + BCS LAB_1624 ; branch if no underflow (save DATA pointer and return) + + BCC LAB_uflow ; else decrement high byte then save DATA pointer and + ; return (branch always) + +; perform NULL + +LAB_NULL + JSR LAB_GTBY ; get byte parameter + STX Nullct ; save new NULL count +LAB_167A + RTS + +; perform CONT + +LAB_CONT + BNE LAB_167A ; if following byte exit to do syntax error + + LDY Cpntrh ; get continue pointer high byte + BNE LAB_166C ; go do continue if we can + + LDX #$1E ; error code $1E ("Can't continue" error) + JMP LAB_XERR ; do error #X, then warm start + + ; we can continue so .. +LAB_166C + LDA #TK_ON ; set token for ON + JSR LAB_IRQ ; set IRQ flags + LDA #TK_ON ; set token for ON + JSR LAB_NMI ; set NMI flags + + STY Bpntrh ; save BASIC execute pointer high byte + LDA Cpntrl ; get continue pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + LDA Blinel ; get break line low byte + LDY Blineh ; get break line high byte + STA Clinel ; set current line low byte + STY Clineh ; set current line high byte + RTS + +; perform RUN + +LAB_RUN + BNE LAB_1696 ; branch if RUN n + JMP LAB_1477 ; reset execution to start, clear variables, flush stack and + ; return + +; does RUN n + +LAB_1696 + JSR LAB_147A ; go do "CLEAR" + BEQ LAB_16B0 ; get n and do GOTO n (branch always as CLEAR sets Z=1) + +; perform DO + +LAB_DO + LDA #$05 ; need 5 bytes for DO + JSR LAB_1212 ; check room on stack for A bytes + LDA Bpntrh ; get BASIC execute pointer high byte + PHA ; push on stack + LDA Bpntrl ; get BASIC execute pointer low byte + PHA ; push on stack + LDA Clineh ; get current line high byte + PHA ; push on stack + LDA Clinel ; get current line low byte + PHA ; push on stack + LDA #TK_DO ; token for DO + PHA ; push on stack + JSR LAB_GBYT ; scan memory + JMP LAB_15C2 ; go do interpreter inner loop + +; perform GOSUB + +LAB_GOSUB + LDA #$05 ; need 5 bytes for GOSUB + JSR LAB_1212 ; check room on stack for A bytes + LDA Bpntrh ; get BASIC execute pointer high byte + PHA ; push on stack + LDA Bpntrl ; get BASIC execute pointer low byte + PHA ; push on stack + LDA Clineh ; get current line high byte + PHA ; push on stack + LDA Clinel ; get current line low byte + PHA ; push on stack + LDA #TK_GOSUB ; token for GOSUB + PHA ; push on stack +LAB_16B0 + JSR LAB_GBYT ; scan memory + JSR LAB_GOTO ; perform GOTO n + JMP LAB_15C2 ; go do interpreter inner loop + ; (can't RTS, we used the stack!) + +; perform GOTO + +LAB_GOTO + JSR LAB_GFPN ; get fixed-point number into temp integer + JSR LAB_SNBL ; scan for next BASIC line + LDA Clineh ; get current line high byte + CMP Itemph ; compare with temporary integer high byte + BCS LAB_16D0 ; branch if >= (start search from beginning) + + TYA ; else copy line index to A + SEC ; set carry (+1) + ADC Bpntrl ; add BASIC execute pointer low byte + LDX Bpntrh ; get BASIC execute pointer high byte + BCC LAB_16D4 ; branch if no overflow to high byte + + INX ; increment high byte + BCS LAB_16D4 ; branch always (can never be carry) + +; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml) + +LAB_16D0 + LDA Smeml ; get start of mem low byte + LDX Smemh ; get start of mem high byte + +; search for line # in temp (Itempl/Itemph) from (AX) + +LAB_16D4 + JSR LAB_SHLN ; search Basic for temp integer line number from AX + BCC LAB_16F7 ; if carry clear go do "Undefined statement" error + ; (unspecified statement) + + ; carry already set for subtract + LDA Baslnl ; get pointer low byte + SBC #$01 ; -1 + STA Bpntrl ; save BASIC execute pointer low byte + LDA Baslnh ; get pointer high byte + SBC #$00 ; subtract carry + STA Bpntrh ; save BASIC execute pointer high byte +LAB_16E5 + RTS + +LAB_DONOK + LDX #$22 ; error code $22 ("LOOP without DO" error) + JMP LAB_XERR ; do error #X, then warm start + +; perform LOOP + +LAB_LOOP + TAY ; save following token + TSX ; copy stack pointer + LDA LAB_STAK+3,X ; get token byte from stack + CMP #TK_DO ; compare with DO token + BNE LAB_DONOK ; branch if no matching DO + + INX ; dump calling routine return address + INX ; dump calling routine return address + TXS ; correct stack + TYA ; get saved following token back + BEQ LoopAlways ; if no following token loop forever + ; (stack pointer in X) + + CMP #':' ; could be ':' + BEQ LoopAlways ; if :... loop forever + + SBC #TK_UNTIL ; subtract token for UNTIL, we know carry is set here + TAX ; copy to X (if it was UNTIL then Y will be correct) + BEQ DoRest ; branch if was UNTIL + + DEX ; decrement result + BNE LAB_16FC ; if not WHILE go do syntax error and warm start + ; only if the token was WHILE will this fail + + DEX ; set invert result byte +DoRest + STX Frnxth ; save invert result byte + JSR LAB_IGBY ; increment and scan memory + JSR LAB_EVEX ; evaluate expression + LDA FAC1_e ; get FAC1 exponent + BEQ DoCmp ; if =0 go do straight compare + + LDA #$FF ; else set all bits +DoCmp + TSX ; copy stack pointer + EOR Frnxth ; EOR with invert byte + BNE LoopDone ; if <> 0 clear stack and back to interpreter loop + + ; loop condition wasn't met so do it again +LoopAlways + LDA LAB_STAK+2,X ; get current line low byte + STA Clinel ; save current line low byte + LDA LAB_STAK+3,X ; get current line high byte + STA Clineh ; save current line high byte + LDA LAB_STAK+4,X ; get BASIC execute pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + LDA LAB_STAK+5,X ; get BASIC execute pointer high byte + STA Bpntrh ; save BASIC execute pointer high byte + JSR LAB_GBYT ; scan memory + JMP LAB_15C2 ; go do interpreter inner loop + + ; clear stack and back to interpreter loop +LoopDone + INX ; dump DO token + INX ; dump current line low byte + INX ; dump current line high byte + INX ; dump BASIC execute pointer low byte + INX ; dump BASIC execute pointer high byte + TXS ; correct stack + JMP LAB_DATA ; go perform DATA (find : or [EOL]) + +; do the return without gosub error + +LAB_16F4 + LDX #$04 ; error code $04 ("RETURN without GOSUB" error) + .byte $2C ; makes next line BIT LAB_0EA2 + +LAB_16F7 ; do undefined statement error + LDX #$0E ; error code $0E ("Undefined statement" error) + JMP LAB_XERR ; do error #X, then warm start + +; perform RETURN + +LAB_RETURN + BNE LAB_16E5 ; exit if following token (to allow syntax error) + +LAB_16E8 + PLA ; dump calling routine return address + PLA ; dump calling routine return address + PLA ; pull token + CMP #TK_GOSUB ; compare with GOSUB token + BNE LAB_16F4 ; branch if no matching GOSUB + +LAB_16FF + PLA ; pull current line low byte + STA Clinel ; save current line low byte + PLA ; pull current line high byte + STA Clineh ; save current line high byte + PLA ; pull BASIC execute pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + PLA ; pull BASIC execute pointer high byte + STA Bpntrh ; save BASIC execute pointer high byte + + ; now do the DATA statement as we could be returning into + ; the middle of an ON GOSUB n,m,p,q line + ; (the return address used by the DATA statement is the one + ; pushed before the GOSUB was executed!) + +; perform DATA + +LAB_DATA + JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL]) + + ; set BASIC execute pointer +LAB_170F + TYA ; copy index to A + CLC ; clear carry for add + ADC Bpntrl ; add BASIC execute pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + BCC LAB_1719 ; skip next if no carry + + INC Bpntrh ; else increment BASIC execute pointer high byte +LAB_1719 + RTS + +LAB_16FC + JMP LAB_SNER ; do syntax error then warm start + +; scan for next BASIC statement ([:] or [EOL]) +; returns Y as index to [:] or [EOL] + +LAB_SNBS + LDX #':' ; set look for character = ":" + .byte $2C ; makes next line BIT $00A2 + +; scan for next BASIC line +; returns Y as index to [EOL] + +LAB_SNBL + LDX #$00 ; set alt search character = [EOL] + LDY #$00 ; set search character = [EOL] + STY Asrch ; store search character +LAB_1725 + TXA ; get alt search character + EOR Asrch ; toggle search character, effectively swap with $00 + STA Asrch ; save swapped search character +LAB_172D + LDA (Bpntrl),Y ; get next byte + BEQ LAB_1719 ; exit if null [EOL] + + CMP Asrch ; compare with search character + BEQ LAB_1719 ; exit if found + + INY ; increment index + CMP #$22 ; compare current character with open quote + BNE LAB_172D ; if not open quote go get next character + + BEQ LAB_1725 ; if found go swap search character for alt search character + +; perform IF + +LAB_IF + JSR LAB_EVEX ; evaluate the expression + JSR LAB_GBYT ; scan memory + CMP #TK_THEN ; compare with THEN token + BEQ LAB_174B ; if it was THEN go do IF + + ; wasn't IF .. THEN so must be IF .. GOTO + CMP #TK_GOTO ; compare with GOTO token + BNE LAB_16FC ; if it wasn't GOTO go do syntax error + + LDX Bpntrl ; save the basic pointer low byte + LDY Bpntrh ; save the basic pointer high byte + JSR LAB_IGBY ; increment and scan memory + BCS LAB_16FC ; if not numeric go do syntax error + + STX Bpntrl ; restore the basic pointer low byte + STY Bpntrh ; restore the basic pointer high byte +LAB_174B + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_174E ; if the result was zero go look for an ELSE + + JSR LAB_IGBY ; else increment and scan memory + BCS LAB_174D ; if not numeric go do var or keyword + +LAB_174C + JMP LAB_GOTO ; else was numeric so do GOTO n + + ; is var or keyword +LAB_174D + CMP #TK_RETURN ; compare the byte with the token for RETURN + BNE LAB_174G ; if it wasn't RETURN go interpret BASIC code from (Bpntrl) + ; and return to this code to process any following code + + JMP LAB_1602 ; else it was RETURN so interpret BASIC code from (Bpntrl) + ; but don't return here + +LAB_174G + JSR LAB_15FF ; interpret BASIC code from (Bpntrl) + +; the IF was executed and there may be a following ELSE so the code needs to return +; here to check and ignore the ELSE if present + + LDY #$00 ; clear the index + LDA (Bpntrl),Y ; get the next BASIC byte + CMP #TK_ELSE ; compare it with the token for ELSE + BEQ LAB_DATA ; if ELSE ignore the following statement + +; there was no ELSE so continue execution of IF THEN [: ]. any +; following ELSE will, correctly, cause a syntax error + + RTS ; else return to the interpreter inner loop + +; perform ELSE after IF + +LAB_174E + LDY #$00 ; clear the BASIC byte index + LDX #$01 ; clear the nesting depth +LAB_1750 + INY ; increment the BASIC byte index + LDA (Bpntrl),Y ; get the next BASIC byte + BEQ LAB_1753 ; if EOL go add the pointer and return + + CMP #TK_IF ; compare the byte with the token for IF + BNE LAB_1752 ; if not IF token skip the depth increment + + INX ; else increment the nesting depth .. + BNE LAB_1750 ; .. and continue looking + +LAB_1752 + CMP #TK_ELSE ; compare the byte with the token for ELSE + BNE LAB_1750 ; if not ELSE token continue looking + + DEX ; was ELSE so decrement the nesting depth + BNE LAB_1750 ; loop if still nested + + INY ; increment the BASIC byte index past the ELSE + +; found the matching ELSE, now do <{n|statement}> + +LAB_1753 + TYA ; else copy line index to A + CLC ; clear carry for add + ADC Bpntrl ; add the BASIC execute pointer low byte + STA Bpntrl ; save the BASIC execute pointer low byte + BCC LAB_1754 ; branch if no overflow to high byte + + INC Bpntrh ; else increment the BASIC execute pointer high byte +LAB_1754 + JSR LAB_GBYT ; scan memory + BCC LAB_174C ; if numeric do GOTO n + ; the code will return to the interpreter loop at the + ; tail end of the GOTO + + JMP LAB_15FF ; interpret BASIC code from (Bpntrl) + ; the code will return to the interpreter loop at the + ; tail end of the + +; perform REM, skip (rest of) line + +LAB_REM + JSR LAB_SNBL ; scan for next BASIC line + JMP LAB_170F ; go set BASIC execute pointer and return, branch always + +LAB_16FD + JMP LAB_SNER ; do syntax error then warm start + +; perform ON + +LAB_ON + CMP #TK_IRQ ; was it IRQ token ? + BNE LAB_NOIN ; if not go check NMI + + JMP LAB_SIRQ ; else go set-up IRQ + +LAB_NOIN + CMP #TK_NMI ; was it NMI token ? + BNE LAB_NONM ; if not go do normal ON command + + JMP LAB_SNMI ; else go set-up NMI + +LAB_NONM + JSR LAB_GTBY ; get byte parameter + PHA ; push GOTO/GOSUB token + CMP #TK_GOSUB ; compare with GOSUB token + BEQ LAB_176B ; branch if GOSUB + + CMP #TK_GOTO ; compare with GOTO token +LAB_1767 + BNE LAB_16FD ; if not GOTO do syntax error then warm start + + +; next character was GOTO or GOSUB + +LAB_176B + DEC FAC1_3 ; decrement index (byte value) + BNE LAB_1773 ; branch if not zero + + PLA ; pull GOTO/GOSUB token + JMP LAB_1602 ; go execute it + +LAB_1773 + JSR LAB_IGBY ; increment and scan memory + JSR LAB_GFPN ; get fixed-point number into temp integer (skip this n) + ; (we could LDX #',' and JSR LAB_SNBL+2, then we + ; just BNE LAB_176B for the loop. should be quicker .. + ; no we can't, what if we meet a colon or [EOL]?) + CMP #$2C ; compare next character with "," + BEQ LAB_176B ; loop if "," + +LAB_177E + PLA ; else pull keyword token (run out of options) + ; also dump +/-1 pointer low byte and exit +LAB_177F + RTS + +; takes n * 106 + 11 cycles where n is the number of digits + +; get fixed-point number into temp integer + +LAB_GFPN + LDX #$00 ; clear reg + STX Itempl ; clear temporary integer low byte +LAB_1785 + STX Itemph ; save temporary integer high byte + BCS LAB_177F ; return if carry set, end of scan, character was + ; not 0-9 + + CPX #$19 ; compare high byte with $19 + TAY ; ensure Zb = 0 if the branch is taken + BCS LAB_1767 ; branch if >=, makes max line # 63999 because next + ; bit does *$0A, = 64000, compare at target will fail + ; and do syntax error + + SBC #'0'-1 ; subtract "0", $2F + carry, from byte + TAY ; copy binary digit + LDA Itempl ; get temporary integer low byte + ASL ; *2 low byte + ROL Itemph ; *2 high byte + ASL ; *2 low byte + ROL Itemph ; *2 high byte, *4 + ADC Itempl ; + low byte, *5 + STA Itempl ; save it + TXA ; get high byte copy to A + ADC Itemph ; + high byte, *5 + ASL Itempl ; *2 low byte, *10d + ROL ; *2 high byte, *10d + TAX ; copy high byte back to X + TYA ; get binary digit back + ADC Itempl ; add number low byte + STA Itempl ; save number low byte + BCC LAB_17B3 ; if no overflow to high byte get next character + + INX ; else increment high byte +LAB_17B3 + JSR LAB_IGBY ; increment and scan memory + JMP LAB_1785 ; loop for next character + +; perform DEC + +LAB_DEC + LDA #LAB_259C ; set +/-1 pointer high byte (both the same) + JSR LAB_246C ; add (AY) to FAC1 + JSR LAB_PFAC ; pack FAC1 into variable (Lvarpl) + + JSR LAB_GBYT ; scan memory + CMP #',' ; compare with "," + BNE LAB_177E ; exit if not "," (either end or error) + + ; was "," so another INCR variable to do + JSR LAB_IGBY ; increment and scan memory + JMP LAB_17B7 ; go do next var + +IncrErr + JMP LAB_1ABC ; do "Type mismatch" error then warm start + +; perform LET + +LAB_LET + JSR LAB_GVAR ; get var address + STA Lvarpl ; save var address low byte + STY Lvarph ; save var address high byte + LDA #TK_EQUAL ; get = token + JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start + LDA Dtypef ; get data type flag, $FF=string, $00=numeric + PHA ; push data type flag + JSR LAB_EVEX ; evaluate expression + PLA ; pop data type flag + ROL ; set carry if type = string + JSR LAB_CKTM ; type match check, set C for string + BNE LAB_17D5 ; branch if string + + JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return + +; string LET + +LAB_17D5 + LDY #$02 ; set index to pointer high byte + LDA (des_pl),Y ; get string pointer high byte + CMP Sstorh ; compare bottom of string space high byte + BCC LAB_17F4 ; if less assign value and exit (was in program memory) + + BNE LAB_17E6 ; branch if > + ; else was equal so compare low bytes + DEY ; decrement index + LDA (des_pl),Y ; get pointer low byte + CMP Sstorl ; compare bottom of string space low byte + BCC LAB_17F4 ; if less assign value and exit (was in program memory) + + ; pointer was >= to bottom of string space pointer +LAB_17E6 + LDY des_ph ; get descriptor pointer high byte + CPY Svarh ; compare start of vars high byte + BCC LAB_17F4 ; branch if less (descriptor is on stack) + + BNE LAB_17FB ; branch if greater (descriptor is not on stack) + + ; else high bytes were equal so .. + LDA des_pl ; get descriptor pointer low byte + CMP Svarl ; compare start of vars low byte + BCS LAB_17FB ; branch if >= (descriptor is not on stack) + +LAB_17F4 + LDA des_pl ; get descriptor pointer low byte + LDY des_ph ; get descriptor pointer high byte + JMP LAB_1811 ; clean stack, copy descriptor to variable and return + + ; make space and copy string +LAB_17FB + LDY #$00 ; index to length + LDA (des_pl),Y ; get string length + JSR LAB_209C ; copy string + LDA des_2l ; get descriptor pointer low byte + LDY des_2h ; get descriptor pointer high byte + STA ssptr_l ; save descriptor pointer low byte + STY ssptr_h ; save descriptor pointer high byte + JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill) + LDA #FAC1_e ; get descriptor pointer high byte + + ; clean stack and assign value to string variable +LAB_1811 + STA des_2l ; save descriptor_2 pointer low byte + STY des_2h ; save descriptor_2 pointer high byte + JSR LAB_22EB ; clean descriptor stack, YA = pointer + LDY #$00 ; index to length + LDA (des_2l),Y ; get string length + STA (Lvarpl),Y ; copy to let string variable + INY ; index to string pointer low byte + LDA (des_2l),Y ; get string pointer low byte + STA (Lvarpl),Y ; copy to let string variable + INY ; index to string pointer high byte + LDA (des_2l),Y ; get string pointer high byte + STA (Lvarpl),Y ; copy to let string variable + RTS + +; perform GET + +LAB_GET + JSR LAB_GVAR ; get var address + STA Lvarpl ; save var address low byte + STY Lvarph ; save var address high byte + JSR INGET ; get input byte + LDX Dtypef ; get data type flag, $FF=string, $00=numeric + BMI LAB_GETS ; go get string character + + ; was numeric get + TAY ; copy character to Y + JSR LAB_1FD0 ; convert Y to byte in FAC1 + JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return + +LAB_GETS + PHA ; save character + LDA #$01 ; string is single byte + BCS LAB_IsByte ; branch if byte received + + PLA ; string is null +LAB_IsByte + JSR LAB_MSSP ; make string space A bytes long A=$AC=length, + ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte + BEQ LAB_NoSt ; skip store if null string + + PLA ; get character back + LDY #$00 ; clear index + STA (str_pl),Y ; save byte in string (byte IS string!) +LAB_NoSt + JSR LAB_RTST ; check for space on descriptor stack then put address + ; and length on descriptor stack and update stack pointers + + JMP LAB_17D5 ; do string LET and return + +; perform PRINT + +LAB_1829 + JSR LAB_18C6 ; print string from Sutill/Sutilh +LAB_182C + JSR LAB_GBYT ; scan memory + +; PRINT + +LAB_PRINT + BEQ LAB_CRLF ; if nothing following just print CR/LF + +LAB_1831 + CMP #TK_TAB ; compare with TAB( token + BEQ LAB_18A2 ; go do TAB/SPC + + CMP #TK_SPC ; compare with SPC( token + BEQ LAB_18A2 ; go do TAB/SPC + + CMP #',' ; compare with "," + BEQ LAB_188B ; go do move to next TAB mark + + CMP #';' ; compare with ";" + BEQ LAB_18BD ; if ";" continue with PRINT processing + + JSR LAB_EVEX ; evaluate expression + BIT Dtypef ; test data type flag, $FF=string, $00=numeric + BMI LAB_1829 ; branch if string + + JSR LAB_296E ; convert FAC1 to string + JSR LAB_20AE ; print " terminated string to Sutill/Sutilh + LDY #$00 ; clear index + +; don't check fit if terminal width byte is zero + + LDA TWidth ; get terminal width byte + BEQ LAB_185E ; skip check if zero + + SEC ; set carry for subtract + SBC TPos ; subtract terminal position + SBC (des_pl),Y ; subtract string length + BCS LAB_185E ; branch if less than terminal width + + JSR LAB_CRLF ; else print CR/LF +LAB_185E + JSR LAB_18C6 ; print string from Sutill/Sutilh + BEQ LAB_182C ; always go continue processing line + +; CR/LF return to BASIC from BASIC input handler + +LAB_1866 + LDA #$00 ; clear byte + STA Ibuffs,X ; null terminate input + LDX #Ibuffs ; set Y to buffer start-1 high byte + +; print CR/LF + +LAB_CRLF + LDA #$0D ; load [CR] + JSR LAB_PRNA ; go print the character + LDA #$0A ; load [LF] + BNE LAB_PRNA ; go print the character and return, branch always + +LAB_188B + LDA TPos ; get terminal position + CMP Iclim ; compare with input column limit + BCC LAB_1897 ; branch if less + + JSR LAB_CRLF ; else print CR/LF (next line) + BNE LAB_18BD ; continue with PRINT processing (branch always) + +LAB_1897 + SEC ; set carry for subtract +LAB_1898 + SBC TabSiz ; subtract TAB size + BCS LAB_1898 ; loop if result was +ve + + EOR #$FF ; complement it + ADC #$01 ; +1 (twos complement) + BNE LAB_18B6 ; always print A spaces (result is never $00) + + ; do TAB/SPC +LAB_18A2 + PHA ; save token + JSR LAB_SGBY ; scan and get byte parameter + CMP #$29 ; is next character ) + BNE LAB_1910 ; if not do syntax error then warm start + + PLA ; get token back + CMP #TK_TAB ; was it TAB ? + BNE LAB_18B7 ; if not go do SPC + + ; calculate TAB offset + TXA ; copy integer value to A + SBC TPos ; subtract terminal position + BCC LAB_18BD ; branch if result was < 0 (can't TAB backwards) + + ; print A spaces +LAB_18B6 + TAX ; copy result to X +LAB_18B7 + TXA ; set flags on size for SPC + BEQ LAB_18BD ; branch if result was = $0, already here + + ; print X spaces +LAB_18BA + JSR LAB_18E0 ; print " " + DEX ; decrement count + BNE LAB_18BA ; loop if not all done + + ; continue with PRINT processing +LAB_18BD + JSR LAB_IGBY ; increment and scan memory + BNE LAB_1831 ; if more to print go do it + + RTS + +; print null terminated string from memory + +LAB_18C3 + JSR LAB_20AE ; print " terminated string to Sutill/Sutilh + +; print string from Sutill/Sutilh + +LAB_18C6 + JSR LAB_22B6 ; pop string off descriptor stack, or from top of string + ; space returns with A = length, X=$71=pointer low byte, + ; Y=$72=pointer high byte + LDY #$00 ; reset index + TAX ; copy length to X + BEQ LAB_188C ; exit (RTS) if null string + +LAB_18CD + + LDA (ut1_pl),Y ; get next byte + JSR LAB_PRNA ; go print the character + INY ; increment index + DEX ; decrement count + BNE LAB_18CD ; loop if not done yet + + RTS + + ; Print single format character +; print " " + +LAB_18E0 + LDA #$20 ; load " " + .byte $2C ; change next line to BIT LAB_3FA9 + +; print "?" character + +LAB_18E3 + LDA #$3F ; load "?" character + +; print character in A +; now includes the null handler +; also includes infinite line length code +; note! some routines expect this one to exit with Zb=0 + +LAB_PRNA + CMP #' ' ; compare with " " + BCC LAB_18F9 ; branch if less (non printing) + + ; else printable character + PHA ; save the character + +; don't check fit if terminal width byte is zero + + LDA TWidth ; get terminal width + BNE LAB_18F0 ; branch if not zero (not infinite length) + +; is "infinite line" so check TAB position + + LDA TPos ; get position + SBC TabSiz ; subtract TAB size, carry set by CMP #$20 above + BNE LAB_18F7 ; skip reset if different + + STA TPos ; else reset position + BEQ LAB_18F7 ; go print character + +LAB_18F0 + CMP TPos ; compare with terminal character position + BNE LAB_18F7 ; branch if not at end of line + + JSR LAB_CRLF ; else print CR/LF +LAB_18F7 + INC TPos ; increment terminal position + PLA ; get character back +LAB_18F9 + JSR V_OUTP ; output byte via output vector + CMP #$0D ; compare with [CR] + BNE LAB_188A ; branch if not [CR] + + ; else print nullct nulls after the [CR] + STX TempB ; save buffer index + LDX Nullct ; get null count + BEQ LAB_1886 ; branch if no nulls + + LDA #$00 ; load [NULL] +LAB_1880 + JSR LAB_PRNA ; go print the character + DEX ; decrement count + BNE LAB_1880 ; loop if not all done + + LDA #$0D ; restore the character (and set the flags) +LAB_1886 + STX TPos ; clear terminal position (X always = zero when we get here) + LDX TempB ; restore buffer index +LAB_188A + AND #$FF ; set the flags +LAB_188C + RTS + +; handle bad input data + +LAB_1904 + LDA Imode ; get input mode flag, $00=INPUT, $00=READ + BPL LAB_1913 ; branch if INPUT (go do redo) + + LDA Dlinel ; get current DATA line low byte + LDY Dlineh ; get current DATA line high byte + STA Clinel ; save current line low byte + STY Clineh ; save current line high byte +LAB_1910 + JMP LAB_SNER ; do syntax error then warm start + + ; mode was INPUT +LAB_1913 + LDA #LAB_REDO ; point to redo message (high addr) + JSR LAB_18C3 ; print null terminated string from memory + LDA Cpntrl ; get continue pointer low byte + LDY Cpntrh ; get continue pointer high byte + STA Bpntrl ; save BASIC execute pointer low byte + STY Bpntrh ; save BASIC execute pointer high byte + RTS + +; perform INPUT + +LAB_INPUT + CMP #$22 ; compare next byte with open quote + BNE LAB_1934 ; branch if no prompt string + + JSR LAB_1BC1 ; print "..." string + LDA #$3B ; load A with ";" + JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start + JSR LAB_18C6 ; print string from Sutill/Sutilh + + ; done with prompt, now get data +LAB_1934 + JSR LAB_CKRN ; check not Direct, back here if ok + JSR LAB_INLN ; print "? " and get BASIC input + LDA #$00 ; set mode = INPUT + CMP Ibuffs ; test first byte in buffer + BNE LAB_1953 ; branch if not null input + + CLC ; was null input so clear carry to exit program + JMP LAB_1647 ; go do BREAK exit + +; perform READ + +LAB_READ + LDX Dptrl ; get DATA pointer low byte + LDY Dptrh ; get DATA pointer high byte + LDA #$80 ; set mode = READ + +LAB_1953 + STA Imode ; set input mode flag, $00=INPUT, $80=READ + STX Rdptrl ; save READ pointer low byte + STY Rdptrh ; save READ pointer high byte + + ; READ or INPUT next variable from list +LAB_195B + JSR LAB_GVAR ; get (var) address + STA Lvarpl ; save address low byte + STY Lvarph ; save address high byte + LDA Bpntrl ; get BASIC execute pointer low byte + LDY Bpntrh ; get BASIC execute pointer high byte + STA Itempl ; save as temporary integer low byte + STY Itemph ; save as temporary integer high byte + LDX Rdptrl ; get READ pointer low byte + LDY Rdptrh ; get READ pointer high byte + STX Bpntrl ; set BASIC execute pointer low byte + STY Bpntrh ; set BASIC execute pointer high byte + JSR LAB_GBYT ; scan memory + BNE LAB_1988 ; branch if not null + + ; pointer was to null entry + BIT Imode ; test input mode flag, $00=INPUT, $80=READ + BMI LAB_19DD ; branch if READ + + ; mode was INPUT + JSR LAB_18E3 ; print "?" character (double ? for extended input) + JSR LAB_INLN ; print "? " and get BASIC input + STX Bpntrl ; set BASIC execute pointer low byte + STY Bpntrh ; set BASIC execute pointer high byte +LAB_1985 + JSR LAB_GBYT ; scan memory +LAB_1988 + BIT Dtypef ; test data type flag, $FF=string, $00=numeric + BPL LAB_19B0 ; branch if numeric + + ; else get string + STA Srchc ; save search character + CMP #$22 ; was it " ? + BEQ LAB_1999 ; branch if so + + LDA #':' ; else search character is ":" + STA Srchc ; set new search character + LDA #',' ; other search character is "," + CLC ; clear carry for add +LAB_1999 + STA Asrch ; set second search character + LDA Bpntrl ; get BASIC execute pointer low byte + LDY Bpntrh ; get BASIC execute pointer high byte + + ADC #$00 ; c is =1 if we came via the BEQ LAB_1999, else =0 + BCC LAB_19A4 ; branch if no execute pointer low byte rollover + + INY ; else increment high byte +LAB_19A4 + JSR LAB_20B4 ; print Srchc or Asrch terminated string to Sutill/Sutilh + JSR LAB_23F3 ; restore BASIC execute pointer from temp (Btmpl/Btmph) + JSR LAB_17D5 ; go do string LET + JMP LAB_19B6 ; go check string terminator + + ; get numeric INPUT +LAB_19B0 + JSR LAB_2887 ; get FAC1 from string + JSR LAB_PFAC ; pack FAC1 into (Lvarpl) +LAB_19B6 + JSR LAB_GBYT ; scan memory + BEQ LAB_19C5 ; branch if null (last entry) + + CMP #',' ; else compare with "," + BEQ LAB_19C2 ; branch if "," + + JMP LAB_1904 ; else go handle bad input data + + ; got good input data +LAB_19C2 + JSR LAB_IGBY ; increment and scan memory +LAB_19C5 + LDA Bpntrl ; get BASIC execute pointer low byte (temp READ/INPUT ptr) + LDY Bpntrh ; get BASIC execute pointer high byte (temp READ/INPUT ptr) + STA Rdptrl ; save for now + STY Rdptrh ; save for now + LDA Itempl ; get temporary integer low byte (temp BASIC execute ptr) + LDY Itemph ; get temporary integer high byte (temp BASIC execute ptr) + STA Bpntrl ; set BASIC execute pointer low byte + STY Bpntrh ; set BASIC execute pointer high byte + JSR LAB_GBYT ; scan memory + BEQ LAB_1A03 ; if null go do extra ignored message + + JSR LAB_1C01 ; else scan for "," , else do syntax error then warm start + JMP LAB_195B ; go INPUT next variable from list + + ; find next DATA statement or do "Out of DATA" error +LAB_19DD + JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL]) + INY ; increment index + TAX ; copy character ([:] or [EOL]) + BNE LAB_19F6 ; branch if [:] + + LDX #$06 ; set for "Out of DATA" error + INY ; increment index, now points to next line pointer high byte + LDA (Bpntrl),Y ; get next line pointer high byte + BEQ LAB_1A54 ; branch if end (eventually does error X) + + INY ; increment index + LDA (Bpntrl),Y ; get next line # low byte + STA Dlinel ; save current DATA line low byte + INY ; increment index + LDA (Bpntrl),Y ; get next line # high byte + INY ; increment index + STA Dlineh ; save current DATA line high byte +LAB_19F6 + LDA (Bpntrl),Y ; get byte + INY ; increment index + TAX ; copy to X + JSR LAB_170F ; set BASIC execute pointer + CPX #TK_DATA ; compare with "DATA" token + BEQ LAB_1985 ; was "DATA" so go do next READ + + BNE LAB_19DD ; go find next statement if not "DATA" + +; end of INPUT/READ routine + +LAB_1A03 + LDA Rdptrl ; get temp READ pointer low byte + LDY Rdptrh ; get temp READ pointer high byte + LDX Imode ; get input mode flag, $00=INPUT, $80=READ + BPL LAB_1A0E ; branch if INPUT + + JMP LAB_1624 ; save AY as DATA pointer and return + + ; we were getting INPUT +LAB_1A0E + LDY #$00 ; clear index + LDA (Rdptrl),Y ; get next byte + BNE LAB_1A1B ; error if not end of INPUT + + RTS + + ; user typed too much +LAB_1A1B + LDA #LAB_IMSG ; point to extra ignored message (high addr) + JMP LAB_18C3 ; print null terminated string from memory and return + +; search the stack for FOR activity +; exit with z=1 if FOR else exit with z=0 + +LAB_11A1 + TSX ; copy stack pointer + INX ; +1 pass return address + INX ; +2 pass return address + INX ; +3 pass calling routine return address + INX ; +4 pass calling routine return address +LAB_11A6 + LDA LAB_STAK+1,X ; get token byte from stack + CMP #TK_FOR ; is it FOR token + BNE LAB_11CE ; exit if not FOR token + + ; was FOR token + LDA Frnxth ; get var pointer for FOR/NEXT high byte + BNE LAB_11BB ; branch if not null + + LDA LAB_STAK+2,X ; get FOR variable pointer low byte + STA Frnxtl ; save var pointer for FOR/NEXT low byte + LDA LAB_STAK+3,X ; get FOR variable pointer high byte + STA Frnxth ; save var pointer for FOR/NEXT high byte +LAB_11BB + CMP LAB_STAK+3,X ; compare var pointer with stacked var pointer (high byte) + BNE LAB_11C7 ; branch if no match + + LDA Frnxtl ; get var pointer for FOR/NEXT low byte + CMP LAB_STAK+2,X ; compare var pointer with stacked var pointer (low byte) + BEQ LAB_11CE ; exit if match found + +LAB_11C7 + TXA ; copy index + CLC ; clear carry for add + ADC #$10 ; add FOR stack use size + TAX ; copy back to index + BNE LAB_11A6 ; loop if not at start of stack + +LAB_11CE + RTS + +; perform NEXT + +LAB_NEXT + BNE LAB_1A46 ; branch if NEXT var + + LDY #$00 ; else clear Y + BEQ LAB_1A49 ; branch always (no variable to search for) + +; NEXT var + +LAB_1A46 + JSR LAB_GVAR ; get variable address +LAB_1A49 + STA Frnxtl ; store variable pointer low byte + STY Frnxth ; store variable pointer high byte + ; (both cleared if no variable defined) + JSR LAB_11A1 ; search the stack for FOR activity + BEQ LAB_1A56 ; branch if found + + LDX #$00 ; else set error $00 ("NEXT without FOR" error) +LAB_1A54 + BEQ LAB_1ABE ; do error #X, then warm start + +LAB_1A56 + TXS ; set stack pointer, X set by search, dumps return addresses + + TXA ; copy stack pointer + SEC ; set carry for subtract + SBC #$F7 ; point to TO var + STA ut2_pl ; save pointer to TO var for compare + ADC #$FB ; point to STEP var + + LDY #>LAB_STAK ; point to stack page high byte + JSR LAB_UFAC ; unpack memory (STEP value) into FAC1 + TSX ; get stack pointer back + LDA LAB_STAK+8,X ; get step sign + STA FAC1_s ; save FAC1 sign (b7) + LDA Frnxtl ; get FOR variable pointer low byte + LDY Frnxth ; get FOR variable pointer high byte + JSR LAB_246C ; add (FOR variable) to FAC1 + JSR LAB_PFAC ; pack FAC1 into (FOR variable) + LDY #>LAB_STAK ; point to stack page high byte + JSR LAB_27FA ; compare FAC1 with (Y,ut2_pl) (TO value) + TSX ; get stack pointer back + CMP LAB_STAK+8,X ; compare step sign + BEQ LAB_1A9B ; branch if = (loop complete) + + ; loop back and do it all again + LDA LAB_STAK+$0D,X ; get FOR line low byte + STA Clinel ; save current line low byte + LDA LAB_STAK+$0E,X ; get FOR line high byte + STA Clineh ; save current line high byte + LDA LAB_STAK+$10,X ; get BASIC execute pointer low byte + STA Bpntrl ; save BASIC execute pointer low byte + LDA LAB_STAK+$0F,X ; get BASIC execute pointer high byte + STA Bpntrh ; save BASIC execute pointer high byte +LAB_1A98 + JMP LAB_15C2 ; go do interpreter inner loop + + ; loop complete so carry on +LAB_1A9B + TXA ; stack copy to A + ADC #$0F ; add $10 ($0F+carry) to dump FOR structure + TAX ; copy back to index + TXS ; copy to stack pointer + JSR LAB_GBYT ; scan memory + CMP #',' ; compare with "," + BNE LAB_1A98 ; branch if not "," (go do interpreter inner loop) + + ; was "," so another NEXT variable to do + JSR LAB_IGBY ; else increment and scan memory + JSR LAB_1A46 ; do NEXT (var) + +; evaluate expression and check is numeric, else do type mismatch + +LAB_EVNM + JSR LAB_EVEX ; evaluate expression + +; check if source is numeric, else do type mismatch + +LAB_CTNM + CLC ; destination is numeric + .byte $24 ; makes next line BIT $38 + +; check if source is string, else do type mismatch + +LAB_CTST + SEC ; required type is string + +; type match check, set C for string, clear C for numeric + +LAB_CKTM + BIT Dtypef ; test data type flag, $FF=string, $00=numeric + BMI LAB_1ABA ; branch if data type is string + + ; else data type was numeric + BCS LAB_1ABC ; if required type is string do type mismatch error +LAB_1AB9 + RTS + + ; data type was string, now check required type +LAB_1ABA + BCS LAB_1AB9 ; exit if required type is string + + ; else do type mismatch error +LAB_1ABC + LDX #$18 ; error code $18 ("Type mismatch" error) +LAB_1ABE + JMP LAB_XERR ; do error #X, then warm start + +; evaluate expression + +LAB_EVEX + LDX Bpntrl ; get BASIC execute pointer low byte + BNE LAB_1AC7 ; skip next if not zero + + DEC Bpntrh ; else decrement BASIC execute pointer high byte +LAB_1AC7 + DEC Bpntrl ; decrement BASIC execute pointer low byte + +LAB_EVEZ + LDA #$00 ; set null precedence (flag done) +LAB_1ACC + PHA ; push precedence byte + LDA #$02 ; 2 bytes + JSR LAB_1212 ; check room on stack for A bytes + JSR LAB_GVAL ; get value from line + LDA #$00 ; clear A + STA comp_f ; clear compare function flag +LAB_1ADB + JSR LAB_GBYT ; scan memory +LAB_1ADE + SEC ; set carry for subtract + SBC #TK_GT ; subtract token for > (lowest comparison function) + BCC LAB_1AFA ; branch if < TK_GT + + CMP #$03 ; compare with ">" to "<" tokens + BCS LAB_1AFA ; branch if >= TK_SGN (highest evaluation function +1) + + ; was token for > = or < (A = 0, 1 or 2) + CMP #$01 ; compare with token for = + ROL ; *2, b0 = carry (=1 if token was = or <) + ; (A = 0, 3 or 5) + EOR #$01 ; toggle b0 + ; (A = 1, 2 or 4. 1 if >, 2 if =, 4 if <) + EOR comp_f ; EOR with compare function flag bits + CMP comp_f ; compare with compare function flag + BCC LAB_1B53 ; if <(comp_f) do syntax error then warm start + ; was more than one <, = or >) + + STA comp_f ; save new compare function flag + JSR LAB_IGBY ; increment and scan memory + JMP LAB_1ADE ; go do next character + + ; token is < ">" or > "<" tokens +LAB_1AFA + LDX comp_f ; get compare function flag + BNE LAB_1B2A ; branch if compare function + + BCS LAB_1B78 ; go do functions + + ; else was < TK_GT so is operator or lower + ADC #TK_GT-TK_PLUS ; add # of operators (+, -, *, /, ^, AND, OR or EOR) + BCC LAB_1B78 ; branch if < + operator + + ; carry was set so token was +, -, *, /, ^, AND, OR or EOR + BNE LAB_1B0B ; branch if not + token + + BIT Dtypef ; test data type flag, $FF=string, $00=numeric + BPL LAB_1B0B ; branch if not string + + ; will only be $00 if type is string and token was + + JMP LAB_224D ; add strings, string 1 is in descriptor des_pl, string 2 + ; is in line, and return + +LAB_1B0B + STA ut1_pl ; save it + ASL ; *2 + ADC ut1_pl ; *3 + TAY ; copy to index +LAB_1B13 + PLA ; pull previous precedence + CMP LAB_OPPT,Y ; compare with precedence byte + BCS LAB_1B7D ; branch if A >= + + JSR LAB_CTNM ; check if source is numeric, else do type mismatch +LAB_1B1C + PHA ; save precedence +LAB_1B1D + JSR LAB_1B43 ; get vector, execute function then continue evaluation + PLA ; restore precedence + LDY prstk ; get precedence stacked flag + BPL LAB_1B3C ; branch if stacked values + + TAX ; copy precedence (set flags) + BEQ LAB_1B9D ; exit if done + + BNE LAB_1B86 ; else pop FAC2 and return, branch always + +LAB_1B2A + ROL Dtypef ; shift data type flag into Cb + TXA ; copy compare function flag + STA Dtypef ; clear data type flag, X is 0xxx xxxx + ROL ; shift data type into compare function byte b0 + LDX Bpntrl ; get BASIC execute pointer low byte + BNE LAB_1B34 ; branch if no underflow + + DEC Bpntrh ; else decrement BASIC execute pointer high byte +LAB_1B34 + DEC Bpntrl ; decrement BASIC execute pointer low byte +TK_LT_PLUS = TK_LT-TK_PLUS + LDY #TK_LT_PLUS*3 ; set offset to last operator entry + STA comp_f ; save new compare function flag + BNE LAB_1B13 ; branch always + +LAB_1B3C + CMP LAB_OPPT,Y ;.compare with stacked function precedence + BCS LAB_1B86 ; branch if A >=, pop FAC2 and return + + BCC LAB_1B1C ; branch always + +;.get vector, execute function then continue evaluation + +LAB_1B43 + LDA LAB_OPPT+2,Y ; get function vector high byte + PHA ; onto stack + LDA LAB_OPPT+1,Y ; get function vector low byte + PHA ; onto stack + ; now push sign, round FAC1 and put on stack + JSR LAB_1B5B ; function will return here, then the next RTS will call + ; the function + LDA comp_f ; get compare function flag + PHA ; push compare evaluation byte + LDA LAB_OPPT,Y ; get precedence byte + JMP LAB_1ACC ; continue evaluating expression + +LAB_1B53 + JMP LAB_SNER ; do syntax error then warm start + +; push sign, round FAC1 and put on stack + +LAB_1B5B + PLA ; get return addr low byte + STA ut1_pl ; save it + INC ut1_pl ; increment it (was ret-1 pushed? yes!) + ; note! no check is made on the high byte! if the calling + ; routine assembles to a page edge then this all goes + ; horribly wrong !!! + PLA ; get return addr high byte + STA ut1_ph ; save it + LDA FAC1_s ; get FAC1 sign (b7) + PHA ; push sign + +; round FAC1 and put on stack + +LAB_1B66 + JSR LAB_27BA ; round FAC1 + LDA FAC1_3 ; get FAC1 mantissa3 + PHA ; push on stack + LDA FAC1_2 ; get FAC1 mantissa2 + PHA ; push on stack + LDA FAC1_1 ; get FAC1 mantissa1 + PHA ; push on stack + LDA FAC1_e ; get FAC1 exponent + PHA ; push on stack + JMP (ut1_pl) ; return, sort of + +; do functions + +LAB_1B78 + LDY #$FF ; flag function + PLA ; pull precedence byte +LAB_1B7B + BEQ LAB_1B9D ; exit if done + +LAB_1B7D + CMP #$64 ; compare previous precedence with $64 + BEQ LAB_1B84 ; branch if was $64 (< function) + + JSR LAB_CTNM ; check if source is numeric, else do type mismatch +LAB_1B84 + STY prstk ; save precedence stacked flag + + ; pop FAC2 and return +LAB_1B86 + PLA ; pop byte + LSR ; shift out comparison evaluation lowest bit + STA Cflag ; save comparison evaluation flag + PLA ; pop exponent + STA FAC2_e ; save FAC2 exponent + PLA ; pop mantissa1 + STA FAC2_1 ; save FAC2 mantissa1 + PLA ; pop mantissa2 + STA FAC2_2 ; save FAC2 mantissa2 + PLA ; pop mantissa3 + STA FAC2_3 ; save FAC2 mantissa3 + PLA ; pop sign + STA FAC2_s ; save FAC2 sign (b7) + EOR FAC1_s ; EOR FAC1 sign (b7) + STA FAC_sc ; save sign compare (FAC1 EOR FAC2) +LAB_1B9D + LDA FAC1_e ; get FAC1 exponent + RTS + +; print "..." string to string util area + +LAB_1BC1 + LDA Bpntrl ; get BASIC execute pointer low byte + LDY Bpntrh ; get BASIC execute pointer high byte + ADC #$00 ; add carry to low byte + BCC LAB_1BCA ; branch if no overflow + + INY ; increment high byte +LAB_1BCA + JSR LAB_20AE ; print " terminated string to Sutill/Sutilh + JMP LAB_23F3 ; restore BASIC execute pointer from temp and return + +; get value from line + +LAB_GVAL + JSR LAB_IGBY ; increment and scan memory + BCS LAB_1BAC ; branch if not numeric character + + ; else numeric string found (e.g. 123) +LAB_1BA9 + JMP LAB_2887 ; get FAC1 from string and return + +; get value from line .. continued + + ; wasn't a number so .. +LAB_1BAC + TAX ; set the flags + BMI LAB_1BD0 ; if -ve go test token values + + ; else it is either a string, number, variable or () + CMP #'$' ; compare with "$" + BEQ LAB_1BA9 ; branch if "$", hex number + + CMP #'%' ; else compare with "%" + BEQ LAB_1BA9 ; branch if "%", binary number + + CMP #'.' ; compare with "." + BEQ LAB_1BA9 ; if so get FAC1 from string and return (e.g. was .123) + + ; it wasn't any sort of number so .. + CMP #$22 ; compare with " + BEQ LAB_1BC1 ; branch if open quote + + ; wasn't any sort of number so .. + +; evaluate expression within parentheses + + CMP #'(' ; compare with "(" + BNE LAB_1C18 ; if not "(" get (var), return value in FAC1 and $ flag + +LAB_1BF7 + JSR LAB_EVEZ ; evaluate expression, no decrement + +; all the 'scan for' routines return the character after the sought character + +; scan for ")" , else do syntax error then warm start + +LAB_1BFB + LDA #$29 ; load A with ")" + +; scan for CHR$(A) , else do syntax error then warm start + +LAB_SCCA + LDY #$00 ; clear index + CMP (Bpntrl),Y ; check next byte is = A + BNE LAB_SNER ; if not do syntax error then warm start + + JMP LAB_IGBY ; increment and scan memory then return + +; scan for "(" , else do syntax error then warm start + +LAB_1BFE + LDA #$28 ; load A with "(" + BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start + ; (branch always) + +; scan for "," , else do syntax error then warm start + +LAB_1C01 + LDA #$2C ; load A with "," + BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start + ; (branch always) + +; syntax error then warm start + +LAB_SNER + LDX #$02 ; error code $02 ("Syntax" error) + JMP LAB_XERR ; do error #X, then warm start + +; get value from line .. continued +; do tokens + +LAB_1BD0 + CMP #TK_MINUS ; compare with token for - + BEQ LAB_1C11 ; branch if - token (do set-up for functions) + + ; wasn't -n so .. + CMP #TK_PLUS ; compare with token for + + BEQ LAB_GVAL ; branch if + token (+n = n so ignore leading +) + + CMP #TK_NOT ; compare with token for NOT + BNE LAB_1BE7 ; branch if not token for NOT + + ; was NOT token +TK_EQUAL_PLUS = TK_EQUAL-TK_PLUS + LDY #TK_EQUAL_PLUS*3 ; offset to NOT function + BNE LAB_1C13 ; do set-up for function then execute (branch always) + +; do = compare + +LAB_EQUAL + JSR LAB_EVIR ; evaluate integer expression (no sign check) + LDA FAC1_3 ; get FAC1 mantissa3 + EOR #$FF ; invert it + TAY ; copy it + LDA FAC1_2 ; get FAC1 mantissa2 + EOR #$FF ; invert it + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; get value from line .. continued + + ; wasn't +, -, or NOT so .. +LAB_1BE7 + CMP #TK_FN ; compare with token for FN + BNE LAB_1BEE ; branch if not token for FN + + JMP LAB_201E ; go evaluate FNx + +; get value from line .. continued + + ; wasn't +, -, NOT or FN so .. +LAB_1BEE + SBC #TK_SGN ; subtract with token for SGN + BCS LAB_1C27 ; if a function token go do it + + JMP LAB_SNER ; else do syntax error + +; set-up for functions + +LAB_1C11 +TK_GT_PLUS = TK_GT-TK_PLUS + LDY #TK_GT_PLUS*3 ; set offset from base to > operator +LAB_1C13 + PLA ; dump return address low byte + PLA ; dump return address high byte + JMP LAB_1B1D ; execute function then continue evaluation + +; variable name set-up +; get (var), return value in FAC_1 and $ flag + +LAB_1C18 + JSR LAB_GVAR ; get (var) address + STA FAC1_2 ; save address low byte in FAC1 mantissa2 + STY FAC1_3 ; save address high byte in FAC1 mantissa3 + LDX Dtypef ; get data type flag, $FF=string, $00=numeric + BMI LAB_1C25 ; if string then return (does RTS) + +LAB_1C24 + JMP LAB_UFAC ; unpack memory (AY) into FAC1 + +LAB_1C25 + RTS + +; get value from line .. continued +; only functions left so .. + +; set up function references + +; new for V2.0+ this replaces a lot of IF .. THEN .. ELSEIF .. THEN .. that was needed +; to process function calls. now the function vector is computed and pushed on the stack +; and the preprocess offset is read. if the preprocess offset is non zero then the vector +; is calculated and the routine called, if not this routine just does RTS. whichever +; happens the RTS at the end of this routine, or the end of the preprocess routine, calls +; the function code + +; this also removes some less than elegant code that was used to bypass type checking +; for functions that returned strings + +LAB_1C27 + ASL ; *2 (2 bytes per function address) + TAY ; copy to index + + LDA LAB_FTBM,Y ; get function jump vector high byte + PHA ; push functions jump vector high byte + LDA LAB_FTBL,Y ; get function jump vector low byte + PHA ; push functions jump vector low byte + + LDA LAB_FTPM,Y ; get function pre process vector high byte + BEQ LAB_1C56 ; skip pre process if null vector + + PHA ; push functions pre process vector high byte + LDA LAB_FTPL,Y ; get function pre process vector low byte + PHA ; push functions pre process vector low byte + +LAB_1C56 + RTS ; do function, or pre process, call + +; process string expression in parenthesis + +LAB_PPFS + JSR LAB_1BF7 ; process expression in parenthesis + JMP LAB_CTST ; check if source is string then do function, + ; else do type mismatch + +; process numeric expression in parenthesis + +LAB_PPFN + JSR LAB_1BF7 ; process expression in parenthesis + JMP LAB_CTNM ; check if source is numeric then do function, + ; else do type mismatch + +; set numeric data type and increment BASIC execute pointer + +LAB_PPBI + LSR Dtypef ; clear data type flag, $FF=string, $00=numeric + JMP LAB_IGBY ; increment and scan memory then do function + +; process string for LEFT$, RIGHT$ or MID$ + +LAB_LRMS + JSR LAB_EVEZ ; evaluate (should be string) expression + JSR LAB_1C01 ; scan for ",", else do syntax error then warm start + JSR LAB_CTST ; check if source is string, else do type mismatch + + PLA ; get function jump vector low byte + TAX ; save functions jump vector low byte + PLA ; get function jump vector high byte + TAY ; save functions jump vector high byte + LDA des_ph ; get descriptor pointer high byte + PHA ; push string pointer high byte + LDA des_pl ; get descriptor pointer low byte + PHA ; push string pointer low byte + TYA ; get function jump vector high byte back + PHA ; save functions jump vector high byte + TXA ; get function jump vector low byte back + PHA ; save functions jump vector low byte + JSR LAB_GTBY ; get byte parameter + TXA ; copy byte parameter to A + RTS ; go do function + +; process numeric expression(s) for BIN$ or HEX$ + +LAB_BHSS + JSR LAB_EVEZ ; process expression + JSR LAB_CTNM ; check if source is numeric, else do type mismatch + LDA FAC1_e ; get FAC1 exponent + CMP #$98 ; compare with exponent = 2^24 + BCS LAB_BHER ; branch if n>=2^24 (is too big) + + JSR LAB_2831 ; convert FAC1 floating-to-fixed + LDX #$02 ; 3 bytes to do +LAB_CFAC + LDA FAC1_1,X ; get byte from FAC1 + STA nums_1,X ; save byte to temp + DEX ; decrement index + BPL LAB_CFAC ; copy FAC1 mantissa to temp + + JSR LAB_GBYT ; get next BASIC byte + LDX #$00 ; set default to no leading "0"s + CMP #')' ; compare with close bracket + BEQ LAB_1C54 ; if ")" go do rest of function + + JSR LAB_SCGB ; scan for "," and get byte + JSR LAB_GBYT ; get last byte back + CMP #')' ; is next character ) + BNE LAB_BHER ; if not ")" go do error + +LAB_1C54 + RTS ; else do function + +LAB_BHER + JMP LAB_FCER ; do function call error then warm start + +; perform EOR + +; added operator format is the same as AND or OR, precedence is the same as OR + +; this bit worked first time but it took a while to sort out the operator table +; pointers and offsets afterwards! + +LAB_EOR + JSR GetFirst ; get first integer expression (no sign check) + EOR XOAw_l ; EOR with expression 1 low byte + TAY ; save in Y + LDA FAC1_2 ; get FAC1 mantissa2 + EOR XOAw_h ; EOR with expression 1 high byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform OR + +LAB_OR + JSR GetFirst ; get first integer expression (no sign check) + ORA XOAw_l ; OR with expression 1 low byte + TAY ; save in Y + LDA FAC1_2 ; get FAC1 mantissa2 + ORA XOAw_h ; OR with expression 1 high byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform AND + +LAB_AND + JSR GetFirst ; get first integer expression (no sign check) + AND XOAw_l ; AND with expression 1 low byte + TAY ; save in Y + LDA FAC1_2 ; get FAC1 mantissa2 + AND XOAw_h ; AND with expression 1 high byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; get first value for OR, AND or EOR + +GetFirst + JSR LAB_EVIR ; evaluate integer expression (no sign check) + LDA FAC1_2 ; get FAC1 mantissa2 + STA XOAw_h ; save it + LDA FAC1_3 ; get FAC1 mantissa3 + STA XOAw_l ; save it + JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression) + JSR LAB_EVIR ; evaluate integer expression (no sign check) + LDA FAC1_3 ; get FAC1 mantissa3 +LAB_1C95 + RTS + +; perform comparisons + +; do < compare + +LAB_LTHAN + JSR LAB_CKTM ; type match check, set C for string + BCS LAB_1CAE ; branch if string + + ; do numeric < compare + LDA FAC2_s ; get FAC2 sign (b7) + ORA #$7F ; set all non sign bits + AND FAC2_1 ; and FAC2 mantissa1 (AND in sign bit) + STA FAC2_1 ; save FAC2 mantissa1 + LDA #FAC2_e ; set pointer high byte to FAC2 + JSR LAB_27F8 ; compare FAC1 with FAC2 (AY) + TAX ; copy result + JMP LAB_1CE1 ; go evaluate result + + ; do string < compare +LAB_1CAE + LSR Dtypef ; clear data type flag, $FF=string, $00=numeric + DEC comp_f ; clear < bit in compare function flag + JSR LAB_22B6 ; pop string off descriptor stack, or from top of string + ; space returns with A = length, X=pointer low byte, + ; Y=pointer high byte + STA str_ln ; save length + STX str_pl ; save string pointer low byte + STY str_ph ; save string pointer high byte + LDA FAC2_2 ; get descriptor pointer low byte + LDY FAC2_3 ; get descriptor pointer high byte + JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space + ; returns with A = length, X=pointer low byte, + ; Y=pointer high byte + STX FAC2_2 ; save string pointer low byte + STY FAC2_3 ; save string pointer high byte + TAX ; copy length + SEC ; set carry for subtract + SBC str_ln ; subtract string 1 length + BEQ LAB_1CD6 ; branch if str 1 length = string 2 length + + LDA #$01 ; set str 1 length > string 2 length + BCC LAB_1CD6 ; branch if so + + LDX str_ln ; get string 1 length + LDA #$FF ; set str 1 length < string 2 length +LAB_1CD6 + STA FAC1_s ; save length compare + LDY #$FF ; set index + INX ; adjust for loop +LAB_1CDB + INY ; increment index + DEX ; decrement count + BNE LAB_1CE6 ; branch if still bytes to do + + LDX FAC1_s ; get length compare back +LAB_1CE1 + BMI LAB_1CF2 ; branch if str 1 < str 2 + + CLC ; flag str 1 <= str 2 + BCC LAB_1CF2 ; go evaluate result + +LAB_1CE6 + LDA (FAC2_2),Y ; get string 2 byte + CMP (FAC1_1),Y ; compare with string 1 byte + BEQ LAB_1CDB ; loop if bytes = + + LDX #$FF ; set str 1 < string 2 + BCS LAB_1CF2 ; branch if so + + LDX #$01 ; set str 1 > string 2 +LAB_1CF2 + INX ; x = 0, 1 or 2 + TXA ; copy to A + ROL ; *2 (1, 2 or 4) + AND Cflag ; AND with comparison evaluation flag + BEQ LAB_1CFB ; branch if 0 (compare is false) + + LDA #$FF ; else set result true +LAB_1CFB + JMP LAB_27DB ; save A as integer byte and return + +LAB_1CFE + JSR LAB_1C01 ; scan for ",", else do syntax error then warm start + +; perform DIM + +LAB_DIM + TAX ; copy "DIM" flag to X + JSR LAB_1D10 ; search for variable + JSR LAB_GBYT ; scan memory + BNE LAB_1CFE ; scan for "," and loop if not null + + RTS + +; perform << (left shift) + +LAB_LSHIFT + JSR GetPair ; get integer expression and byte (no sign check) + LDA FAC1_2 ; get expression high byte + LDX TempB ; get shift count + BEQ NoShift ; branch if zero + + CPX #$10 ; compare bit count with 16d + BCS TooBig ; branch if >= + +Ls_loop + ASL FAC1_3 ; shift low byte + ROL ; shift high byte + DEX ; decrement bit count + BNE Ls_loop ; loop if shift not complete + + LDY FAC1_3 ; get expression low byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform >> (right shift) + +LAB_RSHIFT + JSR GetPair ; get integer expression and byte (no sign check) + LDA FAC1_2 ; get expression high byte + LDX TempB ; get shift count + BEQ NoShift ; branch if zero + + CPX #$10 ; compare bit count with 16d + BCS TooBig ; branch if >= + +Rs_loop + LSR ; shift high byte + ROR FAC1_3 ; shift low byte + DEX ; decrement bit count + BNE Rs_loop ; loop if shift not complete + +NoShift + LDY FAC1_3 ; get expression low byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +TooBig + LDA #$00 ; clear high byte + TAY ; copy to low byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +GetPair + JSR LAB_EVBY ; evaluate byte expression, result in X + STX TempB ; save it + JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression) + JMP LAB_EVIR ; evaluate integer expression (no sign check) + +; search for variable + +; return pointer to variable in Cvaral/Cvarah + +LAB_GVAR + LDX #$00 ; set DIM flag = $00 + JSR LAB_GBYT ; scan memory (1st character) +LAB_1D10 + STX Defdim ; save DIM flag +LAB_1D12 + STA Varnm1 ; save 1st character + AND #$7F ; clear FN flag bit + JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" + BCS LAB_1D1F ; branch if ok + + JMP LAB_SNER ; else syntax error then warm start + + ; was variable name so .. +LAB_1D1F + LDX #$00 ; clear 2nd character temp + STX Dtypef ; clear data type flag, $FF=string, $00=numeric + JSR LAB_IGBY ; increment and scan memory (2nd character) + BCC LAB_1D2D ; branch if character = "0"-"9" (ok) + + ; 2nd character wasn't "0" to "9" so .. + JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" + BCC LAB_1D38 ; branch if <"A" or >"Z" (go check if string) + +LAB_1D2D + TAX ; copy 2nd character + + ; ignore further (valid) characters in the variable name +LAB_1D2E + JSR LAB_IGBY ; increment and scan memory (3rd character) + BCC LAB_1D2E ; loop if character = "0"-"9" (ignore) + + JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z" + BCS LAB_1D2E ; loop if character = "A"-"Z" (ignore) + + ; check if string variable +LAB_1D38 + CMP #'$' ; compare with "$" + BNE LAB_1D47 ; branch if not string + +; to introduce a new variable type (% suffix for integers say) then this branch +; will need to go to that check and then that branch, if it fails, go to LAB_1D47 + + ; type is string + LDA #$FF ; set data type = string + STA Dtypef ; set data type flag, $FF=string, $00=numeric + TXA ; get 2nd character back + ORA #$80 ; set top bit (indicate string var) + TAX ; copy back to 2nd character temp + JSR LAB_IGBY ; increment and scan memory + +; after we have determined the variable type we need to come back here to determine +; if it's an array of type. this would plug in a%(b[,c[,d]])) integer arrays nicely + + +LAB_1D47 ; gets here with character after var name in A + STX Varnm2 ; save 2nd character + ORA Sufnxf ; or with subscript/FNX flag (or FN name) + CMP #'(' ; compare with "(" + BNE LAB_1D53 ; branch if not "(" + + JMP LAB_1E17 ; go find, or make, array + +; either find or create var +; var name (1st two characters only!) is in Varnm1,Varnm2 + + ; variable name wasn't var(... so look for plain var +LAB_1D53 + LDA #$00 ; clear A + STA Sufnxf ; clear subscript/FNX flag + LDA Svarl ; get start of vars low byte + LDX Svarh ; get start of vars high byte + LDY #$00 ; clear index +LAB_1D5D + STX Vrschh ; save search address high byte +LAB_1D5F + STA Vrschl ; save search address low byte + CPX Sarryh ; compare high address with var space end + BNE LAB_1D69 ; skip next compare if <> + + ; high addresses were = so compare low addresses + CMP Sarryl ; compare low address with var space end + BEQ LAB_1D8B ; if not found go make new var + +LAB_1D69 + LDA Varnm1 ; get 1st character of var to find + CMP (Vrschl),Y ; compare with variable name 1st character + BNE LAB_1D77 ; branch if no match + + ; 1st characters match so compare 2nd characters + LDA Varnm2 ; get 2nd character of var to find + INY ; index to point to variable name 2nd character + CMP (Vrschl),Y ; compare with variable name 2nd character + BEQ LAB_1DD7 ; branch if match (found var) + + DEY ; else decrement index (now = $00) +LAB_1D77 + CLC ; clear carry for add + LDA Vrschl ; get search address low byte + ADC #$06 ; +6 (offset to next var name) + BCC LAB_1D5F ; loop if no overflow to high byte + + INX ; else increment high byte + BNE LAB_1D5D ; loop always (RAM doesn't extend to $FFFF !) + +; check byte, return C=0 if<"A" or >"Z" or "a" to "z" + +LAB_CASC + CMP #'a' ; compare with "a" + BCS LAB_1D83 ; go check <"z"+1 + +; check byte, return C=0 if<"A" or >"Z" + +LAB_1D82 + CMP #'A' ; compare with "A" + BCC LAB_1D8A ; exit if less + + ; carry is set + SBC #$5B ; subtract "Z"+1 + SEC ; set carry + SBC #$A5 ; subtract $A5 (restore byte) + ; carry clear if byte>$5A +LAB_1D8A + RTS + +LAB_1D83 + SBC #$7B ; subtract "z"+1 + SEC ; set carry + SBC #$85 ; subtract $85 (restore byte) + ; carry clear if byte>$7A + RTS + + ; reached end of variable mem without match + ; .. so create new variable +LAB_1D8B + PLA ; pop return address low byte + PHA ; push return address low byte +LAB_1C18p2 = LAB_1C18+2 + CMP #LAB_1D96 ; high byte point to $00,$00 + RTS + + ; create new numeric variable +LAB_1D98 + LDA Sarryl ; get var mem end low byte + LDY Sarryh ; get var mem end high byte + STA Ostrtl ; save old block start low byte + STY Ostrth ; save old block start high byte + LDA Earryl ; get array mem end low byte + LDY Earryh ; get array mem end high byte + STA Obendl ; save old block end low byte + STY Obendh ; save old block end high byte + CLC ; clear carry for add + ADC #$06 ; +6 (space for one var) + BCC LAB_1DAE ; branch if no overflow to high byte + + INY ; else increment high byte +LAB_1DAE + STA Nbendl ; set new block end low byte + STY Nbendh ; set new block end high byte + JSR LAB_11CF ; open up space in memory + LDA Nbendl ; get new start low byte + LDY Nbendh ; get new start high byte (-$100) + INY ; correct high byte + STA Sarryl ; save new var mem end low byte + STY Sarryh ; save new var mem end high byte + LDY #$00 ; clear index + LDA Varnm1 ; get var name 1st character + STA (Vrschl),Y ; save var name 1st character + INY ; increment index + LDA Varnm2 ; get var name 2nd character + STA (Vrschl),Y ; save var name 2nd character + LDA #$00 ; clear A + INY ; increment index + STA (Vrschl),Y ; initialise var byte + INY ; increment index + STA (Vrschl),Y ; initialise var byte + INY ; increment index + STA (Vrschl),Y ; initialise var byte + INY ; increment index + STA (Vrschl),Y ; initialise var byte + + ; found a match for var ((Vrschl) = ptr) +LAB_1DD7 + LDA Vrschl ; get var address low byte + CLC ; clear carry for add + ADC #$02 ; +2 (offset past var name bytes) + LDY Vrschh ; get var address high byte + BCC LAB_1DE1 ; branch if no overflow from add + + INY ; else increment high byte +LAB_1DE1 + STA Cvaral ; save current var address low byte + STY Cvarah ; save current var address high byte + RTS + +; set-up array pointer (Adatal/h) to first element in array +; set Adatal,Adatah to Astrtl,Astrth+2*Dimcnt+#$05 + +LAB_1DE6 + LDA Dimcnt ; get # of dimensions (1, 2 or 3) + ASL ; *2 (also clears the carry !) + ADC #$05 ; +5 (result is 7, 9 or 11 here) + ADC Astrtl ; add array start pointer low byte + LDY Astrth ; get array pointer high byte + BCC LAB_1DF2 ; branch if no overflow + + INY ; else increment high byte +LAB_1DF2 + STA Adatal ; save array data pointer low byte + STY Adatah ; save array data pointer high byte + RTS + +; evaluate integer expression + +LAB_EVIN + JSR LAB_IGBY ; increment and scan memory + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + +; evaluate integer expression (no check) + +LAB_EVPI + LDA FAC1_s ; get FAC1 sign (b7) + BMI LAB_1E12 ; do function call error if -ve + +; evaluate integer expression (no sign check) + +LAB_EVIR + LDA FAC1_e ; get FAC1 exponent + CMP #$90 ; compare with exponent = 2^16 (n>2^15) + BCC LAB_1E14 ; branch if n<2^16 (is ok) + + LDA #LAB_1DF7 ; set pointer high byte to -32768 + JSR LAB_27F8 ; compare FAC1 with (AY) +LAB_1E12 + BNE LAB_FCER ; if <> do function call error then warm start + +LAB_1E14 + JMP LAB_2831 ; convert FAC1 floating-to-fixed and return + +; find or make array + +LAB_1E17 + LDA Defdim ; get DIM flag + PHA ; push it + LDA Dtypef ; get data type flag, $FF=string, $00=numeric + PHA ; push it + LDY #$00 ; clear dimensions count + +; now get the array dimension(s) and stack it (them) before the data type and DIM flag + +LAB_1E1F + TYA ; copy dimensions count + PHA ; save it + LDA Varnm2 ; get array name 2nd byte + PHA ; save it + LDA Varnm1 ; get array name 1st byte + PHA ; save it + JSR LAB_EVIN ; evaluate integer expression + PLA ; pull array name 1st byte + STA Varnm1 ; restore array name 1st byte + PLA ; pull array name 2nd byte + STA Varnm2 ; restore array name 2nd byte + PLA ; pull dimensions count + TAY ; restore it + TSX ; copy stack pointer + LDA LAB_STAK+2,X ; get DIM flag + PHA ; push it + LDA LAB_STAK+1,X ; get data type flag + PHA ; push it + LDA FAC1_2 ; get this dimension size high byte + STA LAB_STAK+2,X ; stack before flag bytes + LDA FAC1_3 ; get this dimension size low byte + STA LAB_STAK+1,X ; stack before flag bytes + INY ; increment dimensions count + JSR LAB_GBYT ; scan memory + CMP #',' ; compare with "," + BEQ LAB_1E1F ; if found go do next dimension + + STY Dimcnt ; store dimensions count + JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start + PLA ; pull data type flag + STA Dtypef ; restore data type flag, $FF=string, $00=numeric + PLA ; pull DIM flag + STA Defdim ; restore DIM flag + LDX Sarryl ; get array mem start low byte + LDA Sarryh ; get array mem start high byte + +; now check to see if we are at the end of array memory (we would be if there were +; no arrays). + +LAB_1E5C + STX Astrtl ; save as array start pointer low byte + STA Astrth ; save as array start pointer high byte + CMP Earryh ; compare with array mem end high byte + BNE LAB_1E68 ; branch if not reached array mem end + + CPX Earryl ; else compare with array mem end low byte + BEQ LAB_1EA1 ; go build array if not found + + ; search for array +LAB_1E68 + LDY #$00 ; clear index + LDA (Astrtl),Y ; get array name first byte + INY ; increment index to second name byte + CMP Varnm1 ; compare with this array name first byte + BNE LAB_1E77 ; branch if no match + + LDA Varnm2 ; else get this array name second byte + CMP (Astrtl),Y ; compare with array name second byte + BEQ LAB_1E8D ; array found so branch + + ; no match +LAB_1E77 + INY ; increment index + LDA (Astrtl),Y ; get array size low byte + CLC ; clear carry for add + ADC Astrtl ; add array start pointer low byte + TAX ; copy low byte to X + INY ; increment index + LDA (Astrtl),Y ; get array size high byte + ADC Astrth ; add array mem pointer high byte + BCC LAB_1E5C ; if no overflow go check next array + +; do array bounds error + +LAB_1E85 + LDX #$10 ; error code $10 ("Array bounds" error) + .byte $2C ; makes next bit BIT LAB_08A2 + +; do function call error + +LAB_FCER + LDX #$08 ; error code $08 ("Function call" error) +LAB_1E8A + JMP LAB_XERR ; do error #X, then warm start + + ; found array, are we trying to dimension it? +LAB_1E8D + LDX #$12 ; set error $12 ("Double dimension" error) + LDA Defdim ; get DIM flag + BNE LAB_1E8A ; if we are trying to dimension it do error #X, then warm + ; start + +; found the array and we're not dimensioning it so we must find an element in it + + JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array + ; (Astrtl,Astrth points to start of array) + LDA Dimcnt ; get dimensions count + LDY #$04 ; set index to array's # of dimensions + CMP (Astrtl),Y ; compare with no of dimensions + BNE LAB_1E85 ; if wrong do array bounds error, could do "Wrong + ; dimensions" error here .. if we want a different + ; error message + + JMP LAB_1F28 ; found array so go get element + ; (could jump to LAB_1F28 as all LAB_1F24 does is take + ; Dimcnt and save it at (Astrtl),Y which is already the + ; same or we would have taken the BNE) + + ; array not found, so build it +LAB_1EA1 + JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array + ; (Astrtl,Astrth points to start of array) + JSR LAB_121F ; check available memory, "Out of memory" error if no room + ; addr to check is in AY (low/high) + LDY #$00 ; clear Y (don't need to clear A) + STY Aspth ; clear array data size high byte + LDA Varnm1 ; get variable name 1st byte + STA (Astrtl),Y ; save array name 1st byte + INY ; increment index + LDA Varnm2 ; get variable name 2nd byte + STA (Astrtl),Y ; save array name 2nd byte + LDA Dimcnt ; get dimensions count + LDY #$04 ; index to dimension count + STY Asptl ; set array data size low byte (four bytes per element) + STA (Astrtl),Y ; set array's dimensions count + + ; now calculate the size of the data space for the array + CLC ; clear carry for add (clear on subsequent loops) +LAB_1EC0 + LDX #$0B ; set default dimension value low byte + LDA #$00 ; set default dimension value high byte + BIT Defdim ; test default DIM flag + BVC LAB_1ED0 ; branch if b6 of Defdim is clear + + PLA ; else pull dimension value low byte + ADC #$01 ; +1 (allow for zeroeth element) + TAX ; copy low byte to X + PLA ; pull dimension value high byte + ADC #$00 ; add carry from low byte + +LAB_1ED0 + INY ; index to dimension value high byte + STA (Astrtl),Y ; save dimension value high byte + INY ; index to dimension value high byte + TXA ; get dimension value low byte + STA (Astrtl),Y ; save dimension value low byte + JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl) + STX Asptl ; save array data size low byte + STA Aspth ; save array data size high byte + LDY ut1_pl ; restore index (saved by subroutine) + DEC Dimcnt ; decrement dimensions count + BNE LAB_1EC0 ; loop while not = 0 + + ADC Adatah ; add size high byte to first element high byte + ; (carry is always clear here) + BCS LAB_1F45 ; if overflow go do "Out of memory" error + + STA Adatah ; save end of array high byte + TAY ; copy end high byte to Y + TXA ; get array size low byte + ADC Adatal ; add array start low byte + BCC LAB_1EF3 ; branch if no carry + + INY ; else increment end of array high byte + BEQ LAB_1F45 ; if overflow go do "Out of memory" error + + ; set-up mostly complete, now zero the array +LAB_1EF3 + JSR LAB_121F ; check available memory, "Out of memory" error if no room + ; addr to check is in AY (low/high) + STA Earryl ; save array mem end low byte + STY Earryh ; save array mem end high byte + LDA #$00 ; clear byte for array clear + INC Aspth ; increment array size high byte (now block count) + LDY Asptl ; get array size low byte (now index to block) + BEQ LAB_1F07 ; branch if low byte = $00 + +LAB_1F02 + DEY ; decrement index (do 0 to n-1) + STA (Adatal),Y ; zero byte + BNE LAB_1F02 ; loop until this block done + +LAB_1F07 + DEC Adatah ; decrement array pointer high byte + DEC Aspth ; decrement block count high byte + BNE LAB_1F02 ; loop until all blocks done + + INC Adatah ; correct for last loop + SEC ; set carry for subtract + LDY #$02 ; index to array size low byte + LDA Earryl ; get array mem end low byte + SBC Astrtl ; subtract array start low byte + STA (Astrtl),Y ; save array size low byte + INY ; index to array size high byte + LDA Earryh ; get array mem end high byte + SBC Astrth ; subtract array start high byte + STA (Astrtl),Y ; save array size high byte + LDA Defdim ; get default DIM flag + BNE LAB_1F7B ; exit (RET) if this was a DIM command + + ; else, find element + INY ; index to # of dimensions + +LAB_1F24 + LDA (Astrtl),Y ; get array's dimension count + STA Dimcnt ; save it + +; we have found, or built, the array. now we need to find the element + +LAB_1F28 + LDA #$00 ; clear byte + STA Asptl ; clear array data pointer low byte +LAB_1F2C + STA Aspth ; save array data pointer high byte + INY ; increment index (point to array bound high byte) + PLA ; pull array index low byte + TAX ; copy to X + STA FAC1_2 ; save index low byte to FAC1 mantissa2 + PLA ; pull array index high byte + STA FAC1_3 ; save index high byte to FAC1 mantissa3 + CMP (Astrtl),Y ; compare with array bound high byte + BCC LAB_1F48 ; branch if within bounds + + BNE LAB_1F42 ; if outside bounds do array bounds error + + ; else high byte was = so test low bytes + INY ; index to array bound low byte + TXA ; get array index low byte + CMP (Astrtl),Y ; compare with array bound low byte + BCC LAB_1F49 ; branch if within bounds + +LAB_1F42 + JMP LAB_1E85 ; else do array bounds error + +LAB_1F45 + JMP LAB_OMER ; do "Out of memory" error then warm start + +LAB_1F48 + INY ; index to array bound low byte +LAB_1F49 + LDA Aspth ; get array data pointer high byte + ORA Asptl ; OR with array data pointer low byte + BEQ LAB_1F5A ; branch if array data pointer = null (skip multiply) + + JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl) + TXA ; get result low byte + ADC FAC1_2 ; add index low byte from FAC1 mantissa2 + TAX ; save result low byte + TYA ; get result high byte + LDY ut1_pl ; restore index +LAB_1F5A + ADC FAC1_3 ; add index high byte from FAC1 mantissa3 + STX Asptl ; save array data pointer low byte + DEC Dimcnt ; decrement dimensions count + BNE LAB_1F2C ; loop if dimensions still to do + + ASL Asptl ; array data pointer low byte * 2 + ROL ; array data pointer high byte * 2 + ASL Asptl ; array data pointer low byte * 4 + ROL ; array data pointer high byte * 4 + TAY ; copy high byte + LDA Asptl ; get low byte + ADC Adatal ; add array data start pointer low byte + STA Cvaral ; save as current var address low byte + TYA ; get high byte back + ADC Adatah ; add array data start pointer high byte + STA Cvarah ; save as current var address high byte + TAY ; copy high byte to Y + LDA Cvaral ; get current var address low byte +LAB_1F7B + RTS + +; does XY = (Astrtl),Y * (Asptl) + +LAB_1F7C + STY ut1_pl ; save index + LDA (Astrtl),Y ; get dimension size low byte + STA dims_l ; save dimension size low byte + DEY ; decrement index + LDA (Astrtl),Y ; get dimension size high byte + STA dims_h ; save dimension size high byte + + LDA #$10 ; count = $10 (16 bit multiply) + STA numbit ; save bit count + LDX #$00 ; clear result low byte + LDY #$00 ; clear result high byte +LAB_1F8F + TXA ; get result low byte + ASL ; *2 + TAX ; save result low byte + TYA ; get result high byte + ROL ; *2 + TAY ; save result high byte + BCS LAB_1F45 ; if overflow go do "Out of memory" error + + ASL Asptl ; shift multiplier low byte + ROL Aspth ; shift multiplier high byte + BCC LAB_1FA8 ; skip add if no carry + + CLC ; else clear carry for add + TXA ; get result low byte + ADC dims_l ; add dimension size low byte + TAX ; save result low byte + TYA ; get result high byte + ADC dims_h ; add dimension size high byte + TAY ; save result high byte + BCS LAB_1F45 ; if overflow go do "Out of memory" error + +LAB_1FA8 + DEC numbit ; decrement bit count + BNE LAB_1F8F ; loop until all done + + RTS + +; perform FRE() + +LAB_FRE + LDA Dtypef ; get data type flag, $FF=string, $00=numeric + BPL LAB_1FB4 ; branch if numeric + + JSR LAB_22B6 ; pop string off descriptor stack, or from top of string + ; space returns with A = length, X=$71=pointer low byte, + ; Y=$72=pointer high byte + + ; FRE(n) was numeric so do this +LAB_1FB4 + JSR LAB_GARB ; go do garbage collection + SEC ; set carry for subtract + LDA Sstorl ; get bottom of string space low byte + SBC Earryl ; subtract array mem end low byte + TAY ; copy result to Y + LDA Sstorh ; get bottom of string space high byte + SBC Earryh ; subtract array mem end high byte + +; save and convert integer AY to FAC1 + +LAB_AYFC + LSR Dtypef ; clear data type flag, $FF=string, $00=numeric + STA FAC1_1 ; save FAC1 mantissa1 + STY FAC1_2 ; save FAC1 mantissa2 + LDX #$90 ; set exponent=2^16 (integer) + JMP LAB_27E3 ; set exp=X, clear FAC1_3, normalise and return + +; perform POS() + +LAB_POS + LDY TPos ; get terminal position + +; convert Y to byte in FAC1 + +LAB_1FD0 + LDA #$00 ; clear high byte + BEQ LAB_AYFC ; always save and convert integer AY to FAC1 and return + +; check not Direct (used by DEF and INPUT) + +LAB_CKRN + LDX Clineh ; get current line high byte + INX ; increment it + BNE LAB_1F7B ; return if can continue not direct mode + + ; else do illegal direct error +LAB_1FD9 + LDX #$16 ; error code $16 ("Illegal direct" error) +LAB_1FDB + JMP LAB_XERR ; go do error #X, then warm start + +; perform DEF + +LAB_DEF + JSR LAB_200B ; check FNx syntax + STA func_l ; save function pointer low byte + STY func_h ; save function pointer high byte + JSR LAB_CKRN ; check not Direct (back here if ok) + JSR LAB_1BFE ; scan for "(" , else do syntax error then warm start + LDA #$80 ; set flag for FNx + STA Sufnxf ; save subscript/FNx flag + JSR LAB_GVAR ; get (var) address + JSR LAB_CTNM ; check if source is numeric, else do type mismatch + JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start + LDA #TK_EQUAL ; get = token + JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start + LDA Cvarah ; get current var address high byte + PHA ; push it + LDA Cvaral ; get current var address low byte + PHA ; push it + LDA Bpntrh ; get BASIC execute pointer high byte + PHA ; push it + LDA Bpntrl ; get BASIC execute pointer low byte + PHA ; push it + JSR LAB_DATA ; go perform DATA + JMP LAB_207A ; put execute pointer and variable pointer into function + ; and return + +; check FNx syntax + +LAB_200B + LDA #TK_FN ; get FN" token + JSR LAB_SCCA ; scan for CHR$(A) , else do syntax error then warm start + ; return character after A + ORA #$80 ; set FN flag bit + STA Sufnxf ; save FN flag so array variable test fails + JSR LAB_1D12 ; search for FN variable + JMP LAB_CTNM ; check if source is numeric and return, else do type + ; mismatch + + ; Evaluate FNx +LAB_201E + JSR LAB_200B ; check FNx syntax + PHA ; push function pointer low byte + TYA ; copy function pointer high byte + PHA ; push function pointer high byte + JSR LAB_1BFE ; scan for "(", else do syntax error then warm start + JSR LAB_EVEX ; evaluate expression + JSR LAB_1BFB ; scan for ")", else do syntax error then warm start + JSR LAB_CTNM ; check if source is numeric, else do type mismatch + PLA ; pop function pointer high byte + STA func_h ; restore it + PLA ; pop function pointer low byte + STA func_l ; restore it + LDX #$20 ; error code $20 ("Undefined function" error) + LDY #$03 ; index to variable pointer high byte + LDA (func_l),Y ; get variable pointer high byte + BEQ LAB_1FDB ; if zero go do undefined function error + + STA Cvarah ; save variable address high byte + DEY ; index to variable address low byte + LDA (func_l),Y ; get variable address low byte + STA Cvaral ; save variable address low byte + TAX ; copy address low byte + + ; now stack the function variable value before use + INY ; index to mantissa_3 +LAB_2043 + LDA (Cvaral),Y ; get byte from variable + PHA ; stack it + DEY ; decrement index + BPL LAB_2043 ; loop until variable stacked + + LDY Cvarah ; get variable address high byte + JSR LAB_2778 ; pack FAC1 (function expression value) into (XY) + ; (function variable), return Y=0, always + LDA Bpntrh ; get BASIC execute pointer high byte + PHA ; push it + LDA Bpntrl ; get BASIC execute pointer low byte + PHA ; push it + LDA (func_l),Y ; get function execute pointer low byte + STA Bpntrl ; save as BASIC execute pointer low byte + INY ; index to high byte + LDA (func_l),Y ; get function execute pointer high byte + STA Bpntrh ; save as BASIC execute pointer high byte + LDA Cvarah ; get variable address high byte + PHA ; push it + LDA Cvaral ; get variable address low byte + PHA ; push it + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + PLA ; pull variable address low byte + STA func_l ; save variable address low byte + PLA ; pull variable address high byte + STA func_h ; save variable address high byte + JSR LAB_GBYT ; scan memory + BEQ LAB_2074 ; branch if null (should be [EOL] marker) + + JMP LAB_SNER ; else syntax error then warm start + +; restore Bpntrl,Bpntrh and function variable from stack + +LAB_2074 + PLA ; pull BASIC execute pointer low byte + STA Bpntrl ; restore BASIC execute pointer low byte + PLA ; pull BASIC execute pointer high byte + STA Bpntrh ; restore BASIC execute pointer high byte + +; put execute pointer and variable pointer into function + +LAB_207A + LDY #$00 ; clear index + PLA ; pull BASIC execute pointer low byte + STA (func_l),Y ; save to function + INY ; increment index + PLA ; pull BASIC execute pointer high byte + STA (func_l),Y ; save to function + INY ; increment index + PLA ; pull current var address low byte + STA (func_l),Y ; save to function + INY ; increment index + PLA ; pull current var address high byte + STA (func_l),Y ; save to function + RTS + +; perform STR$() + +LAB_STRS + JSR LAB_CTNM ; check if source is numeric, else do type mismatch + JSR LAB_296E ; convert FAC1 to string + LDA #Decssp1 ; set result string high pointer + BEQ LAB_20AE ; print null terminated string to Sutill/Sutilh + +; Do string vector +; copy des_pl/h to des_2l/h and make string space A bytes long + +LAB_209C + LDX des_pl ; get descriptor pointer low byte + LDY des_ph ; get descriptor pointer high byte + STX des_2l ; save descriptor pointer low byte + STY des_2h ; save descriptor pointer high byte + +; make string space A bytes long +; A=length, X=Sutill=ptr low byte, Y=Sutilh=ptr high byte + +LAB_MSSP + JSR LAB_2115 ; make space in string memory for string A long + ; return X=Sutill=ptr low byte, Y=Sutilh=ptr high byte + STX str_pl ; save string pointer low byte + STY str_ph ; save string pointer high byte + STA str_ln ; save length + RTS + +; Scan, set up string +; print " terminated string to Sutill/Sutilh + +LAB_20AE + LDX #$22 ; set terminator to " + STX Srchc ; set search character (terminator 1) + STX Asrch ; set terminator 2 + +; print [Srchc] or [Asrch] terminated string to Sutill/Sutilh +; source is AY + +LAB_20B4 + STA ssptr_l ; store string start low byte + STY ssptr_h ; store string start high byte + STA str_pl ; save string pointer low byte + STY str_ph ; save string pointer high byte + LDY #$FF ; set length to -1 +LAB_20BE + INY ; increment length + LDA (ssptr_l),Y ; get byte from string + BEQ LAB_20CF ; exit loop if null byte [EOS] + + CMP Srchc ; compare with search character (terminator 1) + BEQ LAB_20CB ; branch if terminator + + CMP Asrch ; compare with terminator 2 + BNE LAB_20BE ; loop if not terminator 2 + +LAB_20CB + CMP #$22 ; compare with " + BEQ LAB_20D0 ; branch if " (carry set if = !) + +LAB_20CF + CLC ; clear carry for add (only if [EOL] terminated string) +LAB_20D0 + STY str_ln ; save length in FAC1 exponent + TYA ; copy length to A + ADC ssptr_l ; add string start low byte + STA Sendl ; save string end low byte + LDX ssptr_h ; get string start high byte + BCC LAB_20DC ; branch if no low byte overflow + + INX ; else increment high byte +LAB_20DC + STX Sendh ; save string end high byte + LDA ssptr_h ; get string start high byte + CMP #>Ram_base ; compare with start of program memory + BCS LAB_RTST ; branch if not in utility area + + ; string in utility area, move to string memory + TYA ; copy length to A + JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes + ; long + LDX ssptr_l ; get string start low byte + LDY ssptr_h ; get string start high byte + JSR LAB_2298 ; store string A bytes long from XY to (Sutill) + +; check for space on descriptor stack then .. +; put string address and length on descriptor stack and update stack pointers + +LAB_RTST + LDX next_s ; get string stack pointer + CPX #des_sk+$09 ; compare with max+1 + BNE LAB_20F8 ; branch if space on string stack + + ; else do string too complex error + LDX #$1C ; error code $1C ("String too complex" error) +LAB_20F5 + JMP LAB_XERR ; do error #X, then warm start + +; put string address and length on descriptor stack and update stack pointers + +LAB_20F8 + LDA str_ln ; get string length + STA PLUS_0,X ; put on string stack + LDA str_pl ; get string pointer low byte + STA PLUS_1,X ; put on string stack + LDA str_ph ; get string pointer high byte + STA PLUS_2,X ; put on string stack + LDY #$00 ; clear Y + STX des_pl ; save string descriptor pointer low byte + STY des_ph ; save string descriptor pointer high byte (always $00) + DEY ; Y = $FF + STY Dtypef ; save data type flag, $FF=string + STX last_sl ; save old stack pointer (current top item) + INX ; update stack pointer + INX ; update stack pointer + INX ; update stack pointer + STX next_s ; save new top item value + RTS + +; Build descriptor +; make space in string memory for string A long +; return X=Sutill=ptr low byte, Y=Sutill=ptr high byte + +LAB_2115 + LSR Gclctd ; clear garbage collected flag (b7) + + ; make space for string A long +LAB_2117 + PHA ; save string length + EOR #$FF ; complement it + SEC ; set carry for subtract (twos comp add) + ADC Sstorl ; add bottom of string space low byte (subtract length) + LDY Sstorh ; get bottom of string space high byte + BCS LAB_2122 ; skip decrement if no underflow + + DEY ; decrement bottom of string space high byte +LAB_2122 + CPY Earryh ; compare with array mem end high byte + BCC LAB_2137 ; do out of memory error if less + + BNE LAB_212C ; if not = skip next test + + CMP Earryl ; compare with array mem end low byte + BCC LAB_2137 ; do out of memory error if less + +LAB_212C + STA Sstorl ; save bottom of string space low byte + STY Sstorh ; save bottom of string space high byte + STA Sutill ; save string utility ptr low byte + STY Sutilh ; save string utility ptr high byte + TAX ; copy low byte to X + PLA ; get string length back + RTS + +LAB_2137 + LDX #$0C ; error code $0C ("Out of memory" error) + LDA Gclctd ; get garbage collected flag + BMI LAB_20F5 ; if set then do error code X + + JSR LAB_GARB ; else go do garbage collection + LDA #$80 ; flag for garbage collected + STA Gclctd ; set garbage collected flag + PLA ; pull length + BNE LAB_2117 ; go try again (loop always, length should never be = $00) + +; garbage collection routine + +LAB_GARB + LDX Ememl ; get end of mem low byte + LDA Ememh ; get end of mem high byte + +; re-run routine from last ending + +LAB_214B + STX Sstorl ; set string storage low byte + STA Sstorh ; set string storage high byte + LDY #$00 ; clear index + STY garb_h ; clear working pointer high byte (flag no strings to move) + LDA Earryl ; get array mem end low byte + LDX Earryh ; get array mem end high byte + STA Histrl ; save as highest string low byte + STX Histrh ; save as highest string high byte + LDA #des_sk ; set descriptor stack pointer + STA ut1_pl ; save descriptor stack pointer low byte + STY ut1_ph ; save descriptor stack pointer high byte ($00) +LAB_2161 + CMP next_s ; compare with descriptor stack pointer + BEQ LAB_216A ; branch if = + + JSR LAB_21D7 ; go garbage collect descriptor stack + BEQ LAB_2161 ; loop always + + ; done stacked strings, now do string vars +LAB_216A + ASL g_step ; set step size = $06 + LDA Svarl ; get start of vars low byte + LDX Svarh ; get start of vars high byte + STA ut1_pl ; save as pointer low byte + STX ut1_ph ; save as pointer high byte +LAB_2176 + CPX Sarryh ; compare start of arrays high byte + BNE LAB_217E ; branch if no high byte match + + CMP Sarryl ; else compare start of arrays low byte + BEQ LAB_2183 ; branch if = var mem end + +LAB_217E + JSR LAB_21D1 ; go garbage collect strings + BEQ LAB_2176 ; loop always + + ; done string vars, now do string arrays +LAB_2183 + STA Nbendl ; save start of arrays low byte as working pointer + STX Nbendh ; save start of arrays high byte as working pointer + LDA #$04 ; set step size + STA g_step ; save step size +LAB_218B + LDA Nbendl ; get pointer low byte + LDX Nbendh ; get pointer high byte +LAB_218F + CPX Earryh ; compare with array mem end high byte + BNE LAB_219A ; branch if not at end + + CMP Earryl ; else compare with array mem end low byte + BEQ LAB_2216 ; tidy up and exit if at end + +LAB_219A + STA ut1_pl ; save pointer low byte + STX ut1_ph ; save pointer high byte + LDY #$02 ; set index + LDA (ut1_pl),Y ; get array size low byte + ADC Nbendl ; add start of this array low byte + STA Nbendl ; save start of next array low byte + INY ; increment index + LDA (ut1_pl),Y ; get array size high byte + ADC Nbendh ; add start of this array high byte + STA Nbendh ; save start of next array high byte + LDY #$01 ; set index + LDA (ut1_pl),Y ; get name second byte + BPL LAB_218B ; skip if not string array + +; was string array so .. + + LDY #$04 ; set index + LDA (ut1_pl),Y ; get # of dimensions + ASL ; *2 + ADC #$05 ; +5 (array header size) + JSR LAB_2208 ; go set up for first element +LAB_21C4 + CPX Nbendh ; compare with start of next array high byte + BNE LAB_21CC ; branch if <> (go do this array) + + CMP Nbendl ; else compare element pointer low byte with next array + ; low byte + BEQ LAB_218F ; if equal then go do next array + +LAB_21CC + JSR LAB_21D7 ; go defrag array strings + BEQ LAB_21C4 ; go do next array string (loop always) + +; defrag string variables +; enter with XA = variable pointer +; return with XA = next variable pointer + +LAB_21D1 + INY ; increment index (Y was $00) + LDA (ut1_pl),Y ; get var name byte 2 + BPL LAB_2206 ; if not string, step pointer to next var and return + + INY ; else increment index +LAB_21D7 + LDA (ut1_pl),Y ; get string length + BEQ LAB_2206 ; if null, step pointer to next string and return + + INY ; else increment index + LDA (ut1_pl),Y ; get string pointer low byte + TAX ; copy to X + INY ; increment index + LDA (ut1_pl),Y ; get string pointer high byte + CMP Sstorh ; compare bottom of string space high byte + BCC LAB_21EC ; branch if less + + BNE LAB_2206 ; if greater, step pointer to next string and return + + ; high bytes were = so compare low bytes + CPX Sstorl ; compare bottom of string space low byte + BCS LAB_2206 ; if >=, step pointer to next string and return + + ; string pointer is < string storage pointer (pos in mem) +LAB_21EC + CMP Histrh ; compare to highest string high byte + BCC LAB_2207 ; if <, step pointer to next string and return + + BNE LAB_21F6 ; if > update pointers, step to next and return + + ; high bytes were = so compare low bytes + CPX Histrl ; compare to highest string low byte + BCC LAB_2207 ; if <, step pointer to next string and return + + ; string is in string memory space +LAB_21F6 + STX Histrl ; save as new highest string low byte + STA Histrh ; save as new highest string high byte + LDA ut1_pl ; get start of vars(descriptors) low byte + LDX ut1_ph ; get start of vars(descriptors) high byte + STA garb_l ; save as working pointer low byte + STX garb_h ; save as working pointer high byte + DEY ; decrement index DIFFERS + DEY ; decrement index (should point to descriptor start) + STY g_indx ; save index pointer + + ; step pointer to next string +LAB_2206 + CLC ; clear carry for add +LAB_2207 + LDA g_step ; get step size +LAB_2208 + ADC ut1_pl ; add pointer low byte + STA ut1_pl ; save pointer low byte + BCC LAB_2211 ; branch if no overflow + + INC ut1_ph ; else increment high byte +LAB_2211 + LDX ut1_ph ; get pointer high byte + LDY #$00 ; clear Y + RTS + +; search complete, now either exit or set-up and move string + +LAB_2216 + DEC g_step ; decrement step size (now $03 for descriptor stack) + LDX garb_h ; get string to move high byte + BEQ LAB_2211 ; exit if nothing to move + + LDY g_indx ; get index byte back (points to descriptor) + CLC ; clear carry for add + LDA (garb_l),Y ; get string length + ADC Histrl ; add highest string low byte + STA Obendl ; save old block end low pointer + LDA Histrh ; get highest string high byte + ADC #$00 ; add any carry + STA Obendh ; save old block end high byte + LDA Sstorl ; get bottom of string space low byte + LDX Sstorh ; get bottom of string space high byte + STA Nbendl ; save new block end low byte + STX Nbendh ; save new block end high byte + JSR LAB_11D6 ; open up space in memory, don't set array end + LDY g_indx ; get index byte + INY ; point to descriptor low byte + LDA Nbendl ; get string pointer low byte + STA (garb_l),Y ; save new string pointer low byte + TAX ; copy string pointer low byte + INC Nbendh ; correct high byte (move sets high byte -1) + LDA Nbendh ; get new string pointer high byte + INY ; point to descriptor high byte + STA (garb_l),Y ; save new string pointer high byte + JMP LAB_214B ; re-run routine from last ending + ; (but don't collect this string) + +; concatenate +; add strings, string 1 is in descriptor des_pl, string 2 is in line + +LAB_224D + LDA des_ph ; get descriptor pointer high byte + PHA ; put on stack + LDA des_pl ; get descriptor pointer low byte + PHA ; put on stack + JSR LAB_GVAL ; get value from line + JSR LAB_CTST ; check if source is string, else do type mismatch + PLA ; get descriptor pointer low byte back + STA ssptr_l ; set pointer low byte + PLA ; get descriptor pointer high byte back + STA ssptr_h ; set pointer high byte + LDY #$00 ; clear index + LDA (ssptr_l),Y ; get length_1 from descriptor + CLC ; clear carry for add + ADC (des_pl),Y ; add length_2 + BCC LAB_226D ; branch if no overflow + + LDX #$1A ; else set error code $1A ("String too long" error) + JMP LAB_XERR ; do error #X, then warm start + +LAB_226D + JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes + ; long + JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill) + LDA des_2l ; get descriptor pointer low byte + LDY des_2h ; get descriptor pointer high byte + JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space + ; returns with A = length, ut1_pl = pointer low byte, + ; ut1_ph = pointer high byte + JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill) + LDA ssptr_l ;.set descriptor pointer low byte + LDY ssptr_h ;.set descriptor pointer high byte + JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space + ; returns with A = length, X=ut1_pl=pointer low byte, + ; Y=ut1_ph=pointer high byte + JSR LAB_RTST ; check for space on descriptor stack then put string + ; address and length on descriptor stack and update stack + ; pointers + JMP LAB_1ADB ;.continue evaluation + +; copy string from descriptor (sdescr) to (Sutill) + +LAB_228A + LDY #$00 ; clear index + LDA (sdescr),Y ; get string length + PHA ; save on stack + INY ; increment index + LDA (sdescr),Y ; get source string pointer low byte + TAX ; copy to X + INY ; increment index + LDA (sdescr),Y ; get source string pointer high byte + TAY ; copy to Y + PLA ; get length back + +; store string A bytes long from YX to (Sutill) + +LAB_2298 + STX ut1_pl ; save source string pointer low byte + STY ut1_ph ; save source string pointer high byte + +; store string A bytes long from (ut1_pl) to (Sutill) + +LAB_229C + TAX ; copy length to index (don't count with Y) + BEQ LAB_22B2 ; branch if = $0 (null string) no need to add zero length + + LDY #$00 ; zero pointer (copy forward) +LAB_22A0 + LDA (ut1_pl),Y ; get source byte + STA (Sutill),Y ; save destination byte + + INY ; increment index + DEX ; decrement counter + BNE LAB_22A0 ; loop while <> 0 + + TYA ; restore length from Y +LAB_22A9 + CLC ; clear carry for add + ADC Sutill ; add string utility ptr low byte + STA Sutill ; save string utility ptr low byte + BCC LAB_22B2 ; branch if no carry + + INC Sutilh ; else increment string utility ptr high byte +LAB_22B2 + RTS + +; evaluate string + +LAB_EVST + JSR LAB_CTST ; check if source is string, else do type mismatch + +; pop string off descriptor stack, or from top of string space +; returns with A = length, X=pointer low byte, Y=pointer high byte + +LAB_22B6 + LDA des_pl ; get descriptor pointer low byte + LDY des_ph ; get descriptor pointer high byte + +; pop (YA) descriptor off stack or from top of string space +; returns with A = length, X=ut1_pl=pointer low byte, Y=ut1_ph=pointer high byte + +LAB_22BA + STA ut1_pl ; save descriptor pointer low byte + STY ut1_ph ; save descriptor pointer high byte + JSR LAB_22EB ; clean descriptor stack, YA = pointer + PHP ; save status flags + LDY #$00 ; clear index + LDA (ut1_pl),Y ; get length from string descriptor + PHA ; put on stack + INY ; increment index + LDA (ut1_pl),Y ; get string pointer low byte from descriptor + TAX ; copy to X + INY ; increment index + LDA (ut1_pl),Y ; get string pointer high byte from descriptor + TAY ; copy to Y + PLA ; get string length back + PLP ; restore status + BNE LAB_22E6 ; branch if pointer <> last_sl,last_sh + + CPY Sstorh ; compare bottom of string space high byte + BNE LAB_22E6 ; branch if <> + + CPX Sstorl ; else compare bottom of string space low byte + BNE LAB_22E6 ; branch if <> + + PHA ; save string length + CLC ; clear carry for add + ADC Sstorl ; add bottom of string space low byte + STA Sstorl ; save bottom of string space low byte + BCC LAB_22E5 ; skip increment if no overflow + + INC Sstorh ; increment bottom of string space high byte +LAB_22E5 + PLA ; restore string length +LAB_22E6 + STX ut1_pl ; save string pointer low byte + STY ut1_ph ; save string pointer high byte + RTS + +; clean descriptor stack, YA = pointer +; checks if AY is on the descriptor stack, if so does a stack discard + +LAB_22EB + CPY last_sh ; compare pointer high byte + BNE LAB_22FB ; exit if <> + + CMP last_sl ; compare pointer low byte + BNE LAB_22FB ; exit if <> + + STA next_s ; save descriptor stack pointer + SBC #$03 ; -3 + STA last_sl ; save low byte -3 + LDY #$00 ; clear high byte +LAB_22FB + RTS + +; perform CHR$() + +LAB_CHRS + JSR LAB_EVBY ; evaluate byte expression, result in X + TXA ; copy to A + PHA ; save character + LDA #$01 ; string is single byte + JSR LAB_MSSP ; make string space A bytes long A=$AC=length, + ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte + PLA ; get character back + LDY #$00 ; clear index + STA (str_pl),Y ; save byte in string (byte IS string!) + JMP LAB_RTST ; check for space on descriptor stack then put string + ; address and length on descriptor stack and update stack + ; pointers + +; perform LEFT$() + +LAB_LEFT + PHA ; push byte parameter + JSR LAB_236F ; pull string data and byte parameter from stack + ; return pointer in des_2l/h, byte in A (and X), Y=0 + CMP (des_2l),Y ; compare byte parameter with string length + TYA ; clear A + BEQ LAB_2316 ; go do string copy (branch always) + +; perform RIGHT$() + +LAB_RIGHT + PHA ; push byte parameter + JSR LAB_236F ; pull string data and byte parameter from stack + ; return pointer in des_2l/h, byte in A (and X), Y=0 + CLC ; clear carry for add-1 + SBC (des_2l),Y ; subtract string length + EOR #$FF ; invert it (A=LEN(expression$)-l) + +LAB_2316 + BCC LAB_231C ; branch if string length > byte parameter + + LDA (des_2l),Y ; else make parameter = length + TAX ; copy to byte parameter copy + TYA ; clear string start offset +LAB_231C + PHA ; save string start offset +LAB_231D + TXA ; copy byte parameter (or string length if <) +LAB_231E + PHA ; save string length + JSR LAB_MSSP ; make string space A bytes long A=$AC=length, + ; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte + LDA des_2l ; get descriptor pointer low byte + LDY des_2h ; get descriptor pointer high byte + JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space + ; returns with A = length, X=ut1_pl=pointer low byte, + ; Y=ut1_ph=pointer high byte + PLA ; get string length back + TAY ; copy length to Y + PLA ; get string start offset back + CLC ; clear carry for add + ADC ut1_pl ; add start offset to string start pointer low byte + STA ut1_pl ; save string start pointer low byte + BCC LAB_2335 ; branch if no overflow + + INC ut1_ph ; else increment string start pointer high byte +LAB_2335 + TYA ; copy length to A + JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill) + JMP LAB_RTST ; check for space on descriptor stack then put string + ; address and length on descriptor stack and update stack + ; pointers + +; perform MID$() + +LAB_MIDS + PHA ; push byte parameter + LDA #$FF ; set default length = 255 + STA mids_l ; save default length + JSR LAB_GBYT ; scan memory + CMP #')' ; compare with ")" + BEQ LAB_2358 ; branch if = ")" (skip second byte get) + + JSR LAB_1C01 ; scan for "," , else do syntax error then warm start + JSR LAB_GTBY ; get byte parameter (use copy in mids_l) +LAB_2358 + JSR LAB_236F ; pull string data and byte parameter from stack + ; return pointer in des_2l/h, byte in A (and X), Y=0 + DEX ; decrement start index + TXA ; copy to A + PHA ; save string start offset + CLC ; clear carry for sub-1 + LDX #$00 ; clear output string length + SBC (des_2l),Y ; subtract string length + BCS LAB_231D ; if start>string length go do null string + + EOR #$FF ; complement -length + CMP mids_l ; compare byte parameter + BCC LAB_231E ; if length>remaining string go do RIGHT$ + + LDA mids_l ; get length byte + BCS LAB_231E ; go do string copy (branch always) + +; pull string data and byte parameter from stack +; return pointer in des_2l/h, byte in A (and X), Y=0 + +LAB_236F + JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start + PLA ; pull return address low byte (return address) + STA Fnxjpl ; save functions jump vector low byte + PLA ; pull return address high byte (return address) + STA Fnxjph ; save functions jump vector high byte + PLA ; pull byte parameter + TAX ; copy byte parameter to X + PLA ; pull string pointer low byte + STA des_2l ; save it + PLA ; pull string pointer high byte + STA des_2h ; save it + LDY #$00 ; clear index + TXA ; copy byte parameter + BEQ LAB_23A8 ; if null do function call error then warm start + + INC Fnxjpl ; increment function jump vector low byte + ; (JSR pushes return addr-1. this is all very nice + ; but will go tits up if either call is on a page + ; boundary!) + JMP (Fnxjpl) ; in effect, RTS + +; perform LCASE$() + +LAB_LCASE + JSR LAB_EVST ; evaluate string + STA str_ln ; set string length + TAY ; copy length to Y + BEQ NoString ; branch if null string + + JSR LAB_MSSP ; make string space A bytes long A=length, + ; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte + STX str_pl ; save string pointer low byte + STY str_ph ; save string pointer high byte + TAY ; get string length back + +LC_loop + DEY ; decrement index + LDA (ut1_pl),Y ; get byte from string + JSR LAB_1D82 ; is character "A" to "Z" + BCC NoUcase ; branch if not upper case alpha + + ORA #$20 ; convert upper to lower case +NoUcase + STA (Sutill),Y ; save byte back to string + TYA ; test index + BNE LC_loop ; loop if not all done + + BEQ NoString ; tidy up and exit, branch always + +; perform UCASE$() + +LAB_UCASE + JSR LAB_EVST ; evaluate string + STA str_ln ; set string length + TAY ; copy length to Y + BEQ NoString ; branch if null string + + JSR LAB_MSSP ; make string space A bytes long A=length, + ; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte + STX str_pl ; save string pointer low byte + STY str_ph ; save string pointer high byte + TAY ; get string length back + +UC_loop + DEY ; decrement index + LDA (ut1_pl),Y ; get byte from string + JSR LAB_CASC ; is character "a" to "z" (or "A" to "Z") + BCC NoLcase ; branch if not alpha + + AND #$DF ; convert lower to upper case +NoLcase + STA (Sutill),Y ; save byte back to string + TYA ; test index + BNE UC_loop ; loop if not all done + +NoString + JMP LAB_RTST ; check for space on descriptor stack then put string + ; address and length on descriptor stack and update stack + ; pointers + +; perform SADD() + +LAB_SADD + JSR LAB_IGBY ; increment and scan memory + JSR LAB_GVAR ; get var address + + JSR LAB_1BFB ; scan for ")", else do syntax error then warm start + JSR LAB_CTST ; check if source is string, else do type mismatch + + LDY #$02 ; index to string pointer high byte + LDA (Cvaral),Y ; get string pointer high byte + TAX ; copy string pointer high byte to X + DEY ; index to string pointer low byte + LDA (Cvaral),Y ; get string pointer low byte + TAY ; copy string pointer low byte to Y + TXA ; copy string pointer high byte to A + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform LEN() + +LAB_LENS + JSR LAB_ESGL ; evaluate string, get length in A (and Y) + JMP LAB_1FD0 ; convert Y to byte in FAC1 and return + +; evaluate string, get length in Y + +LAB_ESGL + JSR LAB_EVST ; evaluate string + TAY ; copy length to Y + RTS + +; perform ASC() + +LAB_ASC + JSR LAB_ESGL ; evaluate string, get length in A (and Y) + BEQ LAB_23A8 ; if null do function call error then warm start + + LDY #$00 ; set index to first character + LDA (ut1_pl),Y ; get byte + TAY ; copy to Y + JMP LAB_1FD0 ; convert Y to byte in FAC1 and return + +; do function call error then warm start + +LAB_23A8 + JMP LAB_FCER ; do function call error then warm start + +; scan and get byte parameter + +LAB_SGBY + JSR LAB_IGBY ; increment and scan memory + +; get byte parameter + +LAB_GTBY + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + +; evaluate byte expression, result in X + +LAB_EVBY + JSR LAB_EVPI ; evaluate integer expression (no check) + + LDY FAC1_2 ; get FAC1 mantissa2 + BNE LAB_23A8 ; if top byte <> 0 do function call error then warm start + + LDX FAC1_3 ; get FAC1 mantissa3 + JMP LAB_GBYT ; scan memory and return + +; perform VAL() + +LAB_VAL + JSR LAB_ESGL ; evaluate string, get length in A (and Y) + BNE LAB_23C5 ; branch if not null string + + ; string was null so set result = $00 + JMP LAB_24F1 ; clear FAC1 exponent and sign and return + +LAB_23C5 + LDX Bpntrl ; get BASIC execute pointer low byte + LDY Bpntrh ; get BASIC execute pointer high byte + STX Btmpl ; save BASIC execute pointer low byte + STY Btmph ; save BASIC execute pointer high byte + LDX ut1_pl ; get string pointer low byte + STX Bpntrl ; save as BASIC execute pointer low byte + CLC ; clear carry + ADC ut1_pl ; add string length + STA ut2_pl ; save string end low byte + LDA ut1_ph ; get string pointer high byte + STA Bpntrh ; save as BASIC execute pointer high byte + ADC #$00 ; add carry to high byte + STA ut2_ph ; save string end high byte + LDY #$00 ; set index to $00 + LDA (ut2_pl),Y ; get string end +1 byte + PHA ; push it + TYA ; clear A + STA (ut2_pl),Y ; terminate string with $00 + JSR LAB_GBYT ; scan memory + JSR LAB_2887 ; get FAC1 from string + PLA ; restore string end +1 byte + LDY #$00 ; set index to zero + STA (ut2_pl),Y ; put string end byte back + +; restore BASIC execute pointer from temp (Btmpl/Btmph) + +LAB_23F3 + LDX Btmpl ; get BASIC execute pointer low byte back + LDY Btmph ; get BASIC execute pointer high byte back + STX Bpntrl ; save BASIC execute pointer low byte + STY Bpntrh ; save BASIC execute pointer high byte + RTS + +; get two parameters for POKE or WAIT + +LAB_GADB + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + JSR LAB_F2FX ; save integer part of FAC1 in temporary integer + +; scan for "," and get byte, else do Syntax error then warm start + +LAB_SCGB + JSR LAB_1C01 ; scan for "," , else do syntax error then warm start + LDA Itemph ; save temporary integer high byte + PHA ; on stack + LDA Itempl ; save temporary integer low byte + PHA ; on stack + JSR LAB_GTBY ; get byte parameter + PLA ; pull low byte + STA Itempl ; restore temporary integer low byte + PLA ; pull high byte + STA Itemph ; restore temporary integer high byte + RTS + +; convert float to fixed routine. accepts any value that fits in 24 bits, +ve or +; -ve and converts it into a right truncated integer in Itempl and Itemph + +; save unsigned 16 bit integer part of FAC1 in temporary integer + +LAB_F2FX + LDA FAC1_e ; get FAC1 exponent + CMP #$98 ; compare with exponent = 2^24 + BCS LAB_23A8 ; if >= do function call error then warm start + +LAB_F2FU + JSR LAB_2831 ; convert FAC1 floating-to-fixed + LDA FAC1_2 ; get FAC1 mantissa2 + LDY FAC1_3 ; get FAC1 mantissa3 + STY Itempl ; save temporary integer low byte + STA Itemph ; save temporary integer high byte + RTS + +; perform PEEK() + +LAB_PEEK + JSR LAB_F2FX ; save integer part of FAC1 in temporary integer + LDX #$00 ; clear index + LDA (Itempl,X) ; get byte via temporary integer (addr) + TAY ; copy byte to Y + JMP LAB_1FD0 ; convert Y to byte in FAC1 and return + +; perform POKE + +LAB_POKE + JSR LAB_GADB ; get two parameters for POKE or WAIT + TXA ; copy byte argument to A + LDX #$00 ; clear index + STA (Itempl,X) ; save byte via temporary integer (addr) + RTS + +; perform DEEK() + +LAB_DEEK + JSR LAB_F2FX ; save integer part of FAC1 in temporary integer + LDX #$00 ; clear index + LDA (Itempl,X) ; PEEK low byte + TAY ; copy to Y + INC Itempl ; increment pointer low byte + BNE Deekh ; skip high increment if no rollover + + INC Itemph ; increment pointer high byte +Deekh + LDA (Itempl,X) ; PEEK high byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform DOKE + +LAB_DOKE + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + JSR LAB_F2FX ; convert floating-to-fixed + + STY Frnxtl ; save pointer low byte (float to fixed returns word in AY) + STA Frnxth ; save pointer high byte + + JSR LAB_1C01 ; scan for "," , else do syntax error then warm start + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + JSR LAB_F2FX ; convert floating-to-fixed + + TYA ; copy value low byte (float to fixed returns word in AY) + LDX #$00 ; clear index + STA (Frnxtl,X) ; POKE low byte + INC Frnxtl ; increment pointer low byte + BNE Dokeh ; skip high increment if no rollover + + INC Frnxth ; increment pointer high byte +Dokeh + LDA Itemph ; get value high byte + STA (Frnxtl,X) ; POKE high byte + JMP LAB_GBYT ; scan memory and return + +; perform SWAP + +LAB_SWAP + JSR LAB_GVAR ; get var1 address + STA Lvarpl ; save var1 address low byte + STY Lvarph ; save var1 address high byte + LDA Dtypef ; get data type flag, $FF=string, $00=numeric + PHA ; save data type flag + + JSR LAB_1C01 ; scan for "," , else do syntax error then warm start + JSR LAB_GVAR ; get var2 address (pointer in Cvaral/h) + PLA ; pull var1 data type flag + EOR Dtypef ; compare with var2 data type + BPL SwapErr ; exit if not both the same type + + LDY #$03 ; four bytes to swap (either value or descriptor+1) +SwapLp + LDA (Lvarpl),Y ; get byte from var1 + TAX ; save var1 byte + LDA (Cvaral),Y ; get byte from var2 + STA (Lvarpl),Y ; save byte to var1 + TXA ; restore var1 byte + STA (Cvaral),Y ; save byte to var2 + DEY ; decrement index + BPL SwapLp ; loop until done + + RTS + +SwapErr + JMP LAB_1ABC ; do "Type mismatch" error then warm start + +; perform CALL + +LAB_CALL + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + JSR LAB_F2FX ; convert floating-to-fixed + LDA #>CallExit ; set return address high byte + PHA ; put on stack + LDA #8 shifts) + BCC LAB_24A8 ;.go subtract mantissas + +; add 0.5 to FAC1 + +LAB_244E + LDA #LAB_2A96 ; set 0.5 pointer high byte + +; add (AY) to FAC1 + +LAB_246C + JSR LAB_264D ; unpack memory (AY) into FAC2 + +; add FAC2 to FAC1 + +LAB_ADD + BNE LAB_2474 ; branch if FAC1 was not zero + +; copy FAC2 to FAC1 + +LAB_279B + LDA FAC2_s ; get FAC2 sign (b7) + +; save FAC1 sign and copy ABS(FAC2) to FAC1 + +LAB_279D + STA FAC1_s ; save FAC1 sign (b7) + LDX #$04 ; 4 bytes to copy +LAB_27A1 + LDA FAC1_o,X ; get byte from FAC2,X + STA FAC1_e-1,X ; save byte at FAC1,X + DEX ; decrement count + BNE LAB_27A1 ; loop if not all done + + STX FAC1_r ; clear FAC1 rounding byte + RTS + + ; FAC1 is non zero +LAB_2474 + LDX FAC1_r ; get FAC1 rounding byte + STX FAC2_r ; save as FAC2 rounding byte + LDX #FAC2_e ; set index to FAC2 exponent addr + LDA FAC2_e ; get FAC2 exponent +LAB_247C + TAY ; copy exponent + BEQ LAB_244D ; exit if zero + + SEC ; set carry for subtract + SBC FAC1_e ; subtract FAC1 exponent + BEQ LAB_24A8 ; branch if = (go add mantissa) + + BCC LAB_2498 ; branch if < + + ; FAC2>FAC1 + STY FAC1_e ; save FAC1 exponent + LDY FAC2_s ; get FAC2 sign (b7) + STY FAC1_s ; save FAC1 sign (b7) + EOR #$FF ; complement A + ADC #$00 ; +1 (twos complement, carry is set) + LDY #$00 ; clear Y + STY FAC2_r ; clear FAC2 rounding byte + LDX #FAC1_e ; set index to FAC1 exponent addr + BNE LAB_249C ; branch always + +LAB_2498 + LDY #$00 ; clear Y + STY FAC1_r ; clear FAC1 rounding byte +LAB_249C + CMP #$F9 ; compare exponent diff with $F9 + BMI LAB_2467 ; branch if range $79-$F8 + + TAY ; copy exponent difference to Y + LDA FAC1_r ; get FAC1 rounding byte + LSR PLUS_1,X ; shift FAC? mantissa1 + JSR LAB_2592 ; shift FACX Y times right + + ; exponents are equal now do mantissa subtract +LAB_24A8 + BIT FAC_sc ; test sign compare (FAC1 EOR FAC2) + BPL LAB_24F8 ; if = add FAC2 mantissa to FAC1 mantissa and return + + LDY #FAC1_e ; set index to FAC1 exponent addr + CPX #FAC2_e ; compare X to FAC2 exponent addr + BEQ LAB_24B4 ; branch if = + + LDY #FAC2_e ; else set index to FAC2 exponent addr + + ; subtract smaller from bigger (take sign of bigger) +LAB_24B4 + SEC ; set carry for subtract + EOR #$FF ; ones complement A + ADC FAC2_r ; add FAC2 rounding byte + STA FAC1_r ; save FAC1 rounding byte + LDA PLUS_3,Y ; get FACY mantissa3 + SBC PLUS_3,X ; subtract FACX mantissa3 + STA FAC1_3 ; save FAC1 mantissa3 + LDA PLUS_2,Y ; get FACY mantissa2 + SBC PLUS_2,X ; subtract FACX mantissa2 + STA FAC1_2 ; save FAC1 mantissa2 + LDA PLUS_1,Y ; get FACY mantissa1 + SBC PLUS_1,X ; subtract FACX mantissa1 + STA FAC1_1 ; save FAC1 mantissa1 + +; do ABS and normalise FAC1 + +LAB_24D0 + BCS LAB_24D5 ; branch if number is +ve + + JSR LAB_2537 ; negate FAC1 + +; normalise FAC1 + +LAB_24D5 + LDY #$00 ; clear Y + TYA ; clear A + CLC ; clear carry for add +LAB_24D9 + LDX FAC1_1 ; get FAC1 mantissa1 + BNE LAB_251B ; if not zero normalise FAC1 + + LDX FAC1_2 ; get FAC1 mantissa2 + STX FAC1_1 ; save FAC1 mantissa1 + LDX FAC1_3 ; get FAC1 mantissa3 + STX FAC1_2 ; save FAC1 mantissa2 + LDX FAC1_r ; get FAC1 rounding byte + STX FAC1_3 ; save FAC1 mantissa3 + STY FAC1_r ; clear FAC1 rounding byte + ADC #$08 ; add x to exponent offset + CMP #$18 ; compare with $18 (max offset, all bits would be =0) + BNE LAB_24D9 ; loop if not max + +; clear FAC1 exponent and sign + +LAB_24F1 + LDA #$00 ; clear A +LAB_24F3 + STA FAC1_e ; set FAC1 exponent + +; save FAC1 sign + +LAB_24F5 + STA FAC1_s ; save FAC1 sign (b7) + RTS + +; add FAC2 mantissa to FAC1 mantissa + +LAB_24F8 + ADC FAC2_r ; add FAC2 rounding byte + STA FAC1_r ; save FAC1 rounding byte + LDA FAC1_3 ; get FAC1 mantissa3 + ADC FAC2_3 ; add FAC2 mantissa3 + STA FAC1_3 ; save FAC1 mantissa3 + LDA FAC1_2 ; get FAC1 mantissa2 + ADC FAC2_2 ; add FAC2 mantissa2 + STA FAC1_2 ; save FAC1 mantissa2 + LDA FAC1_1 ; get FAC1 mantissa1 + ADC FAC2_1 ; add FAC2 mantissa1 + STA FAC1_1 ; save FAC1 mantissa1 + BCS LAB_252A ; if carry then normalise FAC1 for C=1 + + RTS ; else just exit + +LAB_2511 + ADC #$01 ; add 1 to exponent offset + ASL FAC1_r ; shift FAC1 rounding byte + ROL FAC1_3 ; shift FAC1 mantissa3 + ROL FAC1_2 ; shift FAC1 mantissa2 + ROL FAC1_1 ; shift FAC1 mantissa1 + +; normalise FAC1 + +LAB_251B + BPL LAB_2511 ; loop if not normalised + + SEC ; set carry for subtract + SBC FAC1_e ; subtract FAC1 exponent + BCS LAB_24F1 ; branch if underflow (set result = $0) + + EOR #$FF ; complement exponent + ADC #$01 ; +1 (twos complement) + STA FAC1_e ; save FAC1 exponent + +; test and normalise FAC1 for C=0/1 + +LAB_2528 + BCC LAB_2536 ; exit if no overflow + +; normalise FAC1 for C=1 + +LAB_252A + INC FAC1_e ; increment FAC1 exponent + BEQ LAB_2564 ; if zero do overflow error and warm start + + ROR FAC1_1 ; shift FAC1 mantissa1 + ROR FAC1_2 ; shift FAC1 mantissa2 + ROR FAC1_3 ; shift FAC1 mantissa3 + ROR FAC1_r ; shift FAC1 rounding byte +LAB_2536 + RTS + +; negate FAC1 + +LAB_2537 + LDA FAC1_s ; get FAC1 sign (b7) + EOR #$FF ; complement it + STA FAC1_s ; save FAC1 sign (b7) + +; twos complement FAC1 mantissa + +LAB_253D + LDA FAC1_1 ; get FAC1 mantissa1 + EOR #$FF ; complement it + STA FAC1_1 ; save FAC1 mantissa1 + LDA FAC1_2 ; get FAC1 mantissa2 + EOR #$FF ; complement it + STA FAC1_2 ; save FAC1 mantissa2 + LDA FAC1_3 ; get FAC1 mantissa3 + EOR #$FF ; complement it + STA FAC1_3 ; save FAC1 mantissa3 + LDA FAC1_r ; get FAC1 rounding byte + EOR #$FF ; complement it + STA FAC1_r ; save FAC1 rounding byte + INC FAC1_r ; increment FAC1 rounding byte + BNE LAB_2563 ; exit if no overflow + +; increment FAC1 mantissa + +LAB_2559 + INC FAC1_3 ; increment FAC1 mantissa3 + BNE LAB_2563 ; finished if no rollover + + INC FAC1_2 ; increment FAC1 mantissa2 + BNE LAB_2563 ; finished if no rollover + + INC FAC1_1 ; increment FAC1 mantissa1 +LAB_2563 + RTS + +; do overflow error (overflow exit) + +LAB_2564 + LDX #$0A ; error code $0A ("Overflow" error) + JMP LAB_XERR ; do error #X, then warm start + +; shift FCAtemp << A+8 times + +LAB_2569 + LDX #FACt_1-1 ; set offset to FACtemp +LAB_256B + LDY PLUS_3,X ; get FACX mantissa3 + STY FAC1_r ; save as FAC1 rounding byte + LDY PLUS_2,X ; get FACX mantissa2 + STY PLUS_3,X ; save FACX mantissa3 + LDY PLUS_1,X ; get FACX mantissa1 + STY PLUS_2,X ; save FACX mantissa2 + LDY FAC1_o ; get FAC1 overflow byte + STY PLUS_1,X ; save FACX mantissa1 + +; shift FACX -A times right (> 8 shifts) + +LAB_257B + ADC #$08 ; add 8 to shift count + BMI LAB_256B ; go do 8 shift if still -ve + + BEQ LAB_256B ; go do 8 shift if zero + + SBC #$08 ; else subtract 8 again + TAY ; save count to Y + LDA FAC1_r ; get FAC1 rounding byte + BCS LAB_259A ;. + +LAB_2588 + ASL PLUS_1,X ; shift FACX mantissa1 + BCC LAB_258E ; branch if +ve + + INC PLUS_1,X ; this sets b7 eventually +LAB_258E + ROR PLUS_1,X ; shift FACX mantissa1 (correct for ASL) + ROR PLUS_1,X ; shift FACX mantissa1 (put carry in b7) + +; shift FACX Y times right + +LAB_2592 + ROR PLUS_2,X ; shift FACX mantissa2 + ROR PLUS_3,X ; shift FACX mantissa3 + ROR ; shift FACX rounding byte + INY ; increment exponent diff + BNE LAB_2588 ; branch if range adjust not complete + +LAB_259A + CLC ; just clear it + RTS + +; perform LOG() + +LAB_LOG + JSR LAB_27CA ; test sign and zero + BEQ LAB_25C4 ; if zero do function call error then warm start + + BPL LAB_25C7 ; skip error if +ve + +LAB_25C4 + JMP LAB_FCER ; do function call error then warm start (-ve) + +LAB_25C7 + LDA FAC1_e ; get FAC1 exponent + SBC #$7F ; normalise it + PHA ; save it + LDA #$80 ; set exponent to zero + STA FAC1_e ; save FAC1 exponent + LDA #LAB_25AD ; set 1/root2 pointer high byte + JSR LAB_246C ; add (AY) to FAC1 (1/root2) + LDA #LAB_25B1 ; set root2 pointer high byte + JSR LAB_26CA ; convert AY and do (AY)/FAC1 (root2/(x+(1/root2))) + LDA #LAB_259C ; set 1 pointer high byte + JSR LAB_2455 ; subtract (AY) from FAC1 ((root2/(x+(1/root2)))-1) + LDA #LAB_25A0 ; set pointer high byte to counter + JSR LAB_2B6E ; ^2 then series evaluation + LDA #LAB_25B5 ; set -0.5 pointer high byte + JSR LAB_246C ; add (AY) to FAC1 + PLA ; restore FAC1 exponent + JSR LAB_2912 ; evaluate new ASCII digit + LDA #LAB_25B9 ; set LOG(2) pointer high byte + +; do convert AY, FCA1*(AY) + +LAB_25FB + JSR LAB_264D ; unpack memory (AY) into FAC2 +LAB_MULTIPLY + BEQ LAB_264C ; exit if zero + + JSR LAB_2673 ; test and adjust accumulators + LDA #$00 ; clear A + STA FACt_1 ; clear temp mantissa1 + STA FACt_2 ; clear temp mantissa2 + STA FACt_3 ; clear temp mantissa3 + LDA FAC1_r ; get FAC1 rounding byte + JSR LAB_2622 ; go do shift/add FAC2 + LDA FAC1_3 ; get FAC1 mantissa3 + JSR LAB_2622 ; go do shift/add FAC2 + LDA FAC1_2 ; get FAC1 mantissa2 + JSR LAB_2622 ; go do shift/add FAC2 + LDA FAC1_1 ; get FAC1 mantissa1 + JSR LAB_2627 ; go do shift/add FAC2 + JMP LAB_273C ; copy temp to FAC1, normalise and return + +LAB_2622 + BNE LAB_2627 ; branch if byte <> zero + + JMP LAB_2569 ; shift FCAtemp << A+8 times + + ; else do shift and add +LAB_2627 + LSR ; shift byte + ORA #$80 ; set top bit (mark for 8 times) +LAB_262A + TAY ; copy result + BCC LAB_2640 ; skip next if bit was zero + + CLC ; clear carry for add + LDA FACt_3 ; get temp mantissa3 + ADC FAC2_3 ; add FAC2 mantissa3 + STA FACt_3 ; save temp mantissa3 + LDA FACt_2 ; get temp mantissa2 + ADC FAC2_2 ; add FAC2 mantissa2 + STA FACt_2 ; save temp mantissa2 + LDA FACt_1 ; get temp mantissa1 + ADC FAC2_1 ; add FAC2 mantissa1 + STA FACt_1 ; save temp mantissa1 +LAB_2640 + ROR FACt_1 ; shift temp mantissa1 + ROR FACt_2 ; shift temp mantissa2 + ROR FACt_3 ; shift temp mantissa3 + ROR FAC1_r ; shift temp rounding byte + TYA ; get byte back + LSR ; shift byte + BNE LAB_262A ; loop if all bits not done + +LAB_264C + RTS + +; unpack memory (AY) into FAC2 + +LAB_264D + STA ut1_pl ; save pointer low byte + STY ut1_ph ; save pointer high byte + LDY #$03 ; 4 bytes to get (0-3) + LDA (ut1_pl),Y ; get mantissa3 + STA FAC2_3 ; save FAC2 mantissa3 + DEY ; decrement index + LDA (ut1_pl),Y ; get mantissa2 + STA FAC2_2 ; save FAC2 mantissa2 + DEY ; decrement index + LDA (ut1_pl),Y ; get mantissa1+sign + STA FAC2_s ; save FAC2 sign (b7) + EOR FAC1_s ; EOR with FAC1 sign (b7) + STA FAC_sc ; save sign compare (FAC1 EOR FAC2) + LDA FAC2_s ; recover FAC2 sign (b7) + ORA #$80 ; set 1xxx xxx (set normal bit) + STA FAC2_1 ; save FAC2 mantissa1 + DEY ; decrement index + LDA (ut1_pl),Y ; get exponent byte + STA FAC2_e ; save FAC2 exponent + LDA FAC1_e ; get FAC1 exponent + RTS + +; test and adjust accumulators + +LAB_2673 + LDA FAC2_e ; get FAC2 exponent +LAB_2675 + BEQ LAB_2696 ; branch if FAC2 = $00 (handle underflow) + + CLC ; clear carry for add + ADC FAC1_e ; add FAC1 exponent + BCC LAB_2680 ; branch if sum of exponents <$0100 + + BMI LAB_269B ; do overflow error + + CLC ; clear carry for the add + .byte $2C ; makes next line BIT $1410 +LAB_2680 + BPL LAB_2696 ; if +ve go handle underflow + + ADC #$80 ; adjust exponent + STA FAC1_e ; save FAC1 exponent + BNE LAB_268B ; branch if not zero + + JMP LAB_24F5 ; save FAC1 sign and return + +LAB_268B + LDA FAC_sc ; get sign compare (FAC1 EOR FAC2) + STA FAC1_s ; save FAC1 sign (b7) +LAB_268F + RTS + +; handle overflow and underflow + +LAB_2690 + LDA FAC1_s ; get FAC1 sign (b7) + BPL LAB_269B ; do overflow error + + ; handle underflow +LAB_2696 + PLA ; pop return address low byte + PLA ; pop return address high byte + JMP LAB_24F1 ; clear FAC1 exponent and sign and return + +; multiply by 10 + +LAB_269E + JSR LAB_27AB ; round and copy FAC1 to FAC2 + TAX ; copy exponent (set the flags) + BEQ LAB_268F ; exit if zero + + CLC ; clear carry for add + ADC #$02 ; add two to exponent (*4) + BCS LAB_269B ; do overflow error if > $FF + + LDX #$00 ; clear byte + STX FAC_sc ; clear sign compare (FAC1 EOR FAC2) + JSR LAB_247C ; add FAC2 to FAC1 (*5) + INC FAC1_e ; increment FAC1 exponent (*10) + BNE LAB_268F ; if non zero just do RTS + +LAB_269B + JMP LAB_2564 ; do overflow error and warm start + +; divide by 10 + +LAB_26B9 + JSR LAB_27AB ; round and copy FAC1 to FAC2 + LDA #LAB_26B5 ; set pointer to 10d high addr + LDX #$00 ; clear sign + +; divide by (AY) (X=sign) + +LAB_26C2 + STX FAC_sc ; save sign compare (FAC1 EOR FAC2) + JSR LAB_UFAC ; unpack memory (AY) into FAC1 + JMP LAB_DIVIDE ; do FAC2/FAC1 + + ; Perform divide-by +; convert AY and do (AY)/FAC1 + +LAB_26CA + JSR LAB_264D ; unpack memory (AY) into FAC2 + + ; Perform divide-into +LAB_DIVIDE + BEQ LAB_2737 ; if zero go do /0 error + + JSR LAB_27BA ; round FAC1 + LDA #$00 ; clear A + SEC ; set carry for subtract + SBC FAC1_e ; subtract FAC1 exponent (2s complement) + STA FAC1_e ; save FAC1 exponent + JSR LAB_2673 ; test and adjust accumulators + INC FAC1_e ; increment FAC1 exponent + BEQ LAB_269B ; if zero do overflow error + + LDX #$FF ; set index for pre increment + LDA #$01 ; set bit to flag byte save +LAB_26E4 + LDY FAC2_1 ; get FAC2 mantissa1 + CPY FAC1_1 ; compare FAC1 mantissa1 + BNE LAB_26F4 ; branch if <> + + LDY FAC2_2 ; get FAC2 mantissa2 + CPY FAC1_2 ; compare FAC1 mantissa2 + BNE LAB_26F4 ; branch if <> + + LDY FAC2_3 ; get FAC2 mantissa3 + CPY FAC1_3 ; compare FAC1 mantissa3 +LAB_26F4 + PHP ; save FAC2-FAC1 compare status + ROL ; shift the result byte + BCC LAB_2702 ; if no carry skip the byte save + + LDY #$01 ; set bit to flag byte save + INX ; else increment the index to FACt + CPX #$02 ; compare with the index to FACt_3 + BMI LAB_2701 ; if not last byte just go save it + + BNE LAB_272B ; if all done go save FAC1 rounding byte, normalise and + ; return + + LDY #$40 ; set bit to flag byte save for the rounding byte +LAB_2701 + STA FACt_1,X ; write result byte to FACt_1 + index + TYA ; copy the next save byte flag +LAB_2702 + PLP ; restore FAC2-FAC1 compare status + BCC LAB_2704 ; if FAC2 < FAC1 then skip the subtract + + TAY ; save FAC2-FAC1 compare status + LDA FAC2_3 ; get FAC2 mantissa3 + SBC FAC1_3 ; subtract FAC1 mantissa3 + STA FAC2_3 ; save FAC2 mantissa3 + LDA FAC2_2 ; get FAC2 mantissa2 + SBC FAC1_2 ; subtract FAC1 mantissa2 + STA FAC2_2 ; save FAC2 mantissa2 + LDA FAC2_1 ; get FAC2 mantissa1 + SBC FAC1_1 ; subtract FAC1 mantissa1 + STA FAC2_1 ; save FAC2 mantissa1 + TYA ; restore FAC2-FAC1 compare status + + ; FAC2 = FAC2*2 +LAB_2704 + ASL FAC2_3 ; shift FAC2 mantissa3 + ROL FAC2_2 ; shift FAC2 mantissa2 + ROL FAC2_1 ; shift FAC2 mantissa1 + BCS LAB_26F4 ; loop with no compare + + BMI LAB_26E4 ; loop with compare + + BPL LAB_26F4 ; loop always with no compare + +; do A<<6, save as FAC1 rounding byte, normalise and return + +LAB_272B + LSR ; shift b1 - b0 .. + ROR ; .. + ROR ; .. to b7 - b6 + STA FAC1_r ; save FAC1 rounding byte + PLP ; dump FAC2-FAC1 compare status + JMP LAB_273C ; copy temp to FAC1, normalise and return + +; do "Divide by zero" error + +LAB_2737 + LDX #$14 ; error code $14 ("Divide by zero" error) + JMP LAB_XERR ; do error #X, then warm start + +; copy temp to FAC1 and normalise + +LAB_273C + LDA FACt_1 ; get temp mantissa1 + STA FAC1_1 ; save FAC1 mantissa1 + LDA FACt_2 ; get temp mantissa2 + STA FAC1_2 ; save FAC1 mantissa2 + LDA FACt_3 ; get temp mantissa3 + STA FAC1_3 ; save FAC1 mantissa3 + JMP LAB_24D5 ; normalise FAC1 and return + +; unpack memory (AY) into FAC1 + +LAB_UFAC + STA ut1_pl ; save pointer low byte + STY ut1_ph ; save pointer high byte + LDY #$03 ; 4 bytes to do + LDA (ut1_pl),Y ; get last byte + STA FAC1_3 ; save FAC1 mantissa3 + DEY ; decrement index + LDA (ut1_pl),Y ; get last-1 byte + STA FAC1_2 ; save FAC1 mantissa2 + DEY ; decrement index + LDA (ut1_pl),Y ; get second byte + STA FAC1_s ; save FAC1 sign (b7) + ORA #$80 ; set 1xxx xxxx (add normal bit) + STA FAC1_1 ; save FAC1 mantissa1 + DEY ; decrement index + LDA (ut1_pl),Y ; get first byte (exponent) + STA FAC1_e ; save FAC1 exponent + STY FAC1_r ; clear FAC1 rounding byte + RTS + +; pack FAC1 into Adatal + +LAB_276E + LDX #Adatal ; set pointer high byte + BEQ LAB_2778 ; pack FAC1 into (XY) and return + +; pack FAC1 into (Lvarpl) + +LAB_PFAC + LDX Lvarpl ; get destination pointer low byte + LDY Lvarph ; get destination pointer high byte + +; pack FAC1 into (XY) + +LAB_2778 + JSR LAB_27BA ; round FAC1 + STX ut1_pl ; save pointer low byte + STY ut1_ph ; save pointer high byte + LDY #$03 ; set index + LDA FAC1_3 ; get FAC1 mantissa3 + STA (ut1_pl),Y ; store in destination + DEY ; decrement index + LDA FAC1_2 ; get FAC1 mantissa2 + STA (ut1_pl),Y ; store in destination + DEY ; decrement index + LDA FAC1_s ; get FAC1 sign (b7) + ORA #$7F ; set bits x111 1111 + AND FAC1_1 ; AND in FAC1 mantissa1 + STA (ut1_pl),Y ; store in destination + DEY ; decrement index + LDA FAC1_e ; get FAC1 exponent + STA (ut1_pl),Y ; store in destination + STY FAC1_r ; clear FAC1 rounding byte + RTS + +; round and copy FAC1 to FAC2 + +LAB_27AB + JSR LAB_27BA ; round FAC1 + +; copy FAC1 to FAC2 + +LAB_27AE + LDX #$05 ; 5 bytes to copy +LAB_27B0 + LDA FAC1_e-1,X ; get byte from FAC1,X + STA FAC1_o,X ; save byte at FAC2,X + DEX ; decrement count + BNE LAB_27B0 ; loop if not all done + + STX FAC1_r ; clear FAC1 rounding byte +LAB_27B9 + RTS + +; round FAC1 + +LAB_27BA + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_27B9 ; exit if zero + + ASL FAC1_r ; shift FAC1 rounding byte + BCC LAB_27B9 ; exit if no overflow + +; round FAC1 (no check) + +LAB_27C2 + JSR LAB_2559 ; increment FAC1 mantissa + BNE LAB_27B9 ; branch if no overflow + + JMP LAB_252A ; normalise FAC1 for C=1 and return + +; get FAC1 sign +; return A=FF,C=1/-ve A=01,C=0/+ve + +LAB_27CA + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_27D7 ; exit if zero (already correct SGN(0)=0) + +; return A=FF,C=1/-ve A=01,C=0/+ve +; no = 0 check + +LAB_27CE + LDA FAC1_s ; else get FAC1 sign (b7) + +; return A=FF,C=1/-ve A=01,C=0/+ve +; no = 0 check, sign in A + +LAB_27D0 + ROL ; move sign bit to carry + LDA #$FF ; set byte for -ve result + BCS LAB_27D7 ; return if sign was set (-ve) + + LDA #$01 ; else set byte for +ve result +LAB_27D7 + RTS + +; perform SGN() + +LAB_SGN + JSR LAB_27CA ; get FAC1 sign + ; return A=$FF/-ve A=$01/+ve +; save A as integer byte + +LAB_27DB + STA FAC1_1 ; save FAC1 mantissa1 + LDA #$00 ; clear A + STA FAC1_2 ; clear FAC1 mantissa2 + LDX #$88 ; set exponent + +; set exp=X, clearFAC1 mantissa3 and normalise + +LAB_27E3 + LDA FAC1_1 ; get FAC1 mantissa1 + EOR #$FF ; complement it + ROL ; sign bit into carry + +; set exp=X, clearFAC1 mantissa3 and normalise + +LAB_STFA + LDA #$00 ; clear A + STA FAC1_3 ; clear FAC1 mantissa3 + STX FAC1_e ; set FAC1 exponent + STA FAC1_r ; clear FAC1 rounding byte + STA FAC1_s ; clear FAC1 sign (b7) + JMP LAB_24D0 ; do ABS and normalise FAC1 + +; perform ABS() + +LAB_ABS + LSR FAC1_s ; clear FAC1 sign (put zero in b7) + RTS + +; compare FAC1 with (AY) +; returns A=$00 if FAC1 = (AY) +; returns A=$01 if FAC1 > (AY) +; returns A=$FF if FAC1 < (AY) + +LAB_27F8 + STA ut2_pl ; save pointer low byte +LAB_27FA + STY ut2_ph ; save pointer high byte + LDY #$00 ; clear index + LDA (ut2_pl),Y ; get exponent + INY ; increment index + TAX ; copy (AY) exponent to X + BEQ LAB_27CA ; branch if (AY) exponent=0 and get FAC1 sign + ; A=FF,C=1/-ve A=01,C=0/+ve + + LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign) + EOR FAC1_s ; EOR FAC1 sign (b7) + BMI LAB_27CE ; if signs <> do return A=FF,C=1/-ve + ; A=01,C=0/+ve and return + + CPX FAC1_e ; compare (AY) exponent with FAC1 exponent + BNE LAB_2828 ; branch if different + + LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign) + ORA #$80 ; normalise top bit + CMP FAC1_1 ; compare with FAC1 mantissa1 + BNE LAB_2828 ; branch if different + + INY ; increment index + LDA (ut2_pl),Y ; get mantissa2 + CMP FAC1_2 ; compare with FAC1 mantissa2 + BNE LAB_2828 ; branch if different + + INY ; increment index + LDA #$7F ; set for 1/2 value rounding byte + CMP FAC1_r ; compare with FAC1 rounding byte (set carry) + LDA (ut2_pl),Y ; get mantissa3 + SBC FAC1_3 ; subtract FAC1 mantissa3 + BEQ LAB_2850 ; exit if mantissa3 equal + +; gets here if number <> FAC1 + +LAB_2828 + LDA FAC1_s ; get FAC1 sign (b7) + BCC LAB_282E ; branch if FAC1 > (AY) + + EOR #$FF ; else toggle FAC1 sign +LAB_282E + JMP LAB_27D0 ; return A=FF,C=1/-ve A=01,C=0/+ve + +; convert FAC1 floating-to-fixed + +LAB_2831 + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_287F ; if zero go clear FAC1 and return + + SEC ; set carry for subtract + SBC #$98 ; subtract maximum integer range exponent + BIT FAC1_s ; test FAC1 sign (b7) + BPL LAB_2845 ; branch if FAC1 +ve + + ; FAC1 was -ve + TAX ; copy subtracted exponent + LDA #$FF ; overflow for -ve number + STA FAC1_o ; set FAC1 overflow byte + JSR LAB_253D ; twos complement FAC1 mantissa + TXA ; restore subtracted exponent +LAB_2845 + LDX #FAC1_e ; set index to FAC1 + CMP #$F9 ; compare exponent result + BPL LAB_2851 ; if < 8 shifts shift FAC1 A times right and return + + JSR LAB_257B ; shift FAC1 A times right (> 8 shifts) + STY FAC1_o ; clear FAC1 overflow byte +LAB_2850 + RTS + +; shift FAC1 A times right + +LAB_2851 + TAY ; copy shift count + LDA FAC1_s ; get FAC1 sign (b7) + AND #$80 ; mask sign bit only (x000 0000) + LSR FAC1_1 ; shift FAC1 mantissa1 + ORA FAC1_1 ; OR sign in b7 FAC1 mantissa1 + STA FAC1_1 ; save FAC1 mantissa1 + JSR LAB_2592 ; shift FAC1 Y times right + STY FAC1_o ; clear FAC1 overflow byte + RTS + +; perform INT() + +LAB_INT + LDA FAC1_e ; get FAC1 exponent + CMP #$98 ; compare with max int + BCS LAB_2886 ; exit if >= (already int, too big for fractional part!) + + JSR LAB_2831 ; convert FAC1 floating-to-fixed + STY FAC1_r ; save FAC1 rounding byte + LDA FAC1_s ; get FAC1 sign (b7) + STY FAC1_s ; save FAC1 sign (b7) + EOR #$80 ; toggle FAC1 sign + ROL ; shift into carry + LDA #$98 ; set new exponent + STA FAC1_e ; save FAC1 exponent + LDA FAC1_3 ; get FAC1 mantissa3 + STA Temp3 ; save for EXP() function + JMP LAB_24D0 ; do ABS and normalise FAC1 + +; clear FAC1 and return + +LAB_287F + STA FAC1_1 ; clear FAC1 mantissa1 + STA FAC1_2 ; clear FAC1 mantissa2 + STA FAC1_3 ; clear FAC1 mantissa3 + TAY ; clear Y +LAB_2886 + RTS + +; get FAC1 from string +; this routine now handles hex and binary values from strings +; starting with "$" and "%" respectively + +LAB_2887 + LDY #$00 ; clear Y + STY Dtypef ; clear data type flag, $FF=string, $00=numeric + LDX #$09 ; set index +LAB_288B + STY numexp,X ; clear byte + DEX ; decrement index + BPL LAB_288B ; loop until numexp to negnum (and FAC1) = $00 + + BCC LAB_28FE ; branch if 1st character numeric + +; get FAC1 from string .. first character wasn't numeric + + CMP #'-' ; else compare with "-" + BNE LAB_289A ; branch if not "-" + + STX negnum ; set flag for -ve number (X = $FF) + BEQ LAB_289C ; branch always (go scan and check for hex/bin) + +; get FAC1 from string .. first character wasn't numeric or - + +LAB_289A + CMP #'+' ; else compare with "+" + BNE LAB_289D ; branch if not "+" (go check for hex/bin) + +; was "+" or "-" to start, so get next character + +LAB_289C + JSR LAB_IGBY ; increment and scan memory + BCC LAB_28FE ; branch if numeric character + +; code here for hex and binary numbers + +LAB_289D + CMP #'$' ; else compare with "$" + BNE LAB_NHEX ; branch if not "$" + + JMP LAB_CHEX ; branch if "$" + +LAB_NHEX + CMP #'%' ; else compare with "%" + BNE LAB_28A3 ; branch if not "%" (continue original code) + + JMP LAB_CBIN ; branch if "%" + +LAB_289E + JSR LAB_IGBY ; increment and scan memory (ignore + or get next number) +LAB_28A1 + BCC LAB_28FE ; branch if numeric character + +; get FAC1 from string .. character wasn't numeric, -, +, hex or binary + +LAB_28A3 + CMP #'.' ; else compare with "." + BEQ LAB_28D5 ; branch if "." + +; get FAC1 from string .. character wasn't numeric, -, + or . + + CMP #'E' ; else compare with "E" + BNE LAB_28DB ; branch if not "E" + + ; was "E" so evaluate exponential part + JSR LAB_IGBY ; increment and scan memory + BCC LAB_28C7 ; branch if numeric character + + CMP #TK_MINUS ; else compare with token for - + BEQ LAB_28C2 ; branch if token for - + + CMP #'-' ; else compare with "-" + BEQ LAB_28C2 ; branch if "-" + + CMP #TK_PLUS ; else compare with token for + + BEQ LAB_28C4 ; branch if token for + + + CMP #'+' ; else compare with "+" + BEQ LAB_28C4 ; branch if "+" + + BNE LAB_28C9 ; branch always + +LAB_28C2 + ROR expneg ; set exponent -ve flag (C, which=1, into b7) +LAB_28C4 + JSR LAB_IGBY ; increment and scan memory +LAB_28C7 + BCC LAB_2925 ; branch if numeric character + +LAB_28C9 + BIT expneg ; test exponent -ve flag + BPL LAB_28DB ; if +ve go evaluate exponent + + ; else do exponent = -exponent + LDA #$00 ; clear result + SEC ; set carry for subtract + SBC expcnt ; subtract exponent byte + JMP LAB_28DD ; go evaluate exponent + +LAB_28D5 + ROR numdpf ; set decimal point flag + BIT numdpf ; test decimal point flag + BVC LAB_289E ; branch if only one decimal point so far + + ; evaluate exponent +LAB_28DB + LDA expcnt ; get exponent count byte +LAB_28DD + SEC ; set carry for subtract + SBC numexp ; subtract numerator exponent + STA expcnt ; save exponent count byte + BEQ LAB_28F6 ; branch if no adjustment + + BPL LAB_28EF ; else if +ve go do FAC1*10^expcnt + + ; else go do FAC1/10^(0-expcnt) +LAB_28E6 + JSR LAB_26B9 ; divide by 10 + INC expcnt ; increment exponent count byte + BNE LAB_28E6 ; loop until all done + + BEQ LAB_28F6 ; branch always + +LAB_28EF + JSR LAB_269E ; multiply by 10 + DEC expcnt ; decrement exponent count byte + BNE LAB_28EF ; loop until all done + +LAB_28F6 + LDA negnum ; get -ve flag + BMI LAB_28FB ; if -ve do - FAC1 and return + + RTS + +; do - FAC1 and return + +LAB_28FB + JMP LAB_GTHAN ; do - FAC1 and return + +; do unsigned FAC1*10+number + +LAB_28FE + PHA ; save character + BIT numdpf ; test decimal point flag + BPL LAB_2905 ; skip exponent increment if not set + + INC numexp ; else increment number exponent +LAB_2905 + JSR LAB_269E ; multiply FAC1 by 10 + PLA ; restore character + AND #$0F ; convert to binary + JSR LAB_2912 ; evaluate new ASCII digit + JMP LAB_289E ; go do next character + +; evaluate new ASCII digit + +LAB_2912 + PHA ; save digit + JSR LAB_27AB ; round and copy FAC1 to FAC2 + PLA ; restore digit + JSR LAB_27DB ; save A as integer byte + LDA FAC2_s ; get FAC2 sign (b7) + EOR FAC1_s ; toggle with FAC1 sign (b7) + STA FAC_sc ; save sign compare (FAC1 EOR FAC2) + LDX FAC1_e ; get FAC1 exponent + JMP LAB_ADD ; add FAC2 to FAC1 and return + +; evaluate next character of exponential part of number + +LAB_2925 + LDA expcnt ; get exponent count byte + CMP #$0A ; compare with 10 decimal + BCC LAB_2934 ; branch if less + + LDA #$64 ; make all -ve exponents = -100 decimal (causes underflow) + BIT expneg ; test exponent -ve flag + BMI LAB_2942 ; branch if -ve + + JMP LAB_2564 ; else do overflow error + +LAB_2934 + ASL ; * 2 + ASL ; * 4 + ADC expcnt ; * 5 + ASL ; * 10 + LDY #$00 ; set index + ADC (Bpntrl),Y ; add character (will be $30 too much!) + SBC #'0'-1 ; convert character to binary +LAB_2942 + STA expcnt ; save exponent count byte + JMP LAB_28C4 ; go get next character + +; print " in line [LINE #]" + +LAB_2953 + LDA #LAB_LMSG ; point to " in line " message high byte + JSR LAB_18C3 ; print null terminated string from memory + + ; print Basic line # + LDA Clineh ; get current line high byte + LDX Clinel ; get current line low byte + +; print XA as unsigned integer + +LAB_295E + STA FAC1_1 ; save low byte as FAC1 mantissa1 + STX FAC1_2 ; save high byte as FAC1 mantissa2 + LDX #$90 ; set exponent to 16d bits + SEC ; set integer is +ve flag + JSR LAB_STFA ; set exp=X, clearFAC1 mantissa3 and normalise + LDY #$00 ; clear index + TYA ; clear A + JSR LAB_297B ; convert FAC1 to string, skip sign character save + JMP LAB_18C3 ; print null terminated string from memory and return + +; convert FAC1 to ASCII string result in (AY) +; not any more, moved scratchpad to page 0 + +LAB_296E + LDY #$01 ; set index = 1 + LDA #$20 ; character = " " (assume +ve) + BIT FAC1_s ; test FAC1 sign (b7) + BPL LAB_2978 ; branch if +ve + + LDA #$2D ; else character = "-" +LAB_2978 + STA Decss,Y ; save leading character (" " or "-") +LAB_297B + STA FAC1_s ; clear FAC1 sign (b7) + STY Sendl ; save index + INY ; increment index + LDX FAC1_e ; get FAC1 exponent + BNE LAB_2989 ; branch if FAC1<>0 + + ; exponent was $00 so FAC1 is 0 + LDA #'0' ; set character = "0" + JMP LAB_2A89 ; save last character, [EOT] and exit + + ; FAC1 is some non zero value +LAB_2989 + LDA #$00 ; clear (number exponent count) + CPX #$81 ; compare FAC1 exponent with $81 (>1.00000) + + BCS LAB_299A ; branch if FAC1=>1 + + ; FAC1<1 + LDA #LAB_294F ; set pointer high byte to 1,000,000 + JSR LAB_25FB ; do convert AY, FCA1*(AY) + LDA #$FA ; set number exponent count (-6) +LAB_299A + STA numexp ; save number exponent count +LAB_299C + LDA #LAB_294B ; set pointer high byte to 999999.4375 + JSR LAB_27F8 ; compare FAC1 with (AY) + BEQ LAB_29C3 ; exit if FAC1 = (AY) + + BPL LAB_29B9 ; go do /10 if FAC1 > (AY) + + ; FAC1 < (AY) +LAB_29A7 + LDA #LAB_2947 ; set pointer high byte to 99999.9375 + JSR LAB_27F8 ; compare FAC1 with (AY) + BEQ LAB_29B2 ; branch if FAC1 = (AY) (allow decimal places) + + BPL LAB_29C0 ; branch if FAC1 > (AY) (no decimal places) + + ; FAC1 <= (AY) +LAB_29B2 + JSR LAB_269E ; multiply by 10 + DEC numexp ; decrement number exponent count + BNE LAB_29A7 ; go test again (branch always) + +LAB_29B9 + JSR LAB_26B9 ; divide by 10 + INC numexp ; increment number exponent count + BNE LAB_299C ; go test again (branch always) + +; now we have just the digits to do + +LAB_29C0 + JSR LAB_244E ; add 0.5 to FAC1 (round FAC1) +LAB_29C3 + JSR LAB_2831 ; convert FAC1 floating-to-fixed + LDX #$01 ; set default digits before dp = 1 + LDA numexp ; get number exponent count + CLC ; clear carry for add + ADC #$07 ; up to 6 digits before point + BMI LAB_29D8 ; if -ve then 1 digit before dp + + CMP #$08 ; A>=8 if n>=1E6 + BCS LAB_29D9 ; branch if >= $08 + + ; carry is clear + ADC #$FF ; take 1 from digit count + TAX ; copy to A + LDA #$02 ;.set exponent adjust +LAB_29D8 + SEC ; set carry for subtract +LAB_29D9 + SBC #$02 ; -2 + STA expcnt ;.save exponent adjust + STX numexp ; save digits before dp count + TXA ; copy to A + BEQ LAB_29E4 ; branch if no digits before dp + + BPL LAB_29F7 ; branch if digits before dp + +LAB_29E4 + LDY Sendl ; get output string index + LDA #$2E ; character "." + INY ; increment index + STA Decss,Y ; save to output string + TXA ;. + BEQ LAB_29F5 ;. + + LDA #'0' ; character "0" + INY ; increment index + STA Decss,Y ; save to output string +LAB_29F5 + STY Sendl ; save output string index +LAB_29F7 + LDY #$00 ; clear index (point to 100,000) + LDX #$80 ; +LAB_29FB + LDA FAC1_3 ; get FAC1 mantissa3 + CLC ; clear carry for add + ADC LAB_2A9C,Y ; add -ve LSB + STA FAC1_3 ; save FAC1 mantissa3 + LDA FAC1_2 ; get FAC1 mantissa2 + ADC LAB_2A9B,Y ; add -ve NMSB + STA FAC1_2 ; save FAC1 mantissa2 + LDA FAC1_1 ; get FAC1 mantissa1 + ADC LAB_2A9A,Y ; add -ve MSB + STA FAC1_1 ; save FAC1 mantissa1 + INX ; + BCS LAB_2A18 ; + + BPL LAB_29FB ; not -ve so try again + + BMI LAB_2A1A ; + +LAB_2A18 + BMI LAB_29FB ; + +LAB_2A1A + TXA ; + BCC LAB_2A21 ; + + EOR #$FF ; + ADC #$0A ; +LAB_2A21 + ADC #'0'-1 ; add "0"-1 to result + INY ; increment index .. + INY ; .. to next less .. + INY ; .. power of ten + STY Cvaral ; save as current var address low byte + LDY Sendl ; get output string index + INY ; increment output string index + TAX ; copy character to X + AND #$7F ; mask out top bit + STA Decss,Y ; save to output string + DEC numexp ; decrement # of characters before the dp + BNE LAB_2A3B ; branch if still characters to do + + ; else output the point + LDA #$2E ; character "." + INY ; increment output string index + STA Decss,Y ; save to output string +LAB_2A3B + STY Sendl ; save output string index + LDY Cvaral ; get current var address low byte + TXA ; get character back + EOR #$FF ; + AND #$80 ; + TAX ; + CPY #$12 ; compare index with max + BNE LAB_29FB ; loop if not max + + ; now remove trailing zeroes + LDY Sendl ; get output string index +LAB_2A4B + LDA Decss,Y ; get character from output string + DEY ; decrement output string index + CMP #'0' ; compare with "0" + BEQ LAB_2A4B ; loop until non "0" character found + + CMP #'.' ; compare with "." + BEQ LAB_2A58 ; branch if was dp + + ; restore last character + INY ; increment output string index +LAB_2A58 + LDA #$2B ; character "+" + LDX expcnt ; get exponent count + BEQ LAB_2A8C ; if zero go set null terminator and exit + + ; exponent isn't zero so write exponent + BPL LAB_2A68 ; branch if exponent count +ve + + LDA #$00 ; clear A + SEC ; set carry for subtract + SBC expcnt ; subtract exponent count adjust (convert -ve to +ve) + TAX ; copy exponent count to X + LDA #'-' ; character "-" +LAB_2A68 + STA Decss+2,Y ; save to output string + LDA #$45 ; character "E" + STA Decss+1,Y ; save exponent sign to output string + TXA ; get exponent count back + LDX #'0'-1 ; one less than "0" character + SEC ; set carry for subtract +LAB_2A74 + INX ; increment 10's character + SBC #$0A ;.subtract 10 from exponent count + BCS LAB_2A74 ; loop while still >= 0 + + ADC #':' ; add character ":" ($30+$0A, result is 10 less that value) + STA Decss+4,Y ; save to output string + TXA ; copy 10's character + STA Decss+3,Y ; save to output string + LDA #$00 ; set null terminator + STA Decss+5,Y ; save to output string + BEQ LAB_2A91 ; go set string pointer (AY) and exit (branch always) + + ; save last character, [EOT] and exit +LAB_2A89 + STA Decss,Y ; save last character to output string + + ; set null terminator and exit +LAB_2A8C + LDA #$00 ; set null terminator + STA Decss+1,Y ; save after last character + + ; set string pointer (AY) and exit +LAB_2A91 + LDA #Decssp1 ; set result string high pointer + RTS + +; perform power function + +LAB_POWER + BEQ LAB_EXP ; go do EXP() + + LDA FAC2_e ; get FAC2 exponent + BNE LAB_2ABF ; branch if FAC2<>0 + + JMP LAB_24F3 ; clear FAC1 exponent and sign and return + +LAB_2ABF + LDX #func_l ; set destination pointer high byte + JSR LAB_2778 ; pack FAC1 into (XY) + LDA FAC2_s ; get FAC2 sign (b7) + BPL LAB_2AD9 ; branch if FAC2>0 + + ; else FAC2 is -ve and can only be raised to an + ; integer power which gives an x +j0 result + JSR LAB_INT ; perform INT + LDA #func_l ; set source pointer high byte + JSR LAB_27F8 ; compare FAC1 with (AY) + BNE LAB_2AD9 ; branch if FAC1 <> (AY) to allow Function Call error + ; this will leave FAC1 -ve and cause a Function Call + ; error when LOG() is called + + TYA ; clear sign b7 + LDY Temp3 ; save mantissa 3 from INT() function as sign in Y + ; for possible later negation, b0 +LAB_2AD9 + JSR LAB_279D ; save FAC1 sign and copy ABS(FAC2) to FAC1 + TYA ; copy sign back .. + PHA ; .. and save it + JSR LAB_LOG ; do LOG(n) + LDA #garb_l ; set pointer high byte + JSR LAB_25FB ; do convert AY, FCA1*(AY) (square the value) + JSR LAB_EXP ; go do EXP(n) + PLA ; pull sign from stack + LSR ; b0 is to be tested, shift to Cb + BCC LAB_2AF9 ; if no bit then exit + + ; Perform negation +; do - FAC1 + +LAB_GTHAN + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_2AF9 ; exit if FAC1_e = $00 + + LDA FAC1_s ; get FAC1 sign (b7) + EOR #$FF ; complement it + STA FAC1_s ; save FAC1 sign (b7) +LAB_2AF9 + RTS + +; perform EXP() (x^e) + +LAB_EXP + LDA #LAB_2AFA ; set 1.443 pointer high byte + JSR LAB_25FB ; do convert AY, FCA1*(AY) + LDA FAC1_r ; get FAC1 rounding byte + ADC #$50 ; +$50/$100 + BCC LAB_2B2B ; skip rounding if no carry + + JSR LAB_27C2 ; round FAC1 (no check) +LAB_2B2B + STA FAC2_r ; save FAC2 rounding byte + JSR LAB_27AE ; copy FAC1 to FAC2 + LDA FAC1_e ; get FAC1 exponent + CMP #$88 ; compare with EXP limit (256d) + BCC LAB_2B39 ; branch if less + +LAB_2B36 + JSR LAB_2690 ; handle overflow and underflow +LAB_2B39 + JSR LAB_INT ; perform INT + LDA Temp3 ; get mantissa 3 from INT() function + CLC ; clear carry for add + ADC #$81 ; normalise +1 + BEQ LAB_2B36 ; if $00 go handle overflow + + SEC ; set carry for subtract + SBC #$01 ; now correct for exponent + PHA ; save FAC2 exponent + + ; swap FAC1 and FAC2 + LDX #$04 ; 4 bytes to do +LAB_2B49 + LDA FAC2_e,X ; get FAC2,X + LDY FAC1_e,X ; get FAC1,X + STA FAC1_e,X ; save FAC1,X + STY FAC2_e,X ; save FAC2,X + DEX ; decrement count/index + BPL LAB_2B49 ; loop if not all done + + LDA FAC2_r ; get FAC2 rounding byte + STA FAC1_r ; save as FAC1 rounding byte + JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1 + JSR LAB_GTHAN ; do - FAC1 + LDA #LAB_2AFE ; set counter pointer high byte + JSR LAB_2B84 ; go do series evaluation + LDA #$00 ; clear A + STA FAC_sc ; clear sign compare (FAC1 EOR FAC2) + PLA ;.get saved FAC2 exponent + JMP LAB_2675 ; test and adjust accumulators and return + +; ^2 then series evaluation + +LAB_2B6E + STA Cptrl ; save count pointer low byte + STY Cptrh ; save count pointer high byte + JSR LAB_276E ; pack FAC1 into Adatal + LDA #Adatal ; pointer to original # high byte + JMP LAB_25FB ; do convert AY, FCA1*(AY) and return + +; series evaluation + +LAB_2B84 + STA Cptrl ; save count pointer low byte + STY Cptrh ; save count pointer high byte +LAB_2B88 + LDX #numexp ; set pointer high byte to partial @ numexp + DEC numcon ; decrement constants count + BNE LAB_2B9B ; loop until all done + + RTS + +; RND(n), 32 bit Galoise version. make n=0 for 19th next number in sequence or n<>0 +; to get 19th next number in sequence after seed n. This version of the PRNG uses +; the Galois method and a sample of 65536 bytes produced gives the following values. + +; Entropy = 7.997442 bits per byte +; Optimum compression would reduce these 65536 bytes by 0 percent + +; Chi square distribution for 65536 samples is 232.01, and +; randomly would exceed this value 75.00 percent of the time + +; Arithmetic mean value of data bytes is 127.6724, 127.5 would be random +; Monte Carlo value for Pi is 3.122871269, error 0.60 percent +; Serial correlation coefficient is -0.000370, totally uncorrelated would be 0.0 + +LAB_RND + LDA FAC1_e ; get FAC1 exponent + BEQ NextPRN ; do next random # if zero + + ; else get seed into random number store + LDX #Rbyte4 ; set PRNG pointer low byte + LDY #$00 ; set PRNG pointer high byte + JSR LAB_2778 ; pack FAC1 into (XY) +NextPRN + LDX #$AF ; set EOR byte + LDY #$13 ; do this nineteen times +LoopPRN + ASL Rbyte1 ; shift PRNG most significant byte + ROL Rbyte2 ; shift PRNG middle byte + ROL Rbyte3 ; shift PRNG least significant byte + ROL Rbyte4 ; shift PRNG extra byte + BCC Ninc1 ; branch if bit 32 clear + + TXA ; set EOR byte + EOR Rbyte1 ; EOR PRNG extra byte + STA Rbyte1 ; save new PRNG extra byte +Ninc1 + DEY ; decrement loop count + BNE LoopPRN ; loop if not all done + + LDX #$02 ; three bytes to copy +CopyPRNG + LDA Rbyte1,X ; get PRNG byte + STA FAC1_1,X ; save FAC1 byte + DEX + BPL CopyPRNG ; loop if not complete + + LDA #$80 ; set the exponent + STA FAC1_e ; save FAC1 exponent + + ASL ; clear A + STA FAC1_s ; save FAC1 sign + + JMP LAB_24D5 ; normalise FAC1 and return + +; perform COS() + +LAB_COS + LDA #LAB_2C78 ; set (pi/2) pointer high byte + JSR LAB_246C ; add (AY) to FAC1 + +; perform SIN() + +LAB_SIN + JSR LAB_27AB ; round and copy FAC1 to FAC2 + LDA #LAB_2C7C ; set (2*pi) pointer high byte + LDX FAC2_s ; get FAC2 sign (b7) + JSR LAB_26C2 ; divide by (AY) (X=sign) + JSR LAB_27AB ; round and copy FAC1 to FAC2 + JSR LAB_INT ; perform INT + LDA #$00 ; clear byte + STA FAC_sc ; clear sign compare (FAC1 EOR FAC2) + JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1 + LDA #LAB_2C80 ; set 0.25 pointer high byte + JSR LAB_2455 ; perform subtraction, (AY) from FAC1 + LDA FAC1_s ; get FAC1 sign (b7) + PHA ; save FAC1 sign + BPL LAB_2C35 ; branch if +ve + + ; FAC1 sign was -ve + JSR LAB_244E ; add 0.5 to FAC1 + LDA FAC1_s ; get FAC1 sign (b7) + BMI LAB_2C38 ; branch if -ve + + LDA Cflag ; get comparison evaluation flag + EOR #$FF ; toggle flag + STA Cflag ; save comparison evaluation flag +LAB_2C35 + JSR LAB_GTHAN ; do - FAC1 +LAB_2C38 + LDA #LAB_2C80 ; set 0.25 pointer high byte + JSR LAB_246C ; add (AY) to FAC1 + PLA ; restore FAC1 sign + BPL LAB_2C45 ; branch if was +ve + + ; else correct FAC1 + JSR LAB_GTHAN ; do - FAC1 +LAB_2C45 + LDA #LAB_2C84 ; set pointer high byte to counter + JMP LAB_2B6E ; ^2 then series evaluation and return + +; perform TAN() + +LAB_TAN + JSR LAB_276E ; pack FAC1 into Adatal + LDA #$00 ; clear byte + STA Cflag ; clear comparison evaluation flag + JSR LAB_SIN ; go do SIN(n) + LDX #func_l ; set sin(n) pointer high byte + JSR LAB_2778 ; pack FAC1 into (XY) + LDA #Adatal ; set n pointer high addr + JSR LAB_UFAC ; unpack memory (AY) into FAC1 + LDA #$00 ; clear byte + STA FAC1_s ; clear FAC1 sign (b7) + LDA Cflag ; get comparison evaluation flag + JSR LAB_2C74 ; save flag and go do series evaluation + + LDA #func_l ; set sin(n) pointer high byte + JMP LAB_26CA ; convert AY and do (AY)/FAC1 + +LAB_2C74 + PHA ; save comparison evaluation flag + JMP LAB_2C35 ; go do series evaluation + +; perform USR() + +LAB_USR + JSR Usrjmp ; call user code + JMP LAB_1BFB ; scan for ")", else do syntax error then warm start + +; perform ATN() + +LAB_ATN + LDA FAC1_s ; get FAC1 sign (b7) + PHA ; save sign + BPL LAB_2CA1 ; branch if +ve + + JSR LAB_GTHAN ; else do - FAC1 +LAB_2CA1 + LDA FAC1_e ; get FAC1 exponent + PHA ; push exponent + CMP #$81 ; compare with 1 + BCC LAB_2CAF ; branch if FAC1<1 + + LDA #LAB_259C ; set 1 pointer high byte + JSR LAB_26CA ; convert AY and do (AY)/FAC1 +LAB_2CAF + LDA #LAB_2CC9 ; set pointer high byte to counter + JSR LAB_2B6E ; ^2 then series evaluation + PLA ; restore old FAC1 exponent + CMP #$81 ; compare with 1 + BCC LAB_2CC2 ; branch if FAC1<1 + + LDA #LAB_2C78 ; set (pi/2) pointer high byte + JSR LAB_2455 ; perform subtraction, (AY) from FAC1 +LAB_2CC2 + PLA ; restore FAC1 sign + BPL LAB_2D04 ; exit if was +ve + + JMP LAB_GTHAN ; else do - FAC1 and return + +; perform BITSET + +LAB_BITSET + JSR LAB_GADB ; get two parameters for POKE or WAIT + CPX #$08 ; only 0 to 7 are allowed + BCS FCError ; branch if > 7 + + LDA #$00 ; clear A + SEC ; set the carry +S_Bits + ROL ; shift bit + DEX ; decrement bit number + BPL S_Bits ; loop if still +ve + + INX ; make X = $00 + ORA (Itempl,X) ; or with byte via temporary integer (addr) + STA (Itempl,X) ; save byte via temporary integer (addr) +LAB_2D04 + RTS + +; perform BITCLR + +LAB_BITCLR + JSR LAB_GADB ; get two parameters for POKE or WAIT + CPX #$08 ; only 0 to 7 are allowed + BCS FCError ; branch if > 7 + + LDA #$FF ; set A +S_Bitc + ROL ; shift bit + DEX ; decrement bit number + BPL S_Bitc ; loop if still +ve + + INX ; make X = $00 + AND (Itempl,X) ; and with byte via temporary integer (addr) + STA (Itempl,X) ; save byte via temporary integer (addr) + RTS + +FCError + JMP LAB_FCER ; do function call error then warm start + +; perform BITTST() + +LAB_BTST + JSR LAB_IGBY ; increment BASIC pointer + JSR LAB_GADB ; get two parameters for POKE or WAIT + CPX #$08 ; only 0 to 7 are allowed + BCS FCError ; branch if > 7 + + JSR LAB_GBYT ; get next BASIC byte + CMP #')' ; is next character ")" + BEQ TST_OK ; if ")" go do rest of function + + JMP LAB_SNER ; do syntax error then warm start + +TST_OK + JSR LAB_IGBY ; update BASIC execute pointer (to character past ")") + LDA #$00 ; clear A + SEC ; set the carry +T_Bits + ROL ; shift bit + DEX ; decrement bit number + BPL T_Bits ; loop if still +ve + + INX ; make X = $00 + AND (Itempl,X) ; AND with byte via temporary integer (addr) + BEQ LAB_NOTT ; branch if zero (already correct) + + LDA #$FF ; set for -1 result +LAB_NOTT + JMP LAB_27DB ; go do SGN tail + +; perform BIN$() + +LAB_BINS + CPX #$19 ; max + 1 + BCS BinFErr ; exit if too big ( > or = ) + + STX TempB ; save # of characters ($00 = leading zero remove) + LDA #$18 ; need A byte long space + JSR LAB_MSSP ; make string space A bytes long + LDY #$17 ; set index + LDX #$18 ; character count +NextB1 + LSR nums_1 ; shift highest byte + ROR nums_2 ; shift middle byte + ROR nums_3 ; shift lowest byte bit 0 to carry + TXA ; load with "0"/2 + ROL ; shift in carry + STA (str_pl),Y ; save to temp string + index + DEY ; decrement index + BPL NextB1 ; loop if not done + + LDA TempB ; get # of characters + BEQ EndBHS ; branch if truncate + + TAX ; copy length to X + SEC ; set carry for add ! + EOR #$FF ; 1's complement + ADC #$18 ; add 24d + BEQ GoPr2 ; if zero print whole string + + BNE GoPr1 ; else go make output string + +; this is the exit code and is also used by HEX$() +; truncate string to remove leading "0"s + +EndBHS + TAY ; clear index (A=0, X=length here) +NextB2 + LDA (str_pl),Y ; get character from string + CMP #'0' ; compare with "0" + BNE GoPr ; if not "0" then go print string from here + + DEX ; decrement character count + BEQ GoPr3 ; if zero then end of string so go print it + + INY ; else increment index + BPL NextB2 ; loop always + +; make fixed length output string - ignore overflows! + +GoPr3 + INX ; need at least 1 character +GoPr + TYA ; copy result +GoPr1 + CLC ; clear carry for add + ADC str_pl ; add low address + STA str_pl ; save low address + LDA #$00 ; do high byte + ADC str_ph ; add high address + STA str_ph ; save high address +GoPr2 + STX str_ln ; X holds string length + JSR LAB_IGBY ; update BASIC execute pointer (to character past ")") + JMP LAB_RTST ; check for space on descriptor stack then put address + ; and length on descriptor stack and update stack pointers + +BinFErr + JMP LAB_FCER ; do function call error then warm start + +; perform HEX$() + +LAB_HEXS + CPX #$07 ; max + 1 + BCS BinFErr ; exit if too big ( > or = ) + + STX TempB ; save # of characters + + LDA #$06 ; need 6 bytes for string + JSR LAB_MSSP ; make string space A bytes long + LDY #$05 ; set string index + + SED ; need decimal mode for nibble convert + LDA nums_3 ; get lowest byte + JSR LAB_A2HX ; convert A to ASCII hex byte and output + LDA nums_2 ; get middle byte + JSR LAB_A2HX ; convert A to ASCII hex byte and output + LDA nums_1 ; get highest byte + JSR LAB_A2HX ; convert A to ASCII hex byte and output + CLD ; back to binary + + LDX #$06 ; character count + LDA TempB ; get # of characters + BEQ EndBHS ; branch if truncate + + TAX ; copy length to X + SEC ; set carry for add ! + EOR #$FF ; 1's complement + ADC #$06 ; add 6d + BEQ GoPr2 ; if zero print whole string + + BNE GoPr1 ; else go make output string (branch always) + +; convert A to ASCII hex byte and output .. note set decimal mode before calling + +LAB_A2HX + TAX ; save byte + AND #$0F ; mask off top bits + JSR LAB_AL2X ; convert low nibble to ASCII and output + TXA ; get byte back + LSR ; /2 shift high nibble to low nibble + LSR ; /4 + LSR ; /8 + LSR ; /16 +LAB_AL2X + CMP #$0A ; set carry for +1 if >9 + ADC #'0' ; add ASCII "0" + STA (str_pl),Y ; save to temp string + DEY ; decrement counter + RTS + +LAB_NLTO + STA FAC1_e ; save FAC1 exponent + LDA #$00 ; clear sign compare +LAB_MLTE + STA FAC_sc ; save sign compare (FAC1 EOR FAC2) + TXA ; restore character + JSR LAB_2912 ; evaluate new ASCII digit + +; gets here if the first character was "$" for hex +; get hex number + +LAB_CHEX + JSR LAB_IGBY ; increment and scan memory + BCC LAB_ISHN ; branch if numeric character + + ORA #$20 ; case convert, allow "A" to "F" and "a" to "f" + SBC #'a' ; subtract "a" (carry set here) + CMP #$06 ; compare normalised with $06 (max+1) + BCS LAB_EXCH ; exit if >"f" or <"0" + + ADC #$0A ; convert to nibble +LAB_ISHN + AND #$0F ; convert to binary + TAX ; save nibble + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_MLTE ; skip multiply if zero + + ADC #$04 ; add four to exponent (*16 - carry clear here) + BCC LAB_NLTO ; if no overflow do evaluate digit + +LAB_MLTO + JMP LAB_2564 ; do overflow error and warm start + +LAB_NXCH + TAX ; save bit + LDA FAC1_e ; get FAC1 exponent + BEQ LAB_MLBT ; skip multiply if zero + + INC FAC1_e ; increment FAC1 exponent (*2) + BEQ LAB_MLTO ; do overflow error if = $00 + + LDA #$00 ; clear sign compare +LAB_MLBT + STA FAC_sc ; save sign compare (FAC1 EOR FAC2) + TXA ; restore bit + JSR LAB_2912 ; evaluate new ASCII digit + +; gets here if the first character was "%" for binary +; get binary number + +LAB_CBIN + JSR LAB_IGBY ; increment and scan memory + EOR #'0' ; convert "0" to 0 etc. + CMP #$02 ; compare with max+1 + BCC LAB_NXCH ; branch exit if < 2 + +LAB_EXCH + JMP LAB_28F6 ; evaluate -ve flag and return + +; ctrl-c check routine. includes limited "life" byte save for INGET routine +; now also the code that checks to see if an interrupt has occurred + +CTRLC + LDA ccflag ; get [CTRL-C] check flag + BNE LAB_FBA2 ; exit if inhibited + + JSR V_INPT ; scan input device + BCC LAB_FBA0 ; exit if buffer empty + + STA ccbyte ; save received byte + LDX #$20 ; "life" timer for bytes + STX ccnull ; set countdown + JMP LAB_1636 ; return to BASIC + +LAB_FBA0 + LDX ccnull ; get countdown byte + BEQ LAB_FBA2 ; exit if finished + + DEC ccnull ; else decrement countdown +LAB_FBA2 + LDX #NmiBase ; set pointer to NMI values + JSR LAB_CKIN ; go check interrupt + LDX #IrqBase ; set pointer to IRQ values + JSR LAB_CKIN ; go check interrupt +LAB_CRTS + RTS + +; check whichever interrupt is indexed by X + +LAB_CKIN + LDA PLUS_0,X ; get interrupt flag byte + BPL LAB_CRTS ; branch if interrupt not enabled + +; we disable the interrupt here and make two new commands RETIRQ and RETNMI to +; automatically enable the interrupt when we exit + + ASL ; move happened bit to setup bit + AND #$40 ; mask happened bits + BEQ LAB_CRTS ; if no interrupt then exit + + STA PLUS_0,X ; save interrupt flag byte + + TXA ; copy index .. + TAY ; .. to Y + + PLA ; dump return address low byte, call from CTRL-C + PLA ; dump return address high byte + + LDA #$05 ; need 5 bytes for GOSUB + JSR LAB_1212 ; check room on stack for A bytes + LDA Bpntrh ; get BASIC execute pointer high byte + PHA ; push on stack + LDA Bpntrl ; get BASIC execute pointer low byte + PHA ; push on stack + LDA Clineh ; get current line high byte + PHA ; push on stack + LDA Clinel ; get current line low byte + PHA ; push on stack + LDA #TK_GOSUB ; token for GOSUB + PHA ; push on stack + + LDA PLUS_1,Y ; get interrupt code pointer low byte + STA Bpntrl ; save as BASIC execute pointer low byte + LDA PLUS_2,Y ; get interrupt code pointer high byte + STA Bpntrh ; save as BASIC execute pointer high byte + + JMP LAB_15C2 ; go do interpreter inner loop + ; can't RTS, we used the stack! the RTS from the ctrl-c + ; check will be taken when the RETIRQ/RETNMI/RETURN is + ; executed at the end of the subroutine + +; get byte from input device, no waiting +; returns with carry set if byte in A + +INGET + JSR V_INPT ; call scan input device + BCS LAB_FB95 ; if byte go reset timer + + LDA ccnull ; get countdown + BEQ LAB_FB96 ; exit if empty + + LDA ccbyte ; get last received byte + SEC ; flag we got a byte +LAB_FB95 + LDX #$00 ; clear X + STX ccnull ; clear timer because we got a byte +LAB_FB96 + RTS + +; these routines only enable the interrupts if the set-up flag is set +; if not they have no effect + +; perform IRQ {ON|OFF|CLEAR} + +LAB_IRQ + LDX #IrqBase ; set pointer to IRQ values + .byte $2C ; make next line BIT abs. + +; perform NMI {ON|OFF|CLEAR} + +LAB_NMI + LDX #NmiBase ; set pointer to NMI values + CMP #TK_ON ; compare with token for ON + BEQ LAB_INON ; go turn on interrupt + + CMP #TK_OFF ; compare with token for OFF + BEQ LAB_IOFF ; go turn off interrupt + + EOR #TK_CLEAR ; compare with token for CLEAR, A = $00 if = TK_CLEAR + BEQ LAB_INEX ; go clear interrupt flags and return + + JMP LAB_SNER ; do syntax error then warm start + +LAB_IOFF + LDA #$7F ; clear A + AND PLUS_0,X ; AND with interrupt setup flag + BPL LAB_INEX ; go clear interrupt enabled flag and return + +LAB_INON + LDA PLUS_0,X ; get interrupt setup flag + ASL ; Shift bit to enabled flag + ORA PLUS_0,X ; OR with flag byte +LAB_INEX + STA PLUS_0,X ; save interrupt flag byte + JMP LAB_IGBY ; update BASIC execute pointer and return + +; these routines set up the pointers and flags for the interrupt routines +; note that the interrupts are also enabled by these commands + +; perform ON IRQ + +LAB_SIRQ + CLI ; enable interrupts + LDX #IrqBase ; set pointer to IRQ values + .byte $2C ; make next line BIT abs. + +; perform ON NMI + +LAB_SNMI + LDX #NmiBase ; set pointer to NMI values + + STX TempB ; save interrupt pointer + JSR LAB_IGBY ; increment and scan memory (past token) + JSR LAB_GFPN ; get fixed-point number into temp integer + LDA Smeml ; get start of mem low byte + LDX Smemh ; get start of mem high byte + JSR LAB_SHLN ; search Basic for temp integer line number from AX + BCS LAB_LFND ; if carry set go set-up interrupt + + JMP LAB_16F7 ; else go do "Undefined statement" error and warm start + +LAB_LFND + LDX TempB ; get interrupt pointer + LDA Baslnl ; get pointer low byte + SBC #$01 ; -1 (carry already set for subtract) + STA PLUS_1,X ; save as interrupt pointer low byte + LDA Baslnh ; get pointer high byte + SBC #$00 ; subtract carry + STA PLUS_2,X ; save as interrupt pointer high byte + + LDA #$C0 ; set interrupt enabled/setup bits + STA PLUS_0,X ; set interrupt flags +LAB_IRTS + RTS + +; return from IRQ service, restores the enabled flag. + +; perform RETIRQ + +LAB_RETIRQ + BNE LAB_IRTS ; exit if following token (to allow syntax error) + + LDA IrqBase ; get interrupt flags + ASL ; copy setup to enabled (b7) + ORA IrqBase ; OR in setup flag + STA IrqBase ; save enabled flag + JMP LAB_16E8 ; go do rest of RETURN + +; return from NMI service, restores the enabled flag. + +; perform RETNMI + +LAB_RETNMI + BNE LAB_IRTS ; exit if following token (to allow syntax error) + + LDA NmiBase ; get set-up flag + ASL ; copy setup to enabled (b7) + ORA NmiBase ; OR in setup flag + STA NmiBase ; save enabled flag + JMP LAB_16E8 ; go do rest of RETURN + +; MAX() MIN() pre process + +LAB_MMPP + JSR LAB_EVEZ ; process expression + JMP LAB_CTNM ; check if source is numeric, else do type mismatch + +; perform MAX() + +LAB_MAX + JSR LAB_PHFA ; push FAC1, evaluate expression, + ; pull FAC2 and compare with FAC1 + BPL LAB_MAX ; branch if no swap to do + + LDA FAC2_1 ; get FAC2 mantissa1 + ORA #$80 ; set top bit (clear sign from compare) + STA FAC2_1 ; save FAC2 mantissa1 + JSR LAB_279B ; copy FAC2 to FAC1 + BEQ LAB_MAX ; go do next (branch always) + +; perform MIN() + +LAB_MIN + JSR LAB_PHFA ; push FAC1, evaluate expression, + ; pull FAC2 and compare with FAC1 + BMI LAB_MIN ; branch if no swap to do + + BEQ LAB_MIN ; branch if no swap to do + + LDA FAC2_1 ; get FAC2 mantissa1 + ORA #$80 ; set top bit (clear sign from compare) + STA FAC2_1 ; save FAC2 mantissa1 + JSR LAB_279B ; copy FAC2 to FAC1 + BEQ LAB_MIN ; go do next (branch always) + +; exit routine. don't bother returning to the loop code +; check for correct exit, else so syntax error + +LAB_MMEC + CMP #')' ; is it end of function? + BNE LAB_MMSE ; if not do MAX MIN syntax error + + PLA ; dump return address low byte + PLA ; dump return address high byte + JMP LAB_IGBY ; update BASIC execute pointer (to chr past ")") + +LAB_MMSE + JMP LAB_SNER ; do syntax error then warm start + +; check for next, evaluate and return or exit +; this is the routine that does most of the work + +LAB_PHFA + JSR LAB_GBYT ; get next BASIC byte + CMP #',' ; is there more ? + BNE LAB_MMEC ; if not go do end check + + ; push FAC1 + JSR LAB_27BA ; round FAC1 + LDA FAC1_s ; get FAC1 sign + ORA #$7F ; set all non sign bits + AND FAC1_1 ; AND FAC1 mantissa1 (AND in sign bit) + PHA ; push on stack + LDA FAC1_2 ; get FAC1 mantissa2 + PHA ; push on stack + LDA FAC1_3 ; get FAC1 mantissa3 + PHA ; push on stack + LDA FAC1_e ; get FAC1 exponent + PHA ; push on stack + + JSR LAB_IGBY ; scan and get next BASIC byte (after ",") + JSR LAB_EVNM ; evaluate expression and check is numeric, + ; else do type mismatch + + ; pop FAC2 (MAX/MIN expression so far) + PLA ; pop exponent + STA FAC2_e ; save FAC2 exponent + PLA ; pop mantissa3 + STA FAC2_3 ; save FAC2 mantissa3 + PLA ; pop mantissa1 + STA FAC2_2 ; save FAC2 mantissa2 + PLA ; pop sign/mantissa1 + STA FAC2_1 ; save FAC2 sign/mantissa1 + STA FAC2_s ; save FAC2 sign + + ; compare FAC1 with (packed) FAC2 + LDA #FAC2_e ; set pointer high byte to FAC2 + JMP LAB_27F8 ; compare FAC1 with FAC2 (AY) and return + ; returns A=$00 if FAC1 = (AY) + ; returns A=$01 if FAC1 > (AY) + ; returns A=$FF if FAC1 < (AY) + +; perform WIDTH + +LAB_WDTH + CMP #',' ; is next byte "," + BEQ LAB_TBSZ ; if so do tab size + + JSR LAB_GTBY ; get byte parameter + TXA ; copy width to A + BEQ LAB_NSTT ; branch if set for infinite line + + CPX #$10 ; else make min width = 16d + BCC TabErr ; if less do function call error and exit + +; this next compare ensures that we can't exit WIDTH via an error leaving the +; tab size greater than the line length. + + CPX TabSiz ; compare with tab size + BCS LAB_NSTT ; branch if >= tab size + + STX TabSiz ; else make tab size = terminal width +LAB_NSTT + STX TWidth ; set the terminal width + JSR LAB_GBYT ; get BASIC byte back + BEQ WExit ; exit if no following + + CMP #',' ; else is it "," + BNE LAB_MMSE ; if not do syntax error + +LAB_TBSZ + JSR LAB_SGBY ; scan and get byte parameter + TXA ; copy TAB size + BMI TabErr ; if >127 do function call error and exit + + CPX #$01 ; compare with min-1 + BCC TabErr ; if <=1 do function call error and exit + + LDA TWidth ; set flags for width + BEQ LAB_SVTB ; skip check if infinite line + + CPX TWidth ; compare TAB with width + BEQ LAB_SVTB ; ok if = + + BCS TabErr ; branch if too big + +LAB_SVTB + STX TabSiz ; save TAB size + +; calculate tab column limit from TAB size. The Iclim is set to the last tab +; position on a line that still has at least one whole tab width between it +; and the end of the line. + +WExit + LDA TWidth ; get width + BEQ LAB_SULP ; branch if infinite line + + CMP TabSiz ; compare with tab size + BCS LAB_WDLP ; branch if >= tab size + + STA TabSiz ; else make tab size = terminal width +LAB_SULP + SEC ; set carry for subtract +LAB_WDLP + SBC TabSiz ; subtract tab size + BCS LAB_WDLP ; loop while no borrow + + ADC TabSiz ; add tab size back + CLC ; clear carry for add + ADC TabSiz ; add tab size back again + STA Iclim ; save for now + LDA TWidth ; get width back + SEC ; set carry for subtract + SBC Iclim ; subtract remainder + STA Iclim ; save tab column limit +LAB_NOSQ + RTS + +TabErr + JMP LAB_FCER ; do function call error then warm start + +; perform SQR() + +LAB_SQR + LDA FAC1_s ; get FAC1 sign + BMI TabErr ; if -ve do function call error + + LDA FAC1_e ; get exponent + BEQ LAB_NOSQ ; if zero just return + + ; else do root + JSR LAB_27AB ; round and copy FAC1 to FAC2 + LDA #$00 ; clear A + + STA FACt_3 ; clear remainder + STA FACt_2 ; .. + STA FACt_1 ; .. + STA TempB ; .. + + STA FAC1_3 ; clear root + STA FAC1_2 ; .. + STA FAC1_1 ; .. + + LDX #$18 ; 24 pairs of bits to do + LDA FAC2_e ; get exponent + LSR ; check odd/even + BCS LAB_SQE2 ; if odd only 1 shift first time + +LAB_SQE1 + ASL FAC2_3 ; shift highest bit of number .. + ROL FAC2_2 ; .. + ROL FAC2_1 ; .. + ROL FACt_3 ; .. into remainder + ROL FACt_2 ; .. + ROL FACt_1 ; .. + ROL TempB ; .. never overflows +LAB_SQE2 + ASL FAC2_3 ; shift highest bit of number .. + ROL FAC2_2 ; .. + ROL FAC2_1 ; .. + ROL FACt_3 ; .. into remainder + ROL FACt_2 ; .. + ROL FACt_1 ; .. + ROL TempB ; .. never overflows + + ASL FAC1_3 ; root = root * 2 + ROL FAC1_2 ; .. + ROL FAC1_1 ; .. never overflows + + LDA FAC1_3 ; get root low byte + ROL ; *2 + STA Temp3 ; save partial low byte + LDA FAC1_2 ; get root low mid byte + ROL ; *2 + STA Temp3+1 ; save partial low mid byte + LDA FAC1_1 ; get root high mid byte + ROL ; *2 + STA Temp3+2 ; save partial high mid byte + LDA #$00 ; get root high byte (always $00) + ROL ; *2 + STA Temp3+3 ; save partial high byte + + ; carry clear for subtract +1 + LDA FACt_3 ; get remainder low byte + SBC Temp3 ; subtract partial low byte + STA Temp3 ; save partial low byte + + LDA FACt_2 ; get remainder low mid byte + SBC Temp3+1 ; subtract partial low mid byte + STA Temp3+1 ; save partial low mid byte + + LDA FACt_1 ; get remainder high mid byte + SBC Temp3+2 ; subtract partial high mid byte + TAY ; copy partial high mid byte + + LDA TempB ; get remainder high byte + SBC Temp3+3 ; subtract partial high byte + BCC LAB_SQNS ; skip sub if remainder smaller + + STA TempB ; save remainder high byte + + STY FACt_1 ; save remainder high mid byte + + LDA Temp3+1 ; get remainder low mid byte + STA FACt_2 ; save remainder low mid byte + + LDA Temp3 ; get partial low byte + STA FACt_3 ; save remainder low byte + + INC FAC1_3 ; increment root low byte (never any rollover) +LAB_SQNS + DEX ; decrement bit pair count + BNE LAB_SQE1 ; loop if not all done + + SEC ; set carry for subtract + LDA FAC2_e ; get exponent + SBC #$80 ; normalise + ROR ; /2 and re-bias to $80 + ADC #$00 ; add bit zero back in (allow for half shift) + STA FAC1_e ; save it + JMP LAB_24D5 ; normalise FAC1 and return + +; perform VARPTR() + +LAB_VARPTR + JSR LAB_IGBY ; increment and scan memory + JSR LAB_GVAR ; get var address + JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start + LDY Cvaral ; get var address low byte + LDA Cvarah ; get var address high byte + JMP LAB_AYFC ; save and convert integer AY to FAC1 and return + +; perform PI + +LAB_PI + LDA #LAB_2C7C ; set (2*pi) pointer high byte + JSR LAB_UFAC ; unpack memory (AY) into FAC1 + DEC FAC1_e ; make result = PI + RTS + +; perform TWOPI + +LAB_TWOPI + LDA #LAB_2C7C ; set (2*pi) pointer high byte + JMP LAB_UFAC ; unpack memory (AY) into FAC1 and return + +; system dependant i/o vectors +; these are in RAM and are set by the monitor at start-up + +V_INPT + JMP (VEC_IN) ; non halting scan input device +V_OUTP + JMP (VEC_OUT) ; send byte to output device +V_LOAD + JMP (VEC_LD) ; load BASIC program +V_SAVE + JMP (VEC_SV) ; save BASIC program + +; The rest are tables messages and code for RAM + +; the rest of the code is tables and BASIC start-up code + +PG2_TABS + .byte $FF ; ctrl-c flag - $00 = enabled + .byte $00 ; ctrl-c byte - GET needs this + .byte $00 ; ctrl-c byte timeout - GET needs this + .word CTRLC ; ctrl c check vector + .word CHRIN ; non halting key input - monitor to set this + .word CHROUT ; output vector - monitor to set this +; .word xxxx ; load vector - monitor to set this +; .word xxxx ; save vector - monitor to set this +PG2_TABE + +; character get subroutine for zero page + +; For a 1.8432MHz 6502 including the JSR and RTS +; fastest (>=":") = 29 cycles = 15.7uS +; slowest (<":") = 40 cycles = 21.7uS +; space skip = +21 cycles = +11.4uS +; inc across page = +4 cycles = +2.2uS + +; the target address for the LDA at LAB_2CF4 becomes the BASIC execute pointer once the +; block is copied to it's destination, any non zero page address will do at assembly +; time, to assemble a three byte instruction. + +; page 0 initialisation table from $BC +; increment and scan memory + +LAB_2CEE + INC Bpntrl ; increment BASIC execute pointer low byte + BNE LAB_2CF4 ; branch if no carry + ; else + INC Bpntrh ; increment BASIC execute pointer high byte + +; page 0 initialisation table from $C2 +; scan memory + +LAB_2CF4 + LDA $FFFF ; get byte to scan (addr set by call routine) + CMP #TK_ELSE ; compare with the token for ELSE + BEQ LAB_2D05 ; exit if ELSE, not numeric, carry set + + CMP #':' ; compare with ":" + BCS LAB_2D05 ; exit if >= ":", not numeric, carry set + + CMP #' ' ; compare with " " + BEQ LAB_2CEE ; if " " go do next + + SEC ; set carry for SBC + SBC #'0' ; subtract "0" + SEC ; set carry for SBC + SBC #$D0 ; subtract -"0" + ; clear carry if byte = "0"-"9" +LAB_2D05 + RTS + +; page zero initialisation table $00-$12 inclusive + +StrTab + .byte $4C ; JMP opcode + .word LAB_COLD ; initial warm start vector (cold start) + + .byte $00 ; these bytes are not used by BASIC + .word $0000 ; + .word $0000 ; + .word $0000 ; + + .byte $4C ; JMP opcode + .word LAB_FCER ; initial user function vector ("Function call" error) + .byte $00 ; default NULL count + .byte $00 ; clear terminal position + .byte $00 ; default terminal width byte + .byte $F2 ; default limit for TAB = 14 + .word Ram_base ; start of user RAM +EndTab + +LAB_MSZM + .byte $0D,$0A,"Memory size ",$00 + +LAB_SMSG + .byte " Bytes free",$0D,$0A,$0A + .byte "Enhanced BASIC 2.22",$0A,$00 + +; numeric constants and series + + ; constants and series for LOG(n) +LAB_25A0 + .byte $02 ; counter + .byte $80,$19,$56,$62 ; 0.59898 + .byte $80,$76,$22,$F3 ; 0.96147 +;## .byte $80,$76,$22,$F1 ; 0.96147 + .byte $82,$38,$AA,$40 ; 2.88539 +;## .byte $82,$38,$AA,$45 ; 2.88539 + +LAB_25AD + .byte $80,$35,$04,$F3 ; 0.70711 1/root 2 +LAB_25B1 + .byte $81,$35,$04,$F3 ; 1.41421 root 2 +LAB_25B5 + .byte $80,$80,$00,$00 ; -0.5 +LAB_25B9 + .byte $80,$31,$72,$18 ; 0.69315 LOG(2) + + ; numeric PRINT constants +LAB_2947 + .byte $91,$43,$4F,$F8 ; 99999.9375 (max value with at least one decimal) +LAB_294B + .byte $94,$74,$23,$F7 ; 999999.4375 (max value before scientific notation) +LAB_294F + .byte $94,$74,$24,$00 ; 1000000 + + ; EXP(n) constants and series +LAB_2AFA + .byte $81,$38,$AA,$3B ; 1.4427 (1/LOG base 2 e) +LAB_2AFE + .byte $06 ; counter + .byte $74,$63,$90,$8C ; 2.17023e-4 + .byte $77,$23,$0C,$AB ; 0.00124 + .byte $7A,$1E,$94,$00 ; 0.00968 + .byte $7C,$63,$42,$80 ; 0.05548 + .byte $7E,$75,$FE,$D0 ; 0.24023 + .byte $80,$31,$72,$15 ; 0.69315 + .byte $81,$00,$00,$00 ; 1.00000 + +;## .byte $07 ; counter +;## .byte $74,$94,$2E,$40 ; -1/7! (-1/5040) +;## .byte $77,$2E,$4F,$70 ; 1/6! ( 1/720) +;## .byte $7A,$88,$02,$6E ; -1/5! (-1/120) +;## .byte $7C,$2A,$A0,$E6 ; 1/4! ( 1/24) +;## .byte $7E,$AA,$AA,$50 ; -1/3! (-1/6) +;## .byte $7F,$7F,$FF,$FF ; 1/2! ( 1/2) +;## .byte $81,$80,$00,$00 ; -1/1! (-1/1) +;## .byte $81,$00,$00,$00 ; 1/0! ( 1/1) + + ; trigonometric constants and series +LAB_2C78 + .byte $81,$49,$0F,$DB ; 1.570796371 (pi/2) as floating # +LAB_2C84 + .byte $04 ; counter + .byte $86,$1E,$D7,$FB ; 39.7109 +;## .byte $86,$1E,$D7,$BA ; 39.7109 + .byte $87,$99,$26,$65 ;-76.575 +;## .byte $87,$99,$26,$64 ;-76.575 + .byte $87,$23,$34,$58 ; 81.6022 + .byte $86,$A5,$5D,$E1 ;-41.3417 +;## .byte $86,$A5,$5D,$E0 ;-41.3417 +LAB_2C7C + .byte $83,$49,$0F,$DB ; 6.28319 (2*pi) as floating # +;## .byte $83,$49,$0F,$DA ; 6.28319 (2*pi) as floating # + +LAB_2CC9 + .byte $08 ; counter + .byte $78,$3A,$C5,$37 ; 0.00285 + .byte $7B,$83,$A2,$5C ;-0.0160686 + .byte $7C,$2E,$DD,$4D ; 0.0426915 + .byte $7D,$99,$B0,$1E ;-0.0750429 + .byte $7D,$59,$ED,$24 ; 0.106409 + .byte $7E,$91,$72,$00 ;-0.142036 + .byte $7E,$4C,$B9,$73 ; 0.199926 + .byte $7F,$AA,$AA,$53 ;-0.333331 + +;## .byte $08 ; counter +;## .byte $78,$3B,$D7,$4A ; 1/17 +;## .byte $7B,$84,$6E,$02 ;-1/15 +;## .byte $7C,$2F,$C1,$FE ; 1/13 +;## .byte $7D,$9A,$31,$74 ;-1/11 +;## .byte $7D,$5A,$3D,$84 ; 1/9 +;## .byte $7E,$91,$7F,$C8 ;-1/7 +;## .byte $7E,$4C,$BB,$E4 ; 1/5 +;## .byte $7F,$AA,$AA,$6C ;-1/3 + +LAB_1D96 = *+1 ; $00,$00 used for undefined variables +LAB_259C + .byte $81,$00,$00,$00 ; 1.000000, used for INC +LAB_2AFD + .byte $81,$80,$00,$00 ; -1.00000, used for DEC. must be on the same page as +1.00 + + ; misc constants +LAB_1DF7 + .byte $90 ;-32768 (uses first three bytes from 0.5) +LAB_2A96 + .byte $80,$00,$00,$00 ; 0.5 +LAB_2C80 + .byte $7F,$00,$00,$00 ; 0.25 +LAB_26B5 + .byte $84,$20,$00,$00 ; 10.0000 divide by 10 constant + +; This table is used in converting numbers to ASCII. + +LAB_2A9A +LAB_2A9B = LAB_2A9A+1 +LAB_2A9C = LAB_2A9B+1 + .byte $FE,$79,$60 ; -100000 + .byte $00,$27,$10 ; 10000 + .byte $FF,$FC,$18 ; -1000 + .byte $00,$00,$64 ; 100 + .byte $FF,$FF,$F6 ; -10 + .byte $00,$00,$01 ; 1 + +LAB_CTBL + .word LAB_END-1 ; END + .word LAB_FOR-1 ; FOR + .word LAB_NEXT-1 ; NEXT + .word LAB_DATA-1 ; DATA + .word LAB_INPUT-1 ; INPUT + .word LAB_DIM-1 ; DIM + .word LAB_READ-1 ; READ + .word LAB_LET-1 ; LET + .word LAB_DEC-1 ; DEC new command + .word LAB_GOTO-1 ; GOTO + .word LAB_RUN-1 ; RUN + .word LAB_IF-1 ; IF + .word LAB_RESTORE-1 ; RESTORE modified command + .word LAB_GOSUB-1 ; GOSUB + .word LAB_RETIRQ-1 ; RETIRQ new command + .word LAB_RETNMI-1 ; RETNMI new command + .word LAB_RETURN-1 ; RETURN + .word LAB_REM-1 ; REM + .word LAB_STOP-1 ; STOP + .word LAB_ON-1 ; ON modified command + .word LAB_NULL-1 ; NULL modified command + .word LAB_INC-1 ; INC new command + .word LAB_WAIT-1 ; WAIT + .word V_LOAD-1 ; LOAD + .word V_SAVE-1 ; SAVE + .word LAB_DEF-1 ; DEF + .word LAB_POKE-1 ; POKE + .word LAB_DOKE-1 ; DOKE new command + .word LAB_CALL-1 ; CALL new command + .word LAB_DO-1 ; DO new command + .word LAB_LOOP-1 ; LOOP new command + .word LAB_PRINT-1 ; PRINT + .word LAB_CONT-1 ; CONT + .word LAB_LIST-1 ; LIST + .word LAB_CLEAR-1 ; CLEAR + .word LAB_NEW-1 ; NEW + .word LAB_WDTH-1 ; WIDTH new command + .word LAB_GET-1 ; GET new command + .word LAB_SWAP-1 ; SWAP new command + .word LAB_BITSET-1 ; BITSET new command + .word LAB_BITCLR-1 ; BITCLR new command + .word LAB_IRQ-1 ; IRQ new command + .word LAB_NMI-1 ; NMI new command + +; function pre process routine table + +LAB_FTPL +LAB_FTPM = LAB_FTPL+$01 + .word LAB_PPFN-1 ; SGN(n) process numeric expression in () + .word LAB_PPFN-1 ; INT(n) " + .word LAB_PPFN-1 ; ABS(n) " + .word LAB_EVEZ-1 ; USR(x) process any expression + .word LAB_1BF7-1 ; FRE(x) " + .word LAB_1BF7-1 ; POS(x) " + .word LAB_PPFN-1 ; SQR(n) process numeric expression in () + .word LAB_PPFN-1 ; RND(n) " + .word LAB_PPFN-1 ; LOG(n) " + .word LAB_PPFN-1 ; EXP(n) " + .word LAB_PPFN-1 ; COS(n) " + .word LAB_PPFN-1 ; SIN(n) " + .word LAB_PPFN-1 ; TAN(n) " + .word LAB_PPFN-1 ; ATN(n) " + .word LAB_PPFN-1 ; PEEK(n) " + .word LAB_PPFN-1 ; DEEK(n) " + .word $0000 ; SADD() none + .word LAB_PPFS-1 ; LEN($) process string expression in () + .word LAB_PPFN-1 ; STR$(n) process numeric expression in () + .word LAB_PPFS-1 ; VAL($) process string expression in () + .word LAB_PPFS-1 ; ASC($) " + .word LAB_PPFS-1 ; UCASE$($) " + .word LAB_PPFS-1 ; LCASE$($) " + .word LAB_PPFN-1 ; CHR$(n) process numeric expression in () + .word LAB_BHSS-1 ; HEX$(n) " + .word LAB_BHSS-1 ; BIN$(n) " + .word $0000 ; BITTST() none + .word LAB_MMPP-1 ; MAX() process numeric expression + .word LAB_MMPP-1 ; MIN() " + .word LAB_PPBI-1 ; PI advance pointer + .word LAB_PPBI-1 ; TWOPI " + .word $0000 ; VARPTR() none + .word LAB_LRMS-1 ; LEFT$() process string expression + .word LAB_LRMS-1 ; RIGHT$() " + .word LAB_LRMS-1 ; MID$() " + +; action addresses for functions + +LAB_FTBL +LAB_FTBM = LAB_FTBL+$01 + .word LAB_SGN-1 ; SGN() + .word LAB_INT-1 ; INT() + .word LAB_ABS-1 ; ABS() + .word LAB_USR-1 ; USR() + .word LAB_FRE-1 ; FRE() + .word LAB_POS-1 ; POS() + .word LAB_SQR-1 ; SQR() + .word LAB_RND-1 ; RND() modified function + .word LAB_LOG-1 ; LOG() + .word LAB_EXP-1 ; EXP() + .word LAB_COS-1 ; COS() + .word LAB_SIN-1 ; SIN() + .word LAB_TAN-1 ; TAN() + .word LAB_ATN-1 ; ATN() + .word LAB_PEEK-1 ; PEEK() + .word LAB_DEEK-1 ; DEEK() new function + .word LAB_SADD-1 ; SADD() new function + .word LAB_LENS-1 ; LEN() + .word LAB_STRS-1 ; STR$() + .word LAB_VAL-1 ; VAL() + .word LAB_ASC-1 ; ASC() + .word LAB_UCASE-1 ; UCASE$() new function + .word LAB_LCASE-1 ; LCASE$() new function + .word LAB_CHRS-1 ; CHR$() + .word LAB_HEXS-1 ; HEX$() new function + .word LAB_BINS-1 ; BIN$() new function + .word LAB_BTST-1 ; BITTST() new function + .word LAB_MAX-1 ; MAX() new function + .word LAB_MIN-1 ; MIN() new function + .word LAB_PI-1 ; PI new function + .word LAB_TWOPI-1 ; TWOPI new function + .word LAB_VARPTR-1 ; VARPTR() new function + .word LAB_LEFT-1 ; LEFT$() + .word LAB_RIGHT-1 ; RIGHT$() + .word LAB_MIDS-1 ; MID$() + +; hierarchy and action addresses for operator + +LAB_OPPT + .byte $79 ; + + .word LAB_ADD-1 + .byte $79 ; - + .word LAB_SUBTRACT-1 + .byte $7B ; * + .word LAB_MULTIPLY-1 + .byte $7B ; / + .word LAB_DIVIDE-1 + .byte $7F ; ^ + .word LAB_POWER-1 + .byte $50 ; AND + .word LAB_AND-1 + .byte $46 ; EOR new operator + .word LAB_EOR-1 + .byte $46 ; OR + .word LAB_OR-1 + .byte $56 ; >> new operator + .word LAB_RSHIFT-1 + .byte $56 ; << new operator + .word LAB_LSHIFT-1 + .byte $7D ; > + .word LAB_GTHAN-1 + .byte $5A ; = + .word LAB_EQUAL-1 + .byte $64 ; < + .word LAB_LTHAN-1 + +; keywords start with .. +; this is the first character table and must be in alphabetic order + +TAB_1STC + .byte "*" + .byte "+" + .byte "-" + .byte "/" + .byte "<" + .byte "=" + .byte ">" + .byte "?" + .byte "A" + .byte "B" + .byte "C" + .byte "D" + .byte "E" + .byte "F" + .byte "G" + .byte "H" + .byte "I" + .byte "L" + .byte "M" + .byte "N" + .byte "O" + .byte "P" + .byte "R" + .byte "S" + .byte "T" + .byte "U" + .byte "V" + .byte "W" + .byte "^" + .byte $00 ; table terminator + +; pointers to keyword tables + +TAB_CHRT + .word TAB_STAR ; table for "*" + .word TAB_PLUS ; table for "+" + .word TAB_MNUS ; table for "-" + .word TAB_SLAS ; table for "/" + .word TAB_LESS ; table for "<" + .word TAB_EQUL ; table for "=" + .word TAB_MORE ; table for ">" + .word TAB_QEST ; table for "?" + .word TAB_ASCA ; table for "A" + .word TAB_ASCB ; table for "B" + .word TAB_ASCC ; table for "C" + .word TAB_ASCD ; table for "D" + .word TAB_ASCE ; table for "E" + .word TAB_ASCF ; table for "F" + .word TAB_ASCG ; table for "G" + .word TAB_ASCH ; table for "H" + .word TAB_ASCI ; table for "I" + .word TAB_ASCL ; table for "L" + .word TAB_ASCM ; table for "M" + .word TAB_ASCN ; table for "N" + .word TAB_ASCO ; table for "O" + .word TAB_ASCP ; table for "P" + .word TAB_ASCR ; table for "R" + .word TAB_ASCS ; table for "S" + .word TAB_ASCT ; table for "T" + .word TAB_ASCU ; table for "U" + .word TAB_ASCV ; table for "V" + .word TAB_ASCW ; table for "W" + .word TAB_POWR ; table for "^" + +; tables for each start character, note if a longer keyword with the same start +; letters as a shorter one exists then it must come first, else the list is in +; alphabetical order as follows .. + +; [keyword,token +; [keyword,token]] +; end marker (#$00) + +TAB_STAR + .byte TK_MUL,$00 ; * +TAB_PLUS + .byte TK_PLUS,$00 ; + +TAB_MNUS + .byte TK_MINUS,$00 ; - +TAB_SLAS + .byte TK_DIV,$00 ; / +TAB_LESS +LBB_LSHIFT + .byte "<",TK_LSHIFT ; << note - "<<" must come before "<" + .byte TK_LT ; < + .byte $00 +TAB_EQUL + .byte TK_EQUAL,$00 ; = +TAB_MORE +LBB_RSHIFT + .byte ">",TK_RSHIFT ; >> note - ">>" must come before ">" + .byte TK_GT ; > + .byte $00 +TAB_QEST + .byte TK_PRINT,$00 ; ? +TAB_ASCA +LBB_ABS + .byte "BS(",TK_ABS ; ABS( +LBB_AND + .byte "ND",TK_AND ; AND +LBB_ASC + .byte "SC(",TK_ASC ; ASC( +LBB_ATN + .byte "TN(",TK_ATN ; ATN( + .byte $00 +TAB_ASCB +LBB_BINS + .byte "IN$(",TK_BINS ; BIN$( +LBB_BITCLR + .byte "ITCLR",TK_BITCLR ; BITCLR +LBB_BITSET + .byte "ITSET",TK_BITSET ; BITSET +LBB_BITTST + .byte "ITTST(",TK_BITTST + ; BITTST( + .byte $00 +TAB_ASCC +LBB_CALL + .byte "ALL",TK_CALL ; CALL +LBB_CHRS + .byte "HR$(",TK_CHRS ; CHR$( +LBB_CLEAR + .byte "LEAR",TK_CLEAR ; CLEAR +LBB_CONT + .byte "ONT",TK_CONT ; CONT +LBB_COS + .byte "OS(",TK_COS ; COS( + .byte $00 +TAB_ASCD +LBB_DATA + .byte "ATA",TK_DATA ; DATA +LBB_DEC + .byte "EC",TK_DEC ; DEC +LBB_DEEK + .byte "EEK(",TK_DEEK ; DEEK( +LBB_DEF + .byte "EF",TK_DEF ; DEF +LBB_DIM + .byte "IM",TK_DIM ; DIM +LBB_DOKE + .byte "OKE",TK_DOKE ; DOKE note - "DOKE" must come before "DO" +LBB_DO + .byte "O",TK_DO ; DO + .byte $00 +TAB_ASCE +LBB_ELSE + .byte "LSE",TK_ELSE ; ELSE +LBB_END + .byte "ND",TK_END ; END +LBB_EOR + .byte "OR",TK_EOR ; EOR +LBB_EXP + .byte "XP(",TK_EXP ; EXP( + .byte $00 +TAB_ASCF +LBB_FN + .byte "N",TK_FN ; FN +LBB_FOR + .byte "OR",TK_FOR ; FOR +LBB_FRE + .byte "RE(",TK_FRE ; FRE( + .byte $00 +TAB_ASCG +LBB_GET + .byte "ET",TK_GET ; GET +LBB_GOSUB + .byte "OSUB",TK_GOSUB ; GOSUB +LBB_GOTO + .byte "OTO",TK_GOTO ; GOTO + .byte $00 +TAB_ASCH +LBB_HEXS + .byte "EX$(",TK_HEXS ; HEX$( + .byte $00 +TAB_ASCI +LBB_IF + .byte "F",TK_IF ; IF +LBB_INC + .byte "NC",TK_INC ; INC +LBB_INPUT + .byte "NPUT",TK_INPUT ; INPUT +LBB_INT + .byte "NT(",TK_INT ; INT( +LBB_IRQ + .byte "RQ",TK_IRQ ; IRQ + .byte $00 +TAB_ASCL +LBB_LCASES + .byte "CASE$(",TK_LCASES + ; LCASE$( +LBB_LEFTS + .byte "EFT$(",TK_LEFTS ; LEFT$( +LBB_LEN + .byte "EN(",TK_LEN ; LEN( +LBB_LET + .byte "ET",TK_LET ; LET +LBB_LIST + .byte "IST",TK_LIST ; LIST +LBB_LOAD + .byte "OAD",TK_LOAD ; LOAD +LBB_LOG + .byte "OG(",TK_LOG ; LOG( +LBB_LOOP + .byte "OOP",TK_LOOP ; LOOP + .byte $00 +TAB_ASCM +LBB_MAX + .byte "AX(",TK_MAX ; MAX( +LBB_MIDS + .byte "ID$(",TK_MIDS ; MID$( +LBB_MIN + .byte "IN(",TK_MIN ; MIN( + .byte $00 +TAB_ASCN +LBB_NEW + .byte "EW",TK_NEW ; NEW +LBB_NEXT + .byte "EXT",TK_NEXT ; NEXT +LBB_NMI + .byte "MI",TK_NMI ; NMI +LBB_NOT + .byte "OT",TK_NOT ; NOT +LBB_NULL + .byte "ULL",TK_NULL ; NULL + .byte $00 +TAB_ASCO +LBB_OFF + .byte "FF",TK_OFF ; OFF +LBB_ON + .byte "N",TK_ON ; ON +LBB_OR + .byte "R",TK_OR ; OR + .byte $00 +TAB_ASCP +LBB_PEEK + .byte "EEK(",TK_PEEK ; PEEK( +LBB_PI + .byte "I",TK_PI ; PI +LBB_POKE + .byte "OKE",TK_POKE ; POKE +LBB_POS + .byte "OS(",TK_POS ; POS( +LBB_PRINT + .byte "RINT",TK_PRINT ; PRINT + .byte $00 +TAB_ASCR +LBB_READ + .byte "EAD",TK_READ ; READ +LBB_REM + .byte "EM",TK_REM ; REM +LBB_RESTORE + .byte "ESTORE",TK_RESTORE + ; RESTORE +LBB_RETIRQ + .byte "ETIRQ",TK_RETIRQ ; RETIRQ +LBB_RETNMI + .byte "ETNMI",TK_RETNMI ; RETNMI +LBB_RETURN + .byte "ETURN",TK_RETURN ; RETURN +LBB_RIGHTS + .byte "IGHT$(",TK_RIGHTS + ; RIGHT$( +LBB_RND + .byte "ND(",TK_RND ; RND( +LBB_RUN + .byte "UN",TK_RUN ; RUN + .byte $00 +TAB_ASCS +LBB_SADD + .byte "ADD(",TK_SADD ; SADD( +LBB_SAVE + .byte "AVE",TK_SAVE ; SAVE +LBB_SGN + .byte "GN(",TK_SGN ; SGN( +LBB_SIN + .byte "IN(",TK_SIN ; SIN( +LBB_SPC + .byte "PC(",TK_SPC ; SPC( +LBB_SQR + .byte "QR(",TK_SQR ; SQR( +LBB_STEP + .byte "TEP",TK_STEP ; STEP +LBB_STOP + .byte "TOP",TK_STOP ; STOP +LBB_STRS + .byte "TR$(",TK_STRS ; STR$( +LBB_SWAP + .byte "WAP",TK_SWAP ; SWAP + .byte $00 +TAB_ASCT +LBB_TAB + .byte "AB(",TK_TAB ; TAB( +LBB_TAN + .byte "AN(",TK_TAN ; TAN( +LBB_THEN + .byte "HEN",TK_THEN ; THEN +LBB_TO + .byte "O",TK_TO ; TO +LBB_TWOPI + .byte "WOPI",TK_TWOPI ; TWOPI + .byte $00 +TAB_ASCU +LBB_UCASES + .byte "CASE$(",TK_UCASES + ; UCASE$( +LBB_UNTIL + .byte "NTIL",TK_UNTIL ; UNTIL +LBB_USR + .byte "SR(",TK_USR ; USR( + .byte $00 +TAB_ASCV +LBB_VAL + .byte "AL(",TK_VAL ; VAL( +LBB_VPTR + .byte "ARPTR(",TK_VPTR ; VARPTR( + .byte $00 +TAB_ASCW +LBB_WAIT + .byte "AIT",TK_WAIT ; WAIT +LBB_WHILE + .byte "HILE",TK_WHILE ; WHILE +LBB_WIDTH + .byte "IDTH",TK_WIDTH ; WIDTH + .byte $00 +TAB_POWR + .byte TK_POWER,$00 ; ^ + +; new decode table for LIST +; Table is .. +; byte - keyword length, keyword first character +; word - pointer to rest of keyword from dictionary + +; note if length is 1 then the pointer is ignored + +LAB_KEYT + .byte 3,'E' + .word LBB_END ; END + .byte 3,'F' + .word LBB_FOR ; FOR + .byte 4,'N' + .word LBB_NEXT ; NEXT + .byte 4,'D' + .word LBB_DATA ; DATA + .byte 5,'I' + .word LBB_INPUT ; INPUT + .byte 3,'D' + .word LBB_DIM ; DIM + .byte 4,'R' + .word LBB_READ ; READ + .byte 3,'L' + .word LBB_LET ; LET + .byte 3,'D' + .word LBB_DEC ; DEC + .byte 4,'G' + .word LBB_GOTO ; GOTO + .byte 3,'R' + .word LBB_RUN ; RUN + .byte 2,'I' + .word LBB_IF ; IF + .byte 7,'R' + .word LBB_RESTORE ; RESTORE + .byte 5,'G' + .word LBB_GOSUB ; GOSUB + .byte 6,'R' + .word LBB_RETIRQ ; RETIRQ + .byte 6,'R' + .word LBB_RETNMI ; RETNMI + .byte 6,'R' + .word LBB_RETURN ; RETURN + .byte 3,'R' + .word LBB_REM ; REM + .byte 4,'S' + .word LBB_STOP ; STOP + .byte 2,'O' + .word LBB_ON ; ON + .byte 4,'N' + .word LBB_NULL ; NULL + .byte 3,'I' + .word LBB_INC ; INC + .byte 4,'W' + .word LBB_WAIT ; WAIT + .byte 4,'L' + .word LBB_LOAD ; LOAD + .byte 4,'S' + .word LBB_SAVE ; SAVE + .byte 3,'D' + .word LBB_DEF ; DEF + .byte 4,'P' + .word LBB_POKE ; POKE + .byte 4,'D' + .word LBB_DOKE ; DOKE + .byte 4,'C' + .word LBB_CALL ; CALL + .byte 2,'D' + .word LBB_DO ; DO + .byte 4,'L' + .word LBB_LOOP ; LOOP + .byte 5,'P' + .word LBB_PRINT ; PRINT + .byte 4,'C' + .word LBB_CONT ; CONT + .byte 4,'L' + .word LBB_LIST ; LIST + .byte 5,'C' + .word LBB_CLEAR ; CLEAR + .byte 3,'N' + .word LBB_NEW ; NEW + .byte 5,'W' + .word LBB_WIDTH ; WIDTH + .byte 3,'G' + .word LBB_GET ; GET + .byte 4,'S' + .word LBB_SWAP ; SWAP + .byte 6,'B' + .word LBB_BITSET ; BITSET + .byte 6,'B' + .word LBB_BITCLR ; BITCLR + .byte 3,'I' + .word LBB_IRQ ; IRQ + .byte 3,'N' + .word LBB_NMI ; NMI + +; secondary commands (can't start a statement) + + .byte 4,'T' + .word LBB_TAB ; TAB + .byte 4,'E' + .word LBB_ELSE ; ELSE + .byte 2,'T' + .word LBB_TO ; TO + .byte 2,'F' + .word LBB_FN ; FN + .byte 4,'S' + .word LBB_SPC ; SPC + .byte 4,'T' + .word LBB_THEN ; THEN + .byte 3,'N' + .word LBB_NOT ; NOT + .byte 4,'S' + .word LBB_STEP ; STEP + .byte 5,'U' + .word LBB_UNTIL ; UNTIL + .byte 5,'W' + .word LBB_WHILE ; WHILE + .byte 3,'O' + .word LBB_OFF ; OFF + +; opperators + + .byte 1,'+' + .word $0000 ; + + .byte 1,'-' + .word $0000 ; - + .byte 1,'*' + .word $0000 ; * + .byte 1,'/' + .word $0000 ; / + .byte 1,'^' + .word $0000 ; ^ + .byte 3,'A' + .word LBB_AND ; AND + .byte 3,'E' + .word LBB_EOR ; EOR + .byte 2,'O' + .word LBB_OR ; OR + .byte 2,'>' + .word LBB_RSHIFT ; >> + .byte 2,'<' + .word LBB_LSHIFT ; << + .byte 1,'>' + .word $0000 ; > + .byte 1,'=' + .word $0000 ; = + .byte 1,'<' + .word $0000 ; < + +; functions + + .byte 4,'S' ; + .word LBB_SGN ; SGN + .byte 4,'I' ; + .word LBB_INT ; INT + .byte 4,'A' ; + .word LBB_ABS ; ABS + .byte 4,'U' ; + .word LBB_USR ; USR + .byte 4,'F' ; + .word LBB_FRE ; FRE + .byte 4,'P' ; + .word LBB_POS ; POS + .byte 4,'S' ; + .word LBB_SQR ; SQR + .byte 4,'R' ; + .word LBB_RND ; RND + .byte 4,'L' ; + .word LBB_LOG ; LOG + .byte 4,'E' ; + .word LBB_EXP ; EXP + .byte 4,'C' ; + .word LBB_COS ; COS + .byte 4,'S' ; + .word LBB_SIN ; SIN + .byte 4,'T' ; + .word LBB_TAN ; TAN + .byte 4,'A' ; + .word LBB_ATN ; ATN + .byte 5,'P' ; + .word LBB_PEEK ; PEEK + .byte 5,'D' ; + .word LBB_DEEK ; DEEK + .byte 5,'S' ; + .word LBB_SADD ; SADD + .byte 4,'L' ; + .word LBB_LEN ; LEN + .byte 5,'S' ; + .word LBB_STRS ; STR$ + .byte 4,'V' ; + .word LBB_VAL ; VAL + .byte 4,'A' ; + .word LBB_ASC ; ASC + .byte 7,'U' ; + .word LBB_UCASES ; UCASE$ + .byte 7,'L' ; + .word LBB_LCASES ; LCASE$ + .byte 5,'C' ; + .word LBB_CHRS ; CHR$ + .byte 5,'H' ; + .word LBB_HEXS ; HEX$ + .byte 5,'B' ; + .word LBB_BINS ; BIN$ + .byte 7,'B' ; + .word LBB_BITTST ; BITTST + .byte 4,'M' ; + .word LBB_MAX ; MAX + .byte 4,'M' ; + .word LBB_MIN ; MIN + .byte 2,'P' ; + .word LBB_PI ; PI + .byte 5,'T' ; + .word LBB_TWOPI ; TWOPI + .byte 7,'V' ; + .word LBB_VPTR ; VARPTR + .byte 6,'L' ; + .word LBB_LEFTS ; LEFT$ + .byte 7,'R' ; + .word LBB_RIGHTS ; RIGHT$ + .byte 5,'M' ; + .word LBB_MIDS ; MID$ + +; BASIC messages, mostly error messages + +LAB_BAER + .word ERR_NF ;$00 NEXT without FOR + .word ERR_SN ;$02 syntax + .word ERR_RG ;$04 RETURN without GOSUB + .word ERR_OD ;$06 out of data + .word ERR_FC ;$08 function call + .word ERR_OV ;$0A overflow + .word ERR_OM ;$0C out of memory + .word ERR_US ;$0E undefined statement + .word ERR_BS ;$10 array bounds + .word ERR_DD ;$12 double dimension array + .word ERR_D0 ;$14 divide by 0 + .word ERR_ID ;$16 illegal direct + .word ERR_TM ;$18 type mismatch + .word ERR_LS ;$1A long string + .word ERR_ST ;$1C string too complex + .word ERR_CN ;$1E continue error + .word ERR_UF ;$20 undefined function + .word ERR_LD ;$22 LOOP without DO + +; I may implement these two errors to force definition of variables and +; dimensioning of arrays before use. + +; .word ERR_UV ;$24 undefined variable + +; the above error has been tested and works (see code and comments below LAB_1D8B) + +; .word ERR_UA ;$26 undimensioned array + +ERR_NF .byte "NEXT without FOR",$00 +ERR_SN .byte "Syntax",$00 +ERR_RG .byte "RETURN without GOSUB",$00 +ERR_OD .byte "Out of DATA",$00 +ERR_FC .byte "Function call",$00 +ERR_OV .byte "Overflow",$00 +ERR_OM .byte "Out of memory",$00 +ERR_US .byte "Undefined statement",$00 +ERR_BS .byte "Array bounds",$00 +ERR_DD .byte "Double dimension",$00 +ERR_D0 .byte "Divide by zero",$00 +ERR_ID .byte "Illegal direct",$00 +ERR_TM .byte "Type mismatch",$00 +ERR_LS .byte "String too long",$00 +ERR_ST .byte "String too complex",$00 +ERR_CN .byte "Can't continue",$00 +ERR_UF .byte "Undefined function",$00 +ERR_LD .byte "LOOP without DO",$00 + +;ERR_UV .byte "Undefined variable",$00 + +; the above error has been tested and works (see code and comments below LAB_1D8B) + +;ERR_UA .byte "Undimensioned array",$00 + +LAB_BMSG .byte $0D,$0A,"Break",$00 +LAB_EMSG .byte " Error",$00 +LAB_LMSG .byte " in line ",$00 +LAB_RMSG .byte $0D,$0A,"Ready",$0D,$0A,$00 + +LAB_IMSG .byte " Extra ignored",$0D,$0A,$00 +LAB_REDO .byte " Redo from start",$0D,$0A,$00 + +AA_end_basic diff --git a/ehbas.dat b/ehbas.dat index df282a4..6c74266 100644 --- a/ehbas.dat +++ b/ehbas.dat @@ -1,2064 +1,2064 @@ -; Program disassembly from $C000 to $FFDF 3/4/2016 -; EhBasic image for MKBASIC 6502 simulator. -; -ORG -$C000 -; Char IO -IOADDR -$FFE0 -; ROM -ROMBEGIN -$FFC0 -ROMEND -$FFDF -; Enable char IO and ROM -ENIO -ENROM -; Auto-execute -EXEC -$C000 -; Data/Code -$D8, $A0, $08, $B9, $FB, $E0, $99, $00 -$02, $88, $10, $F7, $A2, $FF, $8E, $21 -$02, $86, $88, $9A, $A9, $4C, $85, $A1 -$A2, $1C, $BD, $03, $E1, $95, $BB, $CA -$D0, $F8, $A2, $12, $BD, $20, $E1, $95 -$00, $CA, $10, $F8, $A9, $00, $85, $DC -$85, $DF, $85, $B2, $85, $67, $A9, $0E -$85, $64, $A9, $03, $85, $A0, $A2, $68 -$86, $65, $20, $97, $C8, $A9, $33, $A0 -$E1, $20, $D8, $C8, $20, $45, $C2, $86 -$C3, $84, $C4, $20, $C2, $00, $D0, $1F -$A0, $00, $E6, $11, $D0, $08, $E6, $12 -$A5, $12, $C9, $C0, $F0, $1D, $A9, $55 -$91, $11, $D1, $11, $D0, $15, $0A, $91 -$11, $D1, $11, $F0, $E5, $D0, $0C, $20 -$AB, $D9, $A5, $AC, $C9, $98, $B0, $A2 -$20, $FC, $D4, $A5, $11, $A4, $12, $C0 -$01, $90, $97, $85, $85, $84, $86, $85 -$81, $84, $82, $A0, $00, $A2, $03, $84 -$79, $86, $7A, $98, $91, $79, $E6, $79 -$20, $97, $C8, $20, $55, $C3, $A5, $85 -$38, $E5, $79, $AA, $A5, $86, $E5, $7A -$20, $87, $DA, $A9, $42, $A0, $E1, $20 -$D8, $C8, $A9, $5E, $A0, $C1, $85, $01 -$84, $02, $6C, $01, $00, $20, $0F, $C1 -$85, $7F, $84, $80, $38, $A5, $A6, $E5 -$AA, $A8, $A5, $A7, $E5, $AB, $AA, $E8 -$98, $F0, $24, $38, $49, $FF, $65, $A6 -$85, $A6, $B0, $03, $C6, $A7, $38, $98 -$49, $FF, $65, $A4, $85, $A4, $B0, $08 -$C6, $A5, $90, $04, $B1, $A6, $91, $A4 -$88, $D0, $F9, $B1, $A6, $91, $A4, $C6 -$A7, $C6, $A5, $CA, $D0, $F2, $60, $85 -$78, $BA, $E4, $78, $90, $30, $60, $C4 -$82, $90, $2A, $D0, $04, $C5, $81, $90 -$24, $48, $A2, $08, $98, $48, $B5, $A3 -$CA, $10, $FA, $20, $E4, $D1, $A2, $00 -$68, $95, $A4, $E8, $E0, $08, $30, $F8 -$68, $A8, $68, $C4, $82, $90, $06, $D0 -$05, $C5, $81, $B0, $01, $60, $A2, $0C -$20, $97, $C8, $BD, $B2, $E6, $BC, $B3 -$E6, $20, $D8, $C8, $20, $8E, $C3, $A9 -$EF, $A0, $E7, $20, $D8, $C8, $A4, $88 -$C8, $F0, $03, $20, $7C, $DA, $A9, $00 -$85, $DF, $85, $DC, $A9, $00, $A0, $E8 -$20, $D8, $C8, $18, $20, $52, $C2, $86 -$C3, $84, $C4, $20, $C2, $00, $F0, $F4 -$A2, $FF, $86, $88, $90, $06, $20, $83 -$C2, $4C, $F8, $C4, $20, $5A, $C7, $20 -$83, $C2, $84, $5D, $20, $29, $C3, $90 -$44, $A0, $01, $B1, $AA, $85, $72, $A5 -$7B, $85, $71, $A5, $AB, $85, $74, $A5 -$AA, $88, $F1, $AA, $18, $65, $7B, $85 -$7B, $85, $73, $A5, $7C, $69, $FF, $85 -$7C, $E5, $AB, $AA, $38, $A5, $AA, $E5 -$7B, $A8, $B0, $03, $E8, $C6, $74, $18 -$65, $71, $90, $03, $C6, $72, $18, $B1 -$71, $91, $73, $C8, $D0, $F9, $E6, $72 -$E6, $74, $CA, $D0, $F2, $AD, $21, $02 -$F0, $3F, $A5, $85, $A4, $86, $85, $81 -$84, $82, $A5, $7B, $85, $A6, $A4, $7C -$84, $A7, $65, $5D, $90, $01, $C8, $85 -$A4, $84, $A5, $20, $C5, $C0, $A5, $7F -$A4, $80, $85, $7B, $84, $7C, $A4, $5D -$88, $B9, $1D, $02, $91, $AA, $88, $C0 -$03, $D0, $F6, $A5, $12, $91, $AA, $88 -$A5, $11, $91, $AA, $88, $A9, $FF, $91 -$AA, $20, $6A, $C3, $A6, $79, $A5, $7A -$A0, $01, $86, $71, $85, $72, $B1, $71 -$F0, $18, $A0, $04, $C8, $B1, $71, $D0 -$FB, $38, $98, $65, $71, $AA, $A0, $00 -$91, $71, $98, $65, $72, $C8, $91, $71 -$90, $E0, $4C, $6C, $C1, $20, $F0, $C8 -$20, $ED, $C8, $D0, $05, $20, $F2, $C8 -$CA, $2C, $A2, $00, $20, $EF, $E0, $90 -$FB, $F0, $F9, $C9, $07, $F0, $10, $C9 -$0D, $F0, $19, $E0, $00, $D0, $04, $C9 -$21, $90, $E9, $C9, $08, $F0, $DE, $E0 -$47, $B0, $0C, $9D, $21, $02, $E8, $20 -$F2, $C8, $D0, $D8, $4C, $8E, $C8, $A9 -$07, $D0, $F4, $A0, $FF, $38, $A5, $C3 -$E9, $21, $AA, $86, $60, $BD, $21, $02 -$F0, $51, $C9, $5F, $B0, $4D, $C9, $3C -$B0, $0E, $C9, $30, $B0, $45, $85, $5C -$C9, $22, $F0, $61, $C9, $2A, $90, $3B -$24, $60, $70, $37, $86, $78, $84, $BA -$A0, $19, $84, $73, $A0, $E3, $84, $74 -$A0, $00, $D1, $73, $F0, $05, $90, $21 -$C8, $D0, $F7, $98, $0A, $AA, $BD, $37 -$E3, $85, $73, $BD, $38, $E3, $85, $74 -$A0, $FF, $A6, $78, $C8, $B1, $73, $30 -$08, $E8, $DD, $21, $02, $F0, $F5, $D0 -$2B, $A4, $BA, $E8, $C8, $99, $21, $02 -$C9, $00, $F0, $32, $E9, $3A, $F0, $04 -$C9, $49, $D0, $02, $85, $60, $49, $57 -$D0, $93, $85, $5C, $BD, $21, $02, $F0 -$E2, $C5, $5C, $F0, $DE, $C8, $99, $21 -$02, $E8, $D0, $F0, $A6, $78, $B1, $73 -$08, $C8, $28, $10, $F9, $B1, $73, $D0 -$BE, $BD, $21, $02, $10, $C3, $C8, $C8 -$99, $21, $02, $C8, $C8, $C8, $C6, $C3 -$60, $A5, $79, $A6, $7A, $A0, $01, $85 -$AA, $86, $AB, $B1, $AA, $F0, $1A, $A0 -$03, $B1, $AA, $88, $C5, $12, $D0, $04 -$B1, $AA, $C5, $11, $B0, $09, $88, $B1 -$AA, $AA, $88, $B1, $AA, $90, $DE, $F0 -$01, $18, $60, $D0, $FD, $A9, $00, $A8 -$91, $79, $C8, $91, $79, $18, $A5, $79 -$69, $02, $85, $7B, $A5, $7A, $69, $00 -$85, $7C, $18, $A5, $79, $69, $FF, $85 -$C3, $A5, $7A, $69, $FF, $85, $C4, $A5 -$85, $A4, $86, $85, $81, $84, $82, $A5 -$7B, $A4, $7C, $85, $7D, $84, $7E, $85 -$7F, $84, $80, $20, $49, $C5, $A2, $68 -$86, $65, $68, $AA, $68, $8E, $FE, $01 -$8D, $FF, $01, $A2, $FD, $9A, $A9, $00 -$85, $8C, $85, $61, $60, $F0, $D0, $60 -$90, $06, $F0, $04, $C9, $B7, $D0, $F4 -$20, $5A, $C7, $20, $29, $C3, $20, $C2 -$00, $F0, $0C, $C9, $B7, $D0, $93, $20 -$BC, $00, $20, $5A, $C7, $D0, $8B, $A5 -$11, $05, $12, $D0, $06, $A9, $FF, $85 -$11, $85, $12, $A0, $01, $84, $60, $20 -$97, $C8, $B1, $AA, $F0, $3E, $20, $19 -$C5, $C8, $B1, $AA, $AA, $C8, $B1, $AA -$C5, $12, $D0, $04, $E4, $11, $F0, $02 -$B0, $2A, $84, $97, $20, $87, $DA, $A9 -$20, $A4, $97, $29, $7F, $20, $F2, $C8 -$C9, $22, $D0, $06, $A5, $60, $49, $FF -$85, $60, $C8, $B1, $AA, $D0, $0E, $A8 -$B1, $AA, $AA, $C8, $B1, $AA, $86, $AA -$85, $AB, $D0, $B7, $60, $10, $DE, $24 -$60, $30, $DA, $A2, $E5, $0A, $0A, $90 -$02, $E8, $18, $69, $1A, $90, $01, $E8 -$85, $73, $86, $74, $84, $97, $A0, $00 -$B1, $73, $AA, $C8, $B1, $73, $CA, $F0 -$B8, $20, $F2, $C8, $C8, $B1, $73, $48 -$C8, $B1, $73, $A0, $00, $85, $74, $68 -$85, $73, $B1, $73, $CA, $F0, $A2, $20 -$F2, $C8, $C8, $D0, $F5, $A9, $80, $85 -$61, $20, $B9, $C7, $68, $68, $A9, $10 -$20, $07, $C1, $20, $A2, $C6, $18, $98 -$65, $C3, $48, $A5, $C4, $69, $00, $48 -$A5, $88, $48, $A5, $87, $48, $A9, $AD -$20, $F6, $CB, $20, $D5, $CA, $20, $D2 -$CA, $A5, $B0, $09, $7F, $25, $AD, $85 -$AD, $A9, $9C, $A0, $C4, $85, $71, $84 -$72, $4C, $89, $CB, $A9, $E9, $A0, $E1 -$20, $82, $D8, $20, $C2, $00, $C9, $B2 -$D0, $06, $20, $BC, $00, $20, $D2, $CA -$20, $EE, $D8, $85, $B0, $20, $7E, $CB -$A5, $98, $48, $A5, $97, $48, $A9, $81 -$48, $20, $19, $C5, $A5, $C3, $A4, $C4 -$A6, $88, $E8, $F0, $04, $85, $8B, $84 -$8C, $A0, $00, $B1, $C3, $F0, $07, $C9 -$3A, $F0, $1D, $4C, $07, $CC, $A0, $02 -$B1, $C3, $18, $F0, $56, $C8, $B1, $C3 -$85, $87, $C8, $B1, $C3, $85, $88, $98 -$65, $C3, $85, $C3, $90, $02, $E6, $C4 -$20, $BC, $00, $20, $01, $C5, $4C, $C1 -$C4, $F0, $54, $0A, $B0, $03, $4C, $B9 -$C7, $C9, $56, $B0, $CE, $A8, $B9, $11 -$E2, $48, $B9, $10, $E2, $48, $4C, $BC -$00, $6C, $03, $02, $C9, $03, $B0, $01 -$18, $D0, $67, $A5, $C4, $49, $02, $F0 -$10, $49, $02, $A4, $C3, $84, $8B, $85 -$8C, $A5, $87, $A4, $88, $85, $89, $84 -$8A, $68, $68, $90, $07, $A9, $E7, $A0 -$E7, $4C, $53, $C1, $4C, $5E, $C1, $D0 -$0F, $38, $A5, $79, $E9, $01, $A4, $7A -$B0, $01, $88, $85, $8F, $84, $90, $60 -$20, $5A, $C7, $20, $A5, $C6, $A5, $88 -$C5, $12, $B0, $0B, $98, $38, $65, $C3 -$A6, $C4, $90, $07, $E8, $B0, $04, $A5 -$79, $A6, $7A, $20, $2D, $C3, $B0, $03 -$4C, $77, $C6, $A5, $AA, $E9, $01, $A4 -$AB, $B0, $D0, $90, $CD, $20, $91, $D4 -$86, $0D, $60, $D0, $FD, $A4, $8C, $D0 -$05, $A2, $1E, $4C, $40, $C1, $A9, $93 -$20, $19, $DF, $A9, $93, $20, $1C, $DF -$84, $C4, $A5, $8B, $85, $C3, $A5, $89 -$A4, $8A, $85, $87, $84, $88, $60, $D0 -$03, $4C, $6A, $C3, $20, $77, $C3, $F0 -$2E, $A9, $05, $20, $07, $C1, $A5, $C4 -$48, $A5, $C3, $48, $A5, $88, $48, $A5 -$87, $48, $A9, $9D, $48, $20, $C2, $00 -$4C, $C1, $C4, $A9, $05, $20, $07, $C1 -$A5, $C4, $48, $A5, $C3, $48, $A5, $88 -$48, $A5, $87, $48, $A9, $8D, $48, $20 -$C2, $00, $20, $F0, $C5, $4C, $C1, $C4 -$20, $5A, $C7, $20, $A5, $C6, $A5, $88 -$C5, $12, $B0, $0B, $98, $38, $65, $C3 -$A6, $C4, $90, $07, $E8, $B0, $04, $A5 -$79, $A6, $7A, $20, $2D, $C3, $90, $67 -$A5, $AA, $E9, $01, $85, $C3, $A5, $AB -$E9, $00, $85, $C4, $60, $A2, $22, $4C -$40, $C1, $A8, $BA, $BD, $03, $01, $C9 -$9D, $D0, $F2, $E8, $E8, $9A, $98, $F0 -$20, $C9, $3A, $F0, $1C, $E9, $B3, $AA -$F0, $04, $CA, $D0, $62, $CA, $86, $98 -$20, $BC, $00, $20, $E6, $CA, $A5, $AC -$F0, $02, $A9, $FF, $BA, $45, $98, $D0 -$1A, $BD, $02, $01, $85, $87, $BD, $03 -$01, $85, $88, $BD, $04, $01, $85, $C3 -$BD, $05, $01, $85, $C4, $20, $C2, $00 -$4C, $C1, $C4, $E8, $E8, $E8, $E8, $E8 -$9A, $4C, $91, $C6, $A2, $04, $2C, $A2 -$0E, $4C, $40, $C1, $D0, $9E, $68, $68 -$68, $C9, $8D, $D0, $EF, $68, $85, $87 -$68, $85, $88, $68, $85, $C3, $68, $85 -$C4, $20, $A2, $C6, $98, $18, $65, $C3 -$85, $C3, $90, $02, $E6, $C4, $60, $4C -$07, $CC, $A2, $3A, $2C, $A2, $00, $A0 -$00, $84, $5C, $8A, $45, $5C, $85, $5C -$B1, $C3, $F0, $EA, $C5, $5C, $F0, $E6 -$C8, $C9, $22, $D0, $F3, $F0, $EC, $20 -$E6, $CA, $20, $C2, $00, $C9, $B0, $F0 -$11, $C9, $89, $D0, $D2, $A6, $C3, $A4 -$C4, $20, $BC, $00, $B0, $C9, $86, $C3 -$84, $C4, $A5, $AC, $F0, $1B, $20, $BC -$00, $B0, $03, $4C, $F0, $C5, $C9, $90 -$D0, $03, $4C, $03, $C5, $20, $01, $C5 -$A0, $00, $B1, $C3, $C9, $AC, $F0, $99 -$60, $A0, $00, $A2, $01, $C8, $B1, $C3 -$F0, $0F, $C9, $8B, $D0, $03, $E8, $D0 -$F4, $C9, $AC, $D0, $F0, $CA, $D0, $ED -$C8, $98, $18, $65, $C3, $85, $C3, $90 -$02, $E6, $C4, $20, $C2, $00, $90, $C3 -$4C, $01, $C5, $20, $A5, $C6, $4C, $94 -$C6, $4C, $07, $CC, $C9, $A9, $D0, $03 -$4C, $3D, $DF, $C9, $AA, $D0, $03, $4C -$41, $DF, $20, $91, $D4, $48, $C9, $8D -$F0, $04, $C9, $89, $D0, $E3, $C6, $AF -$D0, $04, $68, $4C, $03, $C5, $20, $BC -$00, $20, $5A, $C7, $C9, $2C, $F0, $EE -$68, $60, $A2, $00, $86, $11, $86, $12 -$B0, $F7, $E0, $19, $A8, $B0, $DD, $E9 -$2F, $A8, $A5, $11, $0A, $26, $12, $0A -$26, $12, $65, $11, $85, $11, $8A, $65 -$12, $06, $11, $2A, $AA, $98, $65, $11 -$85, $11, $90, $01, $E8, $20, $BC, $00 -$4C, $5E, $C7, $A9, $ED, $2C, $A9, $E9 -$48, $20, $AF, $CD, $A6, $5F, $30, $1E -$85, $97, $84, $98, $20, $82, $D8, $68 -$48, $A0, $E1, $20, $C3, $D5, $20, $A8 -$D8, $20, $C2, $00, $C9, $2C, $D0, $A8 -$20, $BC, $00, $4C, $91, $C7, $4C, $E1 -$CA, $20, $AF, $CD, $85, $97, $84, $98 -$A9, $C1, $20, $F6, $CB, $A5, $5F, $48 -$20, $E6, $CA, $68, $2A, $20, $D8, $CA -$D0, $03, $4C, $A8, $D8, $A0, $02, $B1 -$AE, $C5, $82, $90, $17, $D0, $07, $88 -$B1, $AE, $C5, $81, $90, $0E, $A4, $AF -$C4, $7C, $90, $08, $D0, $0D, $A5, $AE -$C5, $7B, $B0, $07, $A5, $AE, $A4, $AF -$4C, $11, $C8, $A0, $00, $B1, $AE, $20 -$37, $D1, $A5, $9E, $A4, $9F, $85, $B8 -$84, $B9, $20, $16, $D3, $A9, $AC, $A0 -$00, $85, $9E, $84, $9F, $20, $78, $D3 -$A0, $00, $B1, $9E, $91, $97, $C8, $B1 -$9E, $91, $97, $C8, $B1, $9E, $91, $97 -$60, $20, $AF, $CD, $85, $97, $84, $98 -$20, $05, $DF, $A6, $5F, $30, $07, $A8 -$20, $6B, $D0, $4C, $A8, $D8, $48, $A9 -$01, $B0, $01, $68, $20, $3F, $D1, $F0 -$05, $68, $A0, $00, $91, $AD, $20, $8A -$D1, $4C, $D5, $C7, $20, $DB, $C8, $20 -$C2, $00, $F0, $3B, $C9, $AB, $F0, $56 -$C9, $AF, $F0, $52, $C9, $2C, $F0, $38 -$C9, $3B, $F0, $66, $20, $E6, $CA, $24 -$5F, $30, $E1, $20, $9A, $DA, $20, $49 -$D1, $A0, $00, $A5, $0F, $F0, $0A, $38 -$E5, $0E, $F1, $AE, $B0, $03, $20, $97 -$C8, $20, $DB, $C8, $F0, $C9, $A9, $00 -$9D, $21, $02, $A2, $21, $A0, $02, $A9 -$0D, $20, $F2, $C8, $A9, $0A, $D0, $52 -$A5, $0E, $C5, $10, $90, $05, $20, $97 -$C8, $D0, $27, $38, $E5, $64, $B0, $FC -$49, $FF, $69, $01, $D0, $12, $48, $20 -$8E, $D4, $C9, $29, $D0, $7B, $68, $C9 -$AB, $D0, $06, $8A, $E5, $0E, $90, $0A -$AA, $8A, $F0, $06, $20, $ED, $C8, $CA -$D0, $FA, $20, $BC, $00, $D0, $85, $60 -$20, $49, $D1, $20, $43, $D3, $A0, $00 -$AA, $F0, $49, $B1, $71, $20, $F2, $C8 -$C8, $CA, $D0, $F7, $60, $A9, $20, $2C -$A9, $3F, $C9, $20, $90, $19, $48, $A5 -$0F, $D0, $0A, $A5, $0E, $E5, $64, $D0 -$0B, $85, $0E, $F0, $07, $C5, $0E, $D0 -$03, $20, $97, $C8, $E6, $0E, $68, $20 -$F2, $E0, $C9, $0D, $D0, $14, $86, $78 -$A6, $0D, $F0, $0A, $A9, $00, $20, $F2 -$C8, $CA, $D0, $FA, $A9, $0D, $86, $0E -$A6, $78, $29, $FF, $60, $A5, $62, $10 -$0B, $A5, $8D, $A4, $8E, $85, $87, $84 -$88, $4C, $07, $CC, $A9, $1B, $A0, $E8 -$20, $D8, $C8, $A5, $8B, $A4, $8C, $85 -$C3, $84, $C4, $60, $C9, $22, $D0, $0B -$20, $C3, $CB, $A9, $3B, $20, $F6, $CB -$20, $DB, $C8, $20, $6F, $D0, $20, $45 -$C2, $A9, $00, $CD, $21, $02, $D0, $0A -$18, $4C, $31, $C5, $A6, $8F, $A4, $90 -$A9, $80, $85, $62, $86, $91, $84, $92 -$20, $AF, $CD, $85, $97, $84, $98, $A5 -$C3, $A4, $C4, $85, $11, $84, $12, $A6 -$91, $A4, $92, $86, $C3, $84, $C4, $20 -$C2, $00, $D0, $11, $24, $62, $30, $65 -$20, $F0, $C8, $20, $45, $C2, $86, $C3 -$84, $C4, $20, $C2, $00, $24, $5F, $10 -$24, $85, $5B, $C9, $22, $F0, $07, $A9 -$3A, $85, $5B, $A9, $2C, $18, $85, $5C -$A5, $C3, $A4, $C4, $69, $00, $90, $01 -$C8, $20, $4F, $D1, $20, $D4, $D4, $20 -$D5, $C7, $4C, $D3, $C9, $20, $AB, $D9 -$20, $A8, $D8, $20, $C2, $00, $F0, $0A -$C9, $2C, $F0, $03, $4C, $2D, $C9, $20 -$BC, $00, $A5, $C3, $A4, $C4, $85, $91 -$84, $92, $A5, $11, $A4, $12, $85, $C3 -$84, $C4, $20, $C2, $00, $F0, $2C, $20 -$03, $CC, $4C, $78, $C9, $20, $A2, $C6 -$C8, $AA, $D0, $12, $A2, $06, $C8, $B1 -$C3, $F0, $73, $C8, $B1, $C3, $85, $8D -$C8, $B1, $C3, $C8, $85, $8E, $B1, $C3 -$C8, $AA, $20, $94, $C6, $E0, $83, $F0 -$81, $D0, $DA, $A5, $91, $A4, $92, $A6 -$62, $10, $03, $4C, $53, $C5, $A0, $00 -$B1, $91, $D0, $01, $60, $A9, $0A, $A0 -$E8, $4C, $D8, $C8, $BA, $E8, $E8, $E8 -$E8, $BD, $01, $01, $C9, $81, $D0, $21 -$A5, $98, $D0, $0A, $BD, $02, $01, $85 -$97, $BD, $03, $01, $85, $98, $DD, $03 -$01, $D0, $07, $A5, $97, $DD, $02, $01 -$F0, $07, $8A, $18, $69, $10, $AA, $D0 -$D8, $60, $D0, $04, $A0, $00, $F0, $03 -$20, $AF, $CD, $85, $97, $84, $98, $20 -$3C, $CA, $F0, $04, $A2, $00, $F0, $63 -$9A, $8A, $38, $E9, $F7, $85, $73, $69 -$FB, $A0, $01, $20, $82, $D8, $BA, $BD -$08, $01, $85, $B0, $A5, $97, $A4, $98 -$20, $C3, $D5, $20, $A8, $D8, $A0, $01 -$20, $1E, $D9, $BA, $DD, $08, $01, $F0 -$17, $BD, $0D, $01, $85, $87, $BD, $0E -$01, $85, $88, $BD, $10, $01, $85, $C3 -$BD, $0F, $01, $85, $C4, $4C, $C1, $C4 -$8A, $69, $0F, $AA, $9A, $20, $C2, $00 -$C9, $2C, $D0, $F1, $20, $BC, $00, $20 -$70, $CA, $20, $E6, $CA, $18, $24, $38 -$24, $5F, $30, $03, $B0, $03, $60, $B0 -$FD, $A2, $18, $4C, $40, $C1, $A6, $C3 -$D0, $02, $C6, $C4, $C6, $C3, $A9, $00 -$48, $A9, $02, $20, $07, $C1, $20, $D2 -$CB, $A9, $00, $85, $9B, $20, $C2, $00 -$38, $E9, $C0, $90, $17, $C9, $03, $B0 -$13, $C9, $01, $2A, $49, $01, $45, $9B -$C5, $9B, $90, $67, $85, $9B, $20, $BC -$00, $4C, $00, $CB, $A6, $9B, $D0, $2C -$B0, $79, $69, $0A, $90, $75, $D0, $07 -$24, $5F, $10, $03, $4C, $D9, $D2, $85 -$71, $0A, $65, $71, $A8, $68, $D9, $F2 -$E2, $B0, $65, $20, $D5, $CA, $48, $20 -$67, $CB, $68, $A4, $99, $10, $19, $AA -$F0, $76, $D0, $5D, $26, $5F, $8A, $85 -$5F, $2A, $A6, $C3, $D0, $02, $C6, $C4 -$C6, $C3, $A0, $24, $85, $9B, $D0, $D5 -$D9, $F2, $E2, $B0, $44, $90, $D7, $B9 -$F4, $E2, $48, $B9, $F3, $E2, $48, $20 -$7E, $CB, $A5, $9B, $48, $B9, $F2, $E2 -$4C, $F0, $CA, $4C, $07, $CC, $68, $85 -$71, $E6, $71, $68, $85, $72, $A5, $B0 -$48, $20, $DE, $D8, $A5, $AF, $48, $A5 -$AE, $48, $A5, $AD, $48, $A5, $AC, $48 -$6C, $71, $00, $A0, $FF, $68, $F0, $20 -$C9, $64, $F0, $03, $20, $D5, $CA, $84 -$99, $68, $4A, $85, $63, $68, $85, $B3 -$68, $85, $B4, $68, $85, $B5, $68, $85 -$B6, $68, $85, $B7, $45, $B0, $85, $B8 -$A5, $AC, $60, $A5, $C3, $A4, $C4, $69 -$00, $90, $01, $C8, $20, $49, $D1, $4C -$D4, $D4, $20, $BC, $00, $B0, $03, $4C -$AB, $D9, $AA, $30, $2F, $C9, $24, $F0 -$F6, $C9, $25, $F0, $F2, $C9, $2E, $F0 -$EE, $C9, $22, $F0, $D6, $C9, $28, $D0 -$4F, $20, $EE, $CA, $A9, $29, $A0, $00 -$D1, $C3, $D0, $0B, $4C, $BC, $00, $A9 -$28, $D0, $F3, $A9, $2C, $D0, $EF, $A2 -$02, $4C, $40, $C1, $C9, $B7, $F0, $29 -$C9, $B6, $F0, $BE, $C9, $B1, $D0, $13 -$A0, $21, $D0, $1F, $20, $AB, $CE, $A5 -$AF, $49, $FF, $A8, $A5, $AE, $49, $FF -$4C, $5E, $D0, $C9, $AE, $D0, $03, $4C -$B9, $D0, $E9, $C3, $B0, $19, $4C, $07 -$CC, $A0, $1E, $68, $68, $4C, $3F, $CB -$20, $AF, $CD, $85, $AE, $84, $AF, $A6 -$5F, $30, $03, $4C, $82, $D8, $60, $0A -$A8, $B9, $AD, $E2, $48, $B9, $AC, $E2 -$48, $B9, $67, $E2, $F0, $05, $48, $B9 -$66, $E2, $48, $60, $20, $F1, $CB, $4C -$D7, $CA, $20, $F1, $CB, $4C, $D5, $CA -$46, $5F, $4C, $BC, $00, $20, $EE, $CA -$20, $03, $CC, $20, $D7, $CA, $68, $AA -$68, $A8, $A5, $AF, $48, $A5, $AE, $48 -$98, $48, $8A, $48, $20, $91, $D4, $8A -$60, $20, $EE, $CA, $20, $D5, $CA, $A5 -$AC, $C9, $98, $B0, $20, $20, $55, $D9 -$A2, $02, $B5, $AD, $95, $11, $CA, $10 -$F9, $20, $C2, $00, $A2, $00, $C9, $29 -$F0, $0A, $20, $E3, $D4, $20, $C2, $00 -$C9, $29, $D0, $01, $60, $4C, $2E, $CF -$20, $E7, $CC, $45, $5B, $A8, $A5, $AE -$45, $5C, $4C, $5E, $D0, $20, $E7, $CC -$05, $5B, $A8, $A5, $AE, $05, $5C, $4C -$5E, $D0, $20, $E7, $CC, $25, $5B, $A8 -$A5, $AE, $25, $5C, $4C, $5E, $D0, $20 -$AB, $CE, $A5, $AE, $85, $5C, $A5, $AF -$85, $5B, $20, $C8, $D5, $20, $AB, $CE -$A5, $AF, $60, $20, $D8, $CA, $B0, $13 -$A5, $B7, $09, $7F, $25, $B4, $85, $B4 -$A9, $B3, $A0, $00, $20, $1C, $D9, $AA -$4C, $44, $CD, $46, $5F, $C6, $9B, $20 -$43, $D3, $85, $AC, $86, $AD, $84, $AE -$A5, $B5, $A4, $B6, $20, $47, $D3, $86 -$B5, $84, $B6, $AA, $38, $E5, $AC, $F0 -$08, $A9, $01, $90, $04, $A6, $AC, $A9 -$FF, $85, $B0, $A0, $FF, $E8, $C8, $CA -$D0, $07, $A6, $B0, $30, $0F, $18, $90 -$0C, $B1, $B5, $D1, $AD, $F0, $EF, $A2 -$FF, $B0, $02, $A2, $01, $E8, $8A, $2A -$25, $63, $F0, $02, $A9, $FF, $4C, $FF -$D8, $20, $03, $CC, $AA, $20, $B4, $CD -$20, $C2, $00, $D0, $F4, $60, $20, $A4 -$CD, $A5, $AE, $A6, $78, $F0, $22, $E0 -$10, $B0, $23, $06, $AF, $2A, $CA, $D0 -$FA, $A4, $AF, $4C, $5E, $D0, $20, $A4 -$CD, $A5, $AE, $A6, $78, $F0, $0A, $E0 -$10, $B0, $0B, $4A, $66, $AF, $CA, $D0 -$FA, $A4, $AF, $4C, $5E, $D0, $A9, $00 -$A8, $4C, $5E, $D0, $20, $94, $D4, $86 -$78, $20, $C8, $D5, $4C, $AB, $CE, $A2 -$00, $20, $C2, $00, $86, $5E, $85, $93 -$29, $7F, $20, $23, $CE, $B0, $03, $4C -$07, $CC, $A2, $00, $86, $5F, $20, $BC -$00, $90, $05, $20, $23, $CE, $90, $0B -$AA, $20, $BC, $00, $90, $FB, $20, $23 -$CE, $B0, $F6, $C9, $24, $D0, $0B, $A9 -$FF, $85, $5F, $8A, $09, $80, $AA, $20 -$BC, $00, $86, $94, $05, $61, $C9, $28 -$D0, $03, $4C, $BD, $CE, $A9, $00, $85 -$61, $A5, $7B, $A6, $7C, $A0, $00, $86 -$AB, $85, $AA, $E4, $7E, $D0, $04, $C5 -$7D, $F0, $2C, $A5, $93, $D1, $AA, $D0 -$08, $A5, $94, $C8, $D1, $AA, $F0, $69 -$88, $18, $A5, $AA, $69, $06, $90, $E1 -$E8, $D0, $DC, $C9, $61, $B0, $0A, $C9 -$41, $90, $05, $E9, $5B, $38, $E9, $A5 -$60, $E9, $7B, $38, $E9, $85, $60, $68 -$48, $C9, $42, $D0, $05, $A9, $EA, $A0 -$E1, $60, $A5, $7D, $A4, $7E, $85, $AA -$84, $AB, $A5, $7F, $A4, $80, $85, $A6 -$84, $A7, $18, $69, $06, $90, $01, $C8 -$85, $A4, $84, $A5, $20, $C5, $C0, $A5 -$A4, $A4, $A5, $C8, $85, $7D, $84, $7E -$A0, $00, $A5, $93, $91, $AA, $C8, $A5 -$94, $91, $AA, $A9, $00, $C8, $91, $AA -$C8, $91, $AA, $C8, $91, $AA, $C8, $91 -$AA, $A5, $AA, $18, $69, $02, $A4, $AB -$90, $01, $C8, $85, $95, $84, $96, $60 -$A5, $5D, $0A, $69, $05, $65, $AA, $A4 -$AB, $90, $01, $C8, $85, $A4, $84, $A5 -$60, $20, $BC, $00, $20, $D2, $CA, $A5 -$B0, $30, $0D, $A5, $AC, $C9, $90, $90 -$09, $A9, $F1, $A0, $E1, $20, $1C, $D9 -$D0, $74, $4C, $55, $D9, $A5, $5E, $48 -$A5, $5F, $48, $A0, $00, $98, $48, $A5 -$94, $48, $A5, $93, $48, $20, $A1, $CE -$68, $85, $93, $68, $85, $94, $68, $A8 -$BA, $BD, $02, $01, $48, $BD, $01, $01 -$48, $A5, $AE, $9D, $02, $01, $A5, $AF -$9D, $01, $01, $C8, $20, $C2, $00, $C9 -$2C, $F0, $D2, $84, $5D, $20, $F4, $CB -$68, $85, $5F, $68, $85, $5E, $A6, $7D -$A5, $7E, $86, $AA, $85, $AB, $C5, $80 -$D0, $04, $E4, $7F, $F0, $39, $A0, $00 -$B1, $AA, $C8, $C5, $93, $D0, $06, $A5 -$94, $D1, $AA, $F0, $16, $C8, $B1, $AA -$18, $65, $AA, $AA, $C8, $B1, $AA, $65 -$AB, $90, $D7, $A2, $10, $2C, $A2, $08 -$4C, $40, $C1, $A2, $12, $A5, $5E, $D0 -$F7, $20, $90, $CE, $A5, $5D, $A0, $04 -$D1, $AA, $D0, $E7, $4C, $CA, $CF, $20 -$90, $CE, $20, $0F, $C1, $A0, $00, $84 -$BB, $A5, $93, $91, $AA, $C8, $A5, $94 -$91, $AA, $A5, $5D, $A0, $04, $84, $BA -$91, $AA, $18, $A2, $0B, $A9, $00, $24 -$5E, $50, $07, $68, $69, $01, $AA, $68 -$69, $00, $C8, $91, $AA, $C8, $8A, $91 -$AA, $20, $19, $D0, $86, $BA, $85, $BB -$A4, $71, $C6, $5D, $D0, $DD, $65, $A5 -$B0, $5D, $85, $A5, $A8, $8A, $65, $A4 -$90, $03, $C8, $F0, $52, $20, $0F, $C1 -$85, $7F, $84, $80, $A9, $00, $E6, $BB -$A4, $BA, $F0, $05, $88, $91, $A4, $D0 -$FB, $C6, $A5, $C6, $BB, $D0, $F5, $E6 -$A5, $38, $A0, $02, $A5, $7F, $E5, $AA -$91, $AA, $C8, $A5, $80, $E5, $AB, $91 -$AA, $A5, $5E, $D0, $53, $C8, $B1, $AA -$85, $5D, $A9, $00, $85, $BA, $85, $BB -$C8, $68, $AA, $85, $AE, $68, $85, $AF -$D1, $AA, $90, $0E, $D0, $06, $C8, $8A -$D1, $AA, $90, $07, $4C, $2B, $CF, $4C -$3E, $C1, $C8, $A5, $BB, $05, $BA, $F0 -$0A, $20, $19, $D0, $8A, $65, $AE, $AA -$98, $A4, $71, $65, $AF, $86, $BA, $C6 -$5D, $D0, $CB, $06, $BA, $2A, $06, $BA -$2A, $A8, $A5, $BA, $65, $A4, $85, $95 -$98, $65, $A5, $85, $96, $A8, $A5, $95 -$60, $84, $71, $B1, $AA, $85, $76, $88 -$B1, $AA, $85, $77, $A9, $10, $85, $A8 -$A2, $00, $A0, $00, $8A, $0A, $AA, $98 -$2A, $A8, $B0, $B3, $06, $BA, $26, $BB -$90, $0B, $18, $8A, $65, $76, $AA, $98 -$65, $77, $A8, $B0, $A2, $C6, $A8, $D0 -$E3, $60, $A5, $5F, $10, $03, $20, $43 -$D3, $20, $E4, $D1, $38, $A5, $81, $E5 -$7F, $A8, $A5, $82, $E5, $80, $46, $5F -$85, $AD, $84, $AE, $A2, $90, $4C, $07 -$D9, $A4, $0E, $A9, $00, $F0, $EF, $A6 -$88, $E8, $D0, $A4, $A2, $16, $4C, $40 -$C1, $20, $AA, $D0, $85, $9C, $84, $9D -$20, $6F, $D0, $20, $FF, $CB, $A9, $80 -$85, $61, $20, $AF, $CD, $20, $D5, $CA -$20, $F4, $CB, $A9, $C1, $20, $F6, $CB -$A5, $96, $48, $A5, $95, $48, $A5, $C4 -$48, $A5, $C3, $48, $20, $91, $C6, $4C -$19, $D1, $A9, $AE, $20, $F6, $CB, $09 -$80, $85, $61, $20, $B6, $CD, $4C, $D5 -$CA, $20, $AA, $D0, $48, $98, $48, $20 -$FF, $CB, $20, $E6, $CA, $20, $F4, $CB -$20, $D5, $CA, $68, $85, $9D, $68, $85 -$9C, $A2, $20, $A0, $03, $B1, $9C, $F0 -$9D, $85, $96, $88, $B1, $9C, $85, $95 -$AA, $C8, $B1, $95, $48, $88, $10, $FA -$A4, $96, $20, $AC, $D8, $A5, $C4, $48 -$A5, $C3, $48, $B1, $9C, $85, $C3, $C8 -$B1, $9C, $85, $C4, $A5, $96, $48, $A5 -$95, $48, $20, $D2, $CA, $68, $85, $9C -$68, $85, $9D, $20, $C2, $00, $F0, $03 -$4C, $07, $CC, $68, $85, $C3, $68, $85 -$C4, $A0, $00, $68, $91, $9C, $C8, $68 -$91, $9C, $C8, $68, $91, $9C, $C8, $68 -$91, $9C, $60, $20, $D5, $CA, $20, $9A -$DA, $A9, $F0, $A0, $00, $F0, $12, $A6 -$AE, $A4, $AF, $86, $9E, $84, $9F, $20 -$B2, $D1, $86, $AD, $84, $AE, $85, $AC -$60, $A2, $22, $86, $5B, $86, $5C, $85 -$B8, $84, $B9, $85, $AD, $84, $AE, $A0 -$FF, $C8, $B1, $B8, $F0, $0C, $C5, $5B -$F0, $04, $C5, $5C, $D0, $F3, $C9, $22 -$F0, $01, $18, $84, $AC, $98, $65, $B8 -$85, $BA, $A6, $B9, $90, $01, $E8, $86 -$BB, $A5, $B9, $C9, $03, $B0, $0B, $98 -$20, $37, $D1, $A6, $B8, $A4, $B9, $20 -$24, $D3, $A6, $65, $E0, $71, $D0, $05 -$A2, $1C, $4C, $40, $C1, $A5, $AC, $95 -$00, $A5, $AD, $95, $01, $A5, $AE, $95 -$02, $A0, $00, $86, $AE, $84, $AF, $88 -$84, $5F, $86, $66, $E8, $E8, $E8, $86 -$65, $60, $46, $60, $48, $49, $FF, $38 -$65, $81, $A4, $82, $B0, $01, $88, $C4 -$80, $90, $11, $D0, $04, $C5, $7F, $90 -$0B, $85, $81, $84, $82, $85, $83, $84 -$84, $AA, $68, $60, $A2, $0C, $A5, $60 -$30, $B8, $20, $E4, $D1, $A9, $80, $85 -$60, $68, $D0, $D0, $A6, $85, $A5, $86 -$86, $81, $85, $82, $A0, $00, $84, $9D -$A5, $7F, $A6, $80, $85, $AA, $86, $AB -$A9, $68, $85, $71, $84, $72, $C5, $65 -$F0, $05, $20, $68, $D2, $F0, $F7, $06 -$A0, $A5, $7B, $A6, $7C, $85, $71, $86 -$72, $E4, $7E, $D0, $04, $C5, $7D, $F0 -$05, $20, $62, $D2, $F0, $F3, $85, $A4 -$86, $A5, $A9, $04, $85, $A0, $A5, $A4 -$A6, $A5, $E4, $80, $D0, $04, $C5, $7F -$F0, $75, $85, $71, $86, $72, $A0, $02 -$B1, $71, $65, $A4, $85, $A4, $C8, $B1 -$71, $65, $A5, $85, $A5, $A0, $01, $B1 -$71, $10, $DB, $A0, $04, $B1, $71, $0A -$69, $05, $20, $9A, $D2, $E4, $A5, $D0 -$04, $C5, $A4, $F0, $CD, $20, $68, $D2 -$F0, $F3, $C8, $B1, $71, $10, $30, $C8 -$B1, $71, $F0, $2B, $C8, $B1, $71, $AA -$C8, $B1, $71, $C5, $82, $90, $06, $D0 -$1E, $E4, $81, $B0, $1A, $C5, $AB, $90 -$17, $D0, $04, $E4, $AA, $90, $11, $86 -$AA, $85, $AB, $A5, $71, $A6, $72, $85 -$9C, $86, $9D, $88, $88, $84, $A2, $18 -$A5, $A0, $65, $71, $85, $71, $90, $02 -$E6, $72, $A6, $72, $A0, $00, $60, $C6 -$A0, $A6, $9D, $F0, $F5, $A4, $A2, $18 -$B1, $9C, $65, $AA, $85, $A6, $A5, $AB -$69, $00, $85, $A7, $A5, $81, $A6, $82 -$85, $A4, $86, $A5, $20, $CC, $C0, $A4 -$A2, $C8, $A5, $A4, $91, $9C, $AA, $E6 -$A5, $A5, $A5, $C8, $91, $9C, $4C, $E8 -$D1, $A5, $AF, $48, $A5, $AE, $48, $20 -$D2, $CB, $20, $D7, $CA, $68, $85, $B8 -$68, $85, $B9, $A0, $00, $B1, $B8, $18 -$71, $AE, $90, $05, $A2, $1A, $4C, $40 -$C1, $20, $37, $D1, $20, $16, $D3, $A5 -$9E, $A4, $9F, $20, $47, $D3, $20, $28 -$D3, $A5, $B8, $A4, $B9, $20, $47, $D3 -$20, $8A, $D1, $4C, $FD, $CA, $A0, $00 -$B1, $B8, $48, $C8, $B1, $B8, $AA, $C8 -$B1, $B8, $A8, $68, $86, $71, $84, $72 -$AA, $F0, $14, $A0, $00, $B1, $71, $91 -$83, $C8, $CA, $D0, $F8, $98, $18, $65 -$83, $85, $83, $90, $02, $E6, $84, $60 -$20, $D7, $CA, $A5, $AE, $A4, $AF, $85 -$71, $84, $72, $20, $78, $D3, $08, $A0 -$00, $B1, $71, $48, $C8, $B1, $71, $AA -$C8, $B1, $71, $A8, $68, $28, $D0, $13 -$C4, $82, $D0, $0F, $E4, $81, $D0, $0B -$48, $18, $65, $81, $85, $81, $90, $02 -$E6, $82, $68, $86, $71, $84, $72, $60 -$C4, $67, $D0, $0C, $C5, $66, $D0, $08 -$85, $65, $E9, $03, $85, $66, $A0, $00 -$60, $20, $94, $D4, $8A, $48, $A9, $01 -$20, $3F, $D1, $68, $A0, $00, $91, $AD -$4C, $8A, $D1, $48, $20, $FC, $D3, $D1 -$9E, $98, $F0, $09, $48, $20, $FC, $D3 -$18, $F1, $9E, $49, $FF, $90, $04, $B1 -$9E, $AA, $98, $48, $8A, $48, $20, $3F -$D1, $A5, $9E, $A4, $9F, $20, $47, $D3 -$68, $A8, $68, $18, $65, $71, $85, $71 -$90, $02, $E6, $72, $98, $20, $28, $D3 -$4C, $8A, $D1, $48, $A9, $FF, $85, $AF -$20, $C2, $00, $C9, $29, $F0, $06, $20 -$03, $CC, $20, $91, $D4, $20, $FC, $D3 -$CA, $8A, $48, $18, $A2, $00, $F1, $9E -$B0, $C2, $49, $FF, $C5, $AF, $90, $BD -$A5, $AF, $B0, $B9, $20, $F4, $CB, $68 -$85, $A2, $68, $85, $A3, $68, $AA, $68 -$85, $9E, $68, $85, $9F, $A0, $00, $8A -$F0, $79, $E6, $A2, $6C, $A2, $00, $20 -$40, $D3, $85, $AC, $A8, $F0, $38, $20 -$3F, $D1, $86, $AD, $84, $AE, $A8, $88 -$B1, $71, $20, $27, $CE, $90, $02, $09 -$20, $91, $83, $98, $D0, $F1, $F0, $1F -$20, $40, $D3, $85, $AC, $A8, $F0, $17 -$20, $3F, $D1, $86, $AD, $84, $AE, $A8 -$88, $B1, $71, $20, $23, $CE, $90, $02 -$29, $DF, $91, $83, $98, $D0, $F1, $4C -$8A, $D1, $20, $BC, $00, $20, $AF, $CD -$20, $F4, $CB, $20, $D7, $CA, $A0, $02 -$B1, $95, $AA, $88, $B1, $95, $A8, $8A -$4C, $5E, $D0, $20, $79, $D4, $4C, $6B -$D0, $20, $40, $D3, $A8, $60, $20, $79 -$D4, $F0, $08, $A0, $00, $B1, $71, $A8 -$4C, $6B, $D0, $4C, $2E, $CF, $20, $BC -$00, $20, $D2, $CA, $20, $A7, $CE, $A4 -$AE, $D0, $F0, $A6, $AF, $4C, $C2, $00 -$20, $79, $D4, $D0, $03, $4C, $55, $D6 -$A6, $C3, $A4, $C4, $86, $BA, $84, $BB -$A6, $71, $86, $C3, $18, $65, $71, $85 -$73, $A5, $72, $85, $C4, $69, $00, $85 -$74, $A0, $00, $B1, $73, $48, $98, $91 -$73, $20, $C2, $00, $20, $AB, $D9, $68 -$A0, $00, $91, $73, $A6, $BA, $A4, $BB -$86, $C3, $84, $C4, $60, $20, $D2, $CA -$20, $F6, $D4, $20, $03, $CC, $A5, $12 -$48, $A5, $11, $48, $20, $91, $D4, $68 -$85, $11, $68, $85, $12, $60, $A5, $AC -$C9, $98, $B0, $8F, $20, $55, $D9, $A5 -$AE, $A4, $AF, $84, $11, $85, $12, $60 -$20, $F6, $D4, $A2, $00, $A1, $11, $A8 -$4C, $6B, $D0, $20, $DD, $D4, $8A, $A2 -$00, $81, $11, $60, $20, $F6, $D4, $A2 -$00, $A1, $11, $A8, $E6, $11, $D0, $02 -$E6, $12, $A1, $11, $4C, $5E, $D0, $20 -$D2, $CA, $20, $F6, $D4, $84, $97, $85 -$98, $20, $03, $CC, $20, $D2, $CA, $20 -$F6, $D4, $98, $A2, $00, $81, $97, $E6 -$97, $D0, $02, $E6, $98, $A5, $12, $81 -$97, $4C, $C2, $00, $20, $AF, $CD, $85 -$97, $84, $98, $A5, $5F, $48, $20, $03 -$CC, $20, $AF, $CD, $68, $45, $5F, $10 -$10, $A0, $03, $B1, $97, $AA, $B1, $95 -$91, $97, $8A, $91, $95, $88, $10, $F3 -$60, $4C, $E1, $CA, $20, $D2, $CA, $20 -$F6, $D4, $A9, $D5, $48, $A9, $8A, $48 -$6C, $11, $00, $4C, $C2, $00, $20, $DD -$D4, $86, $97, $A2, $00, $20, $C2, $00 -$F0, $03, $20, $E3, $D4, $86, $98, $B1 -$11, $45, $98, $25, $97, $F0, $F8, $60 -$20, $90, $D7, $A5, $B0, $49, $FF, $85 -$B0, $45, $B7, $85, $B8, $A5, $AC, $4C -$C6, $D5, $20, $DF, $D6, $90, $4D, $A9 -$F2, $A0, $E1, $20, $90, $D7, $D0, $10 -$A5, $B7, $85, $B0, $A2, $04, $B5, $B2 -$95, $AB, $CA, $D0, $F9, $86, $B9, $60 -$A6, $B9, $86, $A3, $A2, $B3, $A5, $B3 -$A8, $F0, $C4, $38, $E5, $AC, $F0, $24 -$90, $12, $84, $AC, $A4, $B7, $84, $B0 -$49, $FF, $69, $00, $A0, $00, $84, $A3 -$A2, $AC, $D0, $04, $A0, $00, $84, $B9 -$C9, $F9, $30, $B6, $A8, $A5, $B9, $56 -$01, $20, $F6, $D6, $24, $B8, $10, $4C -$A0, $AC, $E0, $B3, $F0, $02, $A0, $B3 -$38, $49, $FF, $65, $A3, $85, $B9, $B9 -$03, $00, $F5, $03, $85, $AF, $B9, $02 -$00, $F5, $02, $85, $AE, $B9, $01, $00 -$F5, $01, $85, $AD, $B0, $03, $20, $9B -$D6, $A0, $00, $98, $18, $A6, $AD, $D0 -$3E, $A6, $AE, $86, $AD, $A6, $AF, $86 -$AE, $A6, $B9, $86, $AF, $84, $B9, $69 -$08, $C9, $18, $D0, $E8, $A9, $00, $85 -$AC, $85, $B0, $60, $65, $A3, $85, $B9 -$A5, $AF, $65, $B6, $85, $AF, $A5, $AE -$65, $B5, $85, $AE, $A5, $AD, $65, $B4 -$85, $AD, $B0, $1A, $60, $69, $01, $06 -$B9, $26, $AF, $26, $AE, $26, $AD, $10 -$F4, $38, $E5, $AC, $B0, $CF, $49, $FF -$69, $01, $85, $AC, $90, $0C, $E6, $AC -$F0, $36, $66, $AD, $66, $AE, $66, $AF -$66, $B9, $60, $A5, $B0, $49, $FF, $85 -$B0, $A5, $AD, $49, $FF, $85, $AD, $A5 -$AE, $49, $FF, $85, $AE, $A5, $AF, $49 -$FF, $85, $AF, $A5, $B9, $49, $FF, $85 -$B9, $E6, $B9, $D0, $0A, $E6, $AF, $D0 -$06, $E6, $AE, $D0, $02, $E6, $AD, $60 -$A2, $0A, $4C, $40, $C1, $A2, $74, $B4 -$03, $84, $B9, $B4, $02, $94, $03, $B4 -$01, $94, $02, $A4, $B2, $94, $01, $69 -$08, $30, $EC, $F0, $EA, $E9, $08, $A8 -$A5, $B9, $B0, $12, $16, $01, $90, $02 -$F6, $01, $76, $01, $76, $01, $76, $02 -$76, $03, $6A, $C8, $D0, $EE, $18, $60 -$20, $EE, $D8, $F0, $02, $10, $03, $4C -$2E, $CF, $A5, $AC, $E9, $7F, $48, $A9 -$80, $85, $AC, $A9, $72, $A0, $E1, $20 -$C3, $D5, $A9, $76, $A0, $E1, $20, $06 -$D8, $A9, $E9, $A0, $E1, $20, $A8, $D5 -$A9, $65, $A0, $E1, $20, $56, $DC, $A9 -$7A, $A0, $E1, $20, $C3, $D5, $68, $20 -$4A, $DA, $A9, $7E, $A0, $E1, $20, $90 -$D7, $F0, $4C, $20, $B6, $D7, $A9, $00 -$85, $75, $85, $76, $85, $77, $A5, $B9 -$20, $65, $D7, $A5, $AF, $20, $65, $D7 -$A5, $AE, $20, $65, $D7, $A5, $AD, $20 -$6A, $D7, $4C, $73, $D8, $D0, $03, $4C -$CD, $D6, $4A, $09, $80, $A8, $90, $13 -$18, $A5, $77, $65, $B6, $85, $77, $A5 -$76, $65, $B5, $85, $76, $A5, $75, $65 -$B4, $85, $75, $66, $75, $66, $76, $66 -$77, $66, $B9, $98, $4A, $D0, $DE, $60 -$85, $71, $84, $72, $A0, $03, $B1, $71 -$85, $B6, $88, $B1, $71, $85, $B5, $88 -$B1, $71, $85, $B7, $45, $B0, $85, $B8 -$A5, $B7, $09, $80, $85, $B4, $88, $B1 -$71, $85, $B3, $A5, $AC, $60, $A5, $B3 -$F0, $1D, $18, $65, $AC, $90, $04, $30 -$31, $18, $2C, $10, $12, $69, $80, $85 -$AC, $D0, $03, $4C, $59, $D6, $A5, $B8 -$85, $B0, $60, $A5, $B0, $10, $1B, $68 -$68, $4C, $55, $D6, $20, $CF, $D8, $AA -$F0, $F0, $18, $69, $02, $B0, $0B, $A2 -$00, $86, $B8, $20, $E0, $D5, $E6, $AC -$D0, $E0, $4C, $C8, $D6, $20, $CF, $D8 -$A9, $FA, $A0, $E1, $A2, $00, $86, $B8 -$20, $82, $D8, $4C, $09, $D8, $20, $90 -$D7, $F0, $63, $20, $DE, $D8, $A9, $00 -$38, $E5, $AC, $85, $AC, $20, $B6, $D7 -$E6, $AC, $F0, $D6, $A2, $FF, $A9, $01 -$A4, $B4, $C4, $AD, $D0, $0A, $A4, $B5 -$C4, $AE, $D0, $04, $A4, $B6, $C4, $AF -$08, $2A, $90, $0E, $A0, $01, $E8, $E0 -$02, $30, $04, $D0, $28, $A0, $40, $95 -$75, $98, $28, $90, $14, $A8, $A5, $B6 -$E5, $AF, $85, $B6, $A5, $B5, $E5, $AE -$85, $B5, $A5, $B4, $E5, $AD, $85, $B4 -$98, $06, $B6, $26, $B5, $26, $B4, $B0 -$CF, $30, $BD, $10, $CB, $4A, $6A, $6A -$85, $B9, $28, $4C, $73, $D8, $A2, $14 -$4C, $40, $C1, $A5, $75, $85, $AD, $A5 -$76, $85, $AE, $A5, $77, $85, $AF, $4C -$39, $D6, $85, $71, $84, $72, $A0, $03 -$B1, $71, $85, $AF, $88, $B1, $71, $85 -$AE, $88, $B1, $71, $85, $B0, $09, $80 -$85, $AD, $88, $B1, $71, $85, $AC, $84 -$B9, $60, $A2, $A4, $A0, $00, $F0, $04 -$A6, $97, $A4, $98, $20, $DE, $D8, $86 -$71, $84, $72, $A0, $03, $A5, $AF, $91 -$71, $88, $A5, $AE, $91, $71, $88, $A5 -$B0, $09, $7F, $25, $AD, $91, $71, $88 -$A5, $AC, $91, $71, $84, $B9, $60, $20 -$DE, $D8, $A2, $05, $B5, $AB, $95, $B2 -$CA, $D0, $F9, $86, $B9, $60, $A5, $AC -$F0, $FB, $06, $B9, $90, $F7, $20, $BD -$D6, $D0, $F2, $4C, $8E, $D6, $A5, $AC -$F0, $09, $A5, $B0, $2A, $A9, $FF, $B0 -$02, $A9, $01, $60, $20, $EE, $D8, $85 -$AD, $A9, $00, $85, $AE, $A2, $88, $A5 -$AD, $49, $FF, $2A, $A9, $00, $85, $AF -$86, $AC, $85, $B9, $85, $B0, $4C, $34 -$D6, $46, $B0, $60, $85, $73, $84, $74 -$A0, $00, $B1, $73, $C8, $AA, $F0, $C6 -$B1, $73, $45, $B0, $30, $C4, $E4, $AC -$D0, $1A, $B1, $73, $09, $80, $C5, $AD -$D0, $12, $C8, $B1, $73, $C5, $AE, $D0 -$0B, $C8, $A9, $7F, $C5, $B9, $B1, $73 -$E5, $AF, $F0, $28, $A5, $B0, $90, $02 -$49, $FF, $4C, $F4, $D8, $A5, $AC, $F0 -$4A, $38, $E9, $98, $24, $B0, $10, $09 -$AA, $A9, $FF, $85, $B2, $20, $A1, $D6 -$8A, $A2, $AC, $C9, $F9, $10, $06, $20 -$DF, $D6, $84, $B2, $60, $A8, $A5, $B0 -$29, $80, $46, $AD, $05, $AD, $85, $AD -$20, $F6, $D6, $84, $B2, $60, $A5, $AC -$C9, $98, $B0, $1E, $20, $55, $D9, $84 -$B9, $A5, $B0, $84, $B0, $49, $80, $2A -$A9, $98, $85, $AC, $A5, $AF, $85, $5B -$4C, $34, $D6, $85, $AD, $85, $AE, $85 -$AF, $A8, $60, $A0, $00, $84, $5F, $A2 -$09, $94, $A8, $CA, $10, $FB, $90, $7F -$C9, $2D, $D0, $04, $86, $B1, $F0, $04 -$C9, $2B, $D0, $05, $20, $BC, $00, $90 -$6E, $C9, $24, $D0, $03, $4C, $73, $DE -$C9, $25, $D0, $08, $4C, $A1, $DE, $20 -$BC, $00, $90, $5B, $C9, $2E, $F0, $2E -$C9, $45, $D0, $30, $20, $BC, $00, $90 -$17, $C9, $B7, $F0, $0E, $C9, $2D, $F0 -$0A, $C9, $B6, $F0, $08, $C9, $2B, $F0 -$04, $D0, $07, $66, $AB, $20, $BC, $00 -$90, $5B, $24, $AB, $10, $0E, $A9, $00 -$38, $E5, $A9, $4C, $16, $DA, $66, $AA -$24, $AA, $50, $C3, $A5, $A9, $38, $E5 -$A8, $85, $A9, $F0, $12, $10, $09, $20 -$F5, $D7, $E6, $A9, $D0, $F9, $F0, $07 -$20, $DC, $D7, $C6, $A9, $D0, $F9, $A5 -$B1, $30, $01, $60, $4C, $F9, $DB, $48 -$24, $AA, $10, $02, $E6, $A8, $20, $DC -$D7, $68, $29, $0F, $20, $4A, $DA, $4C -$D7, $D9, $48, $20, $CF, $D8, $68, $20 -$FF, $D8, $A5, $B7, $45, $B0, $85, $B8 -$A6, $AC, $4C, $C6, $D5, $A5, $A9, $C9 -$0A, $90, $09, $A9, $64, $24, $AB, $30 -$0E, $4C, $C8, $D6, $0A, $0A, $65, $A9 -$0A, $A0, $00, $71, $C3, $E9, $2F, $85 -$A9, $4C, $FD, $D9, $A9, $F6, $A0, $E7 -$20, $D8, $C8, $A5, $88, $A6, $87, $85 -$AD, $86, $AE, $A2, $90, $38, $20, $0C -$D9, $A0, $00, $98, $20, $A7, $DA, $4C -$D8, $C8, $A0, $01, $A9, $20, $24, $B0 -$10, $02, $A9, $2D, $99, $EF, $00, $85 -$B0, $84, $BA, $C8, $A6, $AC, $D0, $05 -$A9, $30, $4C, $B3, $DB, $A9, $00, $E0 -$81, $B0, $09, $A9, $8A, $A0, $E1, $20 -$3E, $D7, $A9, $FA, $85, $A8, $A9, $86 -$A0, $E1, $20, $1C, $D9, $F0, $1E, $10 -$12, $A9, $82, $A0, $E1, $20, $1C, $D9 -$F0, $02, $10, $0E, $20, $DC, $D7, $C6 -$A8, $D0, $EE, $20, $F5, $D7, $E6, $A8 -$D0, $DC, $20, $BF, $D5, $20, $55, $D9 -$A2, $01, $A5, $A8, $18, $69, $07, $30 -$09, $C9, $08, $B0, $06, $69, $FF, $AA -$A9, $02, $38, $E9, $02, $85, $A9, $86 -$A8, $8A, $F0, $02, $10, $13, $A4, $BA -$A9, $2E, $C8, $99, $EF, $00, $8A, $F0 -$06, $A9, $30, $C8, $99, $EF, $00, $84 -$BA, $A0, $00, $A2, $80, $A5, $AF, $18 -$79, $00, $E2, $85, $AF, $A5, $AE, $79 -$FF, $E1, $85, $AE, $A5, $AD, $79, $FE -$E1, $85, $AD, $E8, $B0, $04, $10, $E5 -$30, $02, $30, $E1, $8A, $90, $04, $49 -$FF, $69, $0A, $69, $2F, $C8, $C8, $C8 -$84, $95, $A4, $BA, $C8, $AA, $29, $7F -$99, $EF, $00, $C6, $A8, $D0, $06, $A9 -$2E, $C8, $99, $EF, $00, $84, $BA, $A4 -$95, $8A, $49, $FF, $29, $80, $AA, $C0 -$12, $D0, $B2, $A4, $BA, $B9, $EF, $00 -$88, $C9, $30, $F0, $F8, $C9, $2E, $F0 -$01, $C8, $A9, $2B, $A6, $A9, $F0, $2E -$10, $08, $A9, $00, $38, $E5, $A9, $AA -$A9, $2D, $99, $F1, $00, $A9, $45, $99 -$F0, $00, $8A, $A2, $2F, $38, $E8, $E9 -$0A, $B0, $FB, $69, $3A, $99, $F3, $00 -$8A, $99, $F2, $00, $A9, $00, $99, $F4 -$00, $F0, $08, $99, $EF, $00, $A9, $00 -$99, $F0, $00, $A9, $F0, $A0, $00, $60 -$F0, $42, $A5, $B3, $D0, $03, $4C, $57 -$D6, $A2, $9C, $A0, $00, $20, $AC, $D8 -$A5, $B7, $10, $0F, $20, $86, $D9, $A9 -$9C, $A0, $00, $20, $1C, $D9, $D0, $03 -$98, $A4, $5B, $20, $CA, $D5, $98, $48 -$20, $00, $D7, $A9, $9C, $A0, $00, $20 -$3E, $D7, $20, $04, $DC, $68, $4A, $90 -$0A, $A5, $AC, $F0, $06, $A5, $B0, $49 -$FF, $85, $B0, $60, $A9, $8E, $A0, $E1 -$20, $3E, $D7, $A5, $B9, $69, $50, $90 -$03, $20, $E6, $D8, $85, $A3, $20, $D2 -$D8, $A5, $AC, $C9, $88, $90, $03, $20 -$D3, $D7, $20, $86, $D9, $A5, $5B, $18 -$69, $81, $F0, $F3, $38, $E9, $01, $48 -$A2, $04, $B5, $B3, $B4, $AC, $95, $AC -$94, $B3, $CA, $10, $F5, $A5, $A3, $85 -$B9, $20, $AB, $D5, $20, $F9, $DB, $A9 -$92, $A0, $E1, $20, $6C, $DC, $A9, $00 -$85, $B8, $68, $4C, $B8, $D7, $85, $BA -$84, $BB, $20, $A2, $D8, $A9, $A4, $20 -$3E, $D7, $20, $70, $DC, $A9, $A4, $A0 -$00, $4C, $3E, $D7, $85, $BA, $84, $BB -$A2, $A8, $20, $A4, $D8, $B1, $BA, $85 -$B1, $A4, $BA, $C8, $98, $D0, $02, $E6 -$BB, $85, $BA, $A4, $BB, $20, $3E, $D7 -$A5, $BA, $A4, $BB, $18, $69, $04, $90 -$01, $C8, $85, $BA, $84, $BB, $20, $C3 -$D5, $A9, $A8, $A0, $00, $C6, $B1, $D0 -$E4, $60, $A5, $AC, $F0, $07, $A2, $D8 -$A0, $00, $20, $AC, $D8, $A2, $AF, $A0 -$13, $06, $D9, $26, $DA, $26, $DB, $26 -$D8, $90, $05, $8A, $45, $D9, $85, $D9 -$88, $D0, $EE, $A2, $02, $B5, $D9, $95 -$AD, $CA, $10, $F9, $A9, $80, $85, $AC -$0A, $85, $B0, $4C, $39, $D6, $A9, $AF -$A0, $E1, $20, $C3, $D5, $20, $CF, $D8 -$A9, $C4, $A0, $E1, $A6, $B7, $20, $FE -$D7, $20, $CF, $D8, $20, $86, $D9, $A9 -$00, $85, $B8, $20, $AB, $D5, $A9, $F6 -$A0, $E1, $20, $A8, $D5, $A5, $B0, $48 -$10, $0D, $20, $BF, $D5, $A5, $B0, $30 -$09, $A5, $63, $49, $FF, $85, $63, $20 -$F9, $DB, $A9, $F6, $A0, $E1, $20, $C3 -$D5, $68, $10, $03, $20, $F9, $DB, $A9 -$B3, $A0, $E1, $4C, $56, $DC, $20, $A2 -$D8, $A9, $00, $85, $63, $20, $DD, $DC -$A2, $9C, $A0, $00, $20, $AC, $D8, $A9 -$A4, $A0, $00, $20, $82, $D8, $A9, $00 -$85, $B0, $A5, $63, $20, $4E, $DD, $A9 -$9C, $A0, $00, $4C, $06, $D8, $48, $4C -$0F, $DD, $20, $0A, $00, $4C, $F4, $CB -$A5, $B0, $48, $10, $03, $20, $F9, $DB -$A5, $AC, $48, $C9, $81, $90, $07, $A9 -$E9, $A0, $E1, $20, $06, $D8, $A9, $C8 -$A0, $E1, $20, $56, $DC, $68, $C9, $81 -$90, $07, $A9, $AF, $A0, $E1, $20, $A8 -$D5, $68, $10, $16, $4C, $F9, $DB, $20 -$DD, $D4, $E0, $08, $B0, $20, $A9, $00 -$38, $2A, $CA, $10, $FC, $E8, $01, $11 -$81, $11, $60, $20, $DD, $D4, $E0, $08 -$B0, $0C, $A9, $FF, $2A, $CA, $10, $FC -$E8, $21, $11, $81, $11, $60, $4C, $2E -$CF, $20, $BC, $00, $20, $DD, $D4, $E0 -$08, $B0, $F3, $20, $C2, $00, $C9, $29 -$F0, $03, $4C, $07, $CC, $20, $BC, $00 -$A9, $00, $38, $2A, $CA, $10, $FC, $E8 -$21, $11, $F0, $02, $A9, $FF, $4C, $FF -$D8, $E0, $19, $B0, $48, $86, $78, $A9 -$18, $20, $3F, $D1, $A0, $17, $A2, $18 -$46, $11, $66, $12, $66, $13, $8A, $2A -$91, $AD, $88, $10, $F3, $A5, $78, $F0 -$0A, $AA, $38, $49, $FF, $69, $18, $F0 -$1C, $D0, $0F, $A8, $B1, $AD, $C9, $30 -$D0, $07, $CA, $F0, $03, $C8, $10, $F4 -$E8, $98, $18, $65, $AD, $85, $AD, $A9 -$00, $65, $AE, $85, $AE, $86, $AC, $20 -$BC, $00, $4C, $8A, $D1, $4C, $2E, $CF -$E0, $07, $B0, $F9, $86, $78, $A9, $06 -$20, $3F, $D1, $A0, $05, $F8, $A5, $13 -$20, $56, $DE, $A5, $12, $20, $56, $DE -$A5, $11, $20, $56, $DE, $D8, $A2, $06 -$A5, $78, $F0, $B7, $AA, $38, $49, $FF -$69, $06, $F0, $C9, $D0, $BC, $AA, $29 -$0F, $20, $61, $DE, $8A, $4A, $4A, $4A -$4A, $C9, $0A, $69, $30, $91, $AD, $88 -$60, $85, $AC, $A9, $00, $85, $B8, $8A -$20, $4A, $DA, $20, $BC, $00, $90, $0A -$09, $20, $E9, $61, $C9, $06, $B0, $2A -$69, $0A, $29, $0F, $AA, $A5, $AC, $F0 -$E4, $69, $04, $90, $DC, $4C, $C8, $D6 -$AA, $A5, $AC, $F0, $06, $E6, $AC, $F0 -$F4, $A9, $00, $85, $B8, $8A, $20, $4A -$DA, $20, $BC, $00, $49, $30, $C9, $02 -$90, $E6, $4C, $2F, $DA, $AD, $00, $02 -$D0, $18, $20, $EF, $E0, $90, $0B, $8D -$01, $02, $A2, $20, $8E, $02, $02, $4C -$1C, $C5, $AE, $02, $02, $F0, $03, $CE -$02, $02, $A2, $DC, $20, $D5, $DE, $A2 -$DF, $20, $D5, $DE, $60, $B5, $00, $10 -$FB, $0A, $29, $40, $F0, $F6, $95, $00 -$8A, $A8, $68, $68, $A9, $05, $20, $07 -$C1, $A5, $C4, $48, $A5, $C3, $48, $A5 -$88, $48, $A5, $87, $48, $A9, $8D, $48 -$B9, $01, $00, $85, $C3, $B9, $02, $00 -$85, $C4, $4C, $C1, $C4, $20, $EF, $E0 -$B0, $09, $AD, $02, $02, $F0, $09, $AD -$01, $02, $38, $A2, $00, $8E, $02, $02 -$60, $A2, $DF, $2C, $A2, $DC, $C9, $93 -$F0, $11, $C9, $B5, $F0, $07, $49, $A2 -$F0, $0E, $4C, $07, $CC, $A9, $7F, $35 -$00, $10, $05, $B5, $00, $0A, $15, $00 -$95, $00, $4C, $BC, $00, $58, $A2, $DF -$2C, $A2, $DC, $86, $78, $20, $BC, $00 -$20, $5A, $C7, $A5, $79, $A6, $7A, $20 -$2D, $C3, $B0, $03, $4C, $77, $C6, $A6 -$78, $A5, $AA, $E9, $01, $95, $01, $A5 -$AB, $E9, $00, $95, $02, $A9, $C0, $95 -$00, $60, $D0, $FD, $A5, $DF, $0A, $05 -$DF, $85, $DF, $4C, $7E, $C6, $D0, $F1 -$A5, $DC, $0A, $05, $DC, $85, $DC, $4C -$7E, $C6, $20, $EE, $CA, $4C, $D5, $CA -$20, $B6, $DF, $10, $FB, $A5, $B4, $09 -$80, $85, $B4, $20, $C8, $D5, $F0, $F0 -$20, $B6, $DF, $30, $FB, $F0, $F9, $A5 -$B4, $09, $80, $85, $B4, $20, $C8, $D5 -$F0, $EE, $C9, $29, $D0, $05, $68, $68 -$4C, $BC, $00, $4C, $07, $CC, $20, $C2 -$00, $C9, $2C, $D0, $ED, $20, $DE, $D8 -$A5, $B0, $09, $7F, $25, $AD, $48, $A5 -$AE, $48, $A5, $AF, $48, $A5, $AC, $48 -$20, $BC, $00, $20, $D2, $CA, $68, $85 -$B3, $68, $85, $B6, $68, $85, $B5, $68 -$85, $B4, $85, $B7, $A9, $B3, $A0, $00 -$4C, $1C, $D9, $C9, $2C, $F0, $1B, $20 -$91, $D4, $8A, $F0, $0A, $E0, $10, $90 -$45, $E4, $64, $B0, $02, $86, $64, $86 -$0F, $20, $C2, $00, $F0, $1A, $C9, $2C -$D0, $A9, $20, $8E, $D4, $8A, $30, $2E -$E0, $01, $90, $2A, $A5, $0F, $F0, $06 -$E4, $0F, $F0, $02, $B0, $20, $86, $64 -$A5, $0F, $F0, $06, $C5, $64, $B0, $03 -$85, $64, $38, $E5, $64, $B0, $FC, $65 -$64, $18, $65, $64, $85, $10, $A5, $0F -$38, $E5, $10, $85, $10, $60, $4C, $2E -$CF, $A5, $B0, $30, $F9, $A5, $AC, $F0 -$F4, $20, $CF, $D8, $A9, $00, $85, $77 -$85, $76, $85, $75, $85, $78, $85, $AF -$85, $AE, $85, $AD, $A2, $18, $A5, $B3 -$4A, $B0, $0E, $06, $B6, $26, $B5, $26 -$B4, $26, $77, $26, $76, $26, $75, $26 -$78, $06, $B6, $26, $B5, $26, $B4, $26 -$77, $26, $76, $26, $75, $26, $78, $06 -$AF, $26, $AE, $26, $AD, $A5, $AF, $2A -$85, $5B, $A5, $AE, $2A, $85, $5C, $A5 -$AD, $2A, $85, $5D, $A9, $00, $2A, $85 -$5E, $A5, $77, $E5, $5B, $85, $5B, $A5 -$76, $E5, $5C, $85, $5C, $A5, $75, $E5 -$5D, $A8, $A5, $78, $E5, $5E, $90, $0E -$85, $78, $84, $75, $A5, $5C, $85, $76 -$A5, $5B, $85, $77, $E6, $AF, $CA, $D0 -$A2, $38, $A5, $B3, $E9, $80, $6A, $69 -$00, $85, $AC, $4C, $39, $D6, $20, $BC -$00, $20, $AF, $CD, $20, $F4, $CB, $A4 -$95, $A5, $96, $4C, $5E, $D0, $A9, $C4 -$A0, $E1, $20, $82, $D8, $C6, $AC, $60 -$A9, $C4, $A0, $E1, $4C, $82, $D8, $6C -$05, $02, $6C, $07, $02, $6C, $09, $02 -$6C, $0B, $02, $FF, $00, $00, $AD, $DE -$C0, $FF, $D3, $FF, $E6, $C3, $D0, $02 -$E6, $C4, $AD, $FF, $FF, $C9, $AC, $F0 -$0E, $C9, $3A, $B0, $0A, $C9, $20, $F0 -$EB, $38, $E9, $30, $38, $E9, $D0, $60 -$4C, $00, $C0, $00, $00, $00, $00, $00 -$00, $00, $4C, $2E, $CF, $00, $00, $00 -$F2, $00, $03, $0D, $0A, $4D, $65, $6D -$6F, $72, $79, $20, $73, $69, $7A, $65 -$20, $00, $20, $42, $79, $74, $65, $73 -$20, $66, $72, $65, $65, $0D, $0A, $0A -$45, $6E, $68, $61, $6E, $63, $65, $64 -$20, $42, $41, $53, $49, $43, $20, $32 -$2E, $32, $32, $0A, $00, $02, $80, $19 -$56, $62, $80, $76, $22, $F3, $82, $38 -$AA, $40, $80, $35, $04, $F3, $81, $35 -$04, $F3, $80, $80, $00, $00, $80, $31 -$72, $18, $91, $43, $4F, $F8, $94, $74 -$23, $F7, $94, $74, $24, $00, $81, $38 -$AA, $3B, $06, $74, $63, $90, $8C, $77 -$23, $0C, $AB, $7A, $1E, $94, $00, $7C -$63, $42, $80, $7E, $75, $FE, $D0, $80 -$31, $72, $15, $81, $00, $00, $00, $81 -$49, $0F, $DB, $04, $86, $1E, $D7, $FB -$87, $99, $26, $65, $87, $23, $34, $58 -$86, $A5, $5D, $E1, $83, $49, $0F, $DB -$08, $78, $3A, $C5, $37, $7B, $83, $A2 -$5C, $7C, $2E, $DD, $4D, $7D, $99, $B0 -$1E, $7D, $59, $ED, $24, $7E, $91, $72 -$00, $7E, $4C, $B9, $73, $7F, $AA, $AA -$53, $81, $00, $00, $00, $81, $80, $00 -$00, $90, $80, $00, $00, $00, $7F, $00 -$00, $00, $84, $20, $00, $00, $FE, $79 -$60, $00, $27, $10, $FF, $FC, $18, $00 -$00, $64, $FF, $FF, $F6, $00, $00, $01 -$1F, $C5, $5C, $C4, $69, $CA, $90, $C6 -$4B, $C9, $63, $CD, $6B, $C9, $B8, $C7 -$8A, $C7, $EF, $C5, $AE, $C5, $BE, $C6 -$46, $C5, $D2, $C5, $69, $DF, $75, $DF -$7B, $C6, $22, $C7, $1D, $C5, $2B, $C7 -$84, $C5, $8D, $C7, $8D, $D5, $F4, $E0 -$F7, $E0, $78, $D0, $12, $D5, $2E, $D5 -$7B, $D5, $B8, $C5, $21, $C6, $59, $C8 -$8A, $C5, $A7, $C3, $A4, $C3, $52, $C3 -$EA, $DF, $28, $C8, $53, $D5, $86, $DD -$9A, $DD, $18, $DF, $1B, $DF, $69, $CC -$69, $CC, $69, $CC, $ED, $CA, $F0, $CB -$F0, $CB, $69, $CC, $69, $CC, $69, $CC -$69, $CC, $69, $CC, $69, $CC, $69, $CC -$69, $CC, $69, $CC, $69, $CC, $00, $00 -$63, $CC, $69, $CC, $63, $CC, $63, $CC -$63, $CC, $63, $CC, $69, $CC, $90, $CC -$90, $CC, $00, $00, $81, $DF, $81, $DF -$6F, $CC, $6F, $CC, $00, $00, $74, $CC -$74, $CC, $74, $CC, $FB, $D8, $85, $D9 -$18, $D9, $51, $DD, $49, $D0, $68, $D0 -$40, $E0, $A1, $DC, $FF, $D6, $03, $DC -$D5, $DC, $DC, $DC, $25, $DD, $57, $DD -$07, $D5, $1B, $D5, $59, $D4, $72, $D4 -$2A, $D1, $9F, $D4, $7D, $D4, $37, $D4 -$16, $D4, $88, $D3, $27, $DE, $D8, $DD -$B0, $DD, $87, $DF, $97, $DF, $DD, $E0 -$E7, $E0, $CD, $E0, $9A, $D3, $A3, $D3 -$D2, $D3, $79, $C5, $D5, $79, $AA, $D5 -$7B, $40, $D7, $7B, $08, $D8, $7F, $BF -$DB, $50, $D9, $CC, $46, $BF, $CC, $46 -$CC, $CC, $56, $85, $CD, $56, $6D, $CD -$7D, $F8, $DB, $5A, $1B, $CC, $64, $FA -$CC, $2A, $2B, $2D, $2F, $3C, $3D, $3E -$3F, $41, $42, $43, $44, $45, $46, $47 -$48, $49, $4C, $4D, $4E, $4F, $50, $52 -$53, $54, $55, $56, $57, $5E, $00, $71 -$E3, $73, $E3, $75, $E3, $77, $E3, $79 -$E3, $7D, $E3, $7F, $E3, $83, $E3, $85 -$E3, $95, $E3, $AE, $E3, $C5, $E3, $DE -$E3, $ED, $E3, $F7, $E3, $04, $E4, $0A -$E4, $1C, $E4, $41, $E4, $4F, $E4, $61 -$E4, $69, $E4, $7E, $E4, $AD, $E4, $D8 -$E4, $EC, $E4, $FD, $E4, $09, $E5, $18 -$E5, $B8, $00, $B6, $00, $B7, $00, $B9 -$00, $3C, $BF, $C2, $00, $C1, $00, $3E -$BE, $C0, $00, $9F, $00, $42, $53, $28 -$C5, $4E, $44, $BB, $53, $43, $28, $D7 -$54, $4E, $28, $D0, $00, $49, $4E, $24 -$28, $DC, $49, $54, $43, $4C, $52, $A8 -$49, $54, $53, $45, $54, $A7, $49, $54 -$54, $53, $54, $28, $DD, $00, $41, $4C -$4C, $9C, $48, $52, $24, $28, $DA, $4C -$45, $41, $52, $A2, $4F, $4E, $54, $A0 -$4F, $53, $28, $CD, $00, $41, $54, $41 -$83, $45, $43, $88, $45, $45, $4B, $28 -$D2, $45, $46, $99, $49, $4D, $85, $4F -$4B, $45, $9B, $4F, $9D, $00, $4C, $53 -$45, $AC, $4E, $44, $80, $4F, $52, $BC -$58, $50, $28, $CC, $00, $4E, $AE, $4F -$52, $81, $52, $45, $28, $C7, $00, $45 -$54, $A5, $4F, $53, $55, $42, $8D, $4F -$54, $4F, $89, $00, $45, $58, $24, $28 -$DB, $00, $46, $8B, $4E, $43, $95, $4E -$50, $55, $54, $84, $4E, $54, $28, $C4 -$52, $51, $A9, $00, $43, $41, $53, $45 -$24, $28, $D9, $45, $46, $54, $24, $28 -$E3, $45, $4E, $28, $D4, $45, $54, $87 -$49, $53, $54, $A1, $4F, $41, $44, $97 -$4F, $47, $28, $CB, $4F, $4F, $50, $9E -$00, $41, $58, $28, $DE, $49, $44, $24 -$28, $E5, $49, $4E, $28, $DF, $00, $45 -$57, $A3, $45, $58, $54, $82, $4D, $49 -$AA, $4F, $54, $B1, $55, $4C, $4C, $94 -$00, $46, $46, $B5, $4E, $93, $52, $BD -$00, $45, $45, $4B, $28, $D1, $49, $E0 -$4F, $4B, $45, $9A, $4F, $53, $28, $C8 -$52, $49, $4E, $54, $9F, $00, $45, $41 -$44, $86, $45, $4D, $91, $45, $53, $54 -$4F, $52, $45, $8C, $45, $54, $49, $52 -$51, $8E, $45, $54, $4E, $4D, $49, $8F -$45, $54, $55, $52, $4E, $90, $49, $47 -$48, $54, $24, $28, $E4, $4E, $44, $28 -$CA, $55, $4E, $8A, $00, $41, $44, $44 -$28, $D3, $41, $56, $45, $98, $47, $4E -$28, $C3, $49, $4E, $28, $CE, $50, $43 -$28, $AF, $51, $52, $28, $C9, $54, $45 -$50, $B2, $54, $4F, $50, $92, $54, $52 -$24, $28, $D5, $57, $41, $50, $A6, $00 -$41, $42, $28, $AB, $41, $4E, $28, $CF -$48, $45, $4E, $B0, $4F, $AD, $57, $4F -$50, $49, $E1, $00, $43, $41, $53, $45 -$24, $28, $D8, $4E, $54, $49, $4C, $B3 -$53, $52, $28, $C6, $00, $41, $4C, $28 -$D6, $41, $52, $50, $54, $52, $28, $E2 -$00, $41, $49, $54, $96, $48, $49, $4C -$45, $B4, $49, $44, $54, $48, $A4, $00 -$BA, $00, $03, $45, $E2, $E3, $03, $46 -$EF, $E3, $04, $4E, $52, $E4, $04, $44 -$C5, $E3, $05, $49, $0F, $E4, $03, $44 -$D4, $E3, $04, $52, $7E, $E4, $03, $4C -$2D, $E4, $03, $44, $C9, $E3, $04, $47 -$FF, $E3, $03, $52, $A9, $E4, $02, $49 -$0A, $E4, $07, $52, $85, $E4, $05, $47 -$FA, $E3, $06, $52, $8C, $E4, $06, $52 -$92, $E4, $06, $52, $98, $E4, $03, $52 -$82, $E4, $04, $53, $CA, $E4, $02, $4F -$64, $E4, $04, $4E, $5C, $E4, $03, $49 -$0C, $E4, $04, $57, $09, $E5, $04, $4C -$34, $E4, $04, $53, $B2, $E4, $03, $44 -$D1, $E3, $04, $50, $70, $E4, $04, $44 -$D7, $E3, $04, $43, $AE, $E3, $02, $44 -$DB, $E3, $04, $4C, $3C, $E4, $05, $50 -$78, $E4, $04, $43, $BC, $E3, $04, $4C -$30, $E4, $05, $43, $B7, $E3, $03, $4E -$4F, $E4, $05, $57, $12, $E5, $03, $47 -$F7, $E3, $04, $53, $D3, $E4, $06, $42 -$A0, $E3, $06, $42, $9A, $E3, $03, $49 -$18, $E4, $03, $4E, $56, $E4, $04, $54 -$D8, $E4, $04, $45, $DE, $E3, $02, $54 -$E4, $E4, $02, $46, $ED, $E3, $04, $53 -$BE, $E4, $04, $54, $E0, $E4, $03, $4E -$59, $E4, $04, $53, $C6, $E4, $05, $55 -$F3, $E4, $05, $57, $0D, $E5, $03, $4F -$61, $E4, $01, $2B, $00, $00, $01, $2D -$00, $00, $01, $2A, $00, $00, $01, $2F -$00, $00, $01, $5E, $00, $00, $03, $41 -$89, $E3, $03, $45, $E5, $E3, $02, $4F -$66, $E4, $02, $3E, $7F, $E3, $02, $3C -$79, $E3, $01, $3E, $00, $00, $01, $3D -$00, $00, $01, $3C, $00, $00, $04, $53 -$B6, $E4, $04, $49, $14, $E4, $04, $41 -$85, $E3, $04, $55, $F8, $E4, $04, $46 -$F2, $E3, $04, $50, $74, $E4, $04, $53 -$C2, $E4, $04, $52, $A5, $E4, $04, $4C -$38, $E4, $04, $45, $E8, $E3, $04, $43 -$C0, $E3, $04, $53, $BA, $E4, $04, $54 -$DC, $E4, $04, $41, $90, $E3, $05, $50 -$69, $E4, $05, $44, $CC, $E3, $05, $53 -$AD, $E4, $04, $4C, $29, $E4, $05, $53 -$CE, $E4, $04, $56, $FD, $E4, $04, $41 -$8C, $E3, $07, $55, $EC, $E4, $07, $4C -$1C, $E4, $05, $43, $B2, $E3, $05, $48 -$04, $E4, $05, $42, $95, $E3, $07, $42 -$A6, $E3, $04, $4D, $41, $E4, $04, $4D -$4A, $E4, $02, $50, $6E, $E4, $05, $54 -$E6, $E4, $07, $56, $01, $E5, $06, $4C -$23, $E4, $07, $52, $9E, $E4, $05, $4D -$45, $E4, $D6, $E6, $E7, $E6, $EE, $E6 -$03, $E7, $0F, $E7, $1D, $E7, $26, $E7 -$34, $E7, $48, $E7, $55, $E7, $66, $E7 -$75, $E7, $84, $E7, $92, $E7, $A2, $E7 -$B5, $E7, $C4, $E7, $D7, $E7, $4E, $45 -$58, $54, $20, $77, $69, $74, $68, $6F -$75, $74, $20, $46, $4F, $52, $00, $53 -$79, $6E, $74, $61, $78, $00, $52, $45 -$54, $55, $52, $4E, $20, $77, $69, $74 -$68, $6F, $75, $74, $20, $47, $4F, $53 -$55, $42, $00, $4F, $75, $74, $20, $6F -$66, $20, $44, $41, $54, $41, $00, $46 -$75, $6E, $63, $74, $69, $6F, $6E, $20 -$63, $61, $6C, $6C, $00, $4F, $76, $65 -$72, $66, $6C, $6F, $77, $00, $4F, $75 -$74, $20, $6F, $66, $20, $6D, $65, $6D -$6F, $72, $79, $00, $55, $6E, $64, $65 -$66, $69, $6E, $65, $64, $20, $73, $74 -$61, $74, $65, $6D, $65, $6E, $74, $00 -$41, $72, $72, $61, $79, $20, $62, $6F -$75, $6E, $64, $73, $00, $44, $6F, $75 -$62, $6C, $65, $20, $64, $69, $6D, $65 -$6E, $73, $69, $6F, $6E, $00, $44, $69 -$76, $69, $64, $65, $20, $62, $79, $20 -$7A, $65, $72, $6F, $00, $49, $6C, $6C -$65, $67, $61, $6C, $20, $64, $69, $72 -$65, $63, $74, $00, $54, $79, $70, $65 -$20, $6D, $69, $73, $6D, $61, $74, $63 -$68, $00, $53, $74, $72, $69, $6E, $67 -$20, $74, $6F, $6F, $20, $6C, $6F, $6E -$67, $00, $53, $74, $72, $69, $6E, $67 -$20, $74, $6F, $6F, $20, $63, $6F, $6D -$70, $6C, $65, $78, $00, $43, $61, $6E -$27, $74, $20, $63, $6F, $6E, $74, $69 -$6E, $75, $65, $00, $55, $6E, $64, $65 -$66, $69, $6E, $65, $64, $20, $66, $75 -$6E, $63, $74, $69, $6F, $6E, $00, $4C -$4F, $4F, $50, $20, $77, $69, $74, $68 -$6F, $75, $74, $20, $44, $4F, $00, $0D -$0A, $42, $72, $65, $61, $6B, $00, $20 -$45, $72, $72, $6F, $72, $00, $20, $69 -$6E, $20, $6C, $69, $6E, $65, $20, $00 -$0D, $0A, $52, $65, $61, $64, $79, $0D -$0A, $00, $20, $45, $78, $74, $72, $61 -$20, $69, $67, $6E, $6F, $72, $65, $64 -$0D, $0A, $00, $20, $52, $65, $64, $6F -$20, $66, $72, $6F, $6D, $20, $73, $74 -$61, $72, $74, $0D, $0A, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$AD, $E1, $FF, $F0, $0C, $C9, $61, $90 -$06, $C9, $7B, $B0, $02, $29, $5F, $38 -$60, $18, $60, $8D, $E0, $FF, $29, $FF -$60, $00, $00, $00, $00, $00, $00, $00 +; Program disassembly from $C000 to $FFDF 3/4/2016 +; EhBasic image for MKBASIC 6502 simulator. +; +ORG +$C000 +; Char IO +IOADDR +$FFE0 +; ROM +ROMBEGIN +$FFC0 +ROMEND +$FFDF +; Enable char IO and ROM +ENIO +ENROM +; Auto-execute +EXEC +$C000 +; Data/Code +$D8, $A0, $08, $B9, $FB, $E0, $99, $00 +$02, $88, $10, $F7, $A2, $FF, $8E, $21 +$02, $86, $88, $9A, $A9, $4C, $85, $A1 +$A2, $1C, $BD, $03, $E1, $95, $BB, $CA +$D0, $F8, $A2, $12, $BD, $20, $E1, $95 +$00, $CA, $10, $F8, $A9, $00, $85, $DC +$85, $DF, $85, $B2, $85, $67, $A9, $0E +$85, $64, $A9, $03, $85, $A0, $A2, $68 +$86, $65, $20, $97, $C8, $A9, $33, $A0 +$E1, $20, $D8, $C8, $20, $45, $C2, $86 +$C3, $84, $C4, $20, $C2, $00, $D0, $1F +$A0, $00, $E6, $11, $D0, $08, $E6, $12 +$A5, $12, $C9, $C0, $F0, $1D, $A9, $55 +$91, $11, $D1, $11, $D0, $15, $0A, $91 +$11, $D1, $11, $F0, $E5, $D0, $0C, $20 +$AB, $D9, $A5, $AC, $C9, $98, $B0, $A2 +$20, $FC, $D4, $A5, $11, $A4, $12, $C0 +$01, $90, $97, $85, $85, $84, $86, $85 +$81, $84, $82, $A0, $00, $A2, $03, $84 +$79, $86, $7A, $98, $91, $79, $E6, $79 +$20, $97, $C8, $20, $55, $C3, $A5, $85 +$38, $E5, $79, $AA, $A5, $86, $E5, $7A +$20, $87, $DA, $A9, $42, $A0, $E1, $20 +$D8, $C8, $A9, $5E, $A0, $C1, $85, $01 +$84, $02, $6C, $01, $00, $20, $0F, $C1 +$85, $7F, $84, $80, $38, $A5, $A6, $E5 +$AA, $A8, $A5, $A7, $E5, $AB, $AA, $E8 +$98, $F0, $24, $38, $49, $FF, $65, $A6 +$85, $A6, $B0, $03, $C6, $A7, $38, $98 +$49, $FF, $65, $A4, $85, $A4, $B0, $08 +$C6, $A5, $90, $04, $B1, $A6, $91, $A4 +$88, $D0, $F9, $B1, $A6, $91, $A4, $C6 +$A7, $C6, $A5, $CA, $D0, $F2, $60, $85 +$78, $BA, $E4, $78, $90, $30, $60, $C4 +$82, $90, $2A, $D0, $04, $C5, $81, $90 +$24, $48, $A2, $08, $98, $48, $B5, $A3 +$CA, $10, $FA, $20, $E4, $D1, $A2, $00 +$68, $95, $A4, $E8, $E0, $08, $30, $F8 +$68, $A8, $68, $C4, $82, $90, $06, $D0 +$05, $C5, $81, $B0, $01, $60, $A2, $0C +$20, $97, $C8, $BD, $B2, $E6, $BC, $B3 +$E6, $20, $D8, $C8, $20, $8E, $C3, $A9 +$EF, $A0, $E7, $20, $D8, $C8, $A4, $88 +$C8, $F0, $03, $20, $7C, $DA, $A9, $00 +$85, $DF, $85, $DC, $A9, $00, $A0, $E8 +$20, $D8, $C8, $18, $20, $52, $C2, $86 +$C3, $84, $C4, $20, $C2, $00, $F0, $F4 +$A2, $FF, $86, $88, $90, $06, $20, $83 +$C2, $4C, $F8, $C4, $20, $5A, $C7, $20 +$83, $C2, $84, $5D, $20, $29, $C3, $90 +$44, $A0, $01, $B1, $AA, $85, $72, $A5 +$7B, $85, $71, $A5, $AB, $85, $74, $A5 +$AA, $88, $F1, $AA, $18, $65, $7B, $85 +$7B, $85, $73, $A5, $7C, $69, $FF, $85 +$7C, $E5, $AB, $AA, $38, $A5, $AA, $E5 +$7B, $A8, $B0, $03, $E8, $C6, $74, $18 +$65, $71, $90, $03, $C6, $72, $18, $B1 +$71, $91, $73, $C8, $D0, $F9, $E6, $72 +$E6, $74, $CA, $D0, $F2, $AD, $21, $02 +$F0, $3F, $A5, $85, $A4, $86, $85, $81 +$84, $82, $A5, $7B, $85, $A6, $A4, $7C +$84, $A7, $65, $5D, $90, $01, $C8, $85 +$A4, $84, $A5, $20, $C5, $C0, $A5, $7F +$A4, $80, $85, $7B, $84, $7C, $A4, $5D +$88, $B9, $1D, $02, $91, $AA, $88, $C0 +$03, $D0, $F6, $A5, $12, $91, $AA, $88 +$A5, $11, $91, $AA, $88, $A9, $FF, $91 +$AA, $20, $6A, $C3, $A6, $79, $A5, $7A +$A0, $01, $86, $71, $85, $72, $B1, $71 +$F0, $18, $A0, $04, $C8, $B1, $71, $D0 +$FB, $38, $98, $65, $71, $AA, $A0, $00 +$91, $71, $98, $65, $72, $C8, $91, $71 +$90, $E0, $4C, $6C, $C1, $20, $F0, $C8 +$20, $ED, $C8, $D0, $05, $20, $F2, $C8 +$CA, $2C, $A2, $00, $20, $EF, $E0, $90 +$FB, $F0, $F9, $C9, $07, $F0, $10, $C9 +$0D, $F0, $19, $E0, $00, $D0, $04, $C9 +$21, $90, $E9, $C9, $08, $F0, $DE, $E0 +$47, $B0, $0C, $9D, $21, $02, $E8, $20 +$F2, $C8, $D0, $D8, $4C, $8E, $C8, $A9 +$07, $D0, $F4, $A0, $FF, $38, $A5, $C3 +$E9, $21, $AA, $86, $60, $BD, $21, $02 +$F0, $51, $C9, $5F, $B0, $4D, $C9, $3C +$B0, $0E, $C9, $30, $B0, $45, $85, $5C +$C9, $22, $F0, $61, $C9, $2A, $90, $3B +$24, $60, $70, $37, $86, $78, $84, $BA +$A0, $19, $84, $73, $A0, $E3, $84, $74 +$A0, $00, $D1, $73, $F0, $05, $90, $21 +$C8, $D0, $F7, $98, $0A, $AA, $BD, $37 +$E3, $85, $73, $BD, $38, $E3, $85, $74 +$A0, $FF, $A6, $78, $C8, $B1, $73, $30 +$08, $E8, $DD, $21, $02, $F0, $F5, $D0 +$2B, $A4, $BA, $E8, $C8, $99, $21, $02 +$C9, $00, $F0, $32, $E9, $3A, $F0, $04 +$C9, $49, $D0, $02, $85, $60, $49, $57 +$D0, $93, $85, $5C, $BD, $21, $02, $F0 +$E2, $C5, $5C, $F0, $DE, $C8, $99, $21 +$02, $E8, $D0, $F0, $A6, $78, $B1, $73 +$08, $C8, $28, $10, $F9, $B1, $73, $D0 +$BE, $BD, $21, $02, $10, $C3, $C8, $C8 +$99, $21, $02, $C8, $C8, $C8, $C6, $C3 +$60, $A5, $79, $A6, $7A, $A0, $01, $85 +$AA, $86, $AB, $B1, $AA, $F0, $1A, $A0 +$03, $B1, $AA, $88, $C5, $12, $D0, $04 +$B1, $AA, $C5, $11, $B0, $09, $88, $B1 +$AA, $AA, $88, $B1, $AA, $90, $DE, $F0 +$01, $18, $60, $D0, $FD, $A9, $00, $A8 +$91, $79, $C8, $91, $79, $18, $A5, $79 +$69, $02, $85, $7B, $A5, $7A, $69, $00 +$85, $7C, $18, $A5, $79, $69, $FF, $85 +$C3, $A5, $7A, $69, $FF, $85, $C4, $A5 +$85, $A4, $86, $85, $81, $84, $82, $A5 +$7B, $A4, $7C, $85, $7D, $84, $7E, $85 +$7F, $84, $80, $20, $49, $C5, $A2, $68 +$86, $65, $68, $AA, $68, $8E, $FE, $01 +$8D, $FF, $01, $A2, $FD, $9A, $A9, $00 +$85, $8C, $85, $61, $60, $F0, $D0, $60 +$90, $06, $F0, $04, $C9, $B7, $D0, $F4 +$20, $5A, $C7, $20, $29, $C3, $20, $C2 +$00, $F0, $0C, $C9, $B7, $D0, $93, $20 +$BC, $00, $20, $5A, $C7, $D0, $8B, $A5 +$11, $05, $12, $D0, $06, $A9, $FF, $85 +$11, $85, $12, $A0, $01, $84, $60, $20 +$97, $C8, $B1, $AA, $F0, $3E, $20, $19 +$C5, $C8, $B1, $AA, $AA, $C8, $B1, $AA +$C5, $12, $D0, $04, $E4, $11, $F0, $02 +$B0, $2A, $84, $97, $20, $87, $DA, $A9 +$20, $A4, $97, $29, $7F, $20, $F2, $C8 +$C9, $22, $D0, $06, $A5, $60, $49, $FF +$85, $60, $C8, $B1, $AA, $D0, $0E, $A8 +$B1, $AA, $AA, $C8, $B1, $AA, $86, $AA +$85, $AB, $D0, $B7, $60, $10, $DE, $24 +$60, $30, $DA, $A2, $E5, $0A, $0A, $90 +$02, $E8, $18, $69, $1A, $90, $01, $E8 +$85, $73, $86, $74, $84, $97, $A0, $00 +$B1, $73, $AA, $C8, $B1, $73, $CA, $F0 +$B8, $20, $F2, $C8, $C8, $B1, $73, $48 +$C8, $B1, $73, $A0, $00, $85, $74, $68 +$85, $73, $B1, $73, $CA, $F0, $A2, $20 +$F2, $C8, $C8, $D0, $F5, $A9, $80, $85 +$61, $20, $B9, $C7, $68, $68, $A9, $10 +$20, $07, $C1, $20, $A2, $C6, $18, $98 +$65, $C3, $48, $A5, $C4, $69, $00, $48 +$A5, $88, $48, $A5, $87, $48, $A9, $AD +$20, $F6, $CB, $20, $D5, $CA, $20, $D2 +$CA, $A5, $B0, $09, $7F, $25, $AD, $85 +$AD, $A9, $9C, $A0, $C4, $85, $71, $84 +$72, $4C, $89, $CB, $A9, $E9, $A0, $E1 +$20, $82, $D8, $20, $C2, $00, $C9, $B2 +$D0, $06, $20, $BC, $00, $20, $D2, $CA +$20, $EE, $D8, $85, $B0, $20, $7E, $CB +$A5, $98, $48, $A5, $97, $48, $A9, $81 +$48, $20, $19, $C5, $A5, $C3, $A4, $C4 +$A6, $88, $E8, $F0, $04, $85, $8B, $84 +$8C, $A0, $00, $B1, $C3, $F0, $07, $C9 +$3A, $F0, $1D, $4C, $07, $CC, $A0, $02 +$B1, $C3, $18, $F0, $56, $C8, $B1, $C3 +$85, $87, $C8, $B1, $C3, $85, $88, $98 +$65, $C3, $85, $C3, $90, $02, $E6, $C4 +$20, $BC, $00, $20, $01, $C5, $4C, $C1 +$C4, $F0, $54, $0A, $B0, $03, $4C, $B9 +$C7, $C9, $56, $B0, $CE, $A8, $B9, $11 +$E2, $48, $B9, $10, $E2, $48, $4C, $BC +$00, $6C, $03, $02, $C9, $03, $B0, $01 +$18, $D0, $67, $A5, $C4, $49, $02, $F0 +$10, $49, $02, $A4, $C3, $84, $8B, $85 +$8C, $A5, $87, $A4, $88, $85, $89, $84 +$8A, $68, $68, $90, $07, $A9, $E7, $A0 +$E7, $4C, $53, $C1, $4C, $5E, $C1, $D0 +$0F, $38, $A5, $79, $E9, $01, $A4, $7A +$B0, $01, $88, $85, $8F, $84, $90, $60 +$20, $5A, $C7, $20, $A5, $C6, $A5, $88 +$C5, $12, $B0, $0B, $98, $38, $65, $C3 +$A6, $C4, $90, $07, $E8, $B0, $04, $A5 +$79, $A6, $7A, $20, $2D, $C3, $B0, $03 +$4C, $77, $C6, $A5, $AA, $E9, $01, $A4 +$AB, $B0, $D0, $90, $CD, $20, $91, $D4 +$86, $0D, $60, $D0, $FD, $A4, $8C, $D0 +$05, $A2, $1E, $4C, $40, $C1, $A9, $93 +$20, $19, $DF, $A9, $93, $20, $1C, $DF +$84, $C4, $A5, $8B, $85, $C3, $A5, $89 +$A4, $8A, $85, $87, $84, $88, $60, $D0 +$03, $4C, $6A, $C3, $20, $77, $C3, $F0 +$2E, $A9, $05, $20, $07, $C1, $A5, $C4 +$48, $A5, $C3, $48, $A5, $88, $48, $A5 +$87, $48, $A9, $9D, $48, $20, $C2, $00 +$4C, $C1, $C4, $A9, $05, $20, $07, $C1 +$A5, $C4, $48, $A5, $C3, $48, $A5, $88 +$48, $A5, $87, $48, $A9, $8D, $48, $20 +$C2, $00, $20, $F0, $C5, $4C, $C1, $C4 +$20, $5A, $C7, $20, $A5, $C6, $A5, $88 +$C5, $12, $B0, $0B, $98, $38, $65, $C3 +$A6, $C4, $90, $07, $E8, $B0, $04, $A5 +$79, $A6, $7A, $20, $2D, $C3, $90, $67 +$A5, $AA, $E9, $01, $85, $C3, $A5, $AB +$E9, $00, $85, $C4, $60, $A2, $22, $4C +$40, $C1, $A8, $BA, $BD, $03, $01, $C9 +$9D, $D0, $F2, $E8, $E8, $9A, $98, $F0 +$20, $C9, $3A, $F0, $1C, $E9, $B3, $AA +$F0, $04, $CA, $D0, $62, $CA, $86, $98 +$20, $BC, $00, $20, $E6, $CA, $A5, $AC +$F0, $02, $A9, $FF, $BA, $45, $98, $D0 +$1A, $BD, $02, $01, $85, $87, $BD, $03 +$01, $85, $88, $BD, $04, $01, $85, $C3 +$BD, $05, $01, $85, $C4, $20, $C2, $00 +$4C, $C1, $C4, $E8, $E8, $E8, $E8, $E8 +$9A, $4C, $91, $C6, $A2, $04, $2C, $A2 +$0E, $4C, $40, $C1, $D0, $9E, $68, $68 +$68, $C9, $8D, $D0, $EF, $68, $85, $87 +$68, $85, $88, $68, $85, $C3, $68, $85 +$C4, $20, $A2, $C6, $98, $18, $65, $C3 +$85, $C3, $90, $02, $E6, $C4, $60, $4C +$07, $CC, $A2, $3A, $2C, $A2, $00, $A0 +$00, $84, $5C, $8A, $45, $5C, $85, $5C +$B1, $C3, $F0, $EA, $C5, $5C, $F0, $E6 +$C8, $C9, $22, $D0, $F3, $F0, $EC, $20 +$E6, $CA, $20, $C2, $00, $C9, $B0, $F0 +$11, $C9, $89, $D0, $D2, $A6, $C3, $A4 +$C4, $20, $BC, $00, $B0, $C9, $86, $C3 +$84, $C4, $A5, $AC, $F0, $1B, $20, $BC +$00, $B0, $03, $4C, $F0, $C5, $C9, $90 +$D0, $03, $4C, $03, $C5, $20, $01, $C5 +$A0, $00, $B1, $C3, $C9, $AC, $F0, $99 +$60, $A0, $00, $A2, $01, $C8, $B1, $C3 +$F0, $0F, $C9, $8B, $D0, $03, $E8, $D0 +$F4, $C9, $AC, $D0, $F0, $CA, $D0, $ED +$C8, $98, $18, $65, $C3, $85, $C3, $90 +$02, $E6, $C4, $20, $C2, $00, $90, $C3 +$4C, $01, $C5, $20, $A5, $C6, $4C, $94 +$C6, $4C, $07, $CC, $C9, $A9, $D0, $03 +$4C, $3D, $DF, $C9, $AA, $D0, $03, $4C +$41, $DF, $20, $91, $D4, $48, $C9, $8D +$F0, $04, $C9, $89, $D0, $E3, $C6, $AF +$D0, $04, $68, $4C, $03, $C5, $20, $BC +$00, $20, $5A, $C7, $C9, $2C, $F0, $EE +$68, $60, $A2, $00, $86, $11, $86, $12 +$B0, $F7, $E0, $19, $A8, $B0, $DD, $E9 +$2F, $A8, $A5, $11, $0A, $26, $12, $0A +$26, $12, $65, $11, $85, $11, $8A, $65 +$12, $06, $11, $2A, $AA, $98, $65, $11 +$85, $11, $90, $01, $E8, $20, $BC, $00 +$4C, $5E, $C7, $A9, $ED, $2C, $A9, $E9 +$48, $20, $AF, $CD, $A6, $5F, $30, $1E +$85, $97, $84, $98, $20, $82, $D8, $68 +$48, $A0, $E1, $20, $C3, $D5, $20, $A8 +$D8, $20, $C2, $00, $C9, $2C, $D0, $A8 +$20, $BC, $00, $4C, $91, $C7, $4C, $E1 +$CA, $20, $AF, $CD, $85, $97, $84, $98 +$A9, $C1, $20, $F6, $CB, $A5, $5F, $48 +$20, $E6, $CA, $68, $2A, $20, $D8, $CA +$D0, $03, $4C, $A8, $D8, $A0, $02, $B1 +$AE, $C5, $82, $90, $17, $D0, $07, $88 +$B1, $AE, $C5, $81, $90, $0E, $A4, $AF +$C4, $7C, $90, $08, $D0, $0D, $A5, $AE +$C5, $7B, $B0, $07, $A5, $AE, $A4, $AF +$4C, $11, $C8, $A0, $00, $B1, $AE, $20 +$37, $D1, $A5, $9E, $A4, $9F, $85, $B8 +$84, $B9, $20, $16, $D3, $A9, $AC, $A0 +$00, $85, $9E, $84, $9F, $20, $78, $D3 +$A0, $00, $B1, $9E, $91, $97, $C8, $B1 +$9E, $91, $97, $C8, $B1, $9E, $91, $97 +$60, $20, $AF, $CD, $85, $97, $84, $98 +$20, $05, $DF, $A6, $5F, $30, $07, $A8 +$20, $6B, $D0, $4C, $A8, $D8, $48, $A9 +$01, $B0, $01, $68, $20, $3F, $D1, $F0 +$05, $68, $A0, $00, $91, $AD, $20, $8A +$D1, $4C, $D5, $C7, $20, $DB, $C8, $20 +$C2, $00, $F0, $3B, $C9, $AB, $F0, $56 +$C9, $AF, $F0, $52, $C9, $2C, $F0, $38 +$C9, $3B, $F0, $66, $20, $E6, $CA, $24 +$5F, $30, $E1, $20, $9A, $DA, $20, $49 +$D1, $A0, $00, $A5, $0F, $F0, $0A, $38 +$E5, $0E, $F1, $AE, $B0, $03, $20, $97 +$C8, $20, $DB, $C8, $F0, $C9, $A9, $00 +$9D, $21, $02, $A2, $21, $A0, $02, $A9 +$0D, $20, $F2, $C8, $A9, $0A, $D0, $52 +$A5, $0E, $C5, $10, $90, $05, $20, $97 +$C8, $D0, $27, $38, $E5, $64, $B0, $FC +$49, $FF, $69, $01, $D0, $12, $48, $20 +$8E, $D4, $C9, $29, $D0, $7B, $68, $C9 +$AB, $D0, $06, $8A, $E5, $0E, $90, $0A +$AA, $8A, $F0, $06, $20, $ED, $C8, $CA +$D0, $FA, $20, $BC, $00, $D0, $85, $60 +$20, $49, $D1, $20, $43, $D3, $A0, $00 +$AA, $F0, $49, $B1, $71, $20, $F2, $C8 +$C8, $CA, $D0, $F7, $60, $A9, $20, $2C +$A9, $3F, $C9, $20, $90, $19, $48, $A5 +$0F, $D0, $0A, $A5, $0E, $E5, $64, $D0 +$0B, $85, $0E, $F0, $07, $C5, $0E, $D0 +$03, $20, $97, $C8, $E6, $0E, $68, $20 +$F2, $E0, $C9, $0D, $D0, $14, $86, $78 +$A6, $0D, $F0, $0A, $A9, $00, $20, $F2 +$C8, $CA, $D0, $FA, $A9, $0D, $86, $0E +$A6, $78, $29, $FF, $60, $A5, $62, $10 +$0B, $A5, $8D, $A4, $8E, $85, $87, $84 +$88, $4C, $07, $CC, $A9, $1B, $A0, $E8 +$20, $D8, $C8, $A5, $8B, $A4, $8C, $85 +$C3, $84, $C4, $60, $C9, $22, $D0, $0B +$20, $C3, $CB, $A9, $3B, $20, $F6, $CB +$20, $DB, $C8, $20, $6F, $D0, $20, $45 +$C2, $A9, $00, $CD, $21, $02, $D0, $0A +$18, $4C, $31, $C5, $A6, $8F, $A4, $90 +$A9, $80, $85, $62, $86, $91, $84, $92 +$20, $AF, $CD, $85, $97, $84, $98, $A5 +$C3, $A4, $C4, $85, $11, $84, $12, $A6 +$91, $A4, $92, $86, $C3, $84, $C4, $20 +$C2, $00, $D0, $11, $24, $62, $30, $65 +$20, $F0, $C8, $20, $45, $C2, $86, $C3 +$84, $C4, $20, $C2, $00, $24, $5F, $10 +$24, $85, $5B, $C9, $22, $F0, $07, $A9 +$3A, $85, $5B, $A9, $2C, $18, $85, $5C +$A5, $C3, $A4, $C4, $69, $00, $90, $01 +$C8, $20, $4F, $D1, $20, $D4, $D4, $20 +$D5, $C7, $4C, $D3, $C9, $20, $AB, $D9 +$20, $A8, $D8, $20, $C2, $00, $F0, $0A +$C9, $2C, $F0, $03, $4C, $2D, $C9, $20 +$BC, $00, $A5, $C3, $A4, $C4, $85, $91 +$84, $92, $A5, $11, $A4, $12, $85, $C3 +$84, $C4, $20, $C2, $00, $F0, $2C, $20 +$03, $CC, $4C, $78, $C9, $20, $A2, $C6 +$C8, $AA, $D0, $12, $A2, $06, $C8, $B1 +$C3, $F0, $73, $C8, $B1, $C3, $85, $8D +$C8, $B1, $C3, $C8, $85, $8E, $B1, $C3 +$C8, $AA, $20, $94, $C6, $E0, $83, $F0 +$81, $D0, $DA, $A5, $91, $A4, $92, $A6 +$62, $10, $03, $4C, $53, $C5, $A0, $00 +$B1, $91, $D0, $01, $60, $A9, $0A, $A0 +$E8, $4C, $D8, $C8, $BA, $E8, $E8, $E8 +$E8, $BD, $01, $01, $C9, $81, $D0, $21 +$A5, $98, $D0, $0A, $BD, $02, $01, $85 +$97, $BD, $03, $01, $85, $98, $DD, $03 +$01, $D0, $07, $A5, $97, $DD, $02, $01 +$F0, $07, $8A, $18, $69, $10, $AA, $D0 +$D8, $60, $D0, $04, $A0, $00, $F0, $03 +$20, $AF, $CD, $85, $97, $84, $98, $20 +$3C, $CA, $F0, $04, $A2, $00, $F0, $63 +$9A, $8A, $38, $E9, $F7, $85, $73, $69 +$FB, $A0, $01, $20, $82, $D8, $BA, $BD +$08, $01, $85, $B0, $A5, $97, $A4, $98 +$20, $C3, $D5, $20, $A8, $D8, $A0, $01 +$20, $1E, $D9, $BA, $DD, $08, $01, $F0 +$17, $BD, $0D, $01, $85, $87, $BD, $0E +$01, $85, $88, $BD, $10, $01, $85, $C3 +$BD, $0F, $01, $85, $C4, $4C, $C1, $C4 +$8A, $69, $0F, $AA, $9A, $20, $C2, $00 +$C9, $2C, $D0, $F1, $20, $BC, $00, $20 +$70, $CA, $20, $E6, $CA, $18, $24, $38 +$24, $5F, $30, $03, $B0, $03, $60, $B0 +$FD, $A2, $18, $4C, $40, $C1, $A6, $C3 +$D0, $02, $C6, $C4, $C6, $C3, $A9, $00 +$48, $A9, $02, $20, $07, $C1, $20, $D2 +$CB, $A9, $00, $85, $9B, $20, $C2, $00 +$38, $E9, $C0, $90, $17, $C9, $03, $B0 +$13, $C9, $01, $2A, $49, $01, $45, $9B +$C5, $9B, $90, $67, $85, $9B, $20, $BC +$00, $4C, $00, $CB, $A6, $9B, $D0, $2C +$B0, $79, $69, $0A, $90, $75, $D0, $07 +$24, $5F, $10, $03, $4C, $D9, $D2, $85 +$71, $0A, $65, $71, $A8, $68, $D9, $F2 +$E2, $B0, $65, $20, $D5, $CA, $48, $20 +$67, $CB, $68, $A4, $99, $10, $19, $AA +$F0, $76, $D0, $5D, $26, $5F, $8A, $85 +$5F, $2A, $A6, $C3, $D0, $02, $C6, $C4 +$C6, $C3, $A0, $24, $85, $9B, $D0, $D5 +$D9, $F2, $E2, $B0, $44, $90, $D7, $B9 +$F4, $E2, $48, $B9, $F3, $E2, $48, $20 +$7E, $CB, $A5, $9B, $48, $B9, $F2, $E2 +$4C, $F0, $CA, $4C, $07, $CC, $68, $85 +$71, $E6, $71, $68, $85, $72, $A5, $B0 +$48, $20, $DE, $D8, $A5, $AF, $48, $A5 +$AE, $48, $A5, $AD, $48, $A5, $AC, $48 +$6C, $71, $00, $A0, $FF, $68, $F0, $20 +$C9, $64, $F0, $03, $20, $D5, $CA, $84 +$99, $68, $4A, $85, $63, $68, $85, $B3 +$68, $85, $B4, $68, $85, $B5, $68, $85 +$B6, $68, $85, $B7, $45, $B0, $85, $B8 +$A5, $AC, $60, $A5, $C3, $A4, $C4, $69 +$00, $90, $01, $C8, $20, $49, $D1, $4C +$D4, $D4, $20, $BC, $00, $B0, $03, $4C +$AB, $D9, $AA, $30, $2F, $C9, $24, $F0 +$F6, $C9, $25, $F0, $F2, $C9, $2E, $F0 +$EE, $C9, $22, $F0, $D6, $C9, $28, $D0 +$4F, $20, $EE, $CA, $A9, $29, $A0, $00 +$D1, $C3, $D0, $0B, $4C, $BC, $00, $A9 +$28, $D0, $F3, $A9, $2C, $D0, $EF, $A2 +$02, $4C, $40, $C1, $C9, $B7, $F0, $29 +$C9, $B6, $F0, $BE, $C9, $B1, $D0, $13 +$A0, $21, $D0, $1F, $20, $AB, $CE, $A5 +$AF, $49, $FF, $A8, $A5, $AE, $49, $FF +$4C, $5E, $D0, $C9, $AE, $D0, $03, $4C +$B9, $D0, $E9, $C3, $B0, $19, $4C, $07 +$CC, $A0, $1E, $68, $68, $4C, $3F, $CB +$20, $AF, $CD, $85, $AE, $84, $AF, $A6 +$5F, $30, $03, $4C, $82, $D8, $60, $0A +$A8, $B9, $AD, $E2, $48, $B9, $AC, $E2 +$48, $B9, $67, $E2, $F0, $05, $48, $B9 +$66, $E2, $48, $60, $20, $F1, $CB, $4C +$D7, $CA, $20, $F1, $CB, $4C, $D5, $CA +$46, $5F, $4C, $BC, $00, $20, $EE, $CA +$20, $03, $CC, $20, $D7, $CA, $68, $AA +$68, $A8, $A5, $AF, $48, $A5, $AE, $48 +$98, $48, $8A, $48, $20, $91, $D4, $8A +$60, $20, $EE, $CA, $20, $D5, $CA, $A5 +$AC, $C9, $98, $B0, $20, $20, $55, $D9 +$A2, $02, $B5, $AD, $95, $11, $CA, $10 +$F9, $20, $C2, $00, $A2, $00, $C9, $29 +$F0, $0A, $20, $E3, $D4, $20, $C2, $00 +$C9, $29, $D0, $01, $60, $4C, $2E, $CF +$20, $E7, $CC, $45, $5B, $A8, $A5, $AE +$45, $5C, $4C, $5E, $D0, $20, $E7, $CC +$05, $5B, $A8, $A5, $AE, $05, $5C, $4C +$5E, $D0, $20, $E7, $CC, $25, $5B, $A8 +$A5, $AE, $25, $5C, $4C, $5E, $D0, $20 +$AB, $CE, $A5, $AE, $85, $5C, $A5, $AF +$85, $5B, $20, $C8, $D5, $20, $AB, $CE +$A5, $AF, $60, $20, $D8, $CA, $B0, $13 +$A5, $B7, $09, $7F, $25, $B4, $85, $B4 +$A9, $B3, $A0, $00, $20, $1C, $D9, $AA +$4C, $44, $CD, $46, $5F, $C6, $9B, $20 +$43, $D3, $85, $AC, $86, $AD, $84, $AE +$A5, $B5, $A4, $B6, $20, $47, $D3, $86 +$B5, $84, $B6, $AA, $38, $E5, $AC, $F0 +$08, $A9, $01, $90, $04, $A6, $AC, $A9 +$FF, $85, $B0, $A0, $FF, $E8, $C8, $CA +$D0, $07, $A6, $B0, $30, $0F, $18, $90 +$0C, $B1, $B5, $D1, $AD, $F0, $EF, $A2 +$FF, $B0, $02, $A2, $01, $E8, $8A, $2A +$25, $63, $F0, $02, $A9, $FF, $4C, $FF +$D8, $20, $03, $CC, $AA, $20, $B4, $CD +$20, $C2, $00, $D0, $F4, $60, $20, $A4 +$CD, $A5, $AE, $A6, $78, $F0, $22, $E0 +$10, $B0, $23, $06, $AF, $2A, $CA, $D0 +$FA, $A4, $AF, $4C, $5E, $D0, $20, $A4 +$CD, $A5, $AE, $A6, $78, $F0, $0A, $E0 +$10, $B0, $0B, $4A, $66, $AF, $CA, $D0 +$FA, $A4, $AF, $4C, $5E, $D0, $A9, $00 +$A8, $4C, $5E, $D0, $20, $94, $D4, $86 +$78, $20, $C8, $D5, $4C, $AB, $CE, $A2 +$00, $20, $C2, $00, $86, $5E, $85, $93 +$29, $7F, $20, $23, $CE, $B0, $03, $4C +$07, $CC, $A2, $00, $86, $5F, $20, $BC +$00, $90, $05, $20, $23, $CE, $90, $0B +$AA, $20, $BC, $00, $90, $FB, $20, $23 +$CE, $B0, $F6, $C9, $24, $D0, $0B, $A9 +$FF, $85, $5F, $8A, $09, $80, $AA, $20 +$BC, $00, $86, $94, $05, $61, $C9, $28 +$D0, $03, $4C, $BD, $CE, $A9, $00, $85 +$61, $A5, $7B, $A6, $7C, $A0, $00, $86 +$AB, $85, $AA, $E4, $7E, $D0, $04, $C5 +$7D, $F0, $2C, $A5, $93, $D1, $AA, $D0 +$08, $A5, $94, $C8, $D1, $AA, $F0, $69 +$88, $18, $A5, $AA, $69, $06, $90, $E1 +$E8, $D0, $DC, $C9, $61, $B0, $0A, $C9 +$41, $90, $05, $E9, $5B, $38, $E9, $A5 +$60, $E9, $7B, $38, $E9, $85, $60, $68 +$48, $C9, $42, $D0, $05, $A9, $EA, $A0 +$E1, $60, $A5, $7D, $A4, $7E, $85, $AA +$84, $AB, $A5, $7F, $A4, $80, $85, $A6 +$84, $A7, $18, $69, $06, $90, $01, $C8 +$85, $A4, $84, $A5, $20, $C5, $C0, $A5 +$A4, $A4, $A5, $C8, $85, $7D, $84, $7E +$A0, $00, $A5, $93, $91, $AA, $C8, $A5 +$94, $91, $AA, $A9, $00, $C8, $91, $AA +$C8, $91, $AA, $C8, $91, $AA, $C8, $91 +$AA, $A5, $AA, $18, $69, $02, $A4, $AB +$90, $01, $C8, $85, $95, $84, $96, $60 +$A5, $5D, $0A, $69, $05, $65, $AA, $A4 +$AB, $90, $01, $C8, $85, $A4, $84, $A5 +$60, $20, $BC, $00, $20, $D2, $CA, $A5 +$B0, $30, $0D, $A5, $AC, $C9, $90, $90 +$09, $A9, $F1, $A0, $E1, $20, $1C, $D9 +$D0, $74, $4C, $55, $D9, $A5, $5E, $48 +$A5, $5F, $48, $A0, $00, $98, $48, $A5 +$94, $48, $A5, $93, $48, $20, $A1, $CE +$68, $85, $93, $68, $85, $94, $68, $A8 +$BA, $BD, $02, $01, $48, $BD, $01, $01 +$48, $A5, $AE, $9D, $02, $01, $A5, $AF +$9D, $01, $01, $C8, $20, $C2, $00, $C9 +$2C, $F0, $D2, $84, $5D, $20, $F4, $CB +$68, $85, $5F, $68, $85, $5E, $A6, $7D +$A5, $7E, $86, $AA, $85, $AB, $C5, $80 +$D0, $04, $E4, $7F, $F0, $39, $A0, $00 +$B1, $AA, $C8, $C5, $93, $D0, $06, $A5 +$94, $D1, $AA, $F0, $16, $C8, $B1, $AA +$18, $65, $AA, $AA, $C8, $B1, $AA, $65 +$AB, $90, $D7, $A2, $10, $2C, $A2, $08 +$4C, $40, $C1, $A2, $12, $A5, $5E, $D0 +$F7, $20, $90, $CE, $A5, $5D, $A0, $04 +$D1, $AA, $D0, $E7, $4C, $CA, $CF, $20 +$90, $CE, $20, $0F, $C1, $A0, $00, $84 +$BB, $A5, $93, $91, $AA, $C8, $A5, $94 +$91, $AA, $A5, $5D, $A0, $04, $84, $BA +$91, $AA, $18, $A2, $0B, $A9, $00, $24 +$5E, $50, $07, $68, $69, $01, $AA, $68 +$69, $00, $C8, $91, $AA, $C8, $8A, $91 +$AA, $20, $19, $D0, $86, $BA, $85, $BB +$A4, $71, $C6, $5D, $D0, $DD, $65, $A5 +$B0, $5D, $85, $A5, $A8, $8A, $65, $A4 +$90, $03, $C8, $F0, $52, $20, $0F, $C1 +$85, $7F, $84, $80, $A9, $00, $E6, $BB +$A4, $BA, $F0, $05, $88, $91, $A4, $D0 +$FB, $C6, $A5, $C6, $BB, $D0, $F5, $E6 +$A5, $38, $A0, $02, $A5, $7F, $E5, $AA +$91, $AA, $C8, $A5, $80, $E5, $AB, $91 +$AA, $A5, $5E, $D0, $53, $C8, $B1, $AA +$85, $5D, $A9, $00, $85, $BA, $85, $BB +$C8, $68, $AA, $85, $AE, $68, $85, $AF +$D1, $AA, $90, $0E, $D0, $06, $C8, $8A +$D1, $AA, $90, $07, $4C, $2B, $CF, $4C +$3E, $C1, $C8, $A5, $BB, $05, $BA, $F0 +$0A, $20, $19, $D0, $8A, $65, $AE, $AA +$98, $A4, $71, $65, $AF, $86, $BA, $C6 +$5D, $D0, $CB, $06, $BA, $2A, $06, $BA +$2A, $A8, $A5, $BA, $65, $A4, $85, $95 +$98, $65, $A5, $85, $96, $A8, $A5, $95 +$60, $84, $71, $B1, $AA, $85, $76, $88 +$B1, $AA, $85, $77, $A9, $10, $85, $A8 +$A2, $00, $A0, $00, $8A, $0A, $AA, $98 +$2A, $A8, $B0, $B3, $06, $BA, $26, $BB +$90, $0B, $18, $8A, $65, $76, $AA, $98 +$65, $77, $A8, $B0, $A2, $C6, $A8, $D0 +$E3, $60, $A5, $5F, $10, $03, $20, $43 +$D3, $20, $E4, $D1, $38, $A5, $81, $E5 +$7F, $A8, $A5, $82, $E5, $80, $46, $5F +$85, $AD, $84, $AE, $A2, $90, $4C, $07 +$D9, $A4, $0E, $A9, $00, $F0, $EF, $A6 +$88, $E8, $D0, $A4, $A2, $16, $4C, $40 +$C1, $20, $AA, $D0, $85, $9C, $84, $9D +$20, $6F, $D0, $20, $FF, $CB, $A9, $80 +$85, $61, $20, $AF, $CD, $20, $D5, $CA +$20, $F4, $CB, $A9, $C1, $20, $F6, $CB +$A5, $96, $48, $A5, $95, $48, $A5, $C4 +$48, $A5, $C3, $48, $20, $91, $C6, $4C +$19, $D1, $A9, $AE, $20, $F6, $CB, $09 +$80, $85, $61, $20, $B6, $CD, $4C, $D5 +$CA, $20, $AA, $D0, $48, $98, $48, $20 +$FF, $CB, $20, $E6, $CA, $20, $F4, $CB +$20, $D5, $CA, $68, $85, $9D, $68, $85 +$9C, $A2, $20, $A0, $03, $B1, $9C, $F0 +$9D, $85, $96, $88, $B1, $9C, $85, $95 +$AA, $C8, $B1, $95, $48, $88, $10, $FA +$A4, $96, $20, $AC, $D8, $A5, $C4, $48 +$A5, $C3, $48, $B1, $9C, $85, $C3, $C8 +$B1, $9C, $85, $C4, $A5, $96, $48, $A5 +$95, $48, $20, $D2, $CA, $68, $85, $9C +$68, $85, $9D, $20, $C2, $00, $F0, $03 +$4C, $07, $CC, $68, $85, $C3, $68, $85 +$C4, $A0, $00, $68, $91, $9C, $C8, $68 +$91, $9C, $C8, $68, $91, $9C, $C8, $68 +$91, $9C, $60, $20, $D5, $CA, $20, $9A +$DA, $A9, $F0, $A0, $00, $F0, $12, $A6 +$AE, $A4, $AF, $86, $9E, $84, $9F, $20 +$B2, $D1, $86, $AD, $84, $AE, $85, $AC +$60, $A2, $22, $86, $5B, $86, $5C, $85 +$B8, $84, $B9, $85, $AD, $84, $AE, $A0 +$FF, $C8, $B1, $B8, $F0, $0C, $C5, $5B +$F0, $04, $C5, $5C, $D0, $F3, $C9, $22 +$F0, $01, $18, $84, $AC, $98, $65, $B8 +$85, $BA, $A6, $B9, $90, $01, $E8, $86 +$BB, $A5, $B9, $C9, $03, $B0, $0B, $98 +$20, $37, $D1, $A6, $B8, $A4, $B9, $20 +$24, $D3, $A6, $65, $E0, $71, $D0, $05 +$A2, $1C, $4C, $40, $C1, $A5, $AC, $95 +$00, $A5, $AD, $95, $01, $A5, $AE, $95 +$02, $A0, $00, $86, $AE, $84, $AF, $88 +$84, $5F, $86, $66, $E8, $E8, $E8, $86 +$65, $60, $46, $60, $48, $49, $FF, $38 +$65, $81, $A4, $82, $B0, $01, $88, $C4 +$80, $90, $11, $D0, $04, $C5, $7F, $90 +$0B, $85, $81, $84, $82, $85, $83, $84 +$84, $AA, $68, $60, $A2, $0C, $A5, $60 +$30, $B8, $20, $E4, $D1, $A9, $80, $85 +$60, $68, $D0, $D0, $A6, $85, $A5, $86 +$86, $81, $85, $82, $A0, $00, $84, $9D +$A5, $7F, $A6, $80, $85, $AA, $86, $AB +$A9, $68, $85, $71, $84, $72, $C5, $65 +$F0, $05, $20, $68, $D2, $F0, $F7, $06 +$A0, $A5, $7B, $A6, $7C, $85, $71, $86 +$72, $E4, $7E, $D0, $04, $C5, $7D, $F0 +$05, $20, $62, $D2, $F0, $F3, $85, $A4 +$86, $A5, $A9, $04, $85, $A0, $A5, $A4 +$A6, $A5, $E4, $80, $D0, $04, $C5, $7F +$F0, $75, $85, $71, $86, $72, $A0, $02 +$B1, $71, $65, $A4, $85, $A4, $C8, $B1 +$71, $65, $A5, $85, $A5, $A0, $01, $B1 +$71, $10, $DB, $A0, $04, $B1, $71, $0A +$69, $05, $20, $9A, $D2, $E4, $A5, $D0 +$04, $C5, $A4, $F0, $CD, $20, $68, $D2 +$F0, $F3, $C8, $B1, $71, $10, $30, $C8 +$B1, $71, $F0, $2B, $C8, $B1, $71, $AA +$C8, $B1, $71, $C5, $82, $90, $06, $D0 +$1E, $E4, $81, $B0, $1A, $C5, $AB, $90 +$17, $D0, $04, $E4, $AA, $90, $11, $86 +$AA, $85, $AB, $A5, $71, $A6, $72, $85 +$9C, $86, $9D, $88, $88, $84, $A2, $18 +$A5, $A0, $65, $71, $85, $71, $90, $02 +$E6, $72, $A6, $72, $A0, $00, $60, $C6 +$A0, $A6, $9D, $F0, $F5, $A4, $A2, $18 +$B1, $9C, $65, $AA, $85, $A6, $A5, $AB +$69, $00, $85, $A7, $A5, $81, $A6, $82 +$85, $A4, $86, $A5, $20, $CC, $C0, $A4 +$A2, $C8, $A5, $A4, $91, $9C, $AA, $E6 +$A5, $A5, $A5, $C8, $91, $9C, $4C, $E8 +$D1, $A5, $AF, $48, $A5, $AE, $48, $20 +$D2, $CB, $20, $D7, $CA, $68, $85, $B8 +$68, $85, $B9, $A0, $00, $B1, $B8, $18 +$71, $AE, $90, $05, $A2, $1A, $4C, $40 +$C1, $20, $37, $D1, $20, $16, $D3, $A5 +$9E, $A4, $9F, $20, $47, $D3, $20, $28 +$D3, $A5, $B8, $A4, $B9, $20, $47, $D3 +$20, $8A, $D1, $4C, $FD, $CA, $A0, $00 +$B1, $B8, $48, $C8, $B1, $B8, $AA, $C8 +$B1, $B8, $A8, $68, $86, $71, $84, $72 +$AA, $F0, $14, $A0, $00, $B1, $71, $91 +$83, $C8, $CA, $D0, $F8, $98, $18, $65 +$83, $85, $83, $90, $02, $E6, $84, $60 +$20, $D7, $CA, $A5, $AE, $A4, $AF, $85 +$71, $84, $72, $20, $78, $D3, $08, $A0 +$00, $B1, $71, $48, $C8, $B1, $71, $AA +$C8, $B1, $71, $A8, $68, $28, $D0, $13 +$C4, $82, $D0, $0F, $E4, $81, $D0, $0B +$48, $18, $65, $81, $85, $81, $90, $02 +$E6, $82, $68, $86, $71, $84, $72, $60 +$C4, $67, $D0, $0C, $C5, $66, $D0, $08 +$85, $65, $E9, $03, $85, $66, $A0, $00 +$60, $20, $94, $D4, $8A, $48, $A9, $01 +$20, $3F, $D1, $68, $A0, $00, $91, $AD +$4C, $8A, $D1, $48, $20, $FC, $D3, $D1 +$9E, $98, $F0, $09, $48, $20, $FC, $D3 +$18, $F1, $9E, $49, $FF, $90, $04, $B1 +$9E, $AA, $98, $48, $8A, $48, $20, $3F +$D1, $A5, $9E, $A4, $9F, $20, $47, $D3 +$68, $A8, $68, $18, $65, $71, $85, $71 +$90, $02, $E6, $72, $98, $20, $28, $D3 +$4C, $8A, $D1, $48, $A9, $FF, $85, $AF +$20, $C2, $00, $C9, $29, $F0, $06, $20 +$03, $CC, $20, $91, $D4, $20, $FC, $D3 +$CA, $8A, $48, $18, $A2, $00, $F1, $9E +$B0, $C2, $49, $FF, $C5, $AF, $90, $BD +$A5, $AF, $B0, $B9, $20, $F4, $CB, $68 +$85, $A2, $68, $85, $A3, $68, $AA, $68 +$85, $9E, $68, $85, $9F, $A0, $00, $8A +$F0, $79, $E6, $A2, $6C, $A2, $00, $20 +$40, $D3, $85, $AC, $A8, $F0, $38, $20 +$3F, $D1, $86, $AD, $84, $AE, $A8, $88 +$B1, $71, $20, $27, $CE, $90, $02, $09 +$20, $91, $83, $98, $D0, $F1, $F0, $1F +$20, $40, $D3, $85, $AC, $A8, $F0, $17 +$20, $3F, $D1, $86, $AD, $84, $AE, $A8 +$88, $B1, $71, $20, $23, $CE, $90, $02 +$29, $DF, $91, $83, $98, $D0, $F1, $4C +$8A, $D1, $20, $BC, $00, $20, $AF, $CD +$20, $F4, $CB, $20, $D7, $CA, $A0, $02 +$B1, $95, $AA, $88, $B1, $95, $A8, $8A +$4C, $5E, $D0, $20, $79, $D4, $4C, $6B +$D0, $20, $40, $D3, $A8, $60, $20, $79 +$D4, $F0, $08, $A0, $00, $B1, $71, $A8 +$4C, $6B, $D0, $4C, $2E, $CF, $20, $BC +$00, $20, $D2, $CA, $20, $A7, $CE, $A4 +$AE, $D0, $F0, $A6, $AF, $4C, $C2, $00 +$20, $79, $D4, $D0, $03, $4C, $55, $D6 +$A6, $C3, $A4, $C4, $86, $BA, $84, $BB +$A6, $71, $86, $C3, $18, $65, $71, $85 +$73, $A5, $72, $85, $C4, $69, $00, $85 +$74, $A0, $00, $B1, $73, $48, $98, $91 +$73, $20, $C2, $00, $20, $AB, $D9, $68 +$A0, $00, $91, $73, $A6, $BA, $A4, $BB +$86, $C3, $84, $C4, $60, $20, $D2, $CA +$20, $F6, $D4, $20, $03, $CC, $A5, $12 +$48, $A5, $11, $48, $20, $91, $D4, $68 +$85, $11, $68, $85, $12, $60, $A5, $AC +$C9, $98, $B0, $8F, $20, $55, $D9, $A5 +$AE, $A4, $AF, $84, $11, $85, $12, $60 +$20, $F6, $D4, $A2, $00, $A1, $11, $A8 +$4C, $6B, $D0, $20, $DD, $D4, $8A, $A2 +$00, $81, $11, $60, $20, $F6, $D4, $A2 +$00, $A1, $11, $A8, $E6, $11, $D0, $02 +$E6, $12, $A1, $11, $4C, $5E, $D0, $20 +$D2, $CA, $20, $F6, $D4, $84, $97, $85 +$98, $20, $03, $CC, $20, $D2, $CA, $20 +$F6, $D4, $98, $A2, $00, $81, $97, $E6 +$97, $D0, $02, $E6, $98, $A5, $12, $81 +$97, $4C, $C2, $00, $20, $AF, $CD, $85 +$97, $84, $98, $A5, $5F, $48, $20, $03 +$CC, $20, $AF, $CD, $68, $45, $5F, $10 +$10, $A0, $03, $B1, $97, $AA, $B1, $95 +$91, $97, $8A, $91, $95, $88, $10, $F3 +$60, $4C, $E1, $CA, $20, $D2, $CA, $20 +$F6, $D4, $A9, $D5, $48, $A9, $8A, $48 +$6C, $11, $00, $4C, $C2, $00, $20, $DD +$D4, $86, $97, $A2, $00, $20, $C2, $00 +$F0, $03, $20, $E3, $D4, $86, $98, $B1 +$11, $45, $98, $25, $97, $F0, $F8, $60 +$20, $90, $D7, $A5, $B0, $49, $FF, $85 +$B0, $45, $B7, $85, $B8, $A5, $AC, $4C +$C6, $D5, $20, $DF, $D6, $90, $4D, $A9 +$F2, $A0, $E1, $20, $90, $D7, $D0, $10 +$A5, $B7, $85, $B0, $A2, $04, $B5, $B2 +$95, $AB, $CA, $D0, $F9, $86, $B9, $60 +$A6, $B9, $86, $A3, $A2, $B3, $A5, $B3 +$A8, $F0, $C4, $38, $E5, $AC, $F0, $24 +$90, $12, $84, $AC, $A4, $B7, $84, $B0 +$49, $FF, $69, $00, $A0, $00, $84, $A3 +$A2, $AC, $D0, $04, $A0, $00, $84, $B9 +$C9, $F9, $30, $B6, $A8, $A5, $B9, $56 +$01, $20, $F6, $D6, $24, $B8, $10, $4C +$A0, $AC, $E0, $B3, $F0, $02, $A0, $B3 +$38, $49, $FF, $65, $A3, $85, $B9, $B9 +$03, $00, $F5, $03, $85, $AF, $B9, $02 +$00, $F5, $02, $85, $AE, $B9, $01, $00 +$F5, $01, $85, $AD, $B0, $03, $20, $9B +$D6, $A0, $00, $98, $18, $A6, $AD, $D0 +$3E, $A6, $AE, $86, $AD, $A6, $AF, $86 +$AE, $A6, $B9, $86, $AF, $84, $B9, $69 +$08, $C9, $18, $D0, $E8, $A9, $00, $85 +$AC, $85, $B0, $60, $65, $A3, $85, $B9 +$A5, $AF, $65, $B6, $85, $AF, $A5, $AE +$65, $B5, $85, $AE, $A5, $AD, $65, $B4 +$85, $AD, $B0, $1A, $60, $69, $01, $06 +$B9, $26, $AF, $26, $AE, $26, $AD, $10 +$F4, $38, $E5, $AC, $B0, $CF, $49, $FF +$69, $01, $85, $AC, $90, $0C, $E6, $AC +$F0, $36, $66, $AD, $66, $AE, $66, $AF +$66, $B9, $60, $A5, $B0, $49, $FF, $85 +$B0, $A5, $AD, $49, $FF, $85, $AD, $A5 +$AE, $49, $FF, $85, $AE, $A5, $AF, $49 +$FF, $85, $AF, $A5, $B9, $49, $FF, $85 +$B9, $E6, $B9, $D0, $0A, $E6, $AF, $D0 +$06, $E6, $AE, $D0, $02, $E6, $AD, $60 +$A2, $0A, $4C, $40, $C1, $A2, $74, $B4 +$03, $84, $B9, $B4, $02, $94, $03, $B4 +$01, $94, $02, $A4, $B2, $94, $01, $69 +$08, $30, $EC, $F0, $EA, $E9, $08, $A8 +$A5, $B9, $B0, $12, $16, $01, $90, $02 +$F6, $01, $76, $01, $76, $01, $76, $02 +$76, $03, $6A, $C8, $D0, $EE, $18, $60 +$20, $EE, $D8, $F0, $02, $10, $03, $4C +$2E, $CF, $A5, $AC, $E9, $7F, $48, $A9 +$80, $85, $AC, $A9, $72, $A0, $E1, $20 +$C3, $D5, $A9, $76, $A0, $E1, $20, $06 +$D8, $A9, $E9, $A0, $E1, $20, $A8, $D5 +$A9, $65, $A0, $E1, $20, $56, $DC, $A9 +$7A, $A0, $E1, $20, $C3, $D5, $68, $20 +$4A, $DA, $A9, $7E, $A0, $E1, $20, $90 +$D7, $F0, $4C, $20, $B6, $D7, $A9, $00 +$85, $75, $85, $76, $85, $77, $A5, $B9 +$20, $65, $D7, $A5, $AF, $20, $65, $D7 +$A5, $AE, $20, $65, $D7, $A5, $AD, $20 +$6A, $D7, $4C, $73, $D8, $D0, $03, $4C +$CD, $D6, $4A, $09, $80, $A8, $90, $13 +$18, $A5, $77, $65, $B6, $85, $77, $A5 +$76, $65, $B5, $85, $76, $A5, $75, $65 +$B4, $85, $75, $66, $75, $66, $76, $66 +$77, $66, $B9, $98, $4A, $D0, $DE, $60 +$85, $71, $84, $72, $A0, $03, $B1, $71 +$85, $B6, $88, $B1, $71, $85, $B5, $88 +$B1, $71, $85, $B7, $45, $B0, $85, $B8 +$A5, $B7, $09, $80, $85, $B4, $88, $B1 +$71, $85, $B3, $A5, $AC, $60, $A5, $B3 +$F0, $1D, $18, $65, $AC, $90, $04, $30 +$31, $18, $2C, $10, $12, $69, $80, $85 +$AC, $D0, $03, $4C, $59, $D6, $A5, $B8 +$85, $B0, $60, $A5, $B0, $10, $1B, $68 +$68, $4C, $55, $D6, $20, $CF, $D8, $AA +$F0, $F0, $18, $69, $02, $B0, $0B, $A2 +$00, $86, $B8, $20, $E0, $D5, $E6, $AC +$D0, $E0, $4C, $C8, $D6, $20, $CF, $D8 +$A9, $FA, $A0, $E1, $A2, $00, $86, $B8 +$20, $82, $D8, $4C, $09, $D8, $20, $90 +$D7, $F0, $63, $20, $DE, $D8, $A9, $00 +$38, $E5, $AC, $85, $AC, $20, $B6, $D7 +$E6, $AC, $F0, $D6, $A2, $FF, $A9, $01 +$A4, $B4, $C4, $AD, $D0, $0A, $A4, $B5 +$C4, $AE, $D0, $04, $A4, $B6, $C4, $AF +$08, $2A, $90, $0E, $A0, $01, $E8, $E0 +$02, $30, $04, $D0, $28, $A0, $40, $95 +$75, $98, $28, $90, $14, $A8, $A5, $B6 +$E5, $AF, $85, $B6, $A5, $B5, $E5, $AE +$85, $B5, $A5, $B4, $E5, $AD, $85, $B4 +$98, $06, $B6, $26, $B5, $26, $B4, $B0 +$CF, $30, $BD, $10, $CB, $4A, $6A, $6A +$85, $B9, $28, $4C, $73, $D8, $A2, $14 +$4C, $40, $C1, $A5, $75, $85, $AD, $A5 +$76, $85, $AE, $A5, $77, $85, $AF, $4C +$39, $D6, $85, $71, $84, $72, $A0, $03 +$B1, $71, $85, $AF, $88, $B1, $71, $85 +$AE, $88, $B1, $71, $85, $B0, $09, $80 +$85, $AD, $88, $B1, $71, $85, $AC, $84 +$B9, $60, $A2, $A4, $A0, $00, $F0, $04 +$A6, $97, $A4, $98, $20, $DE, $D8, $86 +$71, $84, $72, $A0, $03, $A5, $AF, $91 +$71, $88, $A5, $AE, $91, $71, $88, $A5 +$B0, $09, $7F, $25, $AD, $91, $71, $88 +$A5, $AC, $91, $71, $84, $B9, $60, $20 +$DE, $D8, $A2, $05, $B5, $AB, $95, $B2 +$CA, $D0, $F9, $86, $B9, $60, $A5, $AC +$F0, $FB, $06, $B9, $90, $F7, $20, $BD +$D6, $D0, $F2, $4C, $8E, $D6, $A5, $AC +$F0, $09, $A5, $B0, $2A, $A9, $FF, $B0 +$02, $A9, $01, $60, $20, $EE, $D8, $85 +$AD, $A9, $00, $85, $AE, $A2, $88, $A5 +$AD, $49, $FF, $2A, $A9, $00, $85, $AF +$86, $AC, $85, $B9, $85, $B0, $4C, $34 +$D6, $46, $B0, $60, $85, $73, $84, $74 +$A0, $00, $B1, $73, $C8, $AA, $F0, $C6 +$B1, $73, $45, $B0, $30, $C4, $E4, $AC +$D0, $1A, $B1, $73, $09, $80, $C5, $AD +$D0, $12, $C8, $B1, $73, $C5, $AE, $D0 +$0B, $C8, $A9, $7F, $C5, $B9, $B1, $73 +$E5, $AF, $F0, $28, $A5, $B0, $90, $02 +$49, $FF, $4C, $F4, $D8, $A5, $AC, $F0 +$4A, $38, $E9, $98, $24, $B0, $10, $09 +$AA, $A9, $FF, $85, $B2, $20, $A1, $D6 +$8A, $A2, $AC, $C9, $F9, $10, $06, $20 +$DF, $D6, $84, $B2, $60, $A8, $A5, $B0 +$29, $80, $46, $AD, $05, $AD, $85, $AD +$20, $F6, $D6, $84, $B2, $60, $A5, $AC +$C9, $98, $B0, $1E, $20, $55, $D9, $84 +$B9, $A5, $B0, $84, $B0, $49, $80, $2A +$A9, $98, $85, $AC, $A5, $AF, $85, $5B +$4C, $34, $D6, $85, $AD, $85, $AE, $85 +$AF, $A8, $60, $A0, $00, $84, $5F, $A2 +$09, $94, $A8, $CA, $10, $FB, $90, $7F +$C9, $2D, $D0, $04, $86, $B1, $F0, $04 +$C9, $2B, $D0, $05, $20, $BC, $00, $90 +$6E, $C9, $24, $D0, $03, $4C, $73, $DE +$C9, $25, $D0, $08, $4C, $A1, $DE, $20 +$BC, $00, $90, $5B, $C9, $2E, $F0, $2E +$C9, $45, $D0, $30, $20, $BC, $00, $90 +$17, $C9, $B7, $F0, $0E, $C9, $2D, $F0 +$0A, $C9, $B6, $F0, $08, $C9, $2B, $F0 +$04, $D0, $07, $66, $AB, $20, $BC, $00 +$90, $5B, $24, $AB, $10, $0E, $A9, $00 +$38, $E5, $A9, $4C, $16, $DA, $66, $AA +$24, $AA, $50, $C3, $A5, $A9, $38, $E5 +$A8, $85, $A9, $F0, $12, $10, $09, $20 +$F5, $D7, $E6, $A9, $D0, $F9, $F0, $07 +$20, $DC, $D7, $C6, $A9, $D0, $F9, $A5 +$B1, $30, $01, $60, $4C, $F9, $DB, $48 +$24, $AA, $10, $02, $E6, $A8, $20, $DC +$D7, $68, $29, $0F, $20, $4A, $DA, $4C +$D7, $D9, $48, $20, $CF, $D8, $68, $20 +$FF, $D8, $A5, $B7, $45, $B0, $85, $B8 +$A6, $AC, $4C, $C6, $D5, $A5, $A9, $C9 +$0A, $90, $09, $A9, $64, $24, $AB, $30 +$0E, $4C, $C8, $D6, $0A, $0A, $65, $A9 +$0A, $A0, $00, $71, $C3, $E9, $2F, $85 +$A9, $4C, $FD, $D9, $A9, $F6, $A0, $E7 +$20, $D8, $C8, $A5, $88, $A6, $87, $85 +$AD, $86, $AE, $A2, $90, $38, $20, $0C +$D9, $A0, $00, $98, $20, $A7, $DA, $4C +$D8, $C8, $A0, $01, $A9, $20, $24, $B0 +$10, $02, $A9, $2D, $99, $EF, $00, $85 +$B0, $84, $BA, $C8, $A6, $AC, $D0, $05 +$A9, $30, $4C, $B3, $DB, $A9, $00, $E0 +$81, $B0, $09, $A9, $8A, $A0, $E1, $20 +$3E, $D7, $A9, $FA, $85, $A8, $A9, $86 +$A0, $E1, $20, $1C, $D9, $F0, $1E, $10 +$12, $A9, $82, $A0, $E1, $20, $1C, $D9 +$F0, $02, $10, $0E, $20, $DC, $D7, $C6 +$A8, $D0, $EE, $20, $F5, $D7, $E6, $A8 +$D0, $DC, $20, $BF, $D5, $20, $55, $D9 +$A2, $01, $A5, $A8, $18, $69, $07, $30 +$09, $C9, $08, $B0, $06, $69, $FF, $AA +$A9, $02, $38, $E9, $02, $85, $A9, $86 +$A8, $8A, $F0, $02, $10, $13, $A4, $BA +$A9, $2E, $C8, $99, $EF, $00, $8A, $F0 +$06, $A9, $30, $C8, $99, $EF, $00, $84 +$BA, $A0, $00, $A2, $80, $A5, $AF, $18 +$79, $00, $E2, $85, $AF, $A5, $AE, $79 +$FF, $E1, $85, $AE, $A5, $AD, $79, $FE +$E1, $85, $AD, $E8, $B0, $04, $10, $E5 +$30, $02, $30, $E1, $8A, $90, $04, $49 +$FF, $69, $0A, $69, $2F, $C8, $C8, $C8 +$84, $95, $A4, $BA, $C8, $AA, $29, $7F +$99, $EF, $00, $C6, $A8, $D0, $06, $A9 +$2E, $C8, $99, $EF, $00, $84, $BA, $A4 +$95, $8A, $49, $FF, $29, $80, $AA, $C0 +$12, $D0, $B2, $A4, $BA, $B9, $EF, $00 +$88, $C9, $30, $F0, $F8, $C9, $2E, $F0 +$01, $C8, $A9, $2B, $A6, $A9, $F0, $2E +$10, $08, $A9, $00, $38, $E5, $A9, $AA +$A9, $2D, $99, $F1, $00, $A9, $45, $99 +$F0, $00, $8A, $A2, $2F, $38, $E8, $E9 +$0A, $B0, $FB, $69, $3A, $99, $F3, $00 +$8A, $99, $F2, $00, $A9, $00, $99, $F4 +$00, $F0, $08, $99, $EF, $00, $A9, $00 +$99, $F0, $00, $A9, $F0, $A0, $00, $60 +$F0, $42, $A5, $B3, $D0, $03, $4C, $57 +$D6, $A2, $9C, $A0, $00, $20, $AC, $D8 +$A5, $B7, $10, $0F, $20, $86, $D9, $A9 +$9C, $A0, $00, $20, $1C, $D9, $D0, $03 +$98, $A4, $5B, $20, $CA, $D5, $98, $48 +$20, $00, $D7, $A9, $9C, $A0, $00, $20 +$3E, $D7, $20, $04, $DC, $68, $4A, $90 +$0A, $A5, $AC, $F0, $06, $A5, $B0, $49 +$FF, $85, $B0, $60, $A9, $8E, $A0, $E1 +$20, $3E, $D7, $A5, $B9, $69, $50, $90 +$03, $20, $E6, $D8, $85, $A3, $20, $D2 +$D8, $A5, $AC, $C9, $88, $90, $03, $20 +$D3, $D7, $20, $86, $D9, $A5, $5B, $18 +$69, $81, $F0, $F3, $38, $E9, $01, $48 +$A2, $04, $B5, $B3, $B4, $AC, $95, $AC +$94, $B3, $CA, $10, $F5, $A5, $A3, $85 +$B9, $20, $AB, $D5, $20, $F9, $DB, $A9 +$92, $A0, $E1, $20, $6C, $DC, $A9, $00 +$85, $B8, $68, $4C, $B8, $D7, $85, $BA +$84, $BB, $20, $A2, $D8, $A9, $A4, $20 +$3E, $D7, $20, $70, $DC, $A9, $A4, $A0 +$00, $4C, $3E, $D7, $85, $BA, $84, $BB +$A2, $A8, $20, $A4, $D8, $B1, $BA, $85 +$B1, $A4, $BA, $C8, $98, $D0, $02, $E6 +$BB, $85, $BA, $A4, $BB, $20, $3E, $D7 +$A5, $BA, $A4, $BB, $18, $69, $04, $90 +$01, $C8, $85, $BA, $84, $BB, $20, $C3 +$D5, $A9, $A8, $A0, $00, $C6, $B1, $D0 +$E4, $60, $A5, $AC, $F0, $07, $A2, $D8 +$A0, $00, $20, $AC, $D8, $A2, $AF, $A0 +$13, $06, $D9, $26, $DA, $26, $DB, $26 +$D8, $90, $05, $8A, $45, $D9, $85, $D9 +$88, $D0, $EE, $A2, $02, $B5, $D9, $95 +$AD, $CA, $10, $F9, $A9, $80, $85, $AC +$0A, $85, $B0, $4C, $39, $D6, $A9, $AF +$A0, $E1, $20, $C3, $D5, $20, $CF, $D8 +$A9, $C4, $A0, $E1, $A6, $B7, $20, $FE +$D7, $20, $CF, $D8, $20, $86, $D9, $A9 +$00, $85, $B8, $20, $AB, $D5, $A9, $F6 +$A0, $E1, $20, $A8, $D5, $A5, $B0, $48 +$10, $0D, $20, $BF, $D5, $A5, $B0, $30 +$09, $A5, $63, $49, $FF, $85, $63, $20 +$F9, $DB, $A9, $F6, $A0, $E1, $20, $C3 +$D5, $68, $10, $03, $20, $F9, $DB, $A9 +$B3, $A0, $E1, $4C, $56, $DC, $20, $A2 +$D8, $A9, $00, $85, $63, $20, $DD, $DC +$A2, $9C, $A0, $00, $20, $AC, $D8, $A9 +$A4, $A0, $00, $20, $82, $D8, $A9, $00 +$85, $B0, $A5, $63, $20, $4E, $DD, $A9 +$9C, $A0, $00, $4C, $06, $D8, $48, $4C +$0F, $DD, $20, $0A, $00, $4C, $F4, $CB +$A5, $B0, $48, $10, $03, $20, $F9, $DB +$A5, $AC, $48, $C9, $81, $90, $07, $A9 +$E9, $A0, $E1, $20, $06, $D8, $A9, $C8 +$A0, $E1, $20, $56, $DC, $68, $C9, $81 +$90, $07, $A9, $AF, $A0, $E1, $20, $A8 +$D5, $68, $10, $16, $4C, $F9, $DB, $20 +$DD, $D4, $E0, $08, $B0, $20, $A9, $00 +$38, $2A, $CA, $10, $FC, $E8, $01, $11 +$81, $11, $60, $20, $DD, $D4, $E0, $08 +$B0, $0C, $A9, $FF, $2A, $CA, $10, $FC +$E8, $21, $11, $81, $11, $60, $4C, $2E +$CF, $20, $BC, $00, $20, $DD, $D4, $E0 +$08, $B0, $F3, $20, $C2, $00, $C9, $29 +$F0, $03, $4C, $07, $CC, $20, $BC, $00 +$A9, $00, $38, $2A, $CA, $10, $FC, $E8 +$21, $11, $F0, $02, $A9, $FF, $4C, $FF +$D8, $E0, $19, $B0, $48, $86, $78, $A9 +$18, $20, $3F, $D1, $A0, $17, $A2, $18 +$46, $11, $66, $12, $66, $13, $8A, $2A +$91, $AD, $88, $10, $F3, $A5, $78, $F0 +$0A, $AA, $38, $49, $FF, $69, $18, $F0 +$1C, $D0, $0F, $A8, $B1, $AD, $C9, $30 +$D0, $07, $CA, $F0, $03, $C8, $10, $F4 +$E8, $98, $18, $65, $AD, $85, $AD, $A9 +$00, $65, $AE, $85, $AE, $86, $AC, $20 +$BC, $00, $4C, $8A, $D1, $4C, $2E, $CF +$E0, $07, $B0, $F9, $86, $78, $A9, $06 +$20, $3F, $D1, $A0, $05, $F8, $A5, $13 +$20, $56, $DE, $A5, $12, $20, $56, $DE +$A5, $11, $20, $56, $DE, $D8, $A2, $06 +$A5, $78, $F0, $B7, $AA, $38, $49, $FF +$69, $06, $F0, $C9, $D0, $BC, $AA, $29 +$0F, $20, $61, $DE, $8A, $4A, $4A, $4A +$4A, $C9, $0A, $69, $30, $91, $AD, $88 +$60, $85, $AC, $A9, $00, $85, $B8, $8A +$20, $4A, $DA, $20, $BC, $00, $90, $0A +$09, $20, $E9, $61, $C9, $06, $B0, $2A +$69, $0A, $29, $0F, $AA, $A5, $AC, $F0 +$E4, $69, $04, $90, $DC, $4C, $C8, $D6 +$AA, $A5, $AC, $F0, $06, $E6, $AC, $F0 +$F4, $A9, $00, $85, $B8, $8A, $20, $4A +$DA, $20, $BC, $00, $49, $30, $C9, $02 +$90, $E6, $4C, $2F, $DA, $AD, $00, $02 +$D0, $18, $20, $EF, $E0, $90, $0B, $8D +$01, $02, $A2, $20, $8E, $02, $02, $4C +$1C, $C5, $AE, $02, $02, $F0, $03, $CE +$02, $02, $A2, $DC, $20, $D5, $DE, $A2 +$DF, $20, $D5, $DE, $60, $B5, $00, $10 +$FB, $0A, $29, $40, $F0, $F6, $95, $00 +$8A, $A8, $68, $68, $A9, $05, $20, $07 +$C1, $A5, $C4, $48, $A5, $C3, $48, $A5 +$88, $48, $A5, $87, $48, $A9, $8D, $48 +$B9, $01, $00, $85, $C3, $B9, $02, $00 +$85, $C4, $4C, $C1, $C4, $20, $EF, $E0 +$B0, $09, $AD, $02, $02, $F0, $09, $AD +$01, $02, $38, $A2, $00, $8E, $02, $02 +$60, $A2, $DF, $2C, $A2, $DC, $C9, $93 +$F0, $11, $C9, $B5, $F0, $07, $49, $A2 +$F0, $0E, $4C, $07, $CC, $A9, $7F, $35 +$00, $10, $05, $B5, $00, $0A, $15, $00 +$95, $00, $4C, $BC, $00, $58, $A2, $DF +$2C, $A2, $DC, $86, $78, $20, $BC, $00 +$20, $5A, $C7, $A5, $79, $A6, $7A, $20 +$2D, $C3, $B0, $03, $4C, $77, $C6, $A6 +$78, $A5, $AA, $E9, $01, $95, $01, $A5 +$AB, $E9, $00, $95, $02, $A9, $C0, $95 +$00, $60, $D0, $FD, $A5, $DF, $0A, $05 +$DF, $85, $DF, $4C, $7E, $C6, $D0, $F1 +$A5, $DC, $0A, $05, $DC, $85, $DC, $4C +$7E, $C6, $20, $EE, $CA, $4C, $D5, $CA +$20, $B6, $DF, $10, $FB, $A5, $B4, $09 +$80, $85, $B4, $20, $C8, $D5, $F0, $F0 +$20, $B6, $DF, $30, $FB, $F0, $F9, $A5 +$B4, $09, $80, $85, $B4, $20, $C8, $D5 +$F0, $EE, $C9, $29, $D0, $05, $68, $68 +$4C, $BC, $00, $4C, $07, $CC, $20, $C2 +$00, $C9, $2C, $D0, $ED, $20, $DE, $D8 +$A5, $B0, $09, $7F, $25, $AD, $48, $A5 +$AE, $48, $A5, $AF, $48, $A5, $AC, $48 +$20, $BC, $00, $20, $D2, $CA, $68, $85 +$B3, $68, $85, $B6, $68, $85, $B5, $68 +$85, $B4, $85, $B7, $A9, $B3, $A0, $00 +$4C, $1C, $D9, $C9, $2C, $F0, $1B, $20 +$91, $D4, $8A, $F0, $0A, $E0, $10, $90 +$45, $E4, $64, $B0, $02, $86, $64, $86 +$0F, $20, $C2, $00, $F0, $1A, $C9, $2C +$D0, $A9, $20, $8E, $D4, $8A, $30, $2E +$E0, $01, $90, $2A, $A5, $0F, $F0, $06 +$E4, $0F, $F0, $02, $B0, $20, $86, $64 +$A5, $0F, $F0, $06, $C5, $64, $B0, $03 +$85, $64, $38, $E5, $64, $B0, $FC, $65 +$64, $18, $65, $64, $85, $10, $A5, $0F +$38, $E5, $10, $85, $10, $60, $4C, $2E +$CF, $A5, $B0, $30, $F9, $A5, $AC, $F0 +$F4, $20, $CF, $D8, $A9, $00, $85, $77 +$85, $76, $85, $75, $85, $78, $85, $AF +$85, $AE, $85, $AD, $A2, $18, $A5, $B3 +$4A, $B0, $0E, $06, $B6, $26, $B5, $26 +$B4, $26, $77, $26, $76, $26, $75, $26 +$78, $06, $B6, $26, $B5, $26, $B4, $26 +$77, $26, $76, $26, $75, $26, $78, $06 +$AF, $26, $AE, $26, $AD, $A5, $AF, $2A +$85, $5B, $A5, $AE, $2A, $85, $5C, $A5 +$AD, $2A, $85, $5D, $A9, $00, $2A, $85 +$5E, $A5, $77, $E5, $5B, $85, $5B, $A5 +$76, $E5, $5C, $85, $5C, $A5, $75, $E5 +$5D, $A8, $A5, $78, $E5, $5E, $90, $0E +$85, $78, $84, $75, $A5, $5C, $85, $76 +$A5, $5B, $85, $77, $E6, $AF, $CA, $D0 +$A2, $38, $A5, $B3, $E9, $80, $6A, $69 +$00, $85, $AC, $4C, $39, $D6, $20, $BC +$00, $20, $AF, $CD, $20, $F4, $CB, $A4 +$95, $A5, $96, $4C, $5E, $D0, $A9, $C4 +$A0, $E1, $20, $82, $D8, $C6, $AC, $60 +$A9, $C4, $A0, $E1, $4C, $82, $D8, $6C +$05, $02, $6C, $07, $02, $6C, $09, $02 +$6C, $0B, $02, $FF, $00, $00, $AD, $DE +$C0, $FF, $D3, $FF, $E6, $C3, $D0, $02 +$E6, $C4, $AD, $FF, $FF, $C9, $AC, $F0 +$0E, $C9, $3A, $B0, $0A, $C9, $20, $F0 +$EB, $38, $E9, $30, $38, $E9, $D0, $60 +$4C, $00, $C0, $00, $00, $00, $00, $00 +$00, $00, $4C, $2E, $CF, $00, $00, $00 +$F2, $00, $03, $0D, $0A, $4D, $65, $6D +$6F, $72, $79, $20, $73, $69, $7A, $65 +$20, $00, $20, $42, $79, $74, $65, $73 +$20, $66, $72, $65, $65, $0D, $0A, $0A +$45, $6E, $68, $61, $6E, $63, $65, $64 +$20, $42, $41, $53, $49, $43, $20, $32 +$2E, $32, $32, $0A, $00, $02, $80, $19 +$56, $62, $80, $76, $22, $F3, $82, $38 +$AA, $40, $80, $35, $04, $F3, $81, $35 +$04, $F3, $80, $80, $00, $00, $80, $31 +$72, $18, $91, $43, $4F, $F8, $94, $74 +$23, $F7, $94, $74, $24, $00, $81, $38 +$AA, $3B, $06, $74, $63, $90, $8C, $77 +$23, $0C, $AB, $7A, $1E, $94, $00, $7C +$63, $42, $80, $7E, $75, $FE, $D0, $80 +$31, $72, $15, $81, $00, $00, $00, $81 +$49, $0F, $DB, $04, $86, $1E, $D7, $FB +$87, $99, $26, $65, $87, $23, $34, $58 +$86, $A5, $5D, $E1, $83, $49, $0F, $DB +$08, $78, $3A, $C5, $37, $7B, $83, $A2 +$5C, $7C, $2E, $DD, $4D, $7D, $99, $B0 +$1E, $7D, $59, $ED, $24, $7E, $91, $72 +$00, $7E, $4C, $B9, $73, $7F, $AA, $AA +$53, $81, $00, $00, $00, $81, $80, $00 +$00, $90, $80, $00, $00, $00, $7F, $00 +$00, $00, $84, $20, $00, $00, $FE, $79 +$60, $00, $27, $10, $FF, $FC, $18, $00 +$00, $64, $FF, $FF, $F6, $00, $00, $01 +$1F, $C5, $5C, $C4, $69, $CA, $90, $C6 +$4B, $C9, $63, $CD, $6B, $C9, $B8, $C7 +$8A, $C7, $EF, $C5, $AE, $C5, $BE, $C6 +$46, $C5, $D2, $C5, $69, $DF, $75, $DF +$7B, $C6, $22, $C7, $1D, $C5, $2B, $C7 +$84, $C5, $8D, $C7, $8D, $D5, $F4, $E0 +$F7, $E0, $78, $D0, $12, $D5, $2E, $D5 +$7B, $D5, $B8, $C5, $21, $C6, $59, $C8 +$8A, $C5, $A7, $C3, $A4, $C3, $52, $C3 +$EA, $DF, $28, $C8, $53, $D5, $86, $DD +$9A, $DD, $18, $DF, $1B, $DF, $69, $CC +$69, $CC, $69, $CC, $ED, $CA, $F0, $CB +$F0, $CB, $69, $CC, $69, $CC, $69, $CC +$69, $CC, $69, $CC, $69, $CC, $69, $CC +$69, $CC, $69, $CC, $69, $CC, $00, $00 +$63, $CC, $69, $CC, $63, $CC, $63, $CC +$63, $CC, $63, $CC, $69, $CC, $90, $CC +$90, $CC, $00, $00, $81, $DF, $81, $DF +$6F, $CC, $6F, $CC, $00, $00, $74, $CC +$74, $CC, $74, $CC, $FB, $D8, $85, $D9 +$18, $D9, $51, $DD, $49, $D0, $68, $D0 +$40, $E0, $A1, $DC, $FF, $D6, $03, $DC +$D5, $DC, $DC, $DC, $25, $DD, $57, $DD +$07, $D5, $1B, $D5, $59, $D4, $72, $D4 +$2A, $D1, $9F, $D4, $7D, $D4, $37, $D4 +$16, $D4, $88, $D3, $27, $DE, $D8, $DD +$B0, $DD, $87, $DF, $97, $DF, $DD, $E0 +$E7, $E0, $CD, $E0, $9A, $D3, $A3, $D3 +$D2, $D3, $79, $C5, $D5, $79, $AA, $D5 +$7B, $40, $D7, $7B, $08, $D8, $7F, $BF +$DB, $50, $D9, $CC, $46, $BF, $CC, $46 +$CC, $CC, $56, $85, $CD, $56, $6D, $CD +$7D, $F8, $DB, $5A, $1B, $CC, $64, $FA +$CC, $2A, $2B, $2D, $2F, $3C, $3D, $3E +$3F, $41, $42, $43, $44, $45, $46, $47 +$48, $49, $4C, $4D, $4E, $4F, $50, $52 +$53, $54, $55, $56, $57, $5E, $00, $71 +$E3, $73, $E3, $75, $E3, $77, $E3, $79 +$E3, $7D, $E3, $7F, $E3, $83, $E3, $85 +$E3, $95, $E3, $AE, $E3, $C5, $E3, $DE +$E3, $ED, $E3, $F7, $E3, $04, $E4, $0A +$E4, $1C, $E4, $41, $E4, $4F, $E4, $61 +$E4, $69, $E4, $7E, $E4, $AD, $E4, $D8 +$E4, $EC, $E4, $FD, $E4, $09, $E5, $18 +$E5, $B8, $00, $B6, $00, $B7, $00, $B9 +$00, $3C, $BF, $C2, $00, $C1, $00, $3E +$BE, $C0, $00, $9F, $00, $42, $53, $28 +$C5, $4E, $44, $BB, $53, $43, $28, $D7 +$54, $4E, $28, $D0, $00, $49, $4E, $24 +$28, $DC, $49, $54, $43, $4C, $52, $A8 +$49, $54, $53, $45, $54, $A7, $49, $54 +$54, $53, $54, $28, $DD, $00, $41, $4C +$4C, $9C, $48, $52, $24, $28, $DA, $4C +$45, $41, $52, $A2, $4F, $4E, $54, $A0 +$4F, $53, $28, $CD, $00, $41, $54, $41 +$83, $45, $43, $88, $45, $45, $4B, $28 +$D2, $45, $46, $99, $49, $4D, $85, $4F +$4B, $45, $9B, $4F, $9D, $00, $4C, $53 +$45, $AC, $4E, $44, $80, $4F, $52, $BC +$58, $50, $28, $CC, $00, $4E, $AE, $4F +$52, $81, $52, $45, $28, $C7, $00, $45 +$54, $A5, $4F, $53, $55, $42, $8D, $4F +$54, $4F, $89, $00, $45, $58, $24, $28 +$DB, $00, $46, $8B, $4E, $43, $95, $4E +$50, $55, $54, $84, $4E, $54, $28, $C4 +$52, $51, $A9, $00, $43, $41, $53, $45 +$24, $28, $D9, $45, $46, $54, $24, $28 +$E3, $45, $4E, $28, $D4, $45, $54, $87 +$49, $53, $54, $A1, $4F, $41, $44, $97 +$4F, $47, $28, $CB, $4F, $4F, $50, $9E +$00, $41, $58, $28, $DE, $49, $44, $24 +$28, $E5, $49, $4E, $28, $DF, $00, $45 +$57, $A3, $45, $58, $54, $82, $4D, $49 +$AA, $4F, $54, $B1, $55, $4C, $4C, $94 +$00, $46, $46, $B5, $4E, $93, $52, $BD +$00, $45, $45, $4B, $28, $D1, $49, $E0 +$4F, $4B, $45, $9A, $4F, $53, $28, $C8 +$52, $49, $4E, $54, $9F, $00, $45, $41 +$44, $86, $45, $4D, $91, $45, $53, $54 +$4F, $52, $45, $8C, $45, $54, $49, $52 +$51, $8E, $45, $54, $4E, $4D, $49, $8F +$45, $54, $55, $52, $4E, $90, $49, $47 +$48, $54, $24, $28, $E4, $4E, $44, $28 +$CA, $55, $4E, $8A, $00, $41, $44, $44 +$28, $D3, $41, $56, $45, $98, $47, $4E +$28, $C3, $49, $4E, $28, $CE, $50, $43 +$28, $AF, $51, $52, $28, $C9, $54, $45 +$50, $B2, $54, $4F, $50, $92, $54, $52 +$24, $28, $D5, $57, $41, $50, $A6, $00 +$41, $42, $28, $AB, $41, $4E, $28, $CF +$48, $45, $4E, $B0, $4F, $AD, $57, $4F +$50, $49, $E1, $00, $43, $41, $53, $45 +$24, $28, $D8, $4E, $54, $49, $4C, $B3 +$53, $52, $28, $C6, $00, $41, $4C, $28 +$D6, $41, $52, $50, $54, $52, $28, $E2 +$00, $41, $49, $54, $96, $48, $49, $4C +$45, $B4, $49, $44, $54, $48, $A4, $00 +$BA, $00, $03, $45, $E2, $E3, $03, $46 +$EF, $E3, $04, $4E, $52, $E4, $04, $44 +$C5, $E3, $05, $49, $0F, $E4, $03, $44 +$D4, $E3, $04, $52, $7E, $E4, $03, $4C +$2D, $E4, $03, $44, $C9, $E3, $04, $47 +$FF, $E3, $03, $52, $A9, $E4, $02, $49 +$0A, $E4, $07, $52, $85, $E4, $05, $47 +$FA, $E3, $06, $52, $8C, $E4, $06, $52 +$92, $E4, $06, $52, $98, $E4, $03, $52 +$82, $E4, $04, $53, $CA, $E4, $02, $4F +$64, $E4, $04, $4E, $5C, $E4, $03, $49 +$0C, $E4, $04, $57, $09, $E5, $04, $4C +$34, $E4, $04, $53, $B2, $E4, $03, $44 +$D1, $E3, $04, $50, $70, $E4, $04, $44 +$D7, $E3, $04, $43, $AE, $E3, $02, $44 +$DB, $E3, $04, $4C, $3C, $E4, $05, $50 +$78, $E4, $04, $43, $BC, $E3, $04, $4C +$30, $E4, $05, $43, $B7, $E3, $03, $4E +$4F, $E4, $05, $57, $12, $E5, $03, $47 +$F7, $E3, $04, $53, $D3, $E4, $06, $42 +$A0, $E3, $06, $42, $9A, $E3, $03, $49 +$18, $E4, $03, $4E, $56, $E4, $04, $54 +$D8, $E4, $04, $45, $DE, $E3, $02, $54 +$E4, $E4, $02, $46, $ED, $E3, $04, $53 +$BE, $E4, $04, $54, $E0, $E4, $03, $4E +$59, $E4, $04, $53, $C6, $E4, $05, $55 +$F3, $E4, $05, $57, $0D, $E5, $03, $4F +$61, $E4, $01, $2B, $00, $00, $01, $2D +$00, $00, $01, $2A, $00, $00, $01, $2F +$00, $00, $01, $5E, $00, $00, $03, $41 +$89, $E3, $03, $45, $E5, $E3, $02, $4F +$66, $E4, $02, $3E, $7F, $E3, $02, $3C +$79, $E3, $01, $3E, $00, $00, $01, $3D +$00, $00, $01, $3C, $00, $00, $04, $53 +$B6, $E4, $04, $49, $14, $E4, $04, $41 +$85, $E3, $04, $55, $F8, $E4, $04, $46 +$F2, $E3, $04, $50, $74, $E4, $04, $53 +$C2, $E4, $04, $52, $A5, $E4, $04, $4C +$38, $E4, $04, $45, $E8, $E3, $04, $43 +$C0, $E3, $04, $53, $BA, $E4, $04, $54 +$DC, $E4, $04, $41, $90, $E3, $05, $50 +$69, $E4, $05, $44, $CC, $E3, $05, $53 +$AD, $E4, $04, $4C, $29, $E4, $05, $53 +$CE, $E4, $04, $56, $FD, $E4, $04, $41 +$8C, $E3, $07, $55, $EC, $E4, $07, $4C +$1C, $E4, $05, $43, $B2, $E3, $05, $48 +$04, $E4, $05, $42, $95, $E3, $07, $42 +$A6, $E3, $04, $4D, $41, $E4, $04, $4D +$4A, $E4, $02, $50, $6E, $E4, $05, $54 +$E6, $E4, $07, $56, $01, $E5, $06, $4C +$23, $E4, $07, $52, $9E, $E4, $05, $4D +$45, $E4, $D6, $E6, $E7, $E6, $EE, $E6 +$03, $E7, $0F, $E7, $1D, $E7, $26, $E7 +$34, $E7, $48, $E7, $55, $E7, $66, $E7 +$75, $E7, $84, $E7, $92, $E7, $A2, $E7 +$B5, $E7, $C4, $E7, $D7, $E7, $4E, $45 +$58, $54, $20, $77, $69, $74, $68, $6F +$75, $74, $20, $46, $4F, $52, $00, $53 +$79, $6E, $74, $61, $78, $00, $52, $45 +$54, $55, $52, $4E, $20, $77, $69, $74 +$68, $6F, $75, $74, $20, $47, $4F, $53 +$55, $42, $00, $4F, $75, $74, $20, $6F +$66, $20, $44, $41, $54, $41, $00, $46 +$75, $6E, $63, $74, $69, $6F, $6E, $20 +$63, $61, $6C, $6C, $00, $4F, $76, $65 +$72, $66, $6C, $6F, $77, $00, $4F, $75 +$74, $20, $6F, $66, $20, $6D, $65, $6D +$6F, $72, $79, $00, $55, $6E, $64, $65 +$66, $69, $6E, $65, $64, $20, $73, $74 +$61, $74, $65, $6D, $65, $6E, $74, $00 +$41, $72, $72, $61, $79, $20, $62, $6F +$75, $6E, $64, $73, $00, $44, $6F, $75 +$62, $6C, $65, $20, $64, $69, $6D, $65 +$6E, $73, $69, $6F, $6E, $00, $44, $69 +$76, $69, $64, $65, $20, $62, $79, $20 +$7A, $65, $72, $6F, $00, $49, $6C, $6C +$65, $67, $61, $6C, $20, $64, $69, $72 +$65, $63, $74, $00, $54, $79, $70, $65 +$20, $6D, $69, $73, $6D, $61, $74, $63 +$68, $00, $53, $74, $72, $69, $6E, $67 +$20, $74, $6F, $6F, $20, $6C, $6F, $6E +$67, $00, $53, $74, $72, $69, $6E, $67 +$20, $74, $6F, $6F, $20, $63, $6F, $6D +$70, $6C, $65, $78, $00, $43, $61, $6E +$27, $74, $20, $63, $6F, $6E, $74, $69 +$6E, $75, $65, $00, $55, $6E, $64, $65 +$66, $69, $6E, $65, $64, $20, $66, $75 +$6E, $63, $74, $69, $6F, $6E, $00, $4C +$4F, $4F, $50, $20, $77, $69, $74, $68 +$6F, $75, $74, $20, $44, $4F, $00, $0D +$0A, $42, $72, $65, $61, $6B, $00, $20 +$45, $72, $72, $6F, $72, $00, $20, $69 +$6E, $20, $6C, $69, $6E, $65, $20, $00 +$0D, $0A, $52, $65, $61, $64, $79, $0D +$0A, $00, $20, $45, $78, $74, $72, $61 +$20, $69, $67, $6E, $6F, $72, $65, $64 +$0D, $0A, $00, $20, $52, $65, $64, $6F +$20, $66, $72, $6F, $6D, $20, $73, $74 +$61, $72, $74, $0D, $0A, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$AD, $E1, $FF, $F0, $0C, $C9, $61, $90 +$06, $C9, $7B, $B0, $02, $29, $5F, $38 +$60, $18, $60, $8D, $E0, $FF, $29, $FF +$60, $00, $00, $00, $00, $00, $00, $00 diff --git a/hello_world.bas b/hello_world.bas index eb77a7f..6d8c396 100644 --- a/hello_world.bas +++ b/hello_world.bas @@ -1,5 +1,5 @@ -10 LET A=0 -20 PR A;") HELLO WORLD FROM MKHBC!" -30 LET A=A+1 -40 IF A>100 THEN END -50 GOTO 20 +10 LET A=0 +20 PR A;") HELLO WORLD FROM MKHBC!" +30 LET A=A+1 +40 IF A>100 THEN END +50 GOTO 20 diff --git a/main.cpp b/main.cpp index 01bd0a3..b5b08c5 100644 --- a/main.cpp +++ b/main.cpp @@ -1,695 +1,694 @@ -#include -#include -#include -#include -#include -#include "system.h" -#include "MKCpu.h" -#include "Memory.h" -#include "Display.h" -#include "VMachine.h" -#include "MKGenException.h" - -using namespace std; -using namespace MKBasic; - -#define ANIM_DELAY 250 - -const bool ClsIfDirty = true; - -VMachine *pvm = NULL; -Regs *preg = NULL; -bool ioecho = false, opbrk = false; -int g_stackdisp_lines = 1; - -bool ShowRegs(Regs *preg, VMachine *pvm, bool ioecho, bool showiostat); -void ShowHelp(); - -#if defined(LINUX) - -#include - -void trap_signal(int signum); - -/* - *-------------------------------------------------------------------- - * Method: trap_signal() - * Purpose: handle signal - * Arguments: signum - signal # - * Returns: n/a - *-------------------------------------------------------------------- - */ -void trap_signal(int signum) -{ - cout << "Signal caught: " << dec << signum << endl; - if (NULL != pvm && NULL != preg) { - pvm->SetOpInterrupt(); - opbrk = true; - } - //exit(signum); - return; -} - -#endif - -#if defined(WINDOWS) -#include - -BOOL CtrlHandler(DWORD fdwCtrlType); - -/* - *-------------------------------------------------------------------- - * Method: CtrlHandler() - * Purpose: handle signal - * Arguments: fdwCtrlType - event type - * Returns: BOOL - TRUE if event handled, FALSE if needs further - * processing. - *-------------------------------------------------------------------- - */ -BOOL CtrlHandler(DWORD fdwCtrlType) -{ - switch( fdwCtrlType ) - { - case CTRL_C_EVENT: - //Beep( 750, 300 ); - if (NULL != pvm && NULL != preg) { - pvm->SetOpInterrupt(); - opbrk = true; - } - return TRUE; - - - case CTRL_CLOSE_EVENT: - //Beep( 600, 200 ); - cout << "Ctrl-Close event" << endl; - return TRUE ; - - case CTRL_BREAK_EVENT: - //Beep( 900, 200 ); - if (NULL != pvm && NULL != preg) { - pvm->SetOpInterrupt(); - opbrk = true; - } - return TRUE; - - case CTRL_LOGOFF_EVENT: - //Beep( 1000, 200 ); - cout << "Ctrl-Logoff event" << endl; - return FALSE; - - case CTRL_SHUTDOWN_EVENT: - Beep( 750, 500 ); - cout << "Ctrl-Shutdown event" << endl; - return FALSE; - - default: - return FALSE; - } -} - -#endif - -/* - *-------------------------------------------------------------------- - * Method: PromptNewAddress() - * Purpose: Prompt user to enter 16-bit address (hex) in console. - * Arguments: prompt - prompt text - * Returns: unsigned int - address entered by user - *-------------------------------------------------------------------- - */ -unsigned int PromptNewAddress(string prompt) -{ - unsigned int newaddr = 0x10000; - - while (newaddr > 0xFFFF) { - cout << prompt; - cin >> hex >> newaddr; - } - - return newaddr; -} - -/* - *-------------------------------------------------------------------- - * Thank you stackoverflow.com. - * http://stackoverflow.com/questions/111928/ - * is-there-a-printf-converter-to-print-in-binary-format - *-------------------------------------------------------------------- - */ -#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d" -#define BYTETOBINARY(byte) \ - (byte & 0x80 ? 1 : 0), \ - (byte & 0x40 ? 1 : 0), \ - (byte & 0x20 ? 1 : 0), \ - (byte & 0x10 ? 1 : 0), \ - (byte & 0x08 ? 1 : 0), \ - (byte & 0x04 ? 1 : 0), \ - (byte & 0x02 ? 1 : 0), \ - (byte & 0x01 ? 1 : 0) - -/* - *-------------------------------------------------------------------- - * Method: ShowRegs() - * Purpose: Display status of CPU registers on DOS console. - * Arguments: preg - pointer to registers structure - * pvm - pointer to VM - * ioaddr - address setup for char I/O emulation - * ioecho - local I/O echo flag - * showiostat - if true, I/O emulation status is shown - * Returns: boolean - true if the stack pointer was longer than - * 15 (the screen must be cleared). - *-------------------------------------------------------------------- - */ -bool ShowRegs(Regs *preg, VMachine *pvm, bool ioecho, bool showiostat) -{ - bool ret = false; - char sBuf[80] = {0}; - - sprintf(sBuf, "| PC: $%04x | Acc: $%02x (" BYTETOBINARYPATTERN ") | X: $%02x | Y: $%02x |", - preg->PtrAddr, preg->Acc, BYTETOBINARY(preg->Acc), preg->IndX, preg->IndY); - cout << "*-------------*-----------------------*----------*----------*" << endl; - cout << sBuf << endl; - cout << "*-------------*-----------------------*----------*----------*" << endl; - cout << "| NV-BDIZC |" << endl; - cout << "| " << bitset<8>((int)preg->Flags) << " |"; - cout << " Last instr.: " << preg->LastInstr << " " << endl; - cout << "*-------------*" << endl; - //cout << "Last instr.: " << preg->LastInstr << " " << endl; - cout << endl; - /* - cout << "Registers:" << endl; - cout << " Acc: $" << hex << (unsigned short)preg->Acc << "\t(%" << bitset<8>((int)preg->Acc) << ")" << endl; - cout << " X: $" << hex << (unsigned short)preg->IndX << " " << endl; - cout << " Y: $" << hex << (unsigned short)preg->IndY << " " << endl; - cout << " PC: $" << hex << preg->PtrAddr << " " << endl; - //cout << " Acc16: $" << hex << preg->Acc16 << " " << endl; - //cout << " Ptr16: $" << hex << preg->Ptr16 << " " << endl; - */ - cout << "Stack: $" << hex << (unsigned short)preg->PtrStack << " " << endl; - cout << " \r"; - // display stack contents - cout << " ["; - int j = 0, stacklines = 1; - for (unsigned int addr = 0x0101 + preg->PtrStack; addr < 0x0200; addr++) { - unsigned int hv = (unsigned int)pvm->MemPeek8bit(addr); - if (hv < 16) { - cout << 0; - } - cout << hex << hv << " "; - j++; - if (j > 15) { - cout << "]" << endl; - cout << " ["; - j=0; - stacklines++; - } - } - cout << "] " << endl; - ret = (stacklines < g_stackdisp_lines); - g_stackdisp_lines = stacklines; - // end display stack contents - - if (showiostat) { - cout << endl << "I/O status: " << (pvm->GetCharIOActive() ? "enabled" : "disabled") << ", "; - cout << " at: $" << hex << pvm->GetCharIOAddr() << ", "; - cout << " local echo: " << (ioecho ? "ON" : "OFF") << "." << endl; - cout << "ROM: " << ((pvm->IsROMEnabled()) ? "enabled." : "disabled.") << " "; - cout << "Range: $" << hex << pvm->GetROMBegin() << " - $" << hex << pvm->GetROMEnd() << "." << endl; - } - cout << " \r"; - // cout << "-------------------------------------------------------------------------------" << endl; - return ret; -} - -/* - *-------------------------------------------------------------------- - * Method: - * Purpose: - * Arguments: - * Returns: - *-------------------------------------------------------------------- - */ -void ShowMenu() -{ - cout << "------------------------------------+----------------------------------------" << endl; - cout << " C - continue, S - step | A - set address for next step" << endl; - cout << " G - go/cont. from new address | N - go number of steps" << endl; - cout << " I - toggle char I/O emulation | X - execute from new address" << endl; - cout << " T - show I/O console | B - blank (clear) screen" << endl; - cout << " E - toggle I/O local echo | F - toggle registers animation" << endl; - cout << " J - set animation delay | M - dump memory, W - write memory" << endl; - cout << " K - toggle ROM emulation | R - show registers" << endl; - cout << " L - load memory image | O - display op-codes history" << endl; - cout << " D - disassemble code in memory | Q - quit, H - help" << endl; - cout << "------------------------------------+----------------------------------------" << endl; -} - - -/* - *-------------------------------------------------------------------- - * Method: RUNSTEPS() - macro - * Purpose: Execute multiple steps of CPU emulation. - * Arguments: - * step - boolean flag, true if step by step mode - * nsteps - # if steps - * brk - current status of break flag - * preg - pointer to CPU registers - * stct - step counter - * pvm - pointer to VM - * lrts - status of last RTS flag - * anim - boolean flag, true - registers animation mode - * delay - delay for anim mode - * enrom - rom enabled/disabled flag - * rombegin - begin address of emulated ROM - * romend - end address of emulated ROM - * - * Returns: n/a - *-------------------------------------------------------------------- - */ -#define RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay) \ -{ \ - bool cls = false; \ - brk = preg->SoftIrq; \ - lrts = preg->LastRTS; \ - while(step && nsteps > 1 && !brk && !lrts) { \ - cout << "addr: $" << hex << preg->PtrAddr << ", step: " << dec << stct; \ - cout << " \r"; \ - preg = pvm->Step(); \ - if (anim) { \ - if (cls & ClsIfDirty) { pvm->ClearScreen(); cls = false; } \ - pvm->ScrHome(); \ - cls = ShowRegs(preg,pvm,false,false); \ - cout << endl; \ - this_thread::sleep_for(chrono::milliseconds(delay)); \ - } \ - brk = preg->SoftIrq; \ - nsteps--; \ - stct++; \ - } \ -} - -/* run this program using the console pauser or add your own getch, system("pause") or input loop */ - -int main(int argc, char** argv) { -#if defined(LINUX) - signal(SIGINT, trap_signal); - signal(SIGTERM, trap_signal); -#endif -#if defined(WINDOWS) - SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); -#endif - string romfile("dummy.rom"), ramfile("dummy.ram"); - if (argc > 1) { - ramfile = argv[1]; - } - try { - cout << endl; - pvm = new VMachine(romfile, ramfile); - pvm->ClearScreen(); - cout << "Virtual Machine/CPU Emulator (MOS 6502) and Debugger." << endl; - cout << "Copyright (C) by Marek Karcz 2016. All rights reserved." << endl; - string cmd; - bool runvm = false, step = false, brk = false, execaddr = false, stop = true; - bool lrts = false, execvm = false, anim = false, enrom = pvm->IsROMEnabled(); - unsigned int newaddr = pvm->GetRunAddr(), ioaddr = pvm->GetCharIOAddr(), tmpaddr = 0x0000; - unsigned int rombegin = pvm->GetROMBegin(), romend = pvm->GetROMEnd(), delay = ANIM_DELAY; - int nsteps = 0; - if (pvm->IsAutoExec()) { - execvm = true; - } - if (newaddr == 0) newaddr = 0x10000; - while (true) { - preg = pvm->GetRegs(); - if (runvm) { - if (anim) pvm->ClearScreen(); - int stct = 1; - if (execaddr) { - preg = ((step) ? pvm->Step(newaddr) : pvm->Run(newaddr)); - RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay); - execaddr = false; - } else { - preg = ((step) ? pvm->Step() : pvm->Run()); - RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay); - } - if (step) - cout << "\rExecuted " << dec << stct << ((stct == 1) ? " step." : " steps.") << " " << endl; - nsteps = 0; - runvm = step = false; - newaddr = 0x10000; - } else if (execvm) { - preg = (execaddr ? pvm->Exec(newaddr) : pvm->Exec()); - execvm = false; - execaddr = false; - brk = preg->SoftIrq; - lrts = preg->LastRTS; - newaddr = 0x10000; - } - if (brk || opbrk || stop || lrts) { - cout << endl; - if (opbrk) { - cout << "Interrupted at " << hex << preg->PtrAddr << endl; - opbrk = brk = stop = lrts = false; - } else if (brk) { - cout << "BRK at " << hex << preg->PtrAddr << endl; - opbrk = brk = stop = lrts = false; - } else if (lrts) { - cout << "FINISHED at " << hex << ((newaddr > 0xFFFF) ? preg->PtrAddr : newaddr) << endl; - opbrk = brk = stop = lrts = false; - } else if (stop) { - cout << "STOPPED at " << hex << ((newaddr > 0xFFFF) ? preg->PtrAddr : newaddr) << endl; - opbrk = brk = stop = lrts = false; - } - ShowRegs(preg,pvm,ioecho,true); - } - ShowMenu(); - cout << "> "; - cin >> cmd; - char c = tolower(cmd.c_str()[0]); - if (c == 'h') { // display help - ShowHelp(); - } else if (c == 'o') { - queue exechist(pvm->GetExecHistory()); - cout << "PC : INSTR ACC | X | Y | PS | SP" << endl; - cout << "------------------------------------+-----+-----+-----+-----" << endl; - while (exechist.size()) { - cout << exechist.front() << endl; - exechist.pop(); - } - } else if (c == 'l') { // load memory image - char typ = 0; - while (tolower(typ) != 'b' && tolower(typ) != 'd') { - cout << "Type (B - binary/D - definition): "; - cin >> typ; - } - cout << " [" << ((tolower(typ) == 'b') ? "binary" : "definition") << "]" << endl; - string name; - cout << "Memory Image File Name: "; - cin >> name; - cout << " [" << name << "]" << endl; - if (typ == 'b') pvm->LoadRAMBin(name); - else { - pvm->LoadRAM(name); - if (pvm->IsAutoExec()) execvm = true; - if (newaddr == 0) newaddr = 0x10000; - } - } else if (c == 'k') { // toggle ROM emulation - if (!enrom) { - enrom = true; - do { - rombegin = PromptNewAddress("ROM begin (0200..FFFF): "); - } while (rombegin < 0x0200); - cout << " [" << hex << rombegin << "]" << endl; - do { - romend = PromptNewAddress("ROM end (ROMBEGIN+1..FFFF): "); - } while (romend <= rombegin); - cout << " [" << hex << romend << "]" << endl; - pvm->EnableROM(rombegin, romend); - cout << "ROM activated." << endl; - } else { - enrom = false; - pvm->DisableROM(); - cout << "ROM deactivated." << endl; - } - } else if (c == 'j') { // set registers animation delay - cout << "Delay [ms]: "; - cin >> dec >> delay; - cout << " [" << dec << delay << "]" << endl; - } else if (c == 'f') { // toggle registers animation in step mode - anim = !anim; - cout << "Registers status animation " << ((anim) ? "enabled." : "disabled.") << endl; - } else if (c == 'b') { // clear screen - pvm->ClearScreen(); - } else if (c == 'r') { // show registers - stop = true; - } else if (c == 'e') { // toggle local echo for I/O console - if (pvm->GetCharIOActive()) { - ioecho = !ioecho; - cout << "I/O echo is " << (ioecho ? "activated." : "deactivated.") << endl; - pvm->SetCharIO(ioaddr, ioecho); - } else { - cout << "ERROR: I/O is deactivated." << endl; - } - } else if (c == 't') { // show I/O console - if (pvm->GetCharIOActive()) { - pvm->ShowIO(); - } else { - cout << "ERROR: I/O is deactivated." << endl; - } - } else if (c == 'i') { // toggle I/O - if (pvm->GetCharIOActive()) { - pvm->DisableCharIO(); - cout << "I/O deactivated." << endl; - } else { - ioaddr = PromptNewAddress("Address (0..FFFF): "); - cout << " [" << hex << ioaddr << "]" << endl; - pvm->SetCharIO(ioaddr, ioecho); - cout << "I/O activated." << endl; - } - } else if (c == 'w') { // write to memory - tmpaddr = PromptNewAddress("Address (0..FFFF): "); - cout << " [" << hex << tmpaddr << "]" << endl; - cout << "Enter hex bytes [00..FF] values separated with NL or spaces, end with [100]:" << endl; - unsigned short v = 0; - while (true) { - cin >> hex >> v; - cout << " " << hex << v; - if (v > 0xFF) break; - pvm->MemPoke8bit(tmpaddr++, v & 0xFF); - }; - cout << endl; - } else if (c == 'a') { // change run address - execaddr = stop = true; - newaddr = PromptNewAddress("Address (0..FFFF): "); - cout << " [" << hex << newaddr << "]" << endl; - } else if (c == 's') { - runvm = step = stop = true; - } else if (c == 'n') { // execute # of steps - nsteps = 0; - while (nsteps < 1) { - cout << "# of steps [n>1]: "; - cin >> dec >> nsteps; - } - cout << " [" << dec << nsteps << "]" << endl; - runvm = step = stop = true; - } else if (c == 'c') { // continue running code - runvm = true; - } else if (c == 'g') { // run from new address until BRK - runvm = true; - execaddr = true; - newaddr = PromptNewAddress("Address (0..FFFF): "); - cout << " [" << hex << newaddr << "]" << endl; - } else if (c == 'x') { // execute code at address - execvm = true; - execaddr = true; - newaddr = PromptNewAddress("Address (0..FFFF): "); - cout << " [" << hex << newaddr << "]" << endl; - } else if (c == 'q') { // quit - break; - } else if (c == 'd') { // disassemble code in memory - unsigned int addrbeg = 0x10000, addrend = 0x10000; - cout << "Enter address range (0..0xFFFF)..." << endl; - addrbeg = PromptNewAddress("Start address (0..FFFF): "); - cout << " [" << hex << addrbeg << "]" << endl; - addrend = PromptNewAddress("End address (0..FFFF): "); - cout << " [" << hex << addrend << "]" << endl; - cout << endl; - for (unsigned int addr = addrbeg; addr <= addrend;) { - char instrbuf[DISS_BUF_SIZE]; - addr = pvm->Disassemble((unsigned short)addr, instrbuf); - cout << instrbuf << endl; - } - } else if (c == 'm') { // dump memory - unsigned int addrbeg = 0x10000, addrend = 0x10000; - cout << "Enter address range (0..0xFFFF)..." << endl; - addrbeg = PromptNewAddress("Start address (0..FFFF): "); - cout << " [" << hex << addrbeg << "]" << endl; - addrend = PromptNewAddress("End address (0..FFFF): "); - cout << " [" << hex << addrend << "]" << endl; - cout << endl; - for (unsigned int addr = addrbeg; addr <= addrend; addr+=16) { - cout << "\t|"; - for (unsigned int j=0; j < 16; j++) { - unsigned int hv = (unsigned int)pvm->MemPeek8bit(addr+j); - if (hv < 16) { - cout << 0; - } - cout << hex << hv << " "; - } - cout << "|"; - for (int j=0; j < 16; j++) { - char cc = (char)pvm->MemPeek8bit(addr+j); - if (isprint(cc)) - cout << cc; - else - cout << "?"; - } - cout << '\r'; - cout << hex << addr; - cout << endl; - } - } - } - } - catch (MKGenException& ex) { - cout << ex.GetCause() << endl; - } - catch (...) { - cout << "ERROR: Fatal." << endl; - } - return 0; -} - -/* - *-------------------------------------------------------------------- - * Method: ShowHel2p() - * Purpose: Display commands help. - * Arguments: n/a - * Returns: n/a - *-------------------------------------------------------------------- - */ -void ShowHelp() -{ - cout << R"(Debugger Console Command Reference. - -S - step - Executes single opcode at current address. -C - continue - Continues code execution from current address until BRK. -M - dump memory - Usage: M [startaddr] [endaddr] - Where: startaddr,endaddr - memory addr. in hexadecimal format [0000..FFFF]. - Dumps contents of memory, hexadecimal and ASCII formats." -G - go/continue from new address until BRK - Usage: G [address] - Where: address - memory addr. in hexadecimal format [0000.FFFF]. - Executes code at provided address, interrupted by BRK opcode. -X - execute code from new address until RTS - Usage: X [address] - Where: address - memory addr. in hexadecimal format [0000.FFFF]. - Executes code at provided address, until RTS (last one). -Q - quit - Exits from the emulator/debugger. -A - set address for next step - Usage: A [address] - Where: address - memory addr. in hexadecimal format [0000.FFFF]. - Sets current address to a new value. -N - go number of steps - Usage: N [steps] - Where: steps - number of steps in decimal format - Execute number of opcodes provided in steps argument starting - from current address. -W - write to memory - Usage: W [address] [hexval] [hexval] ... 100 - Where: address - memory addr. in hexadecimal format [0000.FFFF], - hexval - byte value in hexadecimal format [00.FF]. - Writes provided values to memory starting at specified address. -I - toggle char I/O emulation - Usage: I [address] - Where: address - memory addr. in hexadecimal format [0000.FFFF], - Toggles basic character I/O emulation. When enabled, all writes - to the specified memory address also writes a character code to - to a virtual console. All reads from specified memory address - are interpreted as console character input. -R - show registers - Displays CPU registers, flags and stack. -T - show I/O console - Displays/prints the contents of the virtual console screen. - Note that in run mode (commands X, G or C), virtual screen is - displayed automatically in real-time if I/O emulation is enabled. -E - toggle I/O local echo - Toggles local echo on/off when I/O emulation is enabled. -B - blank (clear) screen - Clears the screen, useful when after exiting I/O emulation or - registers animation (long stack) your screen is messed up. -F - toggle registers animation mode - When in multi-step debug mode (command: N), displaying registers - can be suppressed or, when animation mode is enabled - they will - be continuously displayed after each executed step. -J - set registers status animation delay - Usage: J [delay] - Where: delay - time of delay in milliseconds, - Sets the time added at the end of each execution step in multi - step mode (command: N). The default value is 250 ms. -K - toggle ROM emulation - Usage: K [rombegin] [romend] - to enable, - K - to disable, - (OR just use 'K' in both cases and be prompted for arguments.) - Where: - rombegin - hexadecimal address [0200..FFFF], - romend - hexadecimal address [rombegin+1..FFFF]. - Enable/disable ROM emulation and define address range to which the ROM - (read-only memory) will be mapped. Default range: $D000-$DFFF. -L - load memory image - Usage: L [image_type] [image_name] - Where: - image_type - B (binary) OR D (definition), - image_name - name of the image file. - This function allows to load new memory image from either binary - image file or the ASCII definition file. The binary image is always - loaded from address 0x0000 and can be up to 64kB long. The definition - file format is a plain text file that can contain following keywords - and data: - - ADDR This keyword defines the run address of the executable code. - It is optional, but if exists, it must be the 1-st keyword - in the definition file. - Address in decimal or hexadecimal ($xxxx) format must follow - in the next line. - - ORG Changes the current address counter. The line that follows - sets the new address in decimal or hexadecimal format. - Data that follows will be put in memory starting from that - address. This keyword is optional and can be used multiple - times in the definition file. - - IOADDR Defines the address of the character I/O emulation. The - next line sets the address of I/O emulation in decimal or - hexadecimal format. If the I/O emulation is enabled - (see ENIO keyword), then any character written to this - address will be sent to the virtual console. The reading - from that address will invoke character input from the - emulated console. That input procedure is of blocking - type. To invoke non-blocking character procedure, reading - should be performed from IOADDR+1. - - ROMBEGIN Defines the address in memory where the beginning of the - Read Only memory is mapped. The next line that follows this - keyword sets the address in decimal or hexadecimal format. - - ROMEND Defines the address in memory where the end of the Read - Only Memory is mapped. The next line that follows this - keyword sets the address in decimal or hexadecimal format. - - ENIO Putting this keyword in memory definition file enables - rudimentary character I/O emulation and virtual console - emulation. - - ENROM Putting this keyword in memory definition file enables - emulation of Read Only Memory, in range of addresses - defined by ROMBEGIN and ROMEND keywords. - - EXEC Define starting address of code which will be automatically - executed after the memory image is loaded. - The next line that follows this keyword sets the address - in decimal or hexadecimal format. - -O - display op-codes history - Show the history of last executed op-codes/instructions, full with - disassembled mnemonic and argument. -D - diassemble code in memory - Usage: D [startaddr] [endaddr] - Where: startaddr,endaddr - hexadecimal address [0000..FFFF]. - Attempt to disassemble code in specified address range and display - the results (print) on the screen in symbolic form. - -NOTE: - 1. If no arguments provided, each command will prompt user to enter - missing data. - 2. It is possible to exit from running program to debugger console - by pressing CTRL-C or CTRL-Pause/Break, which will generate - a "Operator Interrupt". However in the character input mode - use CTRL-Y combination or CTRL-Break (DOS), CTRL-C (Linux). - You may need to press ENTER after that in input mode (DOS) -)"; - cout << endl; +#include +#include +#include +#include +#include +#include "system.h" +#include "MKCpu.h" +#include "Memory.h" +#include "Display.h" +#include "VMachine.h" +#include "MKGenException.h" + +using namespace std; +using namespace MKBasic; + +#define ANIM_DELAY 250 + +const bool ClsIfDirty = true; + +VMachine *pvm = NULL; +Regs *preg = NULL; +bool ioecho = false, opbrk = false; +int g_stackdisp_lines = 1; + +bool ShowRegs(Regs *preg, VMachine *pvm, bool ioecho, bool showiostat); +void ShowHelp(); + +#if defined(LINUX) + +#include + +void trap_signal(int signum); + +/* + *-------------------------------------------------------------------- + * Method: trap_signal() + * Purpose: handle signal + * Arguments: signum - signal # + * Returns: n/a + *-------------------------------------------------------------------- + */ +void trap_signal(int signum) +{ + cout << "Signal caught: " << dec << signum << endl; + if (NULL != pvm && NULL != preg) { + pvm->SetOpInterrupt(true); + opbrk = true; + } + //exit(signum); + return; +} + +#endif + +#if defined(WINDOWS) +#include + +BOOL CtrlHandler(DWORD fdwCtrlType); + +/* + *-------------------------------------------------------------------- + * Method: CtrlHandler() + * Purpose: handle signal + * Arguments: fdwCtrlType - event type + * Returns: BOOL - TRUE if event handled, FALSE if needs further + * processing. + *-------------------------------------------------------------------- + */ +BOOL CtrlHandler(DWORD fdwCtrlType) +{ + switch( fdwCtrlType ) + { + case CTRL_C_EVENT: + //Beep( 750, 300 ); + if (NULL != pvm && NULL != preg) { + pvm->SetOpInterrupt(true); + opbrk = true; + } + return TRUE; + + + case CTRL_CLOSE_EVENT: + //Beep( 600, 200 ); + cout << "Ctrl-Close event" << endl; + return TRUE ; + + case CTRL_BREAK_EVENT: + //Beep( 900, 200 ); + if (NULL != pvm && NULL != preg) { + pvm->SetOpInterrupt(true); + opbrk = true; + } + return TRUE; + + case CTRL_LOGOFF_EVENT: + //Beep( 1000, 200 ); + cout << "Ctrl-Logoff event" << endl; + return FALSE; + + case CTRL_SHUTDOWN_EVENT: + Beep( 750, 500 ); + cout << "Ctrl-Shutdown event" << endl; + return FALSE; + + default: + return FALSE; + } +} + +#endif + +/* + *-------------------------------------------------------------------- + * Method: PromptNewAddress() + * Purpose: Prompt user to enter 16-bit address (hex) in console. + * Arguments: prompt - prompt text + * Returns: unsigned int - address entered by user + *-------------------------------------------------------------------- + */ +unsigned int PromptNewAddress(string prompt) +{ + unsigned int newaddr = 0x10000; + + while (newaddr > 0xFFFF) { + cout << prompt; + cin >> hex >> newaddr; + } + + return newaddr; +} + +/* + *-------------------------------------------------------------------- + * Thank you stackoverflow.com. + * http://stackoverflow.com/questions/111928/ + * is-there-a-printf-converter-to-print-in-binary-format + *-------------------------------------------------------------------- + */ +#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d" +#define BYTETOBINARY(byte) \ + (byte & 0x80 ? 1 : 0), \ + (byte & 0x40 ? 1 : 0), \ + (byte & 0x20 ? 1 : 0), \ + (byte & 0x10 ? 1 : 0), \ + (byte & 0x08 ? 1 : 0), \ + (byte & 0x04 ? 1 : 0), \ + (byte & 0x02 ? 1 : 0), \ + (byte & 0x01 ? 1 : 0) + +/* + *-------------------------------------------------------------------- + * Method: ShowRegs() + * Purpose: Display status of CPU registers on DOS console. + * Arguments: preg - pointer to registers structure + * pvm - pointer to VM + * ioaddr - address setup for char I/O emulation + * ioecho - local I/O echo flag + * showiostat - if true, I/O emulation status is shown + * Returns: boolean - true if the stack pointer was longer than + * 15 (the screen must be cleared). + *-------------------------------------------------------------------- + */ +bool ShowRegs(Regs *preg, VMachine *pvm, bool ioecho, bool showiostat) +{ + bool ret = false; + char sBuf[80] = {0}; + + sprintf(sBuf, "| PC: $%04x | Acc: $%02x (" BYTETOBINARYPATTERN ") | X: $%02x | Y: $%02x |", + preg->PtrAddr, preg->Acc, BYTETOBINARY(preg->Acc), preg->IndX, preg->IndY); + cout << "*-------------*-----------------------*----------*----------*" << endl; + cout << sBuf << endl; + cout << "*-------------*-----------------------*----------*----------*" << endl; + cout << "| NV-BDIZC |" << endl; + cout << "| " << bitset<8>((int)preg->Flags) << " |"; + cout << " Last instr.: " << preg->LastInstr << " " << endl; + cout << "*-------------*" << endl; + //cout << "Last instr.: " << preg->LastInstr << " " << endl; + cout << endl; + /* + cout << "Registers:" << endl; + cout << " Acc: $" << hex << (unsigned short)preg->Acc << "\t(%" << bitset<8>((int)preg->Acc) << ")" << endl; + cout << " X: $" << hex << (unsigned short)preg->IndX << " " << endl; + cout << " Y: $" << hex << (unsigned short)preg->IndY << " " << endl; + cout << " PC: $" << hex << preg->PtrAddr << " " << endl; + //cout << " Acc16: $" << hex << preg->Acc16 << " " << endl; + //cout << " Ptr16: $" << hex << preg->Ptr16 << " " << endl; + */ + cout << "Stack: $" << hex << (unsigned short)preg->PtrStack << " " << endl; + cout << " \r"; + // display stack contents + cout << " ["; + int j = 0, stacklines = 1; + for (unsigned int addr = 0x0101 + preg->PtrStack; addr < 0x0200; addr++) { + unsigned int hv = (unsigned int)pvm->MemPeek8bit(addr); + if (hv < 16) { + cout << 0; + } + cout << hex << hv << " "; + j++; + if (j > 15) { + cout << "]" << endl; + cout << " ["; + j=0; + stacklines++; + } + } + cout << "] " << endl; + ret = (stacklines < g_stackdisp_lines); + g_stackdisp_lines = stacklines; + // end display stack contents + + if (showiostat) { + cout << endl << "I/O status: " << (pvm->GetCharIOActive() ? "enabled" : "disabled") << ", "; + cout << " at: $" << hex << pvm->GetCharIOAddr() << ", "; + cout << " local echo: " << (ioecho ? "ON" : "OFF") << "." << endl; + cout << "ROM: " << ((pvm->IsROMEnabled()) ? "enabled." : "disabled.") << " "; + cout << "Range: $" << hex << pvm->GetROMBegin() << " - $" << hex << pvm->GetROMEnd() << "." << endl; + } + cout << " \r"; + // cout << "-------------------------------------------------------------------------------" << endl; + return ret; +} + +/* + *-------------------------------------------------------------------- + * Method: + * Purpose: + * Arguments: + * Returns: + *-------------------------------------------------------------------- + */ +void ShowMenu() +{ + cout << "------------------------------------+----------------------------------------" << endl; + cout << " C - continue, S - step | A - set address for next step" << endl; + cout << " G - go/cont. from new address | N - go number of steps" << endl; + cout << " I - toggle char I/O emulation | X - execute from new address" << endl; + cout << " T - show I/O console | B - blank (clear) screen" << endl; + cout << " E - toggle I/O local echo | F - toggle registers animation" << endl; + cout << " J - set animation delay | M - dump memory, W - write memory" << endl; + cout << " K - toggle ROM emulation | R - show registers" << endl; + cout << " L - load memory image | O - display op-codes history" << endl; + cout << " D - disassemble code in memory | Q - quit, H - help" << endl; + cout << "------------------------------------+----------------------------------------" << endl; +} + + +/* + *-------------------------------------------------------------------- + * Method: RUNSTEPS() - macro + * Purpose: Execute multiple steps of CPU emulation. + * Arguments: + * step - boolean flag, true if step by step mode + * nsteps - # if steps + * brk - current status of break flag + * preg - pointer to CPU registers + * stct - step counter + * pvm - pointer to VM + * lrts - status of last RTS flag + * anim - boolean flag, true - registers animation mode + * delay - delay for anim mode + * enrom - rom enabled/disabled flag + * rombegin - begin address of emulated ROM + * romend - end address of emulated ROM + * + * Returns: n/a + *-------------------------------------------------------------------- + */ +#define RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay) \ +{ \ + bool cls = false; \ + brk = preg->SoftIrq; \ + lrts = preg->LastRTS; \ + while(step && nsteps > 1 && !brk && !lrts && !opbrk) { \ + cout << "addr: $" << hex << preg->PtrAddr << ", step: " << dec << stct; \ + cout << " \r"; \ + preg = pvm->Step(); \ + if (anim) { \ + if (cls & ClsIfDirty) { pvm->ClearScreen(); cls = false; } \ + pvm->ScrHome(); \ + cls = ShowRegs(preg,pvm,false,false); \ + cout << endl; \ + this_thread::sleep_for(chrono::milliseconds(delay)); \ + } \ + brk = preg->SoftIrq; \ + lrts = preg->LastRTS; \ + nsteps--; \ + stct++; \ + } \ +} + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char** argv) { +#if defined(LINUX) + signal(SIGINT, trap_signal); + signal(SIGTERM, trap_signal); +#endif +#if defined(WINDOWS) + SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); +#endif + string romfile("dummy.rom"), ramfile("dummy.ram"); + if (argc > 1) { + ramfile = argv[1]; + } + try { + cout << endl; + pvm = new VMachine(romfile, ramfile); + pvm->ClearScreen(); + cout << "Virtual Machine/CPU Emulator (MOS 6502) and Debugger." << endl; + cout << "Copyright (C) by Marek Karcz 2016. All rights reserved." << endl; + string cmd; + bool runvm = false, step = false, brk = false, execaddr = false, stop = true; + bool lrts = false, execvm = false, anim = false, enrom = pvm->IsROMEnabled(); + unsigned int newaddr = pvm->GetRunAddr(), ioaddr = pvm->GetCharIOAddr(), tmpaddr = 0x0000; + unsigned int rombegin = pvm->GetROMBegin(), romend = pvm->GetROMEnd(), delay = ANIM_DELAY; + int nsteps = 0; + if (pvm->IsAutoExec()) { + execvm = true; + } + if (newaddr == 0) newaddr = 0x10000; + while (true) { + preg = pvm->GetRegs(); + if (runvm) { + if (anim) pvm->ClearScreen(); + int stct = 1; + if (execaddr) { + preg = ((step) ? pvm->Step(newaddr) : pvm->Run(newaddr)); + RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay); + execaddr = false; + } else { + preg = ((step) ? pvm->Step() : pvm->Run()); + RUNSTEPS(step,nsteps,brk,preg,stct,pvm,lrts,anim,delay); + } + if (step) + cout << "\rExecuted " << dec << stct << ((stct == 1) ? " step." : " steps.") << " " << endl; + nsteps = 0; + runvm = step = false; + newaddr = 0x10000; + } else if (execvm) { + preg = (execaddr ? pvm->Exec(newaddr) : pvm->Exec()); + execvm = false; + execaddr = false; + brk = preg->SoftIrq; + lrts = preg->LastRTS; + newaddr = 0x10000; + } + if (brk || opbrk || stop || lrts) { + cout << endl; + if (opbrk) { + cout << "Interrupted at " << hex << preg->PtrAddr << endl; + } else if (brk) { + cout << "BRK at " << hex << preg->PtrAddr << endl; + } else if (lrts) { + cout << "FINISHED at " << hex << ((newaddr > 0xFFFF) ? preg->PtrAddr : newaddr) << endl; + } else if (stop) { + cout << "STOPPED at " << hex << ((newaddr > 0xFFFF) ? preg->PtrAddr : newaddr) << endl; + } + opbrk = brk = stop = lrts = false; + pvm->SetOpInterrupt(false); + ShowRegs(preg,pvm,ioecho,true); + } + ShowMenu(); + cout << "> "; + cin >> cmd; + char c = tolower(cmd.c_str()[0]); + if (c == 'h') { // display help + ShowHelp(); + } else if (c == 'o') { + queue exechist(pvm->GetExecHistory()); + cout << "PC : INSTR ACC | X | Y | PS | SP" << endl; + cout << "------------------------------------+-----+-----+-----+-----" << endl; + while (exechist.size()) { + cout << exechist.front() << endl; + exechist.pop(); + } + } else if (c == 'l') { // load memory image + char typ = 0; + while (tolower(typ) != 'b' && tolower(typ) != 'd') { + cout << "Type (B - binary/D - definition): "; + cin >> typ; + } + cout << " [" << ((tolower(typ) == 'b') ? "binary" : "definition") << "]" << endl; + string name; + cout << "Memory Image File Name: "; + cin >> name; + cout << " [" << name << "]" << endl; + if (typ == 'b') pvm->LoadRAMBin(name); + else { + pvm->LoadRAM(name); + if (pvm->IsAutoExec()) execvm = true; + if (newaddr == 0) newaddr = 0x10000; + } + } else if (c == 'k') { // toggle ROM emulation + if (!enrom) { + enrom = true; + do { + rombegin = PromptNewAddress("ROM begin (0200..FFFF): "); + } while (rombegin < 0x0200); + cout << " [" << hex << rombegin << "]" << endl; + do { + romend = PromptNewAddress("ROM end (ROMBEGIN+1..FFFF): "); + } while (romend <= rombegin); + cout << " [" << hex << romend << "]" << endl; + pvm->EnableROM(rombegin, romend); + cout << "ROM activated." << endl; + } else { + enrom = false; + pvm->DisableROM(); + cout << "ROM deactivated." << endl; + } + } else if (c == 'j') { // set registers animation delay + cout << "Delay [ms]: "; + cin >> dec >> delay; + cout << " [" << dec << delay << "]" << endl; + } else if (c == 'f') { // toggle registers animation in step mode + anim = !anim; + cout << "Registers status animation " << ((anim) ? "enabled." : "disabled.") << endl; + } else if (c == 'b') { // clear screen + pvm->ClearScreen(); + } else if (c == 'r') { // show registers + stop = true; + } else if (c == 'e') { // toggle local echo for I/O console + if (pvm->GetCharIOActive()) { + ioecho = !ioecho; + cout << "I/O echo is " << (ioecho ? "activated." : "deactivated.") << endl; + pvm->SetCharIO(ioaddr, ioecho); + } else { + cout << "ERROR: I/O is deactivated." << endl; + } + } else if (c == 't') { // show I/O console + if (pvm->GetCharIOActive()) { + pvm->ShowIO(); + } else { + cout << "ERROR: I/O is deactivated." << endl; + } + } else if (c == 'i') { // toggle I/O + if (pvm->GetCharIOActive()) { + pvm->DisableCharIO(); + cout << "I/O deactivated." << endl; + } else { + ioaddr = PromptNewAddress("Address (0..FFFF): "); + cout << " [" << hex << ioaddr << "]" << endl; + pvm->SetCharIO(ioaddr, ioecho); + cout << "I/O activated." << endl; + } + } else if (c == 'w') { // write to memory + tmpaddr = PromptNewAddress("Address (0..FFFF): "); + cout << " [" << hex << tmpaddr << "]" << endl; + cout << "Enter hex bytes [00..FF] values separated with NL or spaces, end with [100]:" << endl; + unsigned short v = 0; + while (true) { + cin >> hex >> v; + cout << " " << hex << v; + if (v > 0xFF) break; + pvm->MemPoke8bit(tmpaddr++, v & 0xFF); + }; + cout << endl; + } else if (c == 'a') { // change run address + execaddr = stop = true; + newaddr = PromptNewAddress("Address (0..FFFF): "); + cout << " [" << hex << newaddr << "]" << endl; + } else if (c == 's') { + runvm = step = stop = true; + } else if (c == 'n') { // execute # of steps + nsteps = 0; + while (nsteps < 1) { + cout << "# of steps [n>1]: "; + cin >> dec >> nsteps; + } + cout << " [" << dec << nsteps << "]" << endl; + runvm = step = stop = true; + } else if (c == 'c') { // continue running code + runvm = true; + } else if (c == 'g') { // run from new address until BRK + runvm = true; + execaddr = true; + newaddr = PromptNewAddress("Address (0..FFFF): "); + cout << " [" << hex << newaddr << "]" << endl; + } else if (c == 'x') { // execute code at address + execvm = true; + execaddr = true; + newaddr = PromptNewAddress("Address (0..FFFF): "); + cout << " [" << hex << newaddr << "]" << endl; + } else if (c == 'q') { // quit + break; + } else if (c == 'd') { // disassemble code in memory + unsigned int addrbeg = 0x10000, addrend = 0x10000; + cout << "Enter address range (0..0xFFFF)..." << endl; + addrbeg = PromptNewAddress("Start address (0..FFFF): "); + cout << " [" << hex << addrbeg << "]" << endl; + addrend = PromptNewAddress("End address (0..FFFF): "); + cout << " [" << hex << addrend << "]" << endl; + cout << endl; + for (unsigned int addr = addrbeg; addr <= addrend;) { + char instrbuf[DISS_BUF_SIZE]; + addr = pvm->Disassemble((unsigned short)addr, instrbuf); + cout << instrbuf << endl; + } + } else if (c == 'm') { // dump memory + unsigned int addrbeg = 0x10000, addrend = 0x10000; + cout << "Enter address range (0..0xFFFF)..." << endl; + addrbeg = PromptNewAddress("Start address (0..FFFF): "); + cout << " [" << hex << addrbeg << "]" << endl; + addrend = PromptNewAddress("End address (0..FFFF): "); + cout << " [" << hex << addrend << "]" << endl; + cout << endl; + for (unsigned int addr = addrbeg; addr <= addrend; addr+=16) { + cout << "\t|"; + for (unsigned int j=0; j < 16; j++) { + unsigned int hv = (unsigned int)pvm->MemPeek8bit(addr+j); + if (hv < 16) { + cout << 0; + } + cout << hex << hv << " "; + } + cout << "|"; + for (int j=0; j < 16; j++) { + char cc = (char)pvm->MemPeek8bit(addr+j); + if (isprint(cc)) + cout << cc; + else + cout << "?"; + } + cout << '\r'; + cout << hex << addr; + cout << endl; + } + } + } + } + catch (MKGenException& ex) { + cout << ex.GetCause() << endl; + } + catch (...) { + cout << "ERROR: Fatal." << endl; + } + return 0; +} + +/* + *-------------------------------------------------------------------- + * Method: ShowHel2p() + * Purpose: Display commands help. + * Arguments: n/a + * Returns: n/a + *-------------------------------------------------------------------- + */ +void ShowHelp() +{ + cout << R"(Debugger Console Command Reference. + +S - step + Executes single opcode at current address. +C - continue + Continues code execution from current address until BRK. +M - dump memory + Usage: M [startaddr] [endaddr] + Where: startaddr,endaddr - memory addr. in hexadecimal format [0000..FFFF]. + Dumps contents of memory, hexadecimal and ASCII formats." +G - go/continue from new address until BRK + Usage: G [address] + Where: address - memory addr. in hexadecimal format [0000.FFFF]. + Executes code at provided address, interrupted by BRK opcode. +X - execute code from new address until RTS + Usage: X [address] + Where: address - memory addr. in hexadecimal format [0000.FFFF]. + Executes code at provided address, until RTS (last one). +Q - quit + Exits from the emulator/debugger. +A - set address for next step + Usage: A [address] + Where: address - memory addr. in hexadecimal format [0000.FFFF]. + Sets current address to a new value. +N - go number of steps + Usage: N [steps] + Where: steps - number of steps in decimal format + Execute number of opcodes provided in steps argument starting + from current address. +W - write to memory + Usage: W [address] [hexval] [hexval] ... 100 + Where: address - memory addr. in hexadecimal format [0000.FFFF], + hexval - byte value in hexadecimal format [00.FF]. + Writes provided values to memory starting at specified address. +I - toggle char I/O emulation + Usage: I [address] + Where: address - memory addr. in hexadecimal format [0000.FFFF], + Toggles basic character I/O emulation. When enabled, all writes + to the specified memory address also writes a character code to + to a virtual console. All reads from specified memory address + are interpreted as console character input. +R - show registers + Displays CPU registers, flags and stack. +T - show I/O console + Displays/prints the contents of the virtual console screen. + Note that in run mode (commands X, G or C), virtual screen is + displayed automatically in real-time if I/O emulation is enabled. +E - toggle I/O local echo + Toggles local echo on/off when I/O emulation is enabled. +B - blank (clear) screen + Clears the screen, useful when after exiting I/O emulation or + registers animation (long stack) your screen is messed up. +F - toggle registers animation mode + When in multi-step debug mode (command: N), displaying registers + can be suppressed or, when animation mode is enabled - they will + be continuously displayed after each executed step. +J - set registers status animation delay + Usage: J [delay] + Where: delay - time of delay in milliseconds, + Sets the time added at the end of each execution step in multi + step mode (command: N). The default value is 250 ms. +K - toggle ROM emulation + Usage: K [rombegin] [romend] - to enable, + K - to disable, + (OR just use 'K' in both cases and be prompted for arguments.) + Where: + rombegin - hexadecimal address [0200..FFFF], + romend - hexadecimal address [rombegin+1..FFFF]. + Enable/disable ROM emulation and define address range to which the ROM + (read-only memory) will be mapped. Default range: $D000-$DFFF. +L - load memory image + Usage: L [image_type] [image_name] + Where: + image_type - B (binary) OR D (definition), + image_name - name of the image file. + This function allows to load new memory image from either binary + image file or the ASCII definition file. The binary image is always + loaded from address 0x0000 and can be up to 64kB long. The definition + file format is a plain text file that can contain following keywords + and data: + + ADDR This keyword defines the run address of the executable code. + It is optional, but if exists, it must be the 1-st keyword + in the definition file. + Address in decimal or hexadecimal ($xxxx) format must follow + in the next line. + + ORG Changes the current address counter. The line that follows + sets the new address in decimal or hexadecimal format. + Data that follows will be put in memory starting from that + address. This keyword is optional and can be used multiple + times in the definition file. + + IOADDR Defines the address of the character I/O emulation. The + next line sets the address of I/O emulation in decimal or + hexadecimal format. If the I/O emulation is enabled + (see ENIO keyword), then any character written to this + address will be sent to the virtual console. The reading + from that address will invoke character input from the + emulated console. That input procedure is of blocking + type. To invoke non-blocking character procedure, reading + should be performed from IOADDR+1. + + ROMBEGIN Defines the address in memory where the beginning of the + Read Only memory is mapped. The next line that follows this + keyword sets the address in decimal or hexadecimal format. + + ROMEND Defines the address in memory where the end of the Read + Only Memory is mapped. The next line that follows this + keyword sets the address in decimal or hexadecimal format. + + ENIO Putting this keyword in memory definition file enables + rudimentary character I/O emulation and virtual console + emulation. + + ENROM Putting this keyword in memory definition file enables + emulation of Read Only Memory, in range of addresses + defined by ROMBEGIN and ROMEND keywords. + + EXEC Define starting address of code which will be automatically + executed after the memory image is loaded. + The next line that follows this keyword sets the address + in decimal or hexadecimal format. + +O - display op-codes history + Show the history of last executed op-codes/instructions, full with + disassembled mnemonic and argument. +D - diassemble code in memory + Usage: D [startaddr] [endaddr] + Where: startaddr,endaddr - hexadecimal address [0000..FFFF]. + Attempt to disassemble code in specified address range and display + the results (print) on the screen in symbolic form. + +NOTE: + 1. If no arguments provided, each command will prompt user to enter + missing data. + 2. It is possible to exit from running program to debugger console + by pressing CTRL-C or CTRL-Pause/Break, which will generate + a "Operator Interrupt". However in the character input mode + use CTRL-Y combination or CTRL-Break (DOS), CTRL-C (Linux). + You may need to press ENTER after that in input mode (DOS) +)"; + cout << endl; } \ No newline at end of file diff --git a/makefile.mingw b/makefile.mingw index a35382d..2525976 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -1,58 +1,58 @@ -# Project: MKBasic -# Makefile created by Dev-C++ 5.11 -# and modified for standalone MINGW compiler installation. - -CPP = g++.exe -D__DEBUG__ -CC = gcc.exe -D__DEBUG__ -WINDRES = windres.exe -OBJ = main.o VMachine.o MKBasic.o MKCpu.o Memory.o Display.o MKGenException.o -OBJ2 = bin2hex.o -LINKOBJ = main.o VMachine.o MKBasic.o MKCpu.o Memory.o Display.o MKGenException.o -LINKOBJ2 = bin2hex.o -LIBS = -L"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/lib" -L"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/lib" -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic -INCS = -I"C:\mingw-w64\x86_64-5.3.0\mingw64/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0/include" -CXXINCS = -I"C:\mingw-w64\x86_64-5.3.0\mingw64/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0/include" -BIN = mkbasic.exe -BIN2 = bin2hex.exe -CXXFLAGS = $(CXXINCS) -std=c++11 -Wall -Wextra -pedantic -g3 -CFLAGS = $(INCS) -std=c++11 -Wall -Wextra -pedantic -g3 -CXXFLAGS2 = $(CXXINCS) -CFLAGS2 = $(INCS) -RM = del /f - -.PHONY: all all-before all-after clean clean-custom - -all: all-before $(BIN) $(BIN2) all-after - -clean: clean-custom - ${RM} $(OBJ) $(OBJ2) $(BIN) $(BIN2) - -$(BIN): $(OBJ) - $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS) - -main.o: main.cpp - $(CPP) -c main.cpp -o main.o $(CXXFLAGS) - -VMachine.o: VMachine.cpp - $(CPP) -c VMachine.cpp -o VMachine.o $(CXXFLAGS) - -MKBasic.o: MKBasic.cpp - $(CPP) -c MKBasic.cpp -o MKBasic.o $(CXXFLAGS) - -MKCpu.o: MKCpu.cpp - $(CPP) -c MKCpu.cpp -o MKCpu.o $(CXXFLAGS) - -Memory.o: Memory.cpp - $(CPP) -c Memory.cpp -o Memory.o $(CXXFLAGS) - -Display.o: Display.cpp - $(CPP) -c Display.cpp -o Display.o $(CXXFLAGS) - -MKGenException.o: MKGenException.cpp - $(CPP) -c MKGenException.cpp -o MKGenException.o $(CXXFLAGS) - -$(BIN2): $(OBJ2) - $(CC) $(LINKOBJ2) -o $(BIN2) $(LIBS) - -bin2hex.o: bin2hex.c - $(CC) -c bin2hex.c -o bin2hex.o $(CFLAGS2) +# Project: MKBasic +# Makefile created by Dev-C++ 5.11 +# and modified for standalone MINGW compiler installation. + +CPP = g++.exe -D__DEBUG__ +CC = gcc.exe -D__DEBUG__ +WINDRES = windres.exe +OBJ = main.o VMachine.o MKBasic.o MKCpu.o Memory.o Display.o MKGenException.o +OBJ2 = bin2hex.o +LINKOBJ = main.o VMachine.o MKBasic.o MKCpu.o Memory.o Display.o MKGenException.o +LINKOBJ2 = bin2hex.o +LIBS = -L"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/lib" -L"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/lib" -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic +INCS = -I"C:\mingw-w64\x86_64-5.3.0\mingw64/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0/include" +CXXINCS = -I"C:\mingw-w64\x86_64-5.3.0\mingw64/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\x86_64-w64-mingw32/include" -I"C:\mingw-w64\x86_64-5.3.0\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0/include" +BIN = mkbasic.exe +BIN2 = bin2hex.exe +CXXFLAGS = $(CXXINCS) -std=c++11 -Wall -Wextra -pedantic -g3 +CFLAGS = $(INCS) -std=c++11 -Wall -Wextra -pedantic -g3 +CXXFLAGS2 = $(CXXINCS) +CFLAGS2 = $(INCS) +RM = del /f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before $(BIN) $(BIN2) all-after + +clean: clean-custom + ${RM} $(OBJ) $(OBJ2) $(BIN) $(BIN2) + +$(BIN): $(OBJ) + $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS) + +main.o: main.cpp + $(CPP) -c main.cpp -o main.o $(CXXFLAGS) + +VMachine.o: VMachine.cpp + $(CPP) -c VMachine.cpp -o VMachine.o $(CXXFLAGS) + +MKBasic.o: MKBasic.cpp + $(CPP) -c MKBasic.cpp -o MKBasic.o $(CXXFLAGS) + +MKCpu.o: MKCpu.cpp + $(CPP) -c MKCpu.cpp -o MKCpu.o $(CXXFLAGS) + +Memory.o: Memory.cpp + $(CPP) -c Memory.cpp -o Memory.o $(CXXFLAGS) + +Display.o: Display.cpp + $(CPP) -c Display.cpp -o Display.o $(CXXFLAGS) + +MKGenException.o: MKGenException.cpp + $(CPP) -c MKGenException.cpp -o MKGenException.o $(CXXFLAGS) + +$(BIN2): $(OBJ2) + $(CC) $(LINKOBJ2) -o $(BIN2) $(LIBS) + +bin2hex.o: bin2hex.c + $(CC) -c bin2hex.c -o bin2hex.o $(CFLAGS2) diff --git a/makeming.bat b/makeming.bat index 7f2ab63..9f57868 100644 --- a/makeming.bat +++ b/makeming.bat @@ -1,4 +1,4 @@ -rem to make project on win64 with mingw -rem run in mingw console - +rem to make project on win64 with mingw +rem run in mingw console + mingw32-make -f makefile.mingw clean all \ No newline at end of file diff --git a/microchess.asm b/microchess.asm index 0ee1a6e..3b0ea01 100644 --- a/microchess.asm +++ b/microchess.asm @@ -1,1051 +1,1051 @@ -;*********************************************************************** -; -; MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com -; -;*********************************************************************** -; Daryl Rictor: -; I have been given permission to distribute this program by the -; author and copyright holder, Peter Jennings. Please get his -; permission if you wish to re-distribute a modified copy of -; this file to others. He specifically requested that his -; copyright notice be included in the source and binary images. -; Thanks! -; -; Marek Karcz: -; I have been given permission to distribute this program by the -; original author Peter Jennings under condition that I include -; link to his website in attribution. -; Here it is: http://www.benlo.com/microchess/index.html -; I did not bother to contact Daryl Rictor to ask permission to -; distribute his modifications to this software because according to -; the copyright notice on the web page of his project, permission is -; already given for personal non-commercial use: -; http://sbc.rictor.org/avr65c02.html -; http://sbc.rictor.org/download/AVR65C02.zip, readme.txt -; If this is incorrect or I misunderstood the author's intention, -; please note that I acted with no malicious intent and will remove -; this file from my project if I receive such request. -; -; To build this program with CL65: -; -; cl65 -C microchess.cfg -l --start-addr 1024 -t none -o microchess.bin -; microchess.asm -; -; Binary image microchess.bin can be loaded to emulator with 'L' -; command in debug console. Start emulator: mkbasic, then issue -; command in debug console: -; L B MICROCHESS.BIN -; -; Memory image definition file can be generated which can be loaded -; to emulator via command line argument and automatically executed. -; To create that file, build microchess.bin image, then execute: -; -; bin2hex -f microchess.bin -o microchess.dat -w 0 -x 1024 -z -; -; and add following lines at the end of microchess.dat file: -; -; IOADDR -; $E000 -; ENIO -; -; Instructions to play: -; -; Load the game to emulator and auto-execute with command: -; mkbasic microchess.dat -; then perform following steps: -; 1. Press 'C' to setup board. -; 2. Enter your move: 4 digits - BBEE, BB - piece coordinates, -; EE - destination coordinates and press ENTER -; 3. After board is updated, press 'P' to make program make the move. -; 4. Repeat steps 2 and 3 until the game is finished. -; -; -; 1/14/2012 -; Modified Daryl Rictor's port to run on MKHBC-8-R1 homebrew -; computer under MKHBCOS (derivative of M.O.S. by Scott - Chidester). -; -; 3/11/2016 -; Adapted to run in MKBASIC (V65) emulator. -; -; 3/12/2016 -; Modified UI behavior: -; - chess board is only printed after move, not after each -; keystroke -; - copyright banner is only printed once at the start -; of the program -; -; 6551 I/O Port Addresses -; -;ACIADat = $7F70 -;ACIAsta = $7F71 -;ACIACmd = $7F72 -;ACIACtl = $7F73 - -; M.O.S. API defines (kernal) - OK for emulator, no changes - -.define mos_StrPtr $E0 -.define tmp_zpgPt $F6 - -; jumps, originally for M.O.S., now modified for emulator - -.define mos_CallGetCh $FFED -.define mos_CallPutCh $FFF0 -.define mos_CallPuts $FFF3 - - -; -; page zero variables -; -BOARD = $50 -BK = $60 -PIECE = $B0 -SQUARE = $B1 -SP2 = $B2 -SP1 = $B3 -incHEK = $B4 -STATE = $B5 -MOVEN = $B6 -REV = $B7 -OMOVE = $2C -WCAP0 = $2D -COUNT = $2E -BCAP2 = $2E -WCAP2 = $2F -BCAP1 = $20 -WCAP1 = $21 -BCAP0 = $22 -MOB = $23 -MAXC = $24 -CC = $25 -PCAP = $26 -BMOB = $23 -BMAXC = $24 -BMCC = $25 ; was bcc (TASS doesn't like it as a label) -BMAXP = $26 -XMAXC = $28 -WMOB = $2B -WMAXC = $3C -WCC = $3D -WMAXP = $3E -PMOB = $3F -PMAXC = $40 -PCC = $41 -PCP = $42 -OLDKY = $43 -BESTP = $4B -BESTV = $4A -BESTM = $49 -DIS1 = $4B -DIS2 = $4A -DIS3 = $49 -temp = $4C - -; -; -; - -.segment "BEGN" - - .ORG $0000 - -.segment "CODE" - - .ORG $0400 ; load into RAM @ $1000-$15FF - - lda #$00 ; REVERSE TOGGLE - sta REV - jmp CHESS - -PAINT: .byte $FF ; set this flag if board needs painting - ; unset otherwise -PRNBANN: - .byte $FF ; set this flag to print copyright banner - - ;jsr Init_6551 -CHESS: cld ; INITIALIZE - ldx #$FF ; TWO STACKS - txs - ldx #$C8 - stx SP2 -; -; ROUTINES TO LIGHT LED -; DISPLAY and GET KEY -; FROM KEYBOARD -; -OUT: jsr POUT ; DISPLAY and - jsr KIN ; GET INPUT *** my routine waits for a keypress - cmp #$43 ; [C] - bne NOSET ; SET UP - lda #$FF ; set PAINT flag - sta PAINT ; board needs to be diplayed - ldx #$1F ; BOARD -WHSET: lda SETW,X ; FROM - sta BOARD,X ; SETW - dex - bpl WHSET - ldx #$1B ; *ADDED - stx OMOVE ; INITS TO $FF - lda #$CC ; DISPLAY CCC - bne CLDSP -; -NOSET: cmp #$45 ; [E] - bne NOREV ; REVERSE - lda #$FF - sta PAINT - jsr REVERSE ; BOARD IS - sec - lda #$01 - sbc REV - sta REV ; TOGGLE REV FLAG - lda #$EE ; IS - bne CLDSP -; -NOREV: cmp #$40 ; [P] - bne NOGO ; PLAY CHESS - lda #$FF - sta PAINT - jsr GO -CLDSP: sta DIS1 ; DISPLAY - sta DIS2 ; ACROSS - sta DIS3 ; DISPLAY - bne CHESS -; -NOGO: cmp #$0D ; [Enter] - bne NOMV ; MOVE MAN - pha - lda #$FF - sta PAINT - pla - jsr MOVE ; AS ENTERED - jmp DISP -NOMV: cmp #$41 ; [Q] ***Added to allow game exit*** - beq DONE ; quit the game, exit back to system. - pha - lda #$00 - sta PAINT - pla - jmp INPUT ; process move -DONE: rts -;jmp $FF00 ; *** MUST set this to YOUR OS starting address -; -; THE ROUTINE JANUS DIRECTS THE -; ANALYSIS BY DETERMINING WHAT -; SHOULD OCCUR AFTER EACH MOVE -; GENERATED BY GNM -; -; -; -JANUS: ldx STATE - bmi NOCOUNT -; -; THIS ROUTINE COUNTS OCCURRENCES -; IT DEPENDS UPON STATE TO INdex -; THE CORRECT COUNTERS -; -COUNTS: lda PIECE - beq OVER ; IF STATE=8 - cpx #$08 ; DO NOT COUNT - bne OVER ; BLK MAX CAP - cmp BMAXP ; MOVES FOR - beq XRT ; WHITE -; -OVER: inc MOB,X ; MOBILITY - cmp #$01 ; + QUEEN - bne NOQ ; FOR TWO - inc MOB,X -; -NOQ: bvc NOCAP - ldy #$0F ; CALCULATE - lda SQUARE ; POINTS -ELOOP: cmp BK,Y ; CAPTURED - beq FOUN ; BY THIS - dey ; MOVE - bpl ELOOP -FOUN: lda POINTS,Y - cmp MAXC,X - bcc LESS ; SAVE IF - sty PCAP,X ; BEST THIS - sta MAXC,X ; STATE -; -LESS: clc - php ; ADD TO - adc CC,X ; CAPTURE - sta CC,X ; COUNTS - plp -; -NOCAP: cpx #$04 - beq ON4 - bmi TREE ;(=00 ONLY) -XRT: rts -; -; GENERATE FURTHER MOVES FOR COUNT -; and ANALYSIS -; -ON4: lda XMAXC ; SAVE ACTUAL - sta WCAP0 ; CAPTURE - lda #$00 ; STATE=0 - sta STATE - jsr MOVE ; GENERATE - jsr REVERSE ; IMMEDIATE - jsr GNMZ ; REPLY MOVES - jsr REVERSE -; - lda #$08 ; STATE=8 - sta STATE ; GENERATE -; jsr OHM ; CONTINUATION - jsr UMOVE ; MOVES -; - jmp STRATGY ; FINAL EVALUATION -NOCOUNT:cpx #$F9 - bne TREE -; -; DETERMINE IF THE KING CAN BE -; TAKEN, USED BY CHKCHK -; - lda BK ; IS KING - cmp SQUARE ; IN CHECK? - bne RETJ ; SET incHEK=0 - lda #$00 ; IF IT IS - sta incHEK -RETJ: rts -; -; IF A PIECE HAS BEEN CAPTURED BY -; A TRIAL MOVE, GENERATE REPLIES & -; EVALUATE THE EXCHANGE GAIN/LOSS -; -TREE: bvc RETJ ; NO CAP - ldy #$07 ; (PIECES) - lda SQUARE -LOOPX: cmp BK,Y - beq FOUNX - dey - beq RETJ ; (KING) - bpl LOOPX ; SAVE -FOUNX: lda POINTS,Y ; BEST CAP - cmp BCAP0,X ; AT THIS - bcc NOMAX ; LEVEL - sta BCAP0,X -NOMAX: dec STATE - lda #$FB ; IF STATE=FB - cmp STATE ; TIME TO TURN - beq UPTREE ; AROUND - jsr GENRM ; GENERATE FURTHER -UPTREE: inc STATE ; CAPTURES - rts -; -; THE PLAYER'S MOVE IS INPUT -; -INPUT: cmp #$08 ; NOT A LEGAL - bcs ERROR ; SQUARE # - jsr DISMV -DISP: ldx #$1F -SEARCH: lda BOARD,X - cmp DIS2 - beq HERE ; DISPLAY - dex ; PIECE AT - bpl SEARCH ; FROM -HERE: stx DIS1 ; SQUARE - stx PIECE -ERROR: jmp CHESS -; -; GENERATE ALL MOVES FOR ONE -; SIDE, CALL JANUS AFTER EACH -; ONE FOR NEXT STE? -; -; -GNMZ: ldx #$10 ; CLEAR -GNMX: lda #$00 ; COUNTERS -CLEAR: sta COUNT,X - dex - bpl CLEAR -; -GNM: lda #$10 ; SET UP - sta PIECE ; PIECE -NEWP: dec PIECE ; NEW PIECE - bpl NEX ; ALL DONE? - rts ; #NAME? -; -NEX: jsr RESET ; READY - ldy PIECE ; GET PIECE - ldx #$08 - stx MOVEN ; COMMON staRT - cpy #$08 ; WHAT IS IT? - bpl PAWN ; PAWN - cpy #$06 - bpl KNIGHT ; KNIGHT - cpy #$04 - bpl BISHOP ; BISHOP - cpy #$01 - beq QUEEN ; QUEEN - bpl ROOK ; ROOK -; -KING: jsr SNGMV ; MUST BE KING! - bne KING ; MOVES - beq NEWP ; 8 TO 1 -QUEEN: jsr LINE - bne QUEEN ; MOVES - beq NEWP ; 8 TO 1 -; -ROOK: ldx #$04 - stx MOVEN ; MOVES -AGNR: jsr LINE ; 4 TO 1 - bne AGNR - beq NEWP -; -BISHOP: jsr LINE - lda MOVEN ; MOVES - cmp #$04 ; 8 TO 5 - bne BISHOP - beq NEWP -; -KNIGHT: ldx #$10 - stx MOVEN ; MOVES -AGNN: jsr SNGMV ; 16 TO 9 - lda MOVEN - cmp #$08 - bne AGNN - beq NEWP -; -PAWN: ldx #$06 - stx MOVEN -P1: jsr CMOVE ; RIGHT CAP? - bvc P2 - bmi P2 - jsr JANUS ; YES -P2: jsr RESET - dec MOVEN ; LEFT CAP? - lda MOVEN - cmp #$05 - beq P1 -P3: jsr CMOVE ; AHEAD - bvs NEWP ; ILLEGAL - bmi NEWP - jsr JANUS - lda SQUARE ; GETS TO - and #$F0 ; 3RD RANK? - cmp #$20 - beq P3 ; DO DOUBLE - jmp NEWP -; -; CALCULATE SINGLE STEP MOVES -; FOR K,N -; -SNGMV: jsr CMOVE ; CALC MOVE - bmi ILL1 ; -IF LEGAL - jsr JANUS ; -EVALUATE -ILL1: jsr RESET - dec MOVEN - rts -; -; CALCULATE ALL MOVES DOWN A -; STRAIGHT LINE FOR Q,B,R -; -LINE: jsr CMOVE ; CALC MOVE - bcc OVL ; NO CHK - bvc LINE ; NOCAP -OVL: bmi ILL ; RETURN - php - jsr JANUS ; EVALUATE POSN - plp - bvc LINE ; NOT A CAP -ILL: jsr RESET ; LINE STOPPED - dec MOVEN ; NEXT DIR - rts -; -; EXCHANGE SIDES FOR REPLY -; ANALYSIS -; -REVERSE:ldx #$0F -ETC: sec - ldy BK,X ; SUBTRACT - lda #$77 ; POSITION - sbc BOARD,X ; FROM 77 - sta BK,X - sty BOARD,X ; and - sec - lda #$77 ; EXCHANGE - sbc BOARD,X ; PIECES - sta BOARD,X - dex - bpl ETC - rts -; -; CMOVE CALCULATES THE TO SQUARE -; USING SQUARE and THE MOVE -; TABLE FLAGS SET AS FOLLOWS: -; N#NAME? MOVE -; V#NAME? (LEGAL UNLESS IN CR) -; C#NAME? BECAUSE OF CHECK -; [MY &THANKS TO JIM BUTTERFIELD -; WHO WROTE THIS MORE EFFICIENT -; VERSION OF CMOVE) -; -CMOVE: lda SQUARE ; GET SQUARE - ldx MOVEN ; MOVE POINTER - clc - adc MOVEX,X ; MOVE LIST - sta SQUARE ; NEW POS'N - and #$88 - bne ILLEGAL ; OFF BOARD - lda SQUARE -; - ldx #$20 -LOOP: dex ; IS TO - bmi NO ; SQUARE - cmp BOARD,X ; OCCUPIED? - bne LOOP -; - cpx #$10 ; BY SELF? - bmi ILLEGAL -; - lda #$7F ; MUST BE CAP! - adc #$01 ; SET V FLAG - bvs SPX ; (jmp) -; -NO: clv ; NO CAPTURE -; -SPX: lda STATE ; SHOULD WE - bmi RETL ; DO THE - cmp #$08 ; CHECK CHECK? - bpl RETL -; -; CHKCHK REVERSES SIDES -; and LOOKS FOR A KING -; CAPTURE TO INDICATE -; ILLEGAL MOVE BECAUSE OF -; CHECK SincE THIS IS -; TIME CONSUMING, IT IS NOT -; ALWAYS DONE -; -CHKCHK: pha ; STATE #392 - php - lda #$F9 - sta STATE ; GENERATE - sta incHEK ; ALL REPLY - jsr MOVE ; MOVES TO - jsr REVERSE ; SEE IF KING - jsr GNM ; IS IN - jsr RUM ; CHECK - plp - pla - sta STATE - lda incHEK - bmi RETL ; NO - SAFE - sec ; YES - IN CHK - lda #$FF - rts -; -RETL: clc ; LEGAL - lda #$00 ; RETURN - rts -; -ILLEGAL:lda #$FF - clc ; ILLEGAL - clv ; RETURN - rts -; -; REPLACE PIECE ON CORRECT SQUARE -; -RESET: ldx PIECE ; GET LOGAT - lda BOARD,X ; FOR PIECE - sta SQUARE ; FROM BOARD - rts -; -; -; -GENRM: jsr MOVE ; MAKE MOVE -GENR2: jsr REVERSE ; REVERSE BOARD - jsr GNM ; GENERATE MOVES -RUM: jsr REVERSE ; REVERSE BACK -; -; ROUTINE TO UNMAKE A MOVE MADE BY -; MOVE -; -UMOVE: tsx ; UNMAKE MOVE - stx SP1 - ldx SP2 ; EXCHANGE - txs ; STACKS - pla ; MOVEN - sta MOVEN - pla ; CAPTURED - sta PIECE ; PIECE - tax - pla ; FROM SQUARE - sta BOARD,X - pla ; PIECE - tax - pla ; TO SOUARE - sta SQUARE - sta BOARD,X - jmp STRV -; -; THIS ROUTINE MOVES PIECE -; TO SQUARE, PARAMETERS -; ARE SAVED IN A staCK TO UNMAKE -; THE MOVE LATER -; -MOVE: tsx - stx SP1 ; SWITCH - ldx SP2 ; STACKS - txs - lda SQUARE - pha ; TO SQUARE - tay - ldx #$1F -CHECK: cmp BOARD,X ; CHECK FOR - beq TAKE ; CAPTURE - dex - bpl CHECK -TAKE: lda #$CC - sta BOARD,X - txa ; CAPTURED - pha ; PIECE - ldx PIECE - lda BOARD,X - sty BOARD,X ; FROM - pha ; SQUARE - txa - pha ; PIECE - lda MOVEN - pha ; MOVEN -STRV: tsx - stx SP2 ; SWITCH - ldx SP1 ; STACKS - txs ; BACK - rts -; -; CONTINUATION OF SUB STRATGY -; -CHECKS FOR CHECK OR CHECKMATE -; and ASSIGNS VALUE TO MOVE -; -CKMATE: ldy BMAXC ; CAN BLK CAP - cpx POINTS ; MY KING? - bne NOCHEK - lda #$00 ; GULP! - beq RETV ; DUMB MOVE! -; -NOCHEK: ldx BMOB ; IS BLACK - bne RETV ; UNABLE TO - ldx WMAXP ; MOVE and - bne RETV ; KING IN CH? - lda #$FF ; YES! MATE -; -RETV: ldx #$04 ; RESTORE - stx STATE ; STATE=4 -; -; THE VALUE OF THE MOVE (IN ACCU) -; IS COMPARED TO THE BEST MOVE and -; REPLACES IT IF IT IS BETTER -; -PUSH: cmp BESTV ; IS THIS BEST - bcc RETP ; MOVE SO FAR? - beq RETP - sta BESTV ; YES! - lda PIECE ; SAVE IT - sta BESTP - lda SQUARE - sta BESTM ; FLASH DISPLAY -RETP: lda #'.' ; print ... instead of flashing disp - jmp syschout ; print . and return -; -; MAIN PROGRAM TO PLAY CHESS -; PLAY FROM OPENING OR THINK -; -GO: ldx OMOVE ; OPENING? - bmi NOOPEN ; -NO *ADD CHANGE FROM bpl - lda DIS3 ; -YES WAS - cmp OPNING,X ; OPPONENT'S - bne END ; MOVE OK? - dex - lda OPNING,X ; GET NEXT - sta DIS1 ; CANNED - dex ; OPENING MOVE - lda OPNING,X - sta DIS3 ; DISPLAY IT - dex - stx OMOVE ; MOVE IT - bne MV2 ; (jmp) -; -END: lda #$FF ; *ADD - STOP CANNED MOVES - sta OMOVE ; FLAG OPENING -NOOPEN: ldx #$0C ; FINISHED - stx STATE ; STATE=C - stx BESTV ; CLEAR BESTV - ldx #$14 ; GENERATE P - jsr GNMX ; MOVES -; - ldx #$04 ; STATE=4 - stx STATE ; GENERATE and - jsr GNMZ ; TEST AVAILABLE -; -; MOVES -; - ldx BESTV ; GET BEST MOVE - cpx #$0F ; IF NONE - bcc MATE ; OH OH! -; -MV2: ldx BESTP ; MOVE - lda BOARD,X ; THE - sta BESTV ; BEST - stx PIECE ; MOVE - lda BESTM - sta SQUARE ; and DISPLAY - jsr MOVE ; IT - jmp CHESS -; -MATE: lda #$FF ; RESIGN - rts ; OR staLEMATE -; -; SUBROUTINE TO ENTER THE -; PLAYER'S MOVE -; -DISMV: ldx #$04 ; ROTATE -Drol: asl DIS3 ; KEY - rol DIS2 ; INTO - dex ; DISPLAY - bne Drol ; - ora DIS3 - sta DIS3 - sta SQUARE - rts -; -; THE FOLLOWING SUBROUTINE ASSIGNS -; A VALUE TO THE MOVE UNDER -; CONSIDERATION and RETURNS IT IN -; THE ACCUMULATOR -; - -STRATGY:clc - lda #$80 - adc WMOB ; PARAMETERS - adc WMAXC ; WITH WHEIGHT - adc WCC ; OF O25 - adc WCAP1 - adc WCAP2 - sec - sbc PMAXC - sbc PCC - sbc BCAP0 - sbc BCAP1 - sbc BCAP2 - sbc PMOB - sbc BMOB - bcs POS ; UNDERFLOW - lda #$00 ; PREVENTION -POS: lsr - clc ; ************** - adc #$40 - adc WMAXC ; PARAMETERS - adc WCC ; WITH WEIGHT - sec ; OF 05 - sbc BMAXC - lsr ; ************** - clc - adc #$90 - adc WCAP0 ; PARAMETERS - adc WCAP0 ; WITH WEIGHT - adc WCAP0 ; OF 10 - adc WCAP0 - adc WCAP1 - sec ; [UNDER OR OVER- - sbc BMAXC ; FLOW MAY OCCUR - sbc BMAXC ; FROM THIS - sbc BMCC ; secTION] - sbc BMCC - sbc BCAP1 - ldx SQUARE ; *************** - cpx #$33 - beq POSN ; POSITION - cpx #$34 ; BONUS FOR - beq POSN ; MOVE TO - cpx #$22 ; CENTRE - beq POSN ; OR - cpx #$25 ; OUT OF - beq POSN ; BACK RANK - ldx PIECE - beq NOPOSN - ldy BOARD,X - cpy #$10 - bpl NOPOSN -POSN: clc - adc #$02 -NOPOSN: jmp CKMATE ; CONTINUE - - -;----------------------------------------------------------------- -; The following routines were added to allow text-based board -; DISPLAY over a standard RS-232 port. -; -POUT: lda PAINT - bne POUT0 - rts ; return if PAINT flag = 0 -POUT0: jsr POUT9 ; print CRLF - jsr POUT13 ; print copyright - jsr POUT10 ; print column labels - ldy #$00 ; init board location - jsr POUT5 ; print board horz edge -POUT1: lda #'|' ; print vert edge - jsr syschout ; PRINT ONE ASCII CHR - SPACE - ldx #$1F -POUT2: tya ; scan the pieces for a location match - cmp BOARD,X ; match found? - beq POUT4 ; yes; print the piece's color and type - dex ; no - bpl POUT2 ; if not the last piece, try again - tya ; empty square - and #$01 ; odd or even column? - sta temp ; save it - tya ; is the row odd or even - lsr ; shift column right 4 spaces - lsr ; - lsr ; - lsr ; - and #$01 ; strip LSB - clc ; - adc temp ; combine row & col to determine square color - and #$01 ; is board square white or blk? - bne POUT25 ; white, print space - lda #'*' ; black, print * - - .byte $2c ; used to skip over lda #$20 - ;jmp POUT25A - -POUT25: lda #$20 ; ASCII space -POUT25A:jsr syschout ; PRINT ONE ASCII CHR - SPACE - jsr syschout ; PRINT ONE ASCII CHR - SPACE -POUT3: iny ; - tya ; get row number - and #$08 ; have we completed the row? - beq POUT1 ; no, do next column - lda #'|' ; yes, put the right edge on - jsr syschout ; PRINT ONE ASCII CHR - | - jsr POUT12 ; print row number - jsr POUT9 ; print CRLF - jsr POUT5 ; print bottom edge of board - clc ; - tya ; - adc #$08 ; point y to beginning of next row - tay ; - cpy #$80 ; was that the last row? - beq POUT8 ; yes, print the LED values - bne POUT1 ; no, do new row - -POUT4: lda REV ; print piece's color & type - beq POUT41 ; - lda cpl+16,X ; - bne POUT42 ; -POUT41: lda cpl,x ; -POUT42: jsr syschout ; - lda cph,x ; - jsr syschout ; - bne POUT3 ; branch always - -POUT5: txa ; print "-----...-----" - pha - ldx #$19 - lda #'-' -POUT6: jsr syschout ; PRINT ONE ASCII CHR - "-" - dex - bne POUT6 - pla - tax - jsr POUT9 - rts - -POUT8: jsr POUT10 ; - lda BESTP - jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS - lda #$20 - jsr syschout ; PRINT ONE ASCII CHR - SPACE - lda BESTV - jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS - lda #$20 - jsr syschout ; PRINT ONE ASCII CHR - SPACE - lda DIS3 - jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS - -POUT9: lda #$0D - jsr syschout ; PRINT ONE ASCII CHR - CR - lda #$0A - jsr syschout ; PRINT ONE ASCII CHR - LF - rts - -POUT10: ldx #$00 ; print the column labels -POUT11: lda #$20 ; 00 01 02 03 ... 07 - jsr syschout - txa - jsr syshexout - inx - cpx #$08 - bne POUT11 - beq POUT9 -POUT12: tya - and #$70 - jsr syshexout - rts - -; print banner only once, preserve registers A, X, Y -POUT13: stx tmp_zpgPt - sta tmp_zpgPt+1 - sty tmp_zpgPt+2 - lda PRNBANN - beq NOPRNBANN - lda #banner - sta mos_StrPtr+1 - jsr mos_CallPuts -NOPRNBANN: - lda #$00 - sta PRNBANN - ldx tmp_zpgPt - lda tmp_zpgPt+1 - ldy tmp_zpgPt+2 - rts - -; ldx #$00 ; Print the copyright banner -;POUT14: lda banner,x -; beq POUT15 -; jsr syschout -; inx -; bne POUT14 -;POUT15: rts - -KIN: lda #'?' - jsr syschout ; PRINT ONE ASCII CHR - ? - jsr syskin ; GET A KEYSTROKE FROM SYSTEM - jsr syschout ; echo entered character - and #$4F ; MASK 0-7, and ALpha'S - rts -; -; 6551 I/O Support Routines -; -; -;Init_6551 lda #$1F ; 19.2K/8/1 -; sta ACIActl ; control reg -; lda #$0B ; N parity/echo off/rx int off/ dtr active low -; sta ACIAcmd ; command reg -; rts ; done -; -; input chr from ACIA1 (waiting) -; -syskin: - jsr mos_CallGetCh - rts - - ;lda ACIAsta ; Serial port status - ;and #$08 ; is recvr full - ;beq syskin ; no char to get - ;lda ACIAdat ; get chr - ;rts ; -; -; output to OutPut Port -; -syschout: ; MKHBCOS: must preserve X, Y and A - stx tmp_zpgPt - sta tmp_zpgPt+1 - ;sty tmp_zpgPt+2 - jsr mos_CallPutCh - ldx tmp_zpgPt - lda tmp_zpgPt+1 - ;ldy tmp_zpgPt+2 - rts -; pha ; save registers -;ACIA_Out1 lda ACIAsta ; serial port status -; and #$10 ; is tx buffer empty -; beq ACIA_Out1 ; no -; pla ; get chr -; sta ACIAdat ; put character to Port -; rts ; done - -syshexout: pha ; prints AA hex digits - lsr ; MOVE UPPER NIBBLE TO LOWER - lsr ; - lsr ; - lsr ; - jsr PrintDig ; - pla ; -PrintDig: - sty tmp_zpgPt+2 - and #$0F ; - tay ; - lda Hexdigdata,Y ; - ldy tmp_zpgPt+2 ; - jmp syschout ; - -Hexdigdata: .byte "0123456789ABCDEF" -banner: .byte "MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com" - .byte $0d, $0a, $00 -cpl: .byte "WWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWW" -cph: .byte "KQCCBBRRPPPPPPPPKQCCBBRRPPPPPPPP" - .byte $00 -; -; end of added code -; -; BLOCK DATA - -.segment "DATA" - - .ORG $0A20 - -SETW: .byte $03, $04, $00, $07, $02, $05, $01, $06 - .byte $10, $17, $11, $16, $12, $15, $14, $13 - .byte $73, $74, $70, $77, $72, $75, $71, $76 - .byte $60, $67, $61, $66, $62, $65, $64, $63 - -MOVEX: .byte $00, $F0, $FF, $01, $10, $11, $0F, $EF, $F1 - .byte $DF, $E1, $EE, $F2, $12, $0E, $1F, $21 - -POINTS: .byte $0B, $0A, $06, $06, $04, $04, $04, $04 - .byte $02, $02, $02, $02, $02, $02, $02, $02 - -OPNING: .byte $99, $25, $0B, $25, $01, $00, $33, $25 - .byte $07, $36, $34, $0D, $34, $34, $0E, $52 - .byte $25, $0D, $45, $35, $04, $55, $22, $06 - .byte $43, $33, $0F, $CC - -.segment "KERN" - - .ORG $FE00 - -CHRIN: lda $E000 - rts - -CHROUT: sta $E000 - rts - -; this function was shamelessly ripped :-) from M.O.S. code (c) by Scott Chidester - -STROUT: - ldy #0 ; Non-indexed variant starts at zero, of course - lda mos_StrPtr+1 ; Save StrPtr so it isn't modified - pha -PutsLoop: - lda (mos_StrPtr),y ; Get the next char in the string - beq PutsDone ; Zero means end of string - jsr CHROUT ; Otherwise put the char - - ; Update string pointer - iny ; increment StrPtr-lo - bne PutsLoop ; No rollover? Loop back for next character - inc mos_StrPtr+1 ; StrPtr-lo rolled over--carry hi byte - jmp PutsLoop ; Now loop back - -PutsDone: - pla - sta mos_StrPtr+1 ; Restore StrPtr - rts - -.segment "VECT" - - .ORG $FFED - - jmp CHRIN - jmp CHROUT - jmp STROUT - -; -; -; end of file -; +;*********************************************************************** +; +; MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com +; +;*********************************************************************** +; Daryl Rictor: +; I have been given permission to distribute this program by the +; author and copyright holder, Peter Jennings. Please get his +; permission if you wish to re-distribute a modified copy of +; this file to others. He specifically requested that his +; copyright notice be included in the source and binary images. +; Thanks! +; +; Marek Karcz: +; I have been given permission to distribute this program by the +; original author Peter Jennings under condition that I include +; link to his website in attribution. +; Here it is: http://www.benlo.com/microchess/index.html +; I did not bother to contact Daryl Rictor to ask permission to +; distribute his modifications to this software because according to +; the copyright notice on the web page of his project, permission is +; already given for personal non-commercial use: +; http://sbc.rictor.org/avr65c02.html +; http://sbc.rictor.org/download/AVR65C02.zip, readme.txt +; If this is incorrect or I misunderstood the author's intention, +; please note that I acted with no malicious intent and will remove +; this file from my project if I receive such request. +; +; To build this program with CL65: +; +; cl65 -C microchess.cfg -l --start-addr 1024 -t none -o microchess.bin +; microchess.asm +; +; Binary image microchess.bin can be loaded to emulator with 'L' +; command in debug console. Start emulator: mkbasic, then issue +; command in debug console: +; L B MICROCHESS.BIN +; +; Memory image definition file can be generated which can be loaded +; to emulator via command line argument and automatically executed. +; To create that file, build microchess.bin image, then execute: +; +; bin2hex -f microchess.bin -o microchess.dat -w 0 -x 1024 -z +; +; and add following lines at the end of microchess.dat file: +; +; IOADDR +; $E000 +; ENIO +; +; Instructions to play: +; +; Load the game to emulator and auto-execute with command: +; mkbasic microchess.dat +; then perform following steps: +; 1. Press 'C' to setup board. +; 2. Enter your move: 4 digits - BBEE, BB - piece coordinates, +; EE - destination coordinates and press ENTER +; 3. After board is updated, press 'P' to make program make the move. +; 4. Repeat steps 2 and 3 until the game is finished. +; +; +; 1/14/2012 +; Modified Daryl Rictor's port to run on MKHBC-8-R1 homebrew +; computer under MKHBCOS (derivative of M.O.S. by Scott +; Chidester). +; +; 3/11/2016 +; Adapted to run in MKBASIC (V65) emulator. +; +; 3/12/2016 +; Modified UI behavior: +; - chess board is only printed after move, not after each +; keystroke +; - copyright banner is only printed once at the start +; of the program +; +; 6551 I/O Port Addresses +; +;ACIADat = $7F70 +;ACIAsta = $7F71 +;ACIACmd = $7F72 +;ACIACtl = $7F73 + +; M.O.S. API defines (kernal) - OK for emulator, no changes + +.define mos_StrPtr $E0 +.define tmp_zpgPt $F6 + +; jumps, originally for M.O.S., now modified for emulator + +.define mos_CallGetCh $FFED +.define mos_CallPutCh $FFF0 +.define mos_CallPuts $FFF3 + + +; +; page zero variables +; +BOARD = $50 +BK = $60 +PIECE = $B0 +SQUARE = $B1 +SP2 = $B2 +SP1 = $B3 +incHEK = $B4 +STATE = $B5 +MOVEN = $B6 +REV = $B7 +OMOVE = $2C +WCAP0 = $2D +COUNT = $2E +BCAP2 = $2E +WCAP2 = $2F +BCAP1 = $20 +WCAP1 = $21 +BCAP0 = $22 +MOB = $23 +MAXC = $24 +CC = $25 +PCAP = $26 +BMOB = $23 +BMAXC = $24 +BMCC = $25 ; was bcc (TASS doesn't like it as a label) +BMAXP = $26 +XMAXC = $28 +WMOB = $2B +WMAXC = $3C +WCC = $3D +WMAXP = $3E +PMOB = $3F +PMAXC = $40 +PCC = $41 +PCP = $42 +OLDKY = $43 +BESTP = $4B +BESTV = $4A +BESTM = $49 +DIS1 = $4B +DIS2 = $4A +DIS3 = $49 +temp = $4C + +; +; +; + +.segment "BEGN" + + .ORG $0000 + +.segment "CODE" + + .ORG $0400 ; load into RAM @ $1000-$15FF + + lda #$00 ; REVERSE TOGGLE + sta REV + jmp CHESS + +PAINT: .byte $FF ; set this flag if board needs painting + ; unset otherwise +PRNBANN: + .byte $FF ; set this flag to print copyright banner + + ;jsr Init_6551 +CHESS: cld ; INITIALIZE + ldx #$FF ; TWO STACKS + txs + ldx #$C8 + stx SP2 +; +; ROUTINES TO LIGHT LED +; DISPLAY and GET KEY +; FROM KEYBOARD +; +OUT: jsr POUT ; DISPLAY and + jsr KIN ; GET INPUT *** my routine waits for a keypress + cmp #$43 ; [C] + bne NOSET ; SET UP + lda #$FF ; set PAINT flag + sta PAINT ; board needs to be diplayed + ldx #$1F ; BOARD +WHSET: lda SETW,X ; FROM + sta BOARD,X ; SETW + dex + bpl WHSET + ldx #$1B ; *ADDED + stx OMOVE ; INITS TO $FF + lda #$CC ; DISPLAY CCC + bne CLDSP +; +NOSET: cmp #$45 ; [E] + bne NOREV ; REVERSE + lda #$FF + sta PAINT + jsr REVERSE ; BOARD IS + sec + lda #$01 + sbc REV + sta REV ; TOGGLE REV FLAG + lda #$EE ; IS + bne CLDSP +; +NOREV: cmp #$40 ; [P] + bne NOGO ; PLAY CHESS + lda #$FF + sta PAINT + jsr GO +CLDSP: sta DIS1 ; DISPLAY + sta DIS2 ; ACROSS + sta DIS3 ; DISPLAY + bne CHESS +; +NOGO: cmp #$0D ; [Enter] + bne NOMV ; MOVE MAN + pha + lda #$FF + sta PAINT + pla + jsr MOVE ; AS ENTERED + jmp DISP +NOMV: cmp #$41 ; [Q] ***Added to allow game exit*** + beq DONE ; quit the game, exit back to system. + pha + lda #$00 + sta PAINT + pla + jmp INPUT ; process move +DONE: rts +;jmp $FF00 ; *** MUST set this to YOUR OS starting address +; +; THE ROUTINE JANUS DIRECTS THE +; ANALYSIS BY DETERMINING WHAT +; SHOULD OCCUR AFTER EACH MOVE +; GENERATED BY GNM +; +; +; +JANUS: ldx STATE + bmi NOCOUNT +; +; THIS ROUTINE COUNTS OCCURRENCES +; IT DEPENDS UPON STATE TO INdex +; THE CORRECT COUNTERS +; +COUNTS: lda PIECE + beq OVER ; IF STATE=8 + cpx #$08 ; DO NOT COUNT + bne OVER ; BLK MAX CAP + cmp BMAXP ; MOVES FOR + beq XRT ; WHITE +; +OVER: inc MOB,X ; MOBILITY + cmp #$01 ; + QUEEN + bne NOQ ; FOR TWO + inc MOB,X +; +NOQ: bvc NOCAP + ldy #$0F ; CALCULATE + lda SQUARE ; POINTS +ELOOP: cmp BK,Y ; CAPTURED + beq FOUN ; BY THIS + dey ; MOVE + bpl ELOOP +FOUN: lda POINTS,Y + cmp MAXC,X + bcc LESS ; SAVE IF + sty PCAP,X ; BEST THIS + sta MAXC,X ; STATE +; +LESS: clc + php ; ADD TO + adc CC,X ; CAPTURE + sta CC,X ; COUNTS + plp +; +NOCAP: cpx #$04 + beq ON4 + bmi TREE ;(=00 ONLY) +XRT: rts +; +; GENERATE FURTHER MOVES FOR COUNT +; and ANALYSIS +; +ON4: lda XMAXC ; SAVE ACTUAL + sta WCAP0 ; CAPTURE + lda #$00 ; STATE=0 + sta STATE + jsr MOVE ; GENERATE + jsr REVERSE ; IMMEDIATE + jsr GNMZ ; REPLY MOVES + jsr REVERSE +; + lda #$08 ; STATE=8 + sta STATE ; GENERATE +; jsr OHM ; CONTINUATION + jsr UMOVE ; MOVES +; + jmp STRATGY ; FINAL EVALUATION +NOCOUNT:cpx #$F9 + bne TREE +; +; DETERMINE IF THE KING CAN BE +; TAKEN, USED BY CHKCHK +; + lda BK ; IS KING + cmp SQUARE ; IN CHECK? + bne RETJ ; SET incHEK=0 + lda #$00 ; IF IT IS + sta incHEK +RETJ: rts +; +; IF A PIECE HAS BEEN CAPTURED BY +; A TRIAL MOVE, GENERATE REPLIES & +; EVALUATE THE EXCHANGE GAIN/LOSS +; +TREE: bvc RETJ ; NO CAP + ldy #$07 ; (PIECES) + lda SQUARE +LOOPX: cmp BK,Y + beq FOUNX + dey + beq RETJ ; (KING) + bpl LOOPX ; SAVE +FOUNX: lda POINTS,Y ; BEST CAP + cmp BCAP0,X ; AT THIS + bcc NOMAX ; LEVEL + sta BCAP0,X +NOMAX: dec STATE + lda #$FB ; IF STATE=FB + cmp STATE ; TIME TO TURN + beq UPTREE ; AROUND + jsr GENRM ; GENERATE FURTHER +UPTREE: inc STATE ; CAPTURES + rts +; +; THE PLAYER'S MOVE IS INPUT +; +INPUT: cmp #$08 ; NOT A LEGAL + bcs ERROR ; SQUARE # + jsr DISMV +DISP: ldx #$1F +SEARCH: lda BOARD,X + cmp DIS2 + beq HERE ; DISPLAY + dex ; PIECE AT + bpl SEARCH ; FROM +HERE: stx DIS1 ; SQUARE + stx PIECE +ERROR: jmp CHESS +; +; GENERATE ALL MOVES FOR ONE +; SIDE, CALL JANUS AFTER EACH +; ONE FOR NEXT STE? +; +; +GNMZ: ldx #$10 ; CLEAR +GNMX: lda #$00 ; COUNTERS +CLEAR: sta COUNT,X + dex + bpl CLEAR +; +GNM: lda #$10 ; SET UP + sta PIECE ; PIECE +NEWP: dec PIECE ; NEW PIECE + bpl NEX ; ALL DONE? + rts ; #NAME? +; +NEX: jsr RESET ; READY + ldy PIECE ; GET PIECE + ldx #$08 + stx MOVEN ; COMMON staRT + cpy #$08 ; WHAT IS IT? + bpl PAWN ; PAWN + cpy #$06 + bpl KNIGHT ; KNIGHT + cpy #$04 + bpl BISHOP ; BISHOP + cpy #$01 + beq QUEEN ; QUEEN + bpl ROOK ; ROOK +; +KING: jsr SNGMV ; MUST BE KING! + bne KING ; MOVES + beq NEWP ; 8 TO 1 +QUEEN: jsr LINE + bne QUEEN ; MOVES + beq NEWP ; 8 TO 1 +; +ROOK: ldx #$04 + stx MOVEN ; MOVES +AGNR: jsr LINE ; 4 TO 1 + bne AGNR + beq NEWP +; +BISHOP: jsr LINE + lda MOVEN ; MOVES + cmp #$04 ; 8 TO 5 + bne BISHOP + beq NEWP +; +KNIGHT: ldx #$10 + stx MOVEN ; MOVES +AGNN: jsr SNGMV ; 16 TO 9 + lda MOVEN + cmp #$08 + bne AGNN + beq NEWP +; +PAWN: ldx #$06 + stx MOVEN +P1: jsr CMOVE ; RIGHT CAP? + bvc P2 + bmi P2 + jsr JANUS ; YES +P2: jsr RESET + dec MOVEN ; LEFT CAP? + lda MOVEN + cmp #$05 + beq P1 +P3: jsr CMOVE ; AHEAD + bvs NEWP ; ILLEGAL + bmi NEWP + jsr JANUS + lda SQUARE ; GETS TO + and #$F0 ; 3RD RANK? + cmp #$20 + beq P3 ; DO DOUBLE + jmp NEWP +; +; CALCULATE SINGLE STEP MOVES +; FOR K,N +; +SNGMV: jsr CMOVE ; CALC MOVE + bmi ILL1 ; -IF LEGAL + jsr JANUS ; -EVALUATE +ILL1: jsr RESET + dec MOVEN + rts +; +; CALCULATE ALL MOVES DOWN A +; STRAIGHT LINE FOR Q,B,R +; +LINE: jsr CMOVE ; CALC MOVE + bcc OVL ; NO CHK + bvc LINE ; NOCAP +OVL: bmi ILL ; RETURN + php + jsr JANUS ; EVALUATE POSN + plp + bvc LINE ; NOT A CAP +ILL: jsr RESET ; LINE STOPPED + dec MOVEN ; NEXT DIR + rts +; +; EXCHANGE SIDES FOR REPLY +; ANALYSIS +; +REVERSE:ldx #$0F +ETC: sec + ldy BK,X ; SUBTRACT + lda #$77 ; POSITION + sbc BOARD,X ; FROM 77 + sta BK,X + sty BOARD,X ; and + sec + lda #$77 ; EXCHANGE + sbc BOARD,X ; PIECES + sta BOARD,X + dex + bpl ETC + rts +; +; CMOVE CALCULATES THE TO SQUARE +; USING SQUARE and THE MOVE +; TABLE FLAGS SET AS FOLLOWS: +; N#NAME? MOVE +; V#NAME? (LEGAL UNLESS IN CR) +; C#NAME? BECAUSE OF CHECK +; [MY &THANKS TO JIM BUTTERFIELD +; WHO WROTE THIS MORE EFFICIENT +; VERSION OF CMOVE) +; +CMOVE: lda SQUARE ; GET SQUARE + ldx MOVEN ; MOVE POINTER + clc + adc MOVEX,X ; MOVE LIST + sta SQUARE ; NEW POS'N + and #$88 + bne ILLEGAL ; OFF BOARD + lda SQUARE +; + ldx #$20 +LOOP: dex ; IS TO + bmi NO ; SQUARE + cmp BOARD,X ; OCCUPIED? + bne LOOP +; + cpx #$10 ; BY SELF? + bmi ILLEGAL +; + lda #$7F ; MUST BE CAP! + adc #$01 ; SET V FLAG + bvs SPX ; (jmp) +; +NO: clv ; NO CAPTURE +; +SPX: lda STATE ; SHOULD WE + bmi RETL ; DO THE + cmp #$08 ; CHECK CHECK? + bpl RETL +; +; CHKCHK REVERSES SIDES +; and LOOKS FOR A KING +; CAPTURE TO INDICATE +; ILLEGAL MOVE BECAUSE OF +; CHECK SincE THIS IS +; TIME CONSUMING, IT IS NOT +; ALWAYS DONE +; +CHKCHK: pha ; STATE #392 + php + lda #$F9 + sta STATE ; GENERATE + sta incHEK ; ALL REPLY + jsr MOVE ; MOVES TO + jsr REVERSE ; SEE IF KING + jsr GNM ; IS IN + jsr RUM ; CHECK + plp + pla + sta STATE + lda incHEK + bmi RETL ; NO - SAFE + sec ; YES - IN CHK + lda #$FF + rts +; +RETL: clc ; LEGAL + lda #$00 ; RETURN + rts +; +ILLEGAL:lda #$FF + clc ; ILLEGAL + clv ; RETURN + rts +; +; REPLACE PIECE ON CORRECT SQUARE +; +RESET: ldx PIECE ; GET LOGAT + lda BOARD,X ; FOR PIECE + sta SQUARE ; FROM BOARD + rts +; +; +; +GENRM: jsr MOVE ; MAKE MOVE +GENR2: jsr REVERSE ; REVERSE BOARD + jsr GNM ; GENERATE MOVES +RUM: jsr REVERSE ; REVERSE BACK +; +; ROUTINE TO UNMAKE A MOVE MADE BY +; MOVE +; +UMOVE: tsx ; UNMAKE MOVE + stx SP1 + ldx SP2 ; EXCHANGE + txs ; STACKS + pla ; MOVEN + sta MOVEN + pla ; CAPTURED + sta PIECE ; PIECE + tax + pla ; FROM SQUARE + sta BOARD,X + pla ; PIECE + tax + pla ; TO SOUARE + sta SQUARE + sta BOARD,X + jmp STRV +; +; THIS ROUTINE MOVES PIECE +; TO SQUARE, PARAMETERS +; ARE SAVED IN A staCK TO UNMAKE +; THE MOVE LATER +; +MOVE: tsx + stx SP1 ; SWITCH + ldx SP2 ; STACKS + txs + lda SQUARE + pha ; TO SQUARE + tay + ldx #$1F +CHECK: cmp BOARD,X ; CHECK FOR + beq TAKE ; CAPTURE + dex + bpl CHECK +TAKE: lda #$CC + sta BOARD,X + txa ; CAPTURED + pha ; PIECE + ldx PIECE + lda BOARD,X + sty BOARD,X ; FROM + pha ; SQUARE + txa + pha ; PIECE + lda MOVEN + pha ; MOVEN +STRV: tsx + stx SP2 ; SWITCH + ldx SP1 ; STACKS + txs ; BACK + rts +; +; CONTINUATION OF SUB STRATGY +; -CHECKS FOR CHECK OR CHECKMATE +; and ASSIGNS VALUE TO MOVE +; +CKMATE: ldy BMAXC ; CAN BLK CAP + cpx POINTS ; MY KING? + bne NOCHEK + lda #$00 ; GULP! + beq RETV ; DUMB MOVE! +; +NOCHEK: ldx BMOB ; IS BLACK + bne RETV ; UNABLE TO + ldx WMAXP ; MOVE and + bne RETV ; KING IN CH? + lda #$FF ; YES! MATE +; +RETV: ldx #$04 ; RESTORE + stx STATE ; STATE=4 +; +; THE VALUE OF THE MOVE (IN ACCU) +; IS COMPARED TO THE BEST MOVE and +; REPLACES IT IF IT IS BETTER +; +PUSH: cmp BESTV ; IS THIS BEST + bcc RETP ; MOVE SO FAR? + beq RETP + sta BESTV ; YES! + lda PIECE ; SAVE IT + sta BESTP + lda SQUARE + sta BESTM ; FLASH DISPLAY +RETP: lda #'.' ; print ... instead of flashing disp + jmp syschout ; print . and return +; +; MAIN PROGRAM TO PLAY CHESS +; PLAY FROM OPENING OR THINK +; +GO: ldx OMOVE ; OPENING? + bmi NOOPEN ; -NO *ADD CHANGE FROM bpl + lda DIS3 ; -YES WAS + cmp OPNING,X ; OPPONENT'S + bne END ; MOVE OK? + dex + lda OPNING,X ; GET NEXT + sta DIS1 ; CANNED + dex ; OPENING MOVE + lda OPNING,X + sta DIS3 ; DISPLAY IT + dex + stx OMOVE ; MOVE IT + bne MV2 ; (jmp) +; +END: lda #$FF ; *ADD - STOP CANNED MOVES + sta OMOVE ; FLAG OPENING +NOOPEN: ldx #$0C ; FINISHED + stx STATE ; STATE=C + stx BESTV ; CLEAR BESTV + ldx #$14 ; GENERATE P + jsr GNMX ; MOVES +; + ldx #$04 ; STATE=4 + stx STATE ; GENERATE and + jsr GNMZ ; TEST AVAILABLE +; +; MOVES +; + ldx BESTV ; GET BEST MOVE + cpx #$0F ; IF NONE + bcc MATE ; OH OH! +; +MV2: ldx BESTP ; MOVE + lda BOARD,X ; THE + sta BESTV ; BEST + stx PIECE ; MOVE + lda BESTM + sta SQUARE ; and DISPLAY + jsr MOVE ; IT + jmp CHESS +; +MATE: lda #$FF ; RESIGN + rts ; OR staLEMATE +; +; SUBROUTINE TO ENTER THE +; PLAYER'S MOVE +; +DISMV: ldx #$04 ; ROTATE +Drol: asl DIS3 ; KEY + rol DIS2 ; INTO + dex ; DISPLAY + bne Drol ; + ora DIS3 + sta DIS3 + sta SQUARE + rts +; +; THE FOLLOWING SUBROUTINE ASSIGNS +; A VALUE TO THE MOVE UNDER +; CONSIDERATION and RETURNS IT IN +; THE ACCUMULATOR +; + +STRATGY:clc + lda #$80 + adc WMOB ; PARAMETERS + adc WMAXC ; WITH WHEIGHT + adc WCC ; OF O25 + adc WCAP1 + adc WCAP2 + sec + sbc PMAXC + sbc PCC + sbc BCAP0 + sbc BCAP1 + sbc BCAP2 + sbc PMOB + sbc BMOB + bcs POS ; UNDERFLOW + lda #$00 ; PREVENTION +POS: lsr + clc ; ************** + adc #$40 + adc WMAXC ; PARAMETERS + adc WCC ; WITH WEIGHT + sec ; OF 05 + sbc BMAXC + lsr ; ************** + clc + adc #$90 + adc WCAP0 ; PARAMETERS + adc WCAP0 ; WITH WEIGHT + adc WCAP0 ; OF 10 + adc WCAP0 + adc WCAP1 + sec ; [UNDER OR OVER- + sbc BMAXC ; FLOW MAY OCCUR + sbc BMAXC ; FROM THIS + sbc BMCC ; secTION] + sbc BMCC + sbc BCAP1 + ldx SQUARE ; *************** + cpx #$33 + beq POSN ; POSITION + cpx #$34 ; BONUS FOR + beq POSN ; MOVE TO + cpx #$22 ; CENTRE + beq POSN ; OR + cpx #$25 ; OUT OF + beq POSN ; BACK RANK + ldx PIECE + beq NOPOSN + ldy BOARD,X + cpy #$10 + bpl NOPOSN +POSN: clc + adc #$02 +NOPOSN: jmp CKMATE ; CONTINUE + + +;----------------------------------------------------------------- +; The following routines were added to allow text-based board +; DISPLAY over a standard RS-232 port. +; +POUT: lda PAINT + bne POUT0 + rts ; return if PAINT flag = 0 +POUT0: jsr POUT9 ; print CRLF + jsr POUT13 ; print copyright + jsr POUT10 ; print column labels + ldy #$00 ; init board location + jsr POUT5 ; print board horz edge +POUT1: lda #'|' ; print vert edge + jsr syschout ; PRINT ONE ASCII CHR - SPACE + ldx #$1F +POUT2: tya ; scan the pieces for a location match + cmp BOARD,X ; match found? + beq POUT4 ; yes; print the piece's color and type + dex ; no + bpl POUT2 ; if not the last piece, try again + tya ; empty square + and #$01 ; odd or even column? + sta temp ; save it + tya ; is the row odd or even + lsr ; shift column right 4 spaces + lsr ; + lsr ; + lsr ; + and #$01 ; strip LSB + clc ; + adc temp ; combine row & col to determine square color + and #$01 ; is board square white or blk? + bne POUT25 ; white, print space + lda #'*' ; black, print * + + .byte $2c ; used to skip over lda #$20 + ;jmp POUT25A + +POUT25: lda #$20 ; ASCII space +POUT25A:jsr syschout ; PRINT ONE ASCII CHR - SPACE + jsr syschout ; PRINT ONE ASCII CHR - SPACE +POUT3: iny ; + tya ; get row number + and #$08 ; have we completed the row? + beq POUT1 ; no, do next column + lda #'|' ; yes, put the right edge on + jsr syschout ; PRINT ONE ASCII CHR - | + jsr POUT12 ; print row number + jsr POUT9 ; print CRLF + jsr POUT5 ; print bottom edge of board + clc ; + tya ; + adc #$08 ; point y to beginning of next row + tay ; + cpy #$80 ; was that the last row? + beq POUT8 ; yes, print the LED values + bne POUT1 ; no, do new row + +POUT4: lda REV ; print piece's color & type + beq POUT41 ; + lda cpl+16,X ; + bne POUT42 ; +POUT41: lda cpl,x ; +POUT42: jsr syschout ; + lda cph,x ; + jsr syschout ; + bne POUT3 ; branch always + +POUT5: txa ; print "-----...-----" + pha + ldx #$19 + lda #'-' +POUT6: jsr syschout ; PRINT ONE ASCII CHR - "-" + dex + bne POUT6 + pla + tax + jsr POUT9 + rts + +POUT8: jsr POUT10 ; + lda BESTP + jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS + lda #$20 + jsr syschout ; PRINT ONE ASCII CHR - SPACE + lda BESTV + jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS + lda #$20 + jsr syschout ; PRINT ONE ASCII CHR - SPACE + lda DIS3 + jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS + +POUT9: lda #$0D + jsr syschout ; PRINT ONE ASCII CHR - CR + lda #$0A + jsr syschout ; PRINT ONE ASCII CHR - LF + rts + +POUT10: ldx #$00 ; print the column labels +POUT11: lda #$20 ; 00 01 02 03 ... 07 + jsr syschout + txa + jsr syshexout + inx + cpx #$08 + bne POUT11 + beq POUT9 +POUT12: tya + and #$70 + jsr syshexout + rts + +; print banner only once, preserve registers A, X, Y +POUT13: stx tmp_zpgPt + sta tmp_zpgPt+1 + sty tmp_zpgPt+2 + lda PRNBANN + beq NOPRNBANN + lda #banner + sta mos_StrPtr+1 + jsr mos_CallPuts +NOPRNBANN: + lda #$00 + sta PRNBANN + ldx tmp_zpgPt + lda tmp_zpgPt+1 + ldy tmp_zpgPt+2 + rts + +; ldx #$00 ; Print the copyright banner +;POUT14: lda banner,x +; beq POUT15 +; jsr syschout +; inx +; bne POUT14 +;POUT15: rts + +KIN: lda #'?' + jsr syschout ; PRINT ONE ASCII CHR - ? + jsr syskin ; GET A KEYSTROKE FROM SYSTEM + jsr syschout ; echo entered character + and #$4F ; MASK 0-7, and ALpha'S + rts +; +; 6551 I/O Support Routines +; +; +;Init_6551 lda #$1F ; 19.2K/8/1 +; sta ACIActl ; control reg +; lda #$0B ; N parity/echo off/rx int off/ dtr active low +; sta ACIAcmd ; command reg +; rts ; done +; +; input chr from ACIA1 (waiting) +; +syskin: + jsr mos_CallGetCh + rts + + ;lda ACIAsta ; Serial port status + ;and #$08 ; is recvr full + ;beq syskin ; no char to get + ;lda ACIAdat ; get chr + ;rts ; +; +; output to OutPut Port +; +syschout: ; MKHBCOS: must preserve X, Y and A + stx tmp_zpgPt + sta tmp_zpgPt+1 + ;sty tmp_zpgPt+2 + jsr mos_CallPutCh + ldx tmp_zpgPt + lda tmp_zpgPt+1 + ;ldy tmp_zpgPt+2 + rts +; pha ; save registers +;ACIA_Out1 lda ACIAsta ; serial port status +; and #$10 ; is tx buffer empty +; beq ACIA_Out1 ; no +; pla ; get chr +; sta ACIAdat ; put character to Port +; rts ; done + +syshexout: pha ; prints AA hex digits + lsr ; MOVE UPPER NIBBLE TO LOWER + lsr ; + lsr ; + lsr ; + jsr PrintDig ; + pla ; +PrintDig: + sty tmp_zpgPt+2 + and #$0F ; + tay ; + lda Hexdigdata,Y ; + ldy tmp_zpgPt+2 ; + jmp syschout ; + +Hexdigdata: .byte "0123456789ABCDEF" +banner: .byte "MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com" + .byte $0d, $0a, $00 +cpl: .byte "WWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWW" +cph: .byte "KQCCBBRRPPPPPPPPKQCCBBRRPPPPPPPP" + .byte $00 +; +; end of added code +; +; BLOCK DATA + +.segment "DATA" + + .ORG $0A20 + +SETW: .byte $03, $04, $00, $07, $02, $05, $01, $06 + .byte $10, $17, $11, $16, $12, $15, $14, $13 + .byte $73, $74, $70, $77, $72, $75, $71, $76 + .byte $60, $67, $61, $66, $62, $65, $64, $63 + +MOVEX: .byte $00, $F0, $FF, $01, $10, $11, $0F, $EF, $F1 + .byte $DF, $E1, $EE, $F2, $12, $0E, $1F, $21 + +POINTS: .byte $0B, $0A, $06, $06, $04, $04, $04, $04 + .byte $02, $02, $02, $02, $02, $02, $02, $02 + +OPNING: .byte $99, $25, $0B, $25, $01, $00, $33, $25 + .byte $07, $36, $34, $0D, $34, $34, $0E, $52 + .byte $25, $0D, $45, $35, $04, $55, $22, $06 + .byte $43, $33, $0F, $CC + +.segment "KERN" + + .ORG $FE00 + +CHRIN: lda $E000 + rts + +CHROUT: sta $E000 + rts + +; this function was shamelessly ripped :-) from M.O.S. code (c) by Scott Chidester + +STROUT: + ldy #0 ; Non-indexed variant starts at zero, of course + lda mos_StrPtr+1 ; Save StrPtr so it isn't modified + pha +PutsLoop: + lda (mos_StrPtr),y ; Get the next char in the string + beq PutsDone ; Zero means end of string + jsr CHROUT ; Otherwise put the char + + ; Update string pointer + iny ; increment StrPtr-lo + bne PutsLoop ; No rollover? Loop back for next character + inc mos_StrPtr+1 ; StrPtr-lo rolled over--carry hi byte + jmp PutsLoop ; Now loop back + +PutsDone: + pla + sta mos_StrPtr+1 ; Restore StrPtr + rts + +.segment "VECT" + + .ORG $FFED + + jmp CHRIN + jmp CHROUT + jmp STROUT + +; +; +; end of file +; diff --git a/microchess.cfg b/microchess.cfg index 9b86be7..85b8849 100644 --- a/microchess.cfg +++ b/microchess.cfg @@ -1,16 +1,16 @@ -MEMORY { - RAM0: start = $0000, size = $0400, fill = yes; - RAM1: start = $0400, size = $0620, fill = yes; - RAM2: start = $0A20, size = $F3E0, fill = yes; - ROM1: start = $FE00, size = $1ED, fill = yes; - ROM2: start = $FFED, size = $12; -} - -SEGMENTS { - BEGN: load = RAM0, type = rw; - CODE: load = RAM1, type = rw; - DATA: load = RAM2, type = rw; - KERN: load = ROM1, type = ro; - VECT: load = ROM2, type = ro; -} - +MEMORY { + RAM0: start = $0000, size = $0400, fill = yes; + RAM1: start = $0400, size = $0620, fill = yes; + RAM2: start = $0A20, size = $F3E0, fill = yes; + ROM1: start = $FE00, size = $1ED, fill = yes; + ROM2: start = $FFED, size = $12; +} + +SEGMENTS { + BEGN: load = RAM0, type = rw; + CODE: load = RAM1, type = rw; + DATA: load = RAM2, type = rw; + KERN: load = ROM1, type = ro; + VECT: load = ROM2, type = ro; +} + diff --git a/microchess.dat b/microchess.dat index 1d593e4..3b788d7 100644 --- a/microchess.dat +++ b/microchess.dat @@ -1,114 +1,114 @@ -; Created with BIN2HEX (C) Marek Karcz 2016. All rights reserved. -; 03/13/16 00:08:59 -ADDR -$0400 -ORG -$0000 -ORG -$0400 -$a9 $00 $85 $b7 $4c $09 $04 $ff $ff $d8 $a2 $ff $9a $a2 $c8 $86 -$b2 $20 $92 $07 $20 $7d $08 $c9 $43 $d0 $17 $a9 $ff $8d $07 $04 -$a2 $1f $bd $20 $0a $95 $50 $ca $10 $f8 $a2 $1b $86 $2c $a9 $cc -$d0 $23 $c9 $45 $d0 $13 $a9 $ff $8d $07 $04 $20 $db $05 $38 $a9 -$01 $e5 $b7 $85 $b7 $a9 $ee $d0 $0c $c9 $40 $d0 $10 $a9 $ff $8d -$07 $04 $20 $cf $06 $85 $4b $85 $4a $85 $49 $d0 $ac $c9 $0d $d0 -$0d $48 $a9 $ff $8d $07 $04 $68 $20 $75 $06 $4c $17 $05 $c9 $41 -$f0 $0a $48 $a9 $00 $8d $07 $04 $68 $4c $10 $05 $60 $a6 $b5 $30 -$59 $a5 $b0 $f0 $08 $e0 $08 $d0 $04 $c5 $26 $f0 $2e $f6 $23 $c9 -$01 $d0 $02 $f6 $23 $50 $1e $a0 $0f $a5 $b1 $d9 $60 $00 $f0 $03 -$88 $10 $f8 $b9 $51 $0a $d5 $24 $90 $04 $94 $26 $95 $24 $18 $08 -$75 $25 $95 $25 $28 $e0 $04 $f0 $03 $30 $2e $60 $a5 $28 $85 $2d -$a9 $00 $85 $b5 $20 $75 $06 $20 $db $05 $20 $29 $05 $20 $db $05 -$a9 $08 $85 $b5 $20 $5b $06 $4c $2c $07 $e0 $f9 $d0 $0b $a5 $60 -$c5 $b1 $d0 $04 $a9 $00 $85 $b4 $60 $50 $fd $a0 $07 $a5 $b1 $d9 -$60 $00 $f0 $05 $88 $f0 $f1 $10 $f6 $b9 $51 $0a $d5 $22 $90 $02 -$95 $22 $c6 $b5 $a9 $fb $c5 $b5 $f0 $03 $20 $4f $06 $e6 $b5 $60 -$c9 $08 $b0 $12 $20 $1c $07 $a2 $1f $b5 $50 $c5 $4a $f0 $03 $ca -$10 $f7 $86 $4b $86 $b0 $4c $09 $04 $a2 $10 $a9 $00 $95 $2e $ca -$10 $fb $a9 $10 $85 $b0 $c6 $b0 $10 $01 $60 $20 $48 $06 $a4 $b0 -$a2 $08 $86 $b6 $c0 $08 $10 $41 $c0 $06 $10 $2e $c0 $04 $10 $1f -$c0 $01 $f0 $09 $10 $0e $20 $b7 $05 $d0 $fb $f0 $d9 $20 $c5 $05 -$d0 $fb $f0 $d2 $a2 $04 $86 $b6 $20 $c5 $05 $d0 $fb $f0 $c7 $20 -$c5 $05 $a5 $b6 $c9 $04 $d0 $f7 $f0 $bc $a2 $10 $86 $b6 $20 $b7 -$05 $a5 $b6 $c9 $08 $d0 $f7 $f0 $ad $a2 $06 $86 $b6 $20 $f3 $05 -$50 $05 $30 $03 $20 $7d $04 $20 $48 $06 $c6 $b6 $a5 $b6 $c9 $05 -$f0 $eb $20 $f3 $05 $70 $8f $30 $8d $20 $7d $04 $a5 $b1 $29 $f0 -$c9 $20 $f0 $ee $4c $36 $05 $20 $f3 $05 $30 $03 $20 $7d $04 $20 -$48 $06 $c6 $b6 $60 $20 $f3 $05 $90 $02 $50 $f9 $30 $07 $08 $20 -$7d $04 $28 $50 $f0 $20 $48 $06 $c6 $b6 $60 $a2 $0f $38 $b4 $60 -$a9 $77 $f5 $50 $95 $60 $94 $50 $38 $a9 $77 $f5 $50 $95 $50 $ca -$10 $eb $60 $a5 $b1 $a6 $b6 $18 $7d $40 $0a $85 $b1 $29 $88 $d0 -$42 $a5 $b1 $a2 $20 $ca $30 $0e $d5 $50 $d0 $f9 $e0 $10 $30 $33 -$a9 $7f $69 $01 $70 $01 $b8 $a5 $b5 $30 $24 $c9 $08 $10 $20 $48 -$08 $a9 $f9 $85 $b5 $85 $b4 $20 $75 $06 $20 $db $05 $20 $32 $05 -$20 $58 $06 $28 $68 $85 $b5 $a5 $b4 $30 $04 $38 $a9 $ff $60 $18 -$a9 $00 $60 $a9 $ff $18 $b8 $60 $a6 $b0 $b5 $50 $85 $b1 $60 $20 -$75 $06 $20 $db $05 $20 $32 $05 $20 $db $05 $ba $86 $b3 $a6 $b2 -$9a $68 $85 $b6 $68 $85 $b0 $aa $68 $95 $50 $68 $aa $68 $85 $b1 -$95 $50 $4c $9a $06 $ba $86 $b3 $a6 $b2 $9a $a5 $b1 $48 $a8 $a2 -$1f $d5 $50 $f0 $03 $ca $10 $f9 $a9 $cc $95 $50 $8a $48 $a6 $b0 -$b5 $50 $94 $50 $48 $8a $48 $a5 $b6 $48 $ba $86 $b2 $a6 $b3 $9a -$60 $a4 $24 $ec $51 $0a $d0 $04 $a9 $00 $f0 $0a $a6 $23 $d0 $06 -$a6 $3e $d0 $02 $a9 $ff $a2 $04 $86 $b5 $c5 $4a $90 $0c $f0 $0a -$85 $4a $a5 $b0 $85 $4b $a5 $b1 $85 $49 $a9 $2e $4c $8f $08 $a6 -$2c $30 $1c $a5 $49 $dd $61 $0a $d0 $11 $ca $bd $61 $0a $85 $4b -$ca $bd $61 $0a $85 $49 $ca $86 $2c $d0 $1c $a9 $ff $85 $2c $a2 -$0c $86 $b5 $86 $4a $a2 $14 $20 $2b $05 $a2 $04 $86 $b5 $20 $29 -$05 $a6 $4a $e0 $0f $90 $12 $a6 $4b $b5 $50 $85 $4a $86 $b0 $a5 -$49 $85 $b1 $20 $75 $06 $4c $09 $04 $a9 $ff $60 $a2 $04 $06 $49 -$26 $4a $ca $d0 $f9 $05 $49 $85 $49 $85 $b1 $60 $18 $a9 $80 $65 -$2b $65 $3c $65 $3d $65 $21 $65 $2f $38 $e5 $40 $e5 $41 $e5 $22 -$e5 $20 $e5 $2e $e5 $3f $e5 $23 $b0 $02 $a9 $00 $4a $18 $69 $40 -$65 $3c $65 $3d $38 $e5 $24 $4a $18 $69 $90 $65 $2d $65 $2d $65 -$2d $65 $2d $65 $21 $38 $e5 $24 $e5 $24 $e5 $25 $e5 $25 $e5 $20 -$a6 $b1 $e0 $33 $f0 $16 $e0 $34 $f0 $12 $e0 $22 $f0 $0e $e0 $25 -$f0 $0a $a6 $b0 $f0 $09 $b4 $50 $c0 $10 $10 $03 $18 $69 $02 $4c -$a1 $06 $ad $07 $04 $d0 $01 $60 $20 $37 $08 $20 $5b $08 $20 $42 -$08 $a0 $00 $20 $09 $08 $a9 $7c $20 $8f $08 $a2 $1f $98 $d5 $50 -$f0 $40 $ca $10 $f8 $98 $29 $01 $85 $4c $98 $4a $4a $4a $4a $29 -$01 $18 $65 $4c $29 $01 $d0 $03 $a9 $2a $2c $a9 $20 $20 $8f $08 -$20 $8f $08 $c8 $98 $29 $08 $f0 $cd $a9 $7c $20 $8f $08 $20 $54 -$08 $20 $37 $08 $20 $09 $08 $18 $98 $69 $08 $a8 $c0 $80 $f0 $2b -$d0 $b4 $a5 $b7 $f0 $05 $bd $0d $09 $d0 $03 $bd $fd $08 $20 $8f -$08 $bd $2d $09 $20 $8f $08 $d0 $ca $8a $48 $a2 $19 $a9 $2d $20 -$8f $08 $ca $d0 $fa $68 $aa $20 $37 $08 $60 $20 $42 $08 $a5 $4b -$20 $9b $08 $a9 $20 $20 $8f $08 $a5 $4a $20 $9b $08 $a9 $20 $20 -$8f $08 $a5 $49 $20 $9b $08 $a9 $0d $20 $8f $08 $a9 $0a $20 $8f -$08 $60 $a2 $00 $a9 $20 $20 $8f $08 $8a $20 $9b $08 $e8 $e0 $08 -$d0 $f2 $f0 $e3 $98 $29 $70 $20 $9b $08 $60 $86 $f6 $85 $f7 $84 -$f8 $ad $08 $04 $f0 $0b $a9 $c1 $85 $e0 $a9 $08 $85 $e1 $20 $f3 -$ff $a9 $00 $8d $08 $04 $a6 $f6 $a5 $f7 $a4 $f8 $60 $a9 $3f $20 -$8f $08 $20 $8b $08 $20 $8f $08 $29 $4f $60 $20 $ed $ff $60 $86 -$f6 $85 $f7 $20 $f0 $ff $a6 $f6 $a5 $f7 $60 $48 $4a $4a $4a $4a -$20 $a4 $08 $68 $84 $f8 $29 $0f $a8 $b9 $b1 $08 $a4 $f8 $4c $8f -$08 $30 $31 $32 $33 $34 $35 $36 $37 $38 $39 $41 $42 $43 $44 $45 -$46 $4d $69 $63 $72 $6f $43 $68 $65 $73 $73 $20 $28 $63 $29 $20 -$31 $39 $39 $36 $2d $32 $30 $30 $32 $20 $50 $65 $74 $65 $72 $20 -$4a $65 $6e $6e $69 $6e $67 $73 $2c $20 $70 $65 $74 $65 $72 $6a -$40 $62 $65 $6e $6c $6f $2e $63 $6f $6d $0d $0a $00 $57 $57 $57 -$57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $42 $42 $42 -$42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $57 $57 $57 -$57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $4b $51 $43 -$43 $42 $42 $52 $52 $50 $50 $50 $50 $50 $50 $50 $50 $4b $51 $43 -$43 $42 $42 $52 $52 $50 $50 $50 $50 $50 $50 $50 $50 $00 $00 $00 -ORG -$0a20 -$03 $04 $00 $07 $02 $05 $01 $06 $10 $17 $11 $16 $12 $15 $14 $13 -$73 $74 $70 $77 $72 $75 $71 $76 $60 $67 $61 $66 $62 $65 $64 $63 -$00 $f0 $ff $01 $10 $11 $0f $ef $f1 $df $e1 $ee $f2 $12 $0e $1f -$21 $0b $0a $06 $06 $04 $04 $04 $04 $02 $02 $02 $02 $02 $02 $02 -$02 $99 $25 $0b $25 $01 $00 $33 $25 $07 $36 $34 $0d $34 $34 $0e -$52 $25 $0d $45 $35 $04 $55 $22 $06 $43 $33 $0f $cc $00 $00 $00 -ORG -$fe00 -$ad $00 $e0 $60 $8d $00 $e0 $60 $a0 $00 $a5 $e1 $48 $b1 $e0 $f0 -$0b $20 $04 $fe $c8 $d0 $f6 $e6 $e1 $4c $0d $fe $68 $85 $e1 $60 -ORG -$ffe0 -$00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $4c $00 $fe -$4c $04 $fe $4c $08 $fe $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 -IOADDR -$E000 -ENIO -EXEC -$0400 +; Created with BIN2HEX (C) Marek Karcz 2016. All rights reserved. +; 03/13/16 00:08:59 +ADDR +$0400 +ORG +$0000 +ORG +$0400 +$a9 $00 $85 $b7 $4c $09 $04 $ff $ff $d8 $a2 $ff $9a $a2 $c8 $86 +$b2 $20 $92 $07 $20 $7d $08 $c9 $43 $d0 $17 $a9 $ff $8d $07 $04 +$a2 $1f $bd $20 $0a $95 $50 $ca $10 $f8 $a2 $1b $86 $2c $a9 $cc +$d0 $23 $c9 $45 $d0 $13 $a9 $ff $8d $07 $04 $20 $db $05 $38 $a9 +$01 $e5 $b7 $85 $b7 $a9 $ee $d0 $0c $c9 $40 $d0 $10 $a9 $ff $8d +$07 $04 $20 $cf $06 $85 $4b $85 $4a $85 $49 $d0 $ac $c9 $0d $d0 +$0d $48 $a9 $ff $8d $07 $04 $68 $20 $75 $06 $4c $17 $05 $c9 $41 +$f0 $0a $48 $a9 $00 $8d $07 $04 $68 $4c $10 $05 $60 $a6 $b5 $30 +$59 $a5 $b0 $f0 $08 $e0 $08 $d0 $04 $c5 $26 $f0 $2e $f6 $23 $c9 +$01 $d0 $02 $f6 $23 $50 $1e $a0 $0f $a5 $b1 $d9 $60 $00 $f0 $03 +$88 $10 $f8 $b9 $51 $0a $d5 $24 $90 $04 $94 $26 $95 $24 $18 $08 +$75 $25 $95 $25 $28 $e0 $04 $f0 $03 $30 $2e $60 $a5 $28 $85 $2d +$a9 $00 $85 $b5 $20 $75 $06 $20 $db $05 $20 $29 $05 $20 $db $05 +$a9 $08 $85 $b5 $20 $5b $06 $4c $2c $07 $e0 $f9 $d0 $0b $a5 $60 +$c5 $b1 $d0 $04 $a9 $00 $85 $b4 $60 $50 $fd $a0 $07 $a5 $b1 $d9 +$60 $00 $f0 $05 $88 $f0 $f1 $10 $f6 $b9 $51 $0a $d5 $22 $90 $02 +$95 $22 $c6 $b5 $a9 $fb $c5 $b5 $f0 $03 $20 $4f $06 $e6 $b5 $60 +$c9 $08 $b0 $12 $20 $1c $07 $a2 $1f $b5 $50 $c5 $4a $f0 $03 $ca +$10 $f7 $86 $4b $86 $b0 $4c $09 $04 $a2 $10 $a9 $00 $95 $2e $ca +$10 $fb $a9 $10 $85 $b0 $c6 $b0 $10 $01 $60 $20 $48 $06 $a4 $b0 +$a2 $08 $86 $b6 $c0 $08 $10 $41 $c0 $06 $10 $2e $c0 $04 $10 $1f +$c0 $01 $f0 $09 $10 $0e $20 $b7 $05 $d0 $fb $f0 $d9 $20 $c5 $05 +$d0 $fb $f0 $d2 $a2 $04 $86 $b6 $20 $c5 $05 $d0 $fb $f0 $c7 $20 +$c5 $05 $a5 $b6 $c9 $04 $d0 $f7 $f0 $bc $a2 $10 $86 $b6 $20 $b7 +$05 $a5 $b6 $c9 $08 $d0 $f7 $f0 $ad $a2 $06 $86 $b6 $20 $f3 $05 +$50 $05 $30 $03 $20 $7d $04 $20 $48 $06 $c6 $b6 $a5 $b6 $c9 $05 +$f0 $eb $20 $f3 $05 $70 $8f $30 $8d $20 $7d $04 $a5 $b1 $29 $f0 +$c9 $20 $f0 $ee $4c $36 $05 $20 $f3 $05 $30 $03 $20 $7d $04 $20 +$48 $06 $c6 $b6 $60 $20 $f3 $05 $90 $02 $50 $f9 $30 $07 $08 $20 +$7d $04 $28 $50 $f0 $20 $48 $06 $c6 $b6 $60 $a2 $0f $38 $b4 $60 +$a9 $77 $f5 $50 $95 $60 $94 $50 $38 $a9 $77 $f5 $50 $95 $50 $ca +$10 $eb $60 $a5 $b1 $a6 $b6 $18 $7d $40 $0a $85 $b1 $29 $88 $d0 +$42 $a5 $b1 $a2 $20 $ca $30 $0e $d5 $50 $d0 $f9 $e0 $10 $30 $33 +$a9 $7f $69 $01 $70 $01 $b8 $a5 $b5 $30 $24 $c9 $08 $10 $20 $48 +$08 $a9 $f9 $85 $b5 $85 $b4 $20 $75 $06 $20 $db $05 $20 $32 $05 +$20 $58 $06 $28 $68 $85 $b5 $a5 $b4 $30 $04 $38 $a9 $ff $60 $18 +$a9 $00 $60 $a9 $ff $18 $b8 $60 $a6 $b0 $b5 $50 $85 $b1 $60 $20 +$75 $06 $20 $db $05 $20 $32 $05 $20 $db $05 $ba $86 $b3 $a6 $b2 +$9a $68 $85 $b6 $68 $85 $b0 $aa $68 $95 $50 $68 $aa $68 $85 $b1 +$95 $50 $4c $9a $06 $ba $86 $b3 $a6 $b2 $9a $a5 $b1 $48 $a8 $a2 +$1f $d5 $50 $f0 $03 $ca $10 $f9 $a9 $cc $95 $50 $8a $48 $a6 $b0 +$b5 $50 $94 $50 $48 $8a $48 $a5 $b6 $48 $ba $86 $b2 $a6 $b3 $9a +$60 $a4 $24 $ec $51 $0a $d0 $04 $a9 $00 $f0 $0a $a6 $23 $d0 $06 +$a6 $3e $d0 $02 $a9 $ff $a2 $04 $86 $b5 $c5 $4a $90 $0c $f0 $0a +$85 $4a $a5 $b0 $85 $4b $a5 $b1 $85 $49 $a9 $2e $4c $8f $08 $a6 +$2c $30 $1c $a5 $49 $dd $61 $0a $d0 $11 $ca $bd $61 $0a $85 $4b +$ca $bd $61 $0a $85 $49 $ca $86 $2c $d0 $1c $a9 $ff $85 $2c $a2 +$0c $86 $b5 $86 $4a $a2 $14 $20 $2b $05 $a2 $04 $86 $b5 $20 $29 +$05 $a6 $4a $e0 $0f $90 $12 $a6 $4b $b5 $50 $85 $4a $86 $b0 $a5 +$49 $85 $b1 $20 $75 $06 $4c $09 $04 $a9 $ff $60 $a2 $04 $06 $49 +$26 $4a $ca $d0 $f9 $05 $49 $85 $49 $85 $b1 $60 $18 $a9 $80 $65 +$2b $65 $3c $65 $3d $65 $21 $65 $2f $38 $e5 $40 $e5 $41 $e5 $22 +$e5 $20 $e5 $2e $e5 $3f $e5 $23 $b0 $02 $a9 $00 $4a $18 $69 $40 +$65 $3c $65 $3d $38 $e5 $24 $4a $18 $69 $90 $65 $2d $65 $2d $65 +$2d $65 $2d $65 $21 $38 $e5 $24 $e5 $24 $e5 $25 $e5 $25 $e5 $20 +$a6 $b1 $e0 $33 $f0 $16 $e0 $34 $f0 $12 $e0 $22 $f0 $0e $e0 $25 +$f0 $0a $a6 $b0 $f0 $09 $b4 $50 $c0 $10 $10 $03 $18 $69 $02 $4c +$a1 $06 $ad $07 $04 $d0 $01 $60 $20 $37 $08 $20 $5b $08 $20 $42 +$08 $a0 $00 $20 $09 $08 $a9 $7c $20 $8f $08 $a2 $1f $98 $d5 $50 +$f0 $40 $ca $10 $f8 $98 $29 $01 $85 $4c $98 $4a $4a $4a $4a $29 +$01 $18 $65 $4c $29 $01 $d0 $03 $a9 $2a $2c $a9 $20 $20 $8f $08 +$20 $8f $08 $c8 $98 $29 $08 $f0 $cd $a9 $7c $20 $8f $08 $20 $54 +$08 $20 $37 $08 $20 $09 $08 $18 $98 $69 $08 $a8 $c0 $80 $f0 $2b +$d0 $b4 $a5 $b7 $f0 $05 $bd $0d $09 $d0 $03 $bd $fd $08 $20 $8f +$08 $bd $2d $09 $20 $8f $08 $d0 $ca $8a $48 $a2 $19 $a9 $2d $20 +$8f $08 $ca $d0 $fa $68 $aa $20 $37 $08 $60 $20 $42 $08 $a5 $4b +$20 $9b $08 $a9 $20 $20 $8f $08 $a5 $4a $20 $9b $08 $a9 $20 $20 +$8f $08 $a5 $49 $20 $9b $08 $a9 $0d $20 $8f $08 $a9 $0a $20 $8f +$08 $60 $a2 $00 $a9 $20 $20 $8f $08 $8a $20 $9b $08 $e8 $e0 $08 +$d0 $f2 $f0 $e3 $98 $29 $70 $20 $9b $08 $60 $86 $f6 $85 $f7 $84 +$f8 $ad $08 $04 $f0 $0b $a9 $c1 $85 $e0 $a9 $08 $85 $e1 $20 $f3 +$ff $a9 $00 $8d $08 $04 $a6 $f6 $a5 $f7 $a4 $f8 $60 $a9 $3f $20 +$8f $08 $20 $8b $08 $20 $8f $08 $29 $4f $60 $20 $ed $ff $60 $86 +$f6 $85 $f7 $20 $f0 $ff $a6 $f6 $a5 $f7 $60 $48 $4a $4a $4a $4a +$20 $a4 $08 $68 $84 $f8 $29 $0f $a8 $b9 $b1 $08 $a4 $f8 $4c $8f +$08 $30 $31 $32 $33 $34 $35 $36 $37 $38 $39 $41 $42 $43 $44 $45 +$46 $4d $69 $63 $72 $6f $43 $68 $65 $73 $73 $20 $28 $63 $29 $20 +$31 $39 $39 $36 $2d $32 $30 $30 $32 $20 $50 $65 $74 $65 $72 $20 +$4a $65 $6e $6e $69 $6e $67 $73 $2c $20 $70 $65 $74 $65 $72 $6a +$40 $62 $65 $6e $6c $6f $2e $63 $6f $6d $0d $0a $00 $57 $57 $57 +$57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $42 $42 $42 +$42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $42 $57 $57 $57 +$57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $57 $4b $51 $43 +$43 $42 $42 $52 $52 $50 $50 $50 $50 $50 $50 $50 $50 $4b $51 $43 +$43 $42 $42 $52 $52 $50 $50 $50 $50 $50 $50 $50 $50 $00 $00 $00 +ORG +$0a20 +$03 $04 $00 $07 $02 $05 $01 $06 $10 $17 $11 $16 $12 $15 $14 $13 +$73 $74 $70 $77 $72 $75 $71 $76 $60 $67 $61 $66 $62 $65 $64 $63 +$00 $f0 $ff $01 $10 $11 $0f $ef $f1 $df $e1 $ee $f2 $12 $0e $1f +$21 $0b $0a $06 $06 $04 $04 $04 $04 $02 $02 $02 $02 $02 $02 $02 +$02 $99 $25 $0b $25 $01 $00 $33 $25 $07 $36 $34 $0d $34 $34 $0e +$52 $25 $0d $45 $35 $04 $55 $22 $06 $43 $33 $0f $cc $00 $00 $00 +ORG +$fe00 +$ad $00 $e0 $60 $8d $00 $e0 $60 $a0 $00 $a5 $e1 $48 $b1 $e0 $f0 +$0b $20 $04 $fe $c8 $d0 $f6 $e6 $e1 $4c $0d $fe $68 $85 $e1 $60 +ORG +$ffe0 +$00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $4c $00 $fe +$4c $04 $fe $4c $08 $fe $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 +IOADDR +$E000 +ENIO +EXEC +$0400 diff --git a/microchess.lst b/microchess.lst index a733acc..4dce6ff 100644 --- a/microchess.lst +++ b/microchess.lst @@ -1,1033 +1,1033 @@ -ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz -Main file : microchess.asm -Current file: microchess.asm - -000000r 1 ;*********************************************************************** -000000r 1 ; -000000r 1 ; MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com -000000r 1 ; -000000r 1 ;*********************************************************************** -000000r 1 ; Daryl Rictor: -000000r 1 ; I have been given permission to distribute this program by the -000000r 1 ; author and copyright holder, Peter Jennings. Please get his -000000r 1 ; permission if you wish to re-distribute a modified copy of -000000r 1 ; this file to others. He specifically requested that his -000000r 1 ; copyright notice be included in the source and binary images. -000000r 1 ; Thanks! -000000r 1 ; -000000r 1 ; Marek Karcz: -000000r 1 ; I have been given permission to distribute this program by the -000000r 1 ; original author Peter Jennings under condition that I include -000000r 1 ; link to his website in attribution. -000000r 1 ; Here it is: http://www.benlo.com/microchess/index.html -000000r 1 ; I did not bother to contact Daryl Rictor to ask permission to -000000r 1 ; distribute his modifications to this software because according to -000000r 1 ; the copyright notice on the web page of his project, permission is -000000r 1 ; already given for personal non-commercial use: -000000r 1 ; http://sbc.rictor.org/avr65c02.html -000000r 1 ; http://sbc.rictor.org/download/AVR65C02.zip, readme.txt -000000r 1 ; If this is incorrect or I misunderstood the author's intention, -000000r 1 ; please note that I acted with no malicious intent and will remove -000000r 1 ; this file from my project if I receive such request. -000000r 1 ; -000000r 1 ; 1/14/2012 -000000r 1 ; Modified by Marek Karcz to run on MKHBC-8-R1 under MKHBCOS -000000r 1 ; (derivative of M.O.S. by Scott Chidester) -000000r 1 ; 3/11/2016 -000000r 1 ; Adapted to run in MKBASIC (V65) emulator. -000000r 1 ; -000000r 1 ; 6551 I/O Port Addresses -000000r 1 ; -000000r 1 ;ACIADat = $7F70 -000000r 1 ;ACIAsta = $7F71 -000000r 1 ;ACIACmd = $7F72 -000000r 1 ;ACIACtl = $7F73 -000000r 1 -000000r 1 ; M.O.S. API defines (kernal) - OK for emulator, no changes -000000r 1 -000000r 1 .define mos_StrPtr $E0 -000000r 1 .define tmp_zpgPt $F6 -000000r 1 -000000r 1 ; jumps, originally for M.O.S., now modified for emulator -000000r 1 -000000r 1 .define mos_CallGetCh $FFED -000000r 1 .define mos_CallPutCh $FFF0 -000000r 1 .define mos_CallPuts $FFF3 -000000r 1 -000000r 1 -000000r 1 ; -000000r 1 ; page zero variables -000000r 1 ; -000000r 1 BOARD = $50 -000000r 1 BK = $60 -000000r 1 PIECE = $B0 -000000r 1 SQUARE = $B1 -000000r 1 SP2 = $B2 -000000r 1 SP1 = $B3 -000000r 1 incHEK = $B4 -000000r 1 STATE = $B5 -000000r 1 MOVEN = $B6 -000000r 1 REV = $B7 -000000r 1 OMOVE = $2C -000000r 1 WCAP0 = $2D -000000r 1 COUNT = $2E -000000r 1 BCAP2 = $2E -000000r 1 WCAP2 = $2F -000000r 1 BCAP1 = $20 -000000r 1 WCAP1 = $21 -000000r 1 BCAP0 = $22 -000000r 1 MOB = $23 -000000r 1 MAXC = $24 -000000r 1 CC = $25 -000000r 1 PCAP = $26 -000000r 1 BMOB = $23 -000000r 1 BMAXC = $24 -000000r 1 BMCC = $25 ; was bcc (TASS doesn't like it as a label) -000000r 1 BMAXP = $26 -000000r 1 XMAXC = $28 -000000r 1 WMOB = $2B -000000r 1 WMAXC = $3C -000000r 1 WCC = $3D -000000r 1 WMAXP = $3E -000000r 1 PMOB = $3F -000000r 1 PMAXC = $40 -000000r 1 PCC = $41 -000000r 1 PCP = $42 -000000r 1 OLDKY = $43 -000000r 1 BESTP = $4B -000000r 1 BESTV = $4A -000000r 1 BESTM = $49 -000000r 1 DIS1 = $4B -000000r 1 DIS2 = $4A -000000r 1 DIS3 = $49 -000000r 1 temp = $4C -000000r 1 -000000r 1 ; -000000r 1 ; -000000r 1 ; -000000r 1 -000000r 1 .segment "BEGN" -000000r 1 -000000r 1 .ORG $0000 -000000 1 -000000 1 .segment "CODE" -000000 1 -000000 1 .ORG $0400 ; load into RAM @ $1000-$15FF -000400 1 -000400 1 A9 00 lda #$00 ; REVERSE TOGGLE -000402 1 85 B7 sta REV -000404 1 4C 09 04 jmp CHESS -000407 1 -000407 1 FF PAINT: .byte $FF ; set this flag if board needs painting -000408 1 ; unset otherwise -000408 1 PRNBANN: -000408 1 FF .byte $FF ; set this flag to print copyright banner -000409 1 -000409 1 ;jsr Init_6551 -000409 1 D8 CHESS: cld ; INITIALIZE -00040A 1 A2 FF ldx #$FF ; TWO STACKS -00040C 1 9A txs -00040D 1 A2 C8 ldx #$C8 -00040F 1 86 B2 stx SP2 -000411 1 ; -000411 1 ; ROUTINES TO LIGHT LED -000411 1 ; DISPLAY and GET KEY -000411 1 ; FROM KEYBOARD -000411 1 ; -000411 1 20 92 07 OUT: jsr POUT ; DISPLAY and -000414 1 20 7D 08 jsr KIN ; GET INPUT *** my routine waits for a keypress -000417 1 C9 43 cmp #$43 ; [C] -000419 1 D0 17 bne NOSET ; SET UP -00041B 1 A9 FF lda #$FF ; set PAINT flag -00041D 1 8D 07 04 sta PAINT ; board needs to be diplayed -000420 1 A2 1F ldx #$1F ; BOARD -000422 1 BD 20 0A WHSET: lda SETW,X ; FROM -000425 1 95 50 sta BOARD,X ; SETW -000427 1 CA dex -000428 1 10 F8 bpl WHSET -00042A 1 A2 1B ldx #$1B ; *ADDED -00042C 1 86 2C stx OMOVE ; INITS TO $FF -00042E 1 A9 CC lda #$CC ; DISPLAY CCC -000430 1 D0 23 bne CLDSP -000432 1 ; -000432 1 C9 45 NOSET: cmp #$45 ; [E] -000434 1 D0 13 bne NOREV ; REVERSE -000436 1 A9 FF lda #$FF -000438 1 8D 07 04 sta PAINT -00043B 1 20 DB 05 jsr REVERSE ; BOARD IS -00043E 1 38 sec -00043F 1 A9 01 lda #$01 -000441 1 E5 B7 sbc REV -000443 1 85 B7 sta REV ; TOGGLE REV FLAG -000445 1 A9 EE lda #$EE ; IS -000447 1 D0 0C bne CLDSP -000449 1 ; -000449 1 C9 40 NOREV: cmp #$40 ; [P] -00044B 1 D0 10 bne NOGO ; PLAY CHESS -00044D 1 A9 FF lda #$FF -00044F 1 8D 07 04 sta PAINT -000452 1 20 CF 06 jsr GO -000455 1 85 4B CLDSP: sta DIS1 ; DISPLAY -000457 1 85 4A sta DIS2 ; ACROSS -000459 1 85 49 sta DIS3 ; DISPLAY -00045B 1 D0 AC bne CHESS -00045D 1 ; -00045D 1 C9 0D NOGO: cmp #$0D ; [Enter] -00045F 1 D0 0D bne NOMV ; MOVE MAN -000461 1 48 pha -000462 1 A9 FF lda #$FF -000464 1 8D 07 04 sta PAINT -000467 1 68 pla -000468 1 20 75 06 jsr MOVE ; AS ENTERED -00046B 1 4C 17 05 jmp DISP -00046E 1 C9 41 NOMV: cmp #$41 ; [Q] ***Added to allow game exit*** -000470 1 F0 0A beq DONE ; quit the game, exit back to system. -000472 1 48 pha -000473 1 A9 00 lda #$00 -000475 1 8D 07 04 sta PAINT -000478 1 68 pla -000479 1 4C 10 05 jmp INPUT ; process move -00047C 1 60 DONE: rts -00047D 1 ;jmp $FF00 ; *** MUST set this to YOUR OS starting address -00047D 1 ; -00047D 1 ; THE ROUTINE JANUS DIRECTS THE -00047D 1 ; ANALYSIS BY DETERMINING WHAT -00047D 1 ; SHOULD OCCUR AFTER EACH MOVE -00047D 1 ; GENERATED BY GNM -00047D 1 ; -00047D 1 ; -00047D 1 ; -00047D 1 A6 B5 JANUS: ldx STATE -00047F 1 30 59 bmi NOCOUNT -000481 1 ; -000481 1 ; THIS ROUTINE COUNTS OCCURRENCES -000481 1 ; IT DEPENDS UPON STATE TO INdex -000481 1 ; THE CORRECT COUNTERS -000481 1 ; -000481 1 A5 B0 COUNTS: lda PIECE -000483 1 F0 08 beq OVER ; IF STATE=8 -000485 1 E0 08 cpx #$08 ; DO NOT COUNT -000487 1 D0 04 bne OVER ; BLK MAX CAP -000489 1 C5 26 cmp BMAXP ; MOVES FOR -00048B 1 F0 2E beq XRT ; WHITE -00048D 1 ; -00048D 1 F6 23 OVER: inc MOB,X ; MOBILITY -00048F 1 C9 01 cmp #$01 ; + QUEEN -000491 1 D0 02 bne NOQ ; FOR TWO -000493 1 F6 23 inc MOB,X -000495 1 ; -000495 1 50 1E NOQ: bvc NOCAP -000497 1 A0 0F ldy #$0F ; CALCULATE -000499 1 A5 B1 lda SQUARE ; POINTS -00049B 1 D9 60 00 ELOOP: cmp BK,Y ; CAPTURED -00049E 1 F0 03 beq FOUN ; BY THIS -0004A0 1 88 dey ; MOVE -0004A1 1 10 F8 bpl ELOOP -0004A3 1 B9 51 0A FOUN: lda POINTS,Y -0004A6 1 D5 24 cmp MAXC,X -0004A8 1 90 04 bcc LESS ; SAVE IF -0004AA 1 94 26 sty PCAP,X ; BEST THIS -0004AC 1 95 24 sta MAXC,X ; STATE -0004AE 1 ; -0004AE 1 18 LESS: clc -0004AF 1 08 php ; ADD TO -0004B0 1 75 25 adc CC,X ; CAPTURE -0004B2 1 95 25 sta CC,X ; COUNTS -0004B4 1 28 plp -0004B5 1 ; -0004B5 1 E0 04 NOCAP: cpx #$04 -0004B7 1 F0 03 beq ON4 -0004B9 1 30 2E bmi TREE ;(=00 ONLY) -0004BB 1 60 XRT: rts -0004BC 1 ; -0004BC 1 ; GENERATE FURTHER MOVES FOR COUNT -0004BC 1 ; and ANALYSIS -0004BC 1 ; -0004BC 1 A5 28 ON4: lda XMAXC ; SAVE ACTUAL -0004BE 1 85 2D sta WCAP0 ; CAPTURE -0004C0 1 A9 00 lda #$00 ; STATE=0 -0004C2 1 85 B5 sta STATE -0004C4 1 20 75 06 jsr MOVE ; GENERATE -0004C7 1 20 DB 05 jsr REVERSE ; IMMEDIATE -0004CA 1 20 29 05 jsr GNMZ ; REPLY MOVES -0004CD 1 20 DB 05 jsr REVERSE -0004D0 1 ; -0004D0 1 A9 08 lda #$08 ; STATE=8 -0004D2 1 85 B5 sta STATE ; GENERATE -0004D4 1 ; jsr OHM ; CONTINUATION -0004D4 1 20 5B 06 jsr UMOVE ; MOVES -0004D7 1 ; -0004D7 1 4C 2C 07 jmp STRATGY ; FINAL EVALUATION -0004DA 1 E0 F9 NOCOUNT:cpx #$F9 -0004DC 1 D0 0B bne TREE -0004DE 1 ; -0004DE 1 ; DETERMINE IF THE KING CAN BE -0004DE 1 ; TAKEN, USED BY CHKCHK -0004DE 1 ; -0004DE 1 A5 60 lda BK ; IS KING -0004E0 1 C5 B1 cmp SQUARE ; IN CHECK? -0004E2 1 D0 04 bne RETJ ; SET incHEK=0 -0004E4 1 A9 00 lda #$00 ; IF IT IS -0004E6 1 85 B4 sta incHEK -0004E8 1 60 RETJ: rts -0004E9 1 ; -0004E9 1 ; IF A PIECE HAS BEEN CAPTURED BY -0004E9 1 ; A TRIAL MOVE, GENERATE REPLIES & -0004E9 1 ; EVALUATE THE EXCHANGE GAIN/LOSS -0004E9 1 ; -0004E9 1 50 FD TREE: bvc RETJ ; NO CAP -0004EB 1 A0 07 ldy #$07 ; (PIECES) -0004ED 1 A5 B1 lda SQUARE -0004EF 1 D9 60 00 LOOPX: cmp BK,Y -0004F2 1 F0 05 beq FOUNX -0004F4 1 88 dey -0004F5 1 F0 F1 beq RETJ ; (KING) -0004F7 1 10 F6 bpl LOOPX ; SAVE -0004F9 1 B9 51 0A FOUNX: lda POINTS,Y ; BEST CAP -0004FC 1 D5 22 cmp BCAP0,X ; AT THIS -0004FE 1 90 02 bcc NOMAX ; LEVEL -000500 1 95 22 sta BCAP0,X -000502 1 C6 B5 NOMAX: dec STATE -000504 1 A9 FB lda #$FB ; IF STATE=FB -000506 1 C5 B5 cmp STATE ; TIME TO TURN -000508 1 F0 03 beq UPTREE ; AROUND -00050A 1 20 4F 06 jsr GENRM ; GENERATE FURTHER -00050D 1 E6 B5 UPTREE: inc STATE ; CAPTURES -00050F 1 60 rts -000510 1 ; -000510 1 ; THE PLAYER'S MOVE IS INPUT -000510 1 ; -000510 1 C9 08 INPUT: cmp #$08 ; NOT A LEGAL -000512 1 B0 12 bcs ERROR ; SQUARE # -000514 1 20 1C 07 jsr DISMV -000517 1 A2 1F DISP: ldx #$1F -000519 1 B5 50 SEARCH: lda BOARD,X -00051B 1 C5 4A cmp DIS2 -00051D 1 F0 03 beq HERE ; DISPLAY -00051F 1 CA dex ; PIECE AT -000520 1 10 F7 bpl SEARCH ; FROM -000522 1 86 4B HERE: stx DIS1 ; SQUARE -000524 1 86 B0 stx PIECE -000526 1 4C 09 04 ERROR: jmp CHESS -000529 1 ; -000529 1 ; GENERATE ALL MOVES FOR ONE -000529 1 ; SIDE, CALL JANUS AFTER EACH -000529 1 ; ONE FOR NEXT STE? -000529 1 ; -000529 1 ; -000529 1 A2 10 GNMZ: ldx #$10 ; CLEAR -00052B 1 A9 00 GNMX: lda #$00 ; COUNTERS -00052D 1 95 2E CLEAR: sta COUNT,X -00052F 1 CA dex -000530 1 10 FB bpl CLEAR -000532 1 ; -000532 1 A9 10 GNM: lda #$10 ; SET UP -000534 1 85 B0 sta PIECE ; PIECE -000536 1 C6 B0 NEWP: dec PIECE ; NEW PIECE -000538 1 10 01 bpl NEX ; ALL DONE? -00053A 1 60 rts ; #NAME? -00053B 1 ; -00053B 1 20 48 06 NEX: jsr RESET ; READY -00053E 1 A4 B0 ldy PIECE ; GET PIECE -000540 1 A2 08 ldx #$08 -000542 1 86 B6 stx MOVEN ; COMMON staRT -000544 1 C0 08 cpy #$08 ; WHAT IS IT? -000546 1 10 41 bpl PAWN ; PAWN -000548 1 C0 06 cpy #$06 -00054A 1 10 2E bpl KNIGHT ; KNIGHT -00054C 1 C0 04 cpy #$04 -00054E 1 10 1F bpl BISHOP ; BISHOP -000550 1 C0 01 cpy #$01 -000552 1 F0 09 beq QUEEN ; QUEEN -000554 1 10 0E bpl ROOK ; ROOK -000556 1 ; -000556 1 20 B7 05 KING: jsr SNGMV ; MUST BE KING! -000559 1 D0 FB bne KING ; MOVES -00055B 1 F0 D9 beq NEWP ; 8 TO 1 -00055D 1 20 C5 05 QUEEN: jsr LINE -000560 1 D0 FB bne QUEEN ; MOVES -000562 1 F0 D2 beq NEWP ; 8 TO 1 -000564 1 ; -000564 1 A2 04 ROOK: ldx #$04 -000566 1 86 B6 stx MOVEN ; MOVES -000568 1 20 C5 05 AGNR: jsr LINE ; 4 TO 1 -00056B 1 D0 FB bne AGNR -00056D 1 F0 C7 beq NEWP -00056F 1 ; -00056F 1 20 C5 05 BISHOP: jsr LINE -000572 1 A5 B6 lda MOVEN ; MOVES -000574 1 C9 04 cmp #$04 ; 8 TO 5 -000576 1 D0 F7 bne BISHOP -000578 1 F0 BC beq NEWP -00057A 1 ; -00057A 1 A2 10 KNIGHT: ldx #$10 -00057C 1 86 B6 stx MOVEN ; MOVES -00057E 1 20 B7 05 AGNN: jsr SNGMV ; 16 TO 9 -000581 1 A5 B6 lda MOVEN -000583 1 C9 08 cmp #$08 -000585 1 D0 F7 bne AGNN -000587 1 F0 AD beq NEWP -000589 1 ; -000589 1 A2 06 PAWN: ldx #$06 -00058B 1 86 B6 stx MOVEN -00058D 1 20 F3 05 P1: jsr CMOVE ; RIGHT CAP? -000590 1 50 05 bvc P2 -000592 1 30 03 bmi P2 -000594 1 20 7D 04 jsr JANUS ; YES -000597 1 20 48 06 P2: jsr RESET -00059A 1 C6 B6 dec MOVEN ; LEFT CAP? -00059C 1 A5 B6 lda MOVEN -00059E 1 C9 05 cmp #$05 -0005A0 1 F0 EB beq P1 -0005A2 1 20 F3 05 P3: jsr CMOVE ; AHEAD -0005A5 1 70 8F bvs NEWP ; ILLEGAL -0005A7 1 30 8D bmi NEWP -0005A9 1 20 7D 04 jsr JANUS -0005AC 1 A5 B1 lda SQUARE ; GETS TO -0005AE 1 29 F0 and #$F0 ; 3RD RANK? -0005B0 1 C9 20 cmp #$20 -0005B2 1 F0 EE beq P3 ; DO DOUBLE -0005B4 1 4C 36 05 jmp NEWP -0005B7 1 ; -0005B7 1 ; CALCULATE SINGLE STEP MOVES -0005B7 1 ; FOR K,N -0005B7 1 ; -0005B7 1 20 F3 05 SNGMV: jsr CMOVE ; CALC MOVE -0005BA 1 30 03 bmi ILL1 ; -IF LEGAL -0005BC 1 20 7D 04 jsr JANUS ; -EVALUATE -0005BF 1 20 48 06 ILL1: jsr RESET -0005C2 1 C6 B6 dec MOVEN -0005C4 1 60 rts -0005C5 1 ; -0005C5 1 ; CALCULATE ALL MOVES DOWN A -0005C5 1 ; STRAIGHT LINE FOR Q,B,R -0005C5 1 ; -0005C5 1 20 F3 05 LINE: jsr CMOVE ; CALC MOVE -0005C8 1 90 02 bcc OVL ; NO CHK -0005CA 1 50 F9 bvc LINE ; NOCAP -0005CC 1 30 07 OVL: bmi ILL ; RETURN -0005CE 1 08 php -0005CF 1 20 7D 04 jsr JANUS ; EVALUATE POSN -0005D2 1 28 plp -0005D3 1 50 F0 bvc LINE ; NOT A CAP -0005D5 1 20 48 06 ILL: jsr RESET ; LINE STOPPED -0005D8 1 C6 B6 dec MOVEN ; NEXT DIR -0005DA 1 60 rts -0005DB 1 ; -0005DB 1 ; EXCHANGE SIDES FOR REPLY -0005DB 1 ; ANALYSIS -0005DB 1 ; -0005DB 1 A2 0F REVERSE:ldx #$0F -0005DD 1 38 ETC: sec -0005DE 1 B4 60 ldy BK,X ; SUBTRACT -0005E0 1 A9 77 lda #$77 ; POSITION -0005E2 1 F5 50 sbc BOARD,X ; FROM 77 -0005E4 1 95 60 sta BK,X -0005E6 1 94 50 sty BOARD,X ; and -0005E8 1 38 sec -0005E9 1 A9 77 lda #$77 ; EXCHANGE -0005EB 1 F5 50 sbc BOARD,X ; PIECES -0005ED 1 95 50 sta BOARD,X -0005EF 1 CA dex -0005F0 1 10 EB bpl ETC -0005F2 1 60 rts -0005F3 1 ; -0005F3 1 ; CMOVE CALCULATES THE TO SQUARE -0005F3 1 ; USING SQUARE and THE MOVE -0005F3 1 ; TABLE FLAGS SET AS FOLLOWS: -0005F3 1 ; N#NAME? MOVE -0005F3 1 ; V#NAME? (LEGAL UNLESS IN CR) -0005F3 1 ; C#NAME? BECAUSE OF CHECK -0005F3 1 ; [MY &THANKS TO JIM BUTTERFIELD -0005F3 1 ; WHO WROTE THIS MORE EFFICIENT -0005F3 1 ; VERSION OF CMOVE) -0005F3 1 ; -0005F3 1 A5 B1 CMOVE: lda SQUARE ; GET SQUARE -0005F5 1 A6 B6 ldx MOVEN ; MOVE POINTER -0005F7 1 18 clc -0005F8 1 7D 40 0A adc MOVEX,X ; MOVE LIST -0005FB 1 85 B1 sta SQUARE ; NEW POS'N -0005FD 1 29 88 and #$88 -0005FF 1 D0 42 bne ILLEGAL ; OFF BOARD -000601 1 A5 B1 lda SQUARE -000603 1 ; -000603 1 A2 20 ldx #$20 -000605 1 CA LOOP: dex ; IS TO -000606 1 30 0E bmi NO ; SQUARE -000608 1 D5 50 cmp BOARD,X ; OCCUPIED? -00060A 1 D0 F9 bne LOOP -00060C 1 ; -00060C 1 E0 10 cpx #$10 ; BY SELF? -00060E 1 30 33 bmi ILLEGAL -000610 1 ; -000610 1 A9 7F lda #$7F ; MUST BE CAP! -000612 1 69 01 adc #$01 ; SET V FLAG -000614 1 70 01 bvs SPX ; (jmp) -000616 1 ; -000616 1 B8 NO: clv ; NO CAPTURE -000617 1 ; -000617 1 A5 B5 SPX: lda STATE ; SHOULD WE -000619 1 30 24 bmi RETL ; DO THE -00061B 1 C9 08 cmp #$08 ; CHECK CHECK? -00061D 1 10 20 bpl RETL -00061F 1 ; -00061F 1 ; CHKCHK REVERSES SIDES -00061F 1 ; and LOOKS FOR A KING -00061F 1 ; CAPTURE TO INDICATE -00061F 1 ; ILLEGAL MOVE BECAUSE OF -00061F 1 ; CHECK SincE THIS IS -00061F 1 ; TIME CONSUMING, IT IS NOT -00061F 1 ; ALWAYS DONE -00061F 1 ; -00061F 1 48 CHKCHK: pha ; STATE #392 -000620 1 08 php -000621 1 A9 F9 lda #$F9 -000623 1 85 B5 sta STATE ; GENERATE -000625 1 85 B4 sta incHEK ; ALL REPLY -000627 1 20 75 06 jsr MOVE ; MOVES TO -00062A 1 20 DB 05 jsr REVERSE ; SEE IF KING -00062D 1 20 32 05 jsr GNM ; IS IN -000630 1 20 58 06 jsr RUM ; CHECK -000633 1 28 plp -000634 1 68 pla -000635 1 85 B5 sta STATE -000637 1 A5 B4 lda incHEK -000639 1 30 04 bmi RETL ; NO - SAFE -00063B 1 38 sec ; YES - IN CHK -00063C 1 A9 FF lda #$FF -00063E 1 60 rts -00063F 1 ; -00063F 1 18 RETL: clc ; LEGAL -000640 1 A9 00 lda #$00 ; RETURN -000642 1 60 rts -000643 1 ; -000643 1 A9 FF ILLEGAL:lda #$FF -000645 1 18 clc ; ILLEGAL -000646 1 B8 clv ; RETURN -000647 1 60 rts -000648 1 ; -000648 1 ; REPLACE PIECE ON CORRECT SQUARE -000648 1 ; -000648 1 A6 B0 RESET: ldx PIECE ; GET LOGAT -00064A 1 B5 50 lda BOARD,X ; FOR PIECE -00064C 1 85 B1 sta SQUARE ; FROM BOARD -00064E 1 60 rts -00064F 1 ; -00064F 1 ; -00064F 1 ; -00064F 1 20 75 06 GENRM: jsr MOVE ; MAKE MOVE -000652 1 20 DB 05 GENR2: jsr REVERSE ; REVERSE BOARD -000655 1 20 32 05 jsr GNM ; GENERATE MOVES -000658 1 20 DB 05 RUM: jsr REVERSE ; REVERSE BACK -00065B 1 ; -00065B 1 ; ROUTINE TO UNMAKE A MOVE MADE BY -00065B 1 ; MOVE -00065B 1 ; -00065B 1 BA UMOVE: tsx ; UNMAKE MOVE -00065C 1 86 B3 stx SP1 -00065E 1 A6 B2 ldx SP2 ; EXCHANGE -000660 1 9A txs ; STACKS -000661 1 68 pla ; MOVEN -000662 1 85 B6 sta MOVEN -000664 1 68 pla ; CAPTURED -000665 1 85 B0 sta PIECE ; PIECE -000667 1 AA tax -000668 1 68 pla ; FROM SQUARE -000669 1 95 50 sta BOARD,X -00066B 1 68 pla ; PIECE -00066C 1 AA tax -00066D 1 68 pla ; TO SOUARE -00066E 1 85 B1 sta SQUARE -000670 1 95 50 sta BOARD,X -000672 1 4C 9A 06 jmp STRV -000675 1 ; -000675 1 ; THIS ROUTINE MOVES PIECE -000675 1 ; TO SQUARE, PARAMETERS -000675 1 ; ARE SAVED IN A staCK TO UNMAKE -000675 1 ; THE MOVE LATER -000675 1 ; -000675 1 BA MOVE: tsx -000676 1 86 B3 stx SP1 ; SWITCH -000678 1 A6 B2 ldx SP2 ; STACKS -00067A 1 9A txs -00067B 1 A5 B1 lda SQUARE -00067D 1 48 pha ; TO SQUARE -00067E 1 A8 tay -00067F 1 A2 1F ldx #$1F -000681 1 D5 50 CHECK: cmp BOARD,X ; CHECK FOR -000683 1 F0 03 beq TAKE ; CAPTURE -000685 1 CA dex -000686 1 10 F9 bpl CHECK -000688 1 A9 CC TAKE: lda #$CC -00068A 1 95 50 sta BOARD,X -00068C 1 8A txa ; CAPTURED -00068D 1 48 pha ; PIECE -00068E 1 A6 B0 ldx PIECE -000690 1 B5 50 lda BOARD,X -000692 1 94 50 sty BOARD,X ; FROM -000694 1 48 pha ; SQUARE -000695 1 8A txa -000696 1 48 pha ; PIECE -000697 1 A5 B6 lda MOVEN -000699 1 48 pha ; MOVEN -00069A 1 BA STRV: tsx -00069B 1 86 B2 stx SP2 ; SWITCH -00069D 1 A6 B3 ldx SP1 ; STACKS -00069F 1 9A txs ; BACK -0006A0 1 60 rts -0006A1 1 ; -0006A1 1 ; CONTINUATION OF SUB STRATGY -0006A1 1 ; -CHECKS FOR CHECK OR CHECKMATE -0006A1 1 ; and ASSIGNS VALUE TO MOVE -0006A1 1 ; -0006A1 1 A4 24 CKMATE: ldy BMAXC ; CAN BLK CAP -0006A3 1 EC 51 0A cpx POINTS ; MY KING? -0006A6 1 D0 04 bne NOCHEK -0006A8 1 A9 00 lda #$00 ; GULP! -0006AA 1 F0 0A beq RETV ; DUMB MOVE! -0006AC 1 ; -0006AC 1 A6 23 NOCHEK: ldx BMOB ; IS BLACK -0006AE 1 D0 06 bne RETV ; UNABLE TO -0006B0 1 A6 3E ldx WMAXP ; MOVE and -0006B2 1 D0 02 bne RETV ; KING IN CH? -0006B4 1 A9 FF lda #$FF ; YES! MATE -0006B6 1 ; -0006B6 1 A2 04 RETV: ldx #$04 ; RESTORE -0006B8 1 86 B5 stx STATE ; STATE=4 -0006BA 1 ; -0006BA 1 ; THE VALUE OF THE MOVE (IN ACCU) -0006BA 1 ; IS COMPARED TO THE BEST MOVE and -0006BA 1 ; REPLACES IT IF IT IS BETTER -0006BA 1 ; -0006BA 1 C5 4A PUSH: cmp BESTV ; IS THIS BEST -0006BC 1 90 0C bcc RETP ; MOVE SO FAR? -0006BE 1 F0 0A beq RETP -0006C0 1 85 4A sta BESTV ; YES! -0006C2 1 A5 B0 lda PIECE ; SAVE IT -0006C4 1 85 4B sta BESTP -0006C6 1 A5 B1 lda SQUARE -0006C8 1 85 49 sta BESTM ; FLASH DISPLAY -0006CA 1 A9 2E RETP: lda #'.' ; print ... instead of flashing disp -0006CC 1 4C 8F 08 jmp syschout ; print . and return -0006CF 1 ; -0006CF 1 ; MAIN PROGRAM TO PLAY CHESS -0006CF 1 ; PLAY FROM OPENING OR THINK -0006CF 1 ; -0006CF 1 A6 2C GO: ldx OMOVE ; OPENING? -0006D1 1 30 1C bmi NOOPEN ; -NO *ADD CHANGE FROM bpl -0006D3 1 A5 49 lda DIS3 ; -YES WAS -0006D5 1 DD 61 0A cmp OPNING,X ; OPPONENT'S -0006D8 1 D0 11 bne END ; MOVE OK? -0006DA 1 CA dex -0006DB 1 BD 61 0A lda OPNING,X ; GET NEXT -0006DE 1 85 4B sta DIS1 ; CANNED -0006E0 1 CA dex ; OPENING MOVE -0006E1 1 BD 61 0A lda OPNING,X -0006E4 1 85 49 sta DIS3 ; DISPLAY IT -0006E6 1 CA dex -0006E7 1 86 2C stx OMOVE ; MOVE IT -0006E9 1 D0 1C bne MV2 ; (jmp) -0006EB 1 ; -0006EB 1 A9 FF END: lda #$FF ; *ADD - STOP CANNED MOVES -0006ED 1 85 2C sta OMOVE ; FLAG OPENING -0006EF 1 A2 0C NOOPEN: ldx #$0C ; FINISHED -0006F1 1 86 B5 stx STATE ; STATE=C -0006F3 1 86 4A stx BESTV ; CLEAR BESTV -0006F5 1 A2 14 ldx #$14 ; GENERATE P -0006F7 1 20 2B 05 jsr GNMX ; MOVES -0006FA 1 ; -0006FA 1 A2 04 ldx #$04 ; STATE=4 -0006FC 1 86 B5 stx STATE ; GENERATE and -0006FE 1 20 29 05 jsr GNMZ ; TEST AVAILABLE -000701 1 ; -000701 1 ; MOVES -000701 1 ; -000701 1 A6 4A ldx BESTV ; GET BEST MOVE -000703 1 E0 0F cpx #$0F ; IF NONE -000705 1 90 12 bcc MATE ; OH OH! -000707 1 ; -000707 1 A6 4B MV2: ldx BESTP ; MOVE -000709 1 B5 50 lda BOARD,X ; THE -00070B 1 85 4A sta BESTV ; BEST -00070D 1 86 B0 stx PIECE ; MOVE -00070F 1 A5 49 lda BESTM -000711 1 85 B1 sta SQUARE ; and DISPLAY -000713 1 20 75 06 jsr MOVE ; IT -000716 1 4C 09 04 jmp CHESS -000719 1 ; -000719 1 A9 FF MATE: lda #$FF ; RESIGN -00071B 1 60 rts ; OR staLEMATE -00071C 1 ; -00071C 1 ; SUBROUTINE TO ENTER THE -00071C 1 ; PLAYER'S MOVE -00071C 1 ; -00071C 1 A2 04 DISMV: ldx #$04 ; ROTATE -00071E 1 06 49 Drol: asl DIS3 ; KEY -000720 1 26 4A rol DIS2 ; INTO -000722 1 CA dex ; DISPLAY -000723 1 D0 F9 bne Drol ; -000725 1 05 49 ora DIS3 -000727 1 85 49 sta DIS3 -000729 1 85 B1 sta SQUARE -00072B 1 60 rts -00072C 1 ; -00072C 1 ; THE FOLLOWING SUBROUTINE ASSIGNS -00072C 1 ; A VALUE TO THE MOVE UNDER -00072C 1 ; CONSIDERATION and RETURNS IT IN -00072C 1 ; THE ACCUMULATOR -00072C 1 ; -00072C 1 -00072C 1 18 STRATGY:clc -00072D 1 A9 80 lda #$80 -00072F 1 65 2B adc WMOB ; PARAMETERS -000731 1 65 3C adc WMAXC ; WITH WHEIGHT -000733 1 65 3D adc WCC ; OF O25 -000735 1 65 21 adc WCAP1 -000737 1 65 2F adc WCAP2 -000739 1 38 sec -00073A 1 E5 40 sbc PMAXC -00073C 1 E5 41 sbc PCC -00073E 1 E5 22 sbc BCAP0 -000740 1 E5 20 sbc BCAP1 -000742 1 E5 2E sbc BCAP2 -000744 1 E5 3F sbc PMOB -000746 1 E5 23 sbc BMOB -000748 1 B0 02 bcs POS ; UNDERFLOW -00074A 1 A9 00 lda #$00 ; PREVENTION -00074C 1 4A POS: lsr -00074D 1 18 clc ; ************** -00074E 1 69 40 adc #$40 -000750 1 65 3C adc WMAXC ; PARAMETERS -000752 1 65 3D adc WCC ; WITH WEIGHT -000754 1 38 sec ; OF 05 -000755 1 E5 24 sbc BMAXC -000757 1 4A lsr ; ************** -000758 1 18 clc -000759 1 69 90 adc #$90 -00075B 1 65 2D adc WCAP0 ; PARAMETERS -00075D 1 65 2D adc WCAP0 ; WITH WEIGHT -00075F 1 65 2D adc WCAP0 ; OF 10 -000761 1 65 2D adc WCAP0 -000763 1 65 21 adc WCAP1 -000765 1 38 sec ; [UNDER OR OVER- -000766 1 E5 24 sbc BMAXC ; FLOW MAY OCCUR -000768 1 E5 24 sbc BMAXC ; FROM THIS -00076A 1 E5 25 sbc BMCC ; secTION] -00076C 1 E5 25 sbc BMCC -00076E 1 E5 20 sbc BCAP1 -000770 1 A6 B1 ldx SQUARE ; *************** -000772 1 E0 33 cpx #$33 -000774 1 F0 16 beq POSN ; POSITION -000776 1 E0 34 cpx #$34 ; BONUS FOR -000778 1 F0 12 beq POSN ; MOVE TO -00077A 1 E0 22 cpx #$22 ; CENTRE -00077C 1 F0 0E beq POSN ; OR -00077E 1 E0 25 cpx #$25 ; OUT OF -000780 1 F0 0A beq POSN ; BACK RANK -000782 1 A6 B0 ldx PIECE -000784 1 F0 09 beq NOPOSN -000786 1 B4 50 ldy BOARD,X -000788 1 C0 10 cpy #$10 -00078A 1 10 03 bpl NOPOSN -00078C 1 18 POSN: clc -00078D 1 69 02 adc #$02 -00078F 1 4C A1 06 NOPOSN: jmp CKMATE ; CONTINUE -000792 1 -000792 1 -000792 1 ;----------------------------------------------------------------- -000792 1 ; The following routines were added to allow text-based board -000792 1 ; DISPLAY over a standard RS-232 port. -000792 1 ; -000792 1 AD 07 04 POUT: lda PAINT -000795 1 D0 01 bne POUT0 -000797 1 60 rts ; return if PAINT flag = 0 -000798 1 20 37 08 POUT0: jsr POUT9 ; print CRLF -00079B 1 20 5B 08 jsr POUT13 ; print copyright -00079E 1 20 42 08 jsr POUT10 ; print column labels -0007A1 1 A0 00 ldy #$00 ; init board location -0007A3 1 20 09 08 jsr POUT5 ; print board horz edge -0007A6 1 A9 7C POUT1: lda #'|' ; print vert edge -0007A8 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE -0007AB 1 A2 1F ldx #$1F -0007AD 1 98 POUT2: tya ; scan the pieces for a location match -0007AE 1 D5 50 cmp BOARD,X ; match found? -0007B0 1 F0 40 beq POUT4 ; yes; print the piece's color and type -0007B2 1 CA dex ; no -0007B3 1 10 F8 bpl POUT2 ; if not the last piece, try again -0007B5 1 98 tya ; empty square -0007B6 1 29 01 and #$01 ; odd or even column? -0007B8 1 85 4C sta temp ; save it -0007BA 1 98 tya ; is the row odd or even -0007BB 1 4A lsr ; shift column right 4 spaces -0007BC 1 4A lsr ; -0007BD 1 4A lsr ; -0007BE 1 4A lsr ; -0007BF 1 29 01 and #$01 ; strip LSB -0007C1 1 18 clc ; -0007C2 1 65 4C adc temp ; combine row & col to determine square color -0007C4 1 29 01 and #$01 ; is board square white or blk? -0007C6 1 D0 03 bne POUT25 ; white, print space -0007C8 1 A9 2A lda #'*' ; black, print * -0007CA 1 -0007CA 1 2C .byte $2c ; used to skip over lda #$20 -0007CB 1 ;jmp POUT25A -0007CB 1 -0007CB 1 A9 20 POUT25: lda #$20 ; ASCII space -0007CD 1 20 8F 08 POUT25A:jsr syschout ; PRINT ONE ASCII CHR - SPACE -0007D0 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE -0007D3 1 C8 POUT3: iny ; -0007D4 1 98 tya ; get row number -0007D5 1 29 08 and #$08 ; have we completed the row? -0007D7 1 F0 CD beq POUT1 ; no, do next column -0007D9 1 A9 7C lda #'|' ; yes, put the right edge on -0007DB 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - | -0007DE 1 20 54 08 jsr POUT12 ; print row number -0007E1 1 20 37 08 jsr POUT9 ; print CRLF -0007E4 1 20 09 08 jsr POUT5 ; print bottom edge of board -0007E7 1 18 clc ; -0007E8 1 98 tya ; -0007E9 1 69 08 adc #$08 ; point y to beginning of next row -0007EB 1 A8 tay ; -0007EC 1 C0 80 cpy #$80 ; was that the last row? -0007EE 1 F0 2B beq POUT8 ; yes, print the LED values -0007F0 1 D0 B4 bne POUT1 ; no, do new row -0007F2 1 -0007F2 1 A5 B7 POUT4: lda REV ; print piece's color & type -0007F4 1 F0 05 beq POUT41 ; -0007F6 1 BD 0D 09 lda cpl+16,X ; -0007F9 1 D0 03 bne POUT42 ; -0007FB 1 BD FD 08 POUT41: lda cpl,x ; -0007FE 1 20 8F 08 POUT42: jsr syschout ; -000801 1 BD 2D 09 lda cph,x ; -000804 1 20 8F 08 jsr syschout ; -000807 1 D0 CA bne POUT3 ; branch always -000809 1 -000809 1 8A POUT5: txa ; print "-----...-----" -00080A 1 48 pha -00080B 1 A2 19 ldx #$19 -00080D 1 A9 2D lda #'-' -00080F 1 20 8F 08 POUT6: jsr syschout ; PRINT ONE ASCII CHR - "-" -000812 1 CA dex -000813 1 D0 FA bne POUT6 -000815 1 68 pla -000816 1 AA tax -000817 1 20 37 08 jsr POUT9 -00081A 1 60 rts -00081B 1 -00081B 1 20 42 08 POUT8: jsr POUT10 ; -00081E 1 A5 4B lda BESTP -000820 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS -000823 1 A9 20 lda #$20 -000825 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE -000828 1 A5 4A lda BESTV -00082A 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS -00082D 1 A9 20 lda #$20 -00082F 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE -000832 1 A5 49 lda DIS3 -000834 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS -000837 1 -000837 1 A9 0D POUT9: lda #$0D -000839 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - CR -00083C 1 A9 0A lda #$0A -00083E 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - LF -000841 1 60 rts -000842 1 -000842 1 A2 00 POUT10: ldx #$00 ; print the column labels -000844 1 A9 20 POUT11: lda #$20 ; 00 01 02 03 ... 07 -000846 1 20 8F 08 jsr syschout -000849 1 8A txa -00084A 1 20 9B 08 jsr syshexout -00084D 1 E8 inx -00084E 1 E0 08 cpx #$08 -000850 1 D0 F2 bne POUT11 -000852 1 F0 E3 beq POUT9 -000854 1 98 POUT12: tya -000855 1 29 70 and #$70 -000857 1 20 9B 08 jsr syshexout -00085A 1 60 rts -00085B 1 -00085B 1 ; print banner only once, preserve registers A, X, Y -00085B 1 86 F6 POUT13: stx tmp_zpgPt -00085D 1 85 F7 sta tmp_zpgPt+1 -00085F 1 84 F8 sty tmp_zpgPt+2 -000861 1 AD 08 04 lda PRNBANN -000864 1 F0 0B beq NOPRNBANN -000866 1 A9 C1 lda #banner -00086C 1 85 E1 sta mos_StrPtr+1 -00086E 1 20 F3 FF jsr mos_CallPuts -000871 1 NOPRNBANN: -000871 1 A9 00 lda #$00 -000873 1 8D 08 04 sta PRNBANN -000876 1 A6 F6 ldx tmp_zpgPt -000878 1 A5 F7 lda tmp_zpgPt+1 -00087A 1 A4 F8 ldy tmp_zpgPt+2 -00087C 1 60 rts -00087D 1 -00087D 1 ; ldx #$00 ; Print the copyright banner -00087D 1 ;POUT14: lda banner,x -00087D 1 ; beq POUT15 -00087D 1 ; jsr syschout -00087D 1 ; inx -00087D 1 ; bne POUT14 -00087D 1 ;POUT15: rts -00087D 1 -00087D 1 A9 3F KIN: lda #'?' -00087F 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - ? -000882 1 20 8B 08 jsr syskin ; GET A KEYSTROKE FROM SYSTEM -000885 1 20 8F 08 jsr syschout ; echo entered character -000888 1 29 4F and #$4F ; MASK 0-7, and ALpha'S -00088A 1 60 rts -00088B 1 ; -00088B 1 ; 6551 I/O Support Routines -00088B 1 ; -00088B 1 ; -00088B 1 ;Init_6551 lda #$1F ; 19.2K/8/1 -00088B 1 ; sta ACIActl ; control reg -00088B 1 ; lda #$0B ; N parity/echo off/rx int off/ dtr active low -00088B 1 ; sta ACIAcmd ; command reg -00088B 1 ; rts ; done -00088B 1 ; -00088B 1 ; input chr from ACIA1 (waiting) -00088B 1 ; -00088B 1 syskin: -00088B 1 20 ED FF jsr mos_CallGetCh -00088E 1 60 rts -00088F 1 -00088F 1 ;lda ACIAsta ; Serial port status -00088F 1 ;and #$08 ; is recvr full -00088F 1 ;beq syskin ; no char to get -00088F 1 ;lda ACIAdat ; get chr -00088F 1 ;rts ; -00088F 1 ; -00088F 1 ; output to OutPut Port -00088F 1 ; -00088F 1 syschout: ; MKHBCOS: must preserve X, Y and A -00088F 1 86 F6 stx tmp_zpgPt -000891 1 85 F7 sta tmp_zpgPt+1 -000893 1 ;sty tmp_zpgPt+2 -000893 1 20 F0 FF jsr mos_CallPutCh -000896 1 A6 F6 ldx tmp_zpgPt -000898 1 A5 F7 lda tmp_zpgPt+1 -00089A 1 ;ldy tmp_zpgPt+2 -00089A 1 60 rts -00089B 1 ; pha ; save registers -00089B 1 ;ACIA_Out1 lda ACIAsta ; serial port status -00089B 1 ; and #$10 ; is tx buffer empty -00089B 1 ; beq ACIA_Out1 ; no -00089B 1 ; pla ; get chr -00089B 1 ; sta ACIAdat ; put character to Port -00089B 1 ; rts ; done -00089B 1 -00089B 1 48 syshexout: pha ; prints AA hex digits -00089C 1 4A lsr ; MOVE UPPER NIBBLE TO LOWER -00089D 1 4A lsr ; -00089E 1 4A lsr ; -00089F 1 4A lsr ; -0008A0 1 20 A4 08 jsr PrintDig ; -0008A3 1 68 pla ; -0008A4 1 PrintDig: -0008A4 1 84 F8 sty tmp_zpgPt+2 -0008A6 1 29 0F and #$0F ; -0008A8 1 A8 tay ; -0008A9 1 B9 B1 08 lda Hexdigdata,Y ; -0008AC 1 A4 F8 ldy tmp_zpgPt+2 ; -0008AE 1 4C 8F 08 jmp syschout ; -0008B1 1 -0008B1 1 30 31 32 33 Hexdigdata: .byte "0123456789ABCDEF" -0008B5 1 34 35 36 37 -0008B9 1 38 39 41 42 -0008C1 1 4D 69 63 72 banner: .byte "MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com" -0008C5 1 6F 43 68 65 -0008C9 1 73 73 20 28 -0008FA 1 0D 0A 00 .byte $0d, $0a, $00 -0008FD 1 57 57 57 57 cpl: .byte "WWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWW" -000901 1 57 57 57 57 -000905 1 57 57 57 57 -00092D 1 4B 51 43 43 cph: .byte "KQCCBBRRPPPPPPPPKQCCBBRRPPPPPPPP" -000931 1 42 42 52 52 -000935 1 50 50 50 50 -00094D 1 00 .byte $00 -00094E 1 ; -00094E 1 ; end of added code -00094E 1 ; -00094E 1 ; BLOCK DATA -00094E 1 -00094E 1 .segment "DATA" -00094E 1 -00094E 1 .ORG $0A20 -000A20 1 -000A20 1 03 04 00 07 SETW: .byte $03, $04, $00, $07, $02, $05, $01, $06 -000A24 1 02 05 01 06 -000A28 1 10 17 11 16 .byte $10, $17, $11, $16, $12, $15, $14, $13 -000A2C 1 12 15 14 13 -000A30 1 73 74 70 77 .byte $73, $74, $70, $77, $72, $75, $71, $76 -000A34 1 72 75 71 76 -000A38 1 60 67 61 66 .byte $60, $67, $61, $66, $62, $65, $64, $63 -000A3C 1 62 65 64 63 -000A40 1 -000A40 1 00 F0 FF 01 MOVEX: .byte $00, $F0, $FF, $01, $10, $11, $0F, $EF, $F1 -000A44 1 10 11 0F EF -000A48 1 F1 -000A49 1 DF E1 EE F2 .byte $DF, $E1, $EE, $F2, $12, $0E, $1F, $21 -000A4D 1 12 0E 1F 21 -000A51 1 -000A51 1 0B 0A 06 06 POINTS: .byte $0B, $0A, $06, $06, $04, $04, $04, $04 -000A55 1 04 04 04 04 -000A59 1 02 02 02 02 .byte $02, $02, $02, $02, $02, $02, $02, $02 -000A5D 1 02 02 02 02 -000A61 1 -000A61 1 99 25 0B 25 OPNING: .byte $99, $25, $0B, $25, $01, $00, $33, $25 -000A65 1 01 00 33 25 -000A69 1 07 36 34 0D .byte $07, $36, $34, $0D, $34, $34, $0E, $52 -000A6D 1 34 34 0E 52 -000A71 1 25 0D 45 35 .byte $25, $0D, $45, $35, $04, $55, $22, $06 -000A75 1 04 55 22 06 -000A79 1 43 33 0F CC .byte $43, $33, $0F, $CC -000A7D 1 -000A7D 1 .segment "KERN" -000A7D 1 -000A7D 1 .ORG $FE00 -00FE00 1 -00FE00 1 AD 00 E0 CHRIN: lda $E000 -00FE03 1 60 rts -00FE04 1 -00FE04 1 8D 00 E0 CHROUT: sta $E000 -00FE07 1 60 rts -00FE08 1 -00FE08 1 ; this function was shamelessly ripped :-) from M.O.S. code (c) by Scott Chidester -00FE08 1 -00FE08 1 STROUT: -00FE08 1 A0 00 ldy #0 ; Non-indexed variant starts at zero, of course -00FE0A 1 A5 E1 lda mos_StrPtr+1 ; Save StrPtr so it isn't modified -00FE0C 1 48 pha -00FE0D 1 PutsLoop: -00FE0D 1 B1 E0 lda (mos_StrPtr),y ; Get the next char in the string -00FE0F 1 F0 0B beq PutsDone ; Zero means end of string -00FE11 1 20 04 FE jsr CHROUT ; Otherwise put the char -00FE14 1 -00FE14 1 ; Update string pointer -00FE14 1 C8 iny ; increment StrPtr-lo -00FE15 1 D0 F6 bne PutsLoop ; No rollover? Loop back for next character -00FE17 1 E6 E1 inc mos_StrPtr+1 ; StrPtr-lo rolled over--carry hi byte -00FE19 1 4C 0D FE jmp PutsLoop ; Now loop back -00FE1C 1 -00FE1C 1 PutsDone: -00FE1C 1 68 pla -00FE1D 1 85 E1 sta mos_StrPtr+1 ; Restore StrPtr -00FE1F 1 60 rts -00FE20 1 -00FE20 1 .segment "VECT" -00FE20 1 -00FE20 1 .ORG $FFED -00FFED 1 -00FFED 1 4C 00 FE jmp CHRIN -00FFF0 1 4C 04 FE jmp CHROUT -00FFF3 1 4C 08 FE jmp STROUT -00FFF6 1 -00FFF6 1 ; -00FFF6 1 ; -00FFF6 1 ; end of file -00FFF6 1 ; -00FFF6 1 +ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz +Main file : microchess.asm +Current file: microchess.asm + +000000r 1 ;*********************************************************************** +000000r 1 ; +000000r 1 ; MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com +000000r 1 ; +000000r 1 ;*********************************************************************** +000000r 1 ; Daryl Rictor: +000000r 1 ; I have been given permission to distribute this program by the +000000r 1 ; author and copyright holder, Peter Jennings. Please get his +000000r 1 ; permission if you wish to re-distribute a modified copy of +000000r 1 ; this file to others. He specifically requested that his +000000r 1 ; copyright notice be included in the source and binary images. +000000r 1 ; Thanks! +000000r 1 ; +000000r 1 ; Marek Karcz: +000000r 1 ; I have been given permission to distribute this program by the +000000r 1 ; original author Peter Jennings under condition that I include +000000r 1 ; link to his website in attribution. +000000r 1 ; Here it is: http://www.benlo.com/microchess/index.html +000000r 1 ; I did not bother to contact Daryl Rictor to ask permission to +000000r 1 ; distribute his modifications to this software because according to +000000r 1 ; the copyright notice on the web page of his project, permission is +000000r 1 ; already given for personal non-commercial use: +000000r 1 ; http://sbc.rictor.org/avr65c02.html +000000r 1 ; http://sbc.rictor.org/download/AVR65C02.zip, readme.txt +000000r 1 ; If this is incorrect or I misunderstood the author's intention, +000000r 1 ; please note that I acted with no malicious intent and will remove +000000r 1 ; this file from my project if I receive such request. +000000r 1 ; +000000r 1 ; 1/14/2012 +000000r 1 ; Modified by Marek Karcz to run on MKHBC-8-R1 under MKHBCOS +000000r 1 ; (derivative of M.O.S. by Scott Chidester) +000000r 1 ; 3/11/2016 +000000r 1 ; Adapted to run in MKBASIC (V65) emulator. +000000r 1 ; +000000r 1 ; 6551 I/O Port Addresses +000000r 1 ; +000000r 1 ;ACIADat = $7F70 +000000r 1 ;ACIAsta = $7F71 +000000r 1 ;ACIACmd = $7F72 +000000r 1 ;ACIACtl = $7F73 +000000r 1 +000000r 1 ; M.O.S. API defines (kernal) - OK for emulator, no changes +000000r 1 +000000r 1 .define mos_StrPtr $E0 +000000r 1 .define tmp_zpgPt $F6 +000000r 1 +000000r 1 ; jumps, originally for M.O.S., now modified for emulator +000000r 1 +000000r 1 .define mos_CallGetCh $FFED +000000r 1 .define mos_CallPutCh $FFF0 +000000r 1 .define mos_CallPuts $FFF3 +000000r 1 +000000r 1 +000000r 1 ; +000000r 1 ; page zero variables +000000r 1 ; +000000r 1 BOARD = $50 +000000r 1 BK = $60 +000000r 1 PIECE = $B0 +000000r 1 SQUARE = $B1 +000000r 1 SP2 = $B2 +000000r 1 SP1 = $B3 +000000r 1 incHEK = $B4 +000000r 1 STATE = $B5 +000000r 1 MOVEN = $B6 +000000r 1 REV = $B7 +000000r 1 OMOVE = $2C +000000r 1 WCAP0 = $2D +000000r 1 COUNT = $2E +000000r 1 BCAP2 = $2E +000000r 1 WCAP2 = $2F +000000r 1 BCAP1 = $20 +000000r 1 WCAP1 = $21 +000000r 1 BCAP0 = $22 +000000r 1 MOB = $23 +000000r 1 MAXC = $24 +000000r 1 CC = $25 +000000r 1 PCAP = $26 +000000r 1 BMOB = $23 +000000r 1 BMAXC = $24 +000000r 1 BMCC = $25 ; was bcc (TASS doesn't like it as a label) +000000r 1 BMAXP = $26 +000000r 1 XMAXC = $28 +000000r 1 WMOB = $2B +000000r 1 WMAXC = $3C +000000r 1 WCC = $3D +000000r 1 WMAXP = $3E +000000r 1 PMOB = $3F +000000r 1 PMAXC = $40 +000000r 1 PCC = $41 +000000r 1 PCP = $42 +000000r 1 OLDKY = $43 +000000r 1 BESTP = $4B +000000r 1 BESTV = $4A +000000r 1 BESTM = $49 +000000r 1 DIS1 = $4B +000000r 1 DIS2 = $4A +000000r 1 DIS3 = $49 +000000r 1 temp = $4C +000000r 1 +000000r 1 ; +000000r 1 ; +000000r 1 ; +000000r 1 +000000r 1 .segment "BEGN" +000000r 1 +000000r 1 .ORG $0000 +000000 1 +000000 1 .segment "CODE" +000000 1 +000000 1 .ORG $0400 ; load into RAM @ $1000-$15FF +000400 1 +000400 1 A9 00 lda #$00 ; REVERSE TOGGLE +000402 1 85 B7 sta REV +000404 1 4C 09 04 jmp CHESS +000407 1 +000407 1 FF PAINT: .byte $FF ; set this flag if board needs painting +000408 1 ; unset otherwise +000408 1 PRNBANN: +000408 1 FF .byte $FF ; set this flag to print copyright banner +000409 1 +000409 1 ;jsr Init_6551 +000409 1 D8 CHESS: cld ; INITIALIZE +00040A 1 A2 FF ldx #$FF ; TWO STACKS +00040C 1 9A txs +00040D 1 A2 C8 ldx #$C8 +00040F 1 86 B2 stx SP2 +000411 1 ; +000411 1 ; ROUTINES TO LIGHT LED +000411 1 ; DISPLAY and GET KEY +000411 1 ; FROM KEYBOARD +000411 1 ; +000411 1 20 92 07 OUT: jsr POUT ; DISPLAY and +000414 1 20 7D 08 jsr KIN ; GET INPUT *** my routine waits for a keypress +000417 1 C9 43 cmp #$43 ; [C] +000419 1 D0 17 bne NOSET ; SET UP +00041B 1 A9 FF lda #$FF ; set PAINT flag +00041D 1 8D 07 04 sta PAINT ; board needs to be diplayed +000420 1 A2 1F ldx #$1F ; BOARD +000422 1 BD 20 0A WHSET: lda SETW,X ; FROM +000425 1 95 50 sta BOARD,X ; SETW +000427 1 CA dex +000428 1 10 F8 bpl WHSET +00042A 1 A2 1B ldx #$1B ; *ADDED +00042C 1 86 2C stx OMOVE ; INITS TO $FF +00042E 1 A9 CC lda #$CC ; DISPLAY CCC +000430 1 D0 23 bne CLDSP +000432 1 ; +000432 1 C9 45 NOSET: cmp #$45 ; [E] +000434 1 D0 13 bne NOREV ; REVERSE +000436 1 A9 FF lda #$FF +000438 1 8D 07 04 sta PAINT +00043B 1 20 DB 05 jsr REVERSE ; BOARD IS +00043E 1 38 sec +00043F 1 A9 01 lda #$01 +000441 1 E5 B7 sbc REV +000443 1 85 B7 sta REV ; TOGGLE REV FLAG +000445 1 A9 EE lda #$EE ; IS +000447 1 D0 0C bne CLDSP +000449 1 ; +000449 1 C9 40 NOREV: cmp #$40 ; [P] +00044B 1 D0 10 bne NOGO ; PLAY CHESS +00044D 1 A9 FF lda #$FF +00044F 1 8D 07 04 sta PAINT +000452 1 20 CF 06 jsr GO +000455 1 85 4B CLDSP: sta DIS1 ; DISPLAY +000457 1 85 4A sta DIS2 ; ACROSS +000459 1 85 49 sta DIS3 ; DISPLAY +00045B 1 D0 AC bne CHESS +00045D 1 ; +00045D 1 C9 0D NOGO: cmp #$0D ; [Enter] +00045F 1 D0 0D bne NOMV ; MOVE MAN +000461 1 48 pha +000462 1 A9 FF lda #$FF +000464 1 8D 07 04 sta PAINT +000467 1 68 pla +000468 1 20 75 06 jsr MOVE ; AS ENTERED +00046B 1 4C 17 05 jmp DISP +00046E 1 C9 41 NOMV: cmp #$41 ; [Q] ***Added to allow game exit*** +000470 1 F0 0A beq DONE ; quit the game, exit back to system. +000472 1 48 pha +000473 1 A9 00 lda #$00 +000475 1 8D 07 04 sta PAINT +000478 1 68 pla +000479 1 4C 10 05 jmp INPUT ; process move +00047C 1 60 DONE: rts +00047D 1 ;jmp $FF00 ; *** MUST set this to YOUR OS starting address +00047D 1 ; +00047D 1 ; THE ROUTINE JANUS DIRECTS THE +00047D 1 ; ANALYSIS BY DETERMINING WHAT +00047D 1 ; SHOULD OCCUR AFTER EACH MOVE +00047D 1 ; GENERATED BY GNM +00047D 1 ; +00047D 1 ; +00047D 1 ; +00047D 1 A6 B5 JANUS: ldx STATE +00047F 1 30 59 bmi NOCOUNT +000481 1 ; +000481 1 ; THIS ROUTINE COUNTS OCCURRENCES +000481 1 ; IT DEPENDS UPON STATE TO INdex +000481 1 ; THE CORRECT COUNTERS +000481 1 ; +000481 1 A5 B0 COUNTS: lda PIECE +000483 1 F0 08 beq OVER ; IF STATE=8 +000485 1 E0 08 cpx #$08 ; DO NOT COUNT +000487 1 D0 04 bne OVER ; BLK MAX CAP +000489 1 C5 26 cmp BMAXP ; MOVES FOR +00048B 1 F0 2E beq XRT ; WHITE +00048D 1 ; +00048D 1 F6 23 OVER: inc MOB,X ; MOBILITY +00048F 1 C9 01 cmp #$01 ; + QUEEN +000491 1 D0 02 bne NOQ ; FOR TWO +000493 1 F6 23 inc MOB,X +000495 1 ; +000495 1 50 1E NOQ: bvc NOCAP +000497 1 A0 0F ldy #$0F ; CALCULATE +000499 1 A5 B1 lda SQUARE ; POINTS +00049B 1 D9 60 00 ELOOP: cmp BK,Y ; CAPTURED +00049E 1 F0 03 beq FOUN ; BY THIS +0004A0 1 88 dey ; MOVE +0004A1 1 10 F8 bpl ELOOP +0004A3 1 B9 51 0A FOUN: lda POINTS,Y +0004A6 1 D5 24 cmp MAXC,X +0004A8 1 90 04 bcc LESS ; SAVE IF +0004AA 1 94 26 sty PCAP,X ; BEST THIS +0004AC 1 95 24 sta MAXC,X ; STATE +0004AE 1 ; +0004AE 1 18 LESS: clc +0004AF 1 08 php ; ADD TO +0004B0 1 75 25 adc CC,X ; CAPTURE +0004B2 1 95 25 sta CC,X ; COUNTS +0004B4 1 28 plp +0004B5 1 ; +0004B5 1 E0 04 NOCAP: cpx #$04 +0004B7 1 F0 03 beq ON4 +0004B9 1 30 2E bmi TREE ;(=00 ONLY) +0004BB 1 60 XRT: rts +0004BC 1 ; +0004BC 1 ; GENERATE FURTHER MOVES FOR COUNT +0004BC 1 ; and ANALYSIS +0004BC 1 ; +0004BC 1 A5 28 ON4: lda XMAXC ; SAVE ACTUAL +0004BE 1 85 2D sta WCAP0 ; CAPTURE +0004C0 1 A9 00 lda #$00 ; STATE=0 +0004C2 1 85 B5 sta STATE +0004C4 1 20 75 06 jsr MOVE ; GENERATE +0004C7 1 20 DB 05 jsr REVERSE ; IMMEDIATE +0004CA 1 20 29 05 jsr GNMZ ; REPLY MOVES +0004CD 1 20 DB 05 jsr REVERSE +0004D0 1 ; +0004D0 1 A9 08 lda #$08 ; STATE=8 +0004D2 1 85 B5 sta STATE ; GENERATE +0004D4 1 ; jsr OHM ; CONTINUATION +0004D4 1 20 5B 06 jsr UMOVE ; MOVES +0004D7 1 ; +0004D7 1 4C 2C 07 jmp STRATGY ; FINAL EVALUATION +0004DA 1 E0 F9 NOCOUNT:cpx #$F9 +0004DC 1 D0 0B bne TREE +0004DE 1 ; +0004DE 1 ; DETERMINE IF THE KING CAN BE +0004DE 1 ; TAKEN, USED BY CHKCHK +0004DE 1 ; +0004DE 1 A5 60 lda BK ; IS KING +0004E0 1 C5 B1 cmp SQUARE ; IN CHECK? +0004E2 1 D0 04 bne RETJ ; SET incHEK=0 +0004E4 1 A9 00 lda #$00 ; IF IT IS +0004E6 1 85 B4 sta incHEK +0004E8 1 60 RETJ: rts +0004E9 1 ; +0004E9 1 ; IF A PIECE HAS BEEN CAPTURED BY +0004E9 1 ; A TRIAL MOVE, GENERATE REPLIES & +0004E9 1 ; EVALUATE THE EXCHANGE GAIN/LOSS +0004E9 1 ; +0004E9 1 50 FD TREE: bvc RETJ ; NO CAP +0004EB 1 A0 07 ldy #$07 ; (PIECES) +0004ED 1 A5 B1 lda SQUARE +0004EF 1 D9 60 00 LOOPX: cmp BK,Y +0004F2 1 F0 05 beq FOUNX +0004F4 1 88 dey +0004F5 1 F0 F1 beq RETJ ; (KING) +0004F7 1 10 F6 bpl LOOPX ; SAVE +0004F9 1 B9 51 0A FOUNX: lda POINTS,Y ; BEST CAP +0004FC 1 D5 22 cmp BCAP0,X ; AT THIS +0004FE 1 90 02 bcc NOMAX ; LEVEL +000500 1 95 22 sta BCAP0,X +000502 1 C6 B5 NOMAX: dec STATE +000504 1 A9 FB lda #$FB ; IF STATE=FB +000506 1 C5 B5 cmp STATE ; TIME TO TURN +000508 1 F0 03 beq UPTREE ; AROUND +00050A 1 20 4F 06 jsr GENRM ; GENERATE FURTHER +00050D 1 E6 B5 UPTREE: inc STATE ; CAPTURES +00050F 1 60 rts +000510 1 ; +000510 1 ; THE PLAYER'S MOVE IS INPUT +000510 1 ; +000510 1 C9 08 INPUT: cmp #$08 ; NOT A LEGAL +000512 1 B0 12 bcs ERROR ; SQUARE # +000514 1 20 1C 07 jsr DISMV +000517 1 A2 1F DISP: ldx #$1F +000519 1 B5 50 SEARCH: lda BOARD,X +00051B 1 C5 4A cmp DIS2 +00051D 1 F0 03 beq HERE ; DISPLAY +00051F 1 CA dex ; PIECE AT +000520 1 10 F7 bpl SEARCH ; FROM +000522 1 86 4B HERE: stx DIS1 ; SQUARE +000524 1 86 B0 stx PIECE +000526 1 4C 09 04 ERROR: jmp CHESS +000529 1 ; +000529 1 ; GENERATE ALL MOVES FOR ONE +000529 1 ; SIDE, CALL JANUS AFTER EACH +000529 1 ; ONE FOR NEXT STE? +000529 1 ; +000529 1 ; +000529 1 A2 10 GNMZ: ldx #$10 ; CLEAR +00052B 1 A9 00 GNMX: lda #$00 ; COUNTERS +00052D 1 95 2E CLEAR: sta COUNT,X +00052F 1 CA dex +000530 1 10 FB bpl CLEAR +000532 1 ; +000532 1 A9 10 GNM: lda #$10 ; SET UP +000534 1 85 B0 sta PIECE ; PIECE +000536 1 C6 B0 NEWP: dec PIECE ; NEW PIECE +000538 1 10 01 bpl NEX ; ALL DONE? +00053A 1 60 rts ; #NAME? +00053B 1 ; +00053B 1 20 48 06 NEX: jsr RESET ; READY +00053E 1 A4 B0 ldy PIECE ; GET PIECE +000540 1 A2 08 ldx #$08 +000542 1 86 B6 stx MOVEN ; COMMON staRT +000544 1 C0 08 cpy #$08 ; WHAT IS IT? +000546 1 10 41 bpl PAWN ; PAWN +000548 1 C0 06 cpy #$06 +00054A 1 10 2E bpl KNIGHT ; KNIGHT +00054C 1 C0 04 cpy #$04 +00054E 1 10 1F bpl BISHOP ; BISHOP +000550 1 C0 01 cpy #$01 +000552 1 F0 09 beq QUEEN ; QUEEN +000554 1 10 0E bpl ROOK ; ROOK +000556 1 ; +000556 1 20 B7 05 KING: jsr SNGMV ; MUST BE KING! +000559 1 D0 FB bne KING ; MOVES +00055B 1 F0 D9 beq NEWP ; 8 TO 1 +00055D 1 20 C5 05 QUEEN: jsr LINE +000560 1 D0 FB bne QUEEN ; MOVES +000562 1 F0 D2 beq NEWP ; 8 TO 1 +000564 1 ; +000564 1 A2 04 ROOK: ldx #$04 +000566 1 86 B6 stx MOVEN ; MOVES +000568 1 20 C5 05 AGNR: jsr LINE ; 4 TO 1 +00056B 1 D0 FB bne AGNR +00056D 1 F0 C7 beq NEWP +00056F 1 ; +00056F 1 20 C5 05 BISHOP: jsr LINE +000572 1 A5 B6 lda MOVEN ; MOVES +000574 1 C9 04 cmp #$04 ; 8 TO 5 +000576 1 D0 F7 bne BISHOP +000578 1 F0 BC beq NEWP +00057A 1 ; +00057A 1 A2 10 KNIGHT: ldx #$10 +00057C 1 86 B6 stx MOVEN ; MOVES +00057E 1 20 B7 05 AGNN: jsr SNGMV ; 16 TO 9 +000581 1 A5 B6 lda MOVEN +000583 1 C9 08 cmp #$08 +000585 1 D0 F7 bne AGNN +000587 1 F0 AD beq NEWP +000589 1 ; +000589 1 A2 06 PAWN: ldx #$06 +00058B 1 86 B6 stx MOVEN +00058D 1 20 F3 05 P1: jsr CMOVE ; RIGHT CAP? +000590 1 50 05 bvc P2 +000592 1 30 03 bmi P2 +000594 1 20 7D 04 jsr JANUS ; YES +000597 1 20 48 06 P2: jsr RESET +00059A 1 C6 B6 dec MOVEN ; LEFT CAP? +00059C 1 A5 B6 lda MOVEN +00059E 1 C9 05 cmp #$05 +0005A0 1 F0 EB beq P1 +0005A2 1 20 F3 05 P3: jsr CMOVE ; AHEAD +0005A5 1 70 8F bvs NEWP ; ILLEGAL +0005A7 1 30 8D bmi NEWP +0005A9 1 20 7D 04 jsr JANUS +0005AC 1 A5 B1 lda SQUARE ; GETS TO +0005AE 1 29 F0 and #$F0 ; 3RD RANK? +0005B0 1 C9 20 cmp #$20 +0005B2 1 F0 EE beq P3 ; DO DOUBLE +0005B4 1 4C 36 05 jmp NEWP +0005B7 1 ; +0005B7 1 ; CALCULATE SINGLE STEP MOVES +0005B7 1 ; FOR K,N +0005B7 1 ; +0005B7 1 20 F3 05 SNGMV: jsr CMOVE ; CALC MOVE +0005BA 1 30 03 bmi ILL1 ; -IF LEGAL +0005BC 1 20 7D 04 jsr JANUS ; -EVALUATE +0005BF 1 20 48 06 ILL1: jsr RESET +0005C2 1 C6 B6 dec MOVEN +0005C4 1 60 rts +0005C5 1 ; +0005C5 1 ; CALCULATE ALL MOVES DOWN A +0005C5 1 ; STRAIGHT LINE FOR Q,B,R +0005C5 1 ; +0005C5 1 20 F3 05 LINE: jsr CMOVE ; CALC MOVE +0005C8 1 90 02 bcc OVL ; NO CHK +0005CA 1 50 F9 bvc LINE ; NOCAP +0005CC 1 30 07 OVL: bmi ILL ; RETURN +0005CE 1 08 php +0005CF 1 20 7D 04 jsr JANUS ; EVALUATE POSN +0005D2 1 28 plp +0005D3 1 50 F0 bvc LINE ; NOT A CAP +0005D5 1 20 48 06 ILL: jsr RESET ; LINE STOPPED +0005D8 1 C6 B6 dec MOVEN ; NEXT DIR +0005DA 1 60 rts +0005DB 1 ; +0005DB 1 ; EXCHANGE SIDES FOR REPLY +0005DB 1 ; ANALYSIS +0005DB 1 ; +0005DB 1 A2 0F REVERSE:ldx #$0F +0005DD 1 38 ETC: sec +0005DE 1 B4 60 ldy BK,X ; SUBTRACT +0005E0 1 A9 77 lda #$77 ; POSITION +0005E2 1 F5 50 sbc BOARD,X ; FROM 77 +0005E4 1 95 60 sta BK,X +0005E6 1 94 50 sty BOARD,X ; and +0005E8 1 38 sec +0005E9 1 A9 77 lda #$77 ; EXCHANGE +0005EB 1 F5 50 sbc BOARD,X ; PIECES +0005ED 1 95 50 sta BOARD,X +0005EF 1 CA dex +0005F0 1 10 EB bpl ETC +0005F2 1 60 rts +0005F3 1 ; +0005F3 1 ; CMOVE CALCULATES THE TO SQUARE +0005F3 1 ; USING SQUARE and THE MOVE +0005F3 1 ; TABLE FLAGS SET AS FOLLOWS: +0005F3 1 ; N#NAME? MOVE +0005F3 1 ; V#NAME? (LEGAL UNLESS IN CR) +0005F3 1 ; C#NAME? BECAUSE OF CHECK +0005F3 1 ; [MY &THANKS TO JIM BUTTERFIELD +0005F3 1 ; WHO WROTE THIS MORE EFFICIENT +0005F3 1 ; VERSION OF CMOVE) +0005F3 1 ; +0005F3 1 A5 B1 CMOVE: lda SQUARE ; GET SQUARE +0005F5 1 A6 B6 ldx MOVEN ; MOVE POINTER +0005F7 1 18 clc +0005F8 1 7D 40 0A adc MOVEX,X ; MOVE LIST +0005FB 1 85 B1 sta SQUARE ; NEW POS'N +0005FD 1 29 88 and #$88 +0005FF 1 D0 42 bne ILLEGAL ; OFF BOARD +000601 1 A5 B1 lda SQUARE +000603 1 ; +000603 1 A2 20 ldx #$20 +000605 1 CA LOOP: dex ; IS TO +000606 1 30 0E bmi NO ; SQUARE +000608 1 D5 50 cmp BOARD,X ; OCCUPIED? +00060A 1 D0 F9 bne LOOP +00060C 1 ; +00060C 1 E0 10 cpx #$10 ; BY SELF? +00060E 1 30 33 bmi ILLEGAL +000610 1 ; +000610 1 A9 7F lda #$7F ; MUST BE CAP! +000612 1 69 01 adc #$01 ; SET V FLAG +000614 1 70 01 bvs SPX ; (jmp) +000616 1 ; +000616 1 B8 NO: clv ; NO CAPTURE +000617 1 ; +000617 1 A5 B5 SPX: lda STATE ; SHOULD WE +000619 1 30 24 bmi RETL ; DO THE +00061B 1 C9 08 cmp #$08 ; CHECK CHECK? +00061D 1 10 20 bpl RETL +00061F 1 ; +00061F 1 ; CHKCHK REVERSES SIDES +00061F 1 ; and LOOKS FOR A KING +00061F 1 ; CAPTURE TO INDICATE +00061F 1 ; ILLEGAL MOVE BECAUSE OF +00061F 1 ; CHECK SincE THIS IS +00061F 1 ; TIME CONSUMING, IT IS NOT +00061F 1 ; ALWAYS DONE +00061F 1 ; +00061F 1 48 CHKCHK: pha ; STATE #392 +000620 1 08 php +000621 1 A9 F9 lda #$F9 +000623 1 85 B5 sta STATE ; GENERATE +000625 1 85 B4 sta incHEK ; ALL REPLY +000627 1 20 75 06 jsr MOVE ; MOVES TO +00062A 1 20 DB 05 jsr REVERSE ; SEE IF KING +00062D 1 20 32 05 jsr GNM ; IS IN +000630 1 20 58 06 jsr RUM ; CHECK +000633 1 28 plp +000634 1 68 pla +000635 1 85 B5 sta STATE +000637 1 A5 B4 lda incHEK +000639 1 30 04 bmi RETL ; NO - SAFE +00063B 1 38 sec ; YES - IN CHK +00063C 1 A9 FF lda #$FF +00063E 1 60 rts +00063F 1 ; +00063F 1 18 RETL: clc ; LEGAL +000640 1 A9 00 lda #$00 ; RETURN +000642 1 60 rts +000643 1 ; +000643 1 A9 FF ILLEGAL:lda #$FF +000645 1 18 clc ; ILLEGAL +000646 1 B8 clv ; RETURN +000647 1 60 rts +000648 1 ; +000648 1 ; REPLACE PIECE ON CORRECT SQUARE +000648 1 ; +000648 1 A6 B0 RESET: ldx PIECE ; GET LOGAT +00064A 1 B5 50 lda BOARD,X ; FOR PIECE +00064C 1 85 B1 sta SQUARE ; FROM BOARD +00064E 1 60 rts +00064F 1 ; +00064F 1 ; +00064F 1 ; +00064F 1 20 75 06 GENRM: jsr MOVE ; MAKE MOVE +000652 1 20 DB 05 GENR2: jsr REVERSE ; REVERSE BOARD +000655 1 20 32 05 jsr GNM ; GENERATE MOVES +000658 1 20 DB 05 RUM: jsr REVERSE ; REVERSE BACK +00065B 1 ; +00065B 1 ; ROUTINE TO UNMAKE A MOVE MADE BY +00065B 1 ; MOVE +00065B 1 ; +00065B 1 BA UMOVE: tsx ; UNMAKE MOVE +00065C 1 86 B3 stx SP1 +00065E 1 A6 B2 ldx SP2 ; EXCHANGE +000660 1 9A txs ; STACKS +000661 1 68 pla ; MOVEN +000662 1 85 B6 sta MOVEN +000664 1 68 pla ; CAPTURED +000665 1 85 B0 sta PIECE ; PIECE +000667 1 AA tax +000668 1 68 pla ; FROM SQUARE +000669 1 95 50 sta BOARD,X +00066B 1 68 pla ; PIECE +00066C 1 AA tax +00066D 1 68 pla ; TO SOUARE +00066E 1 85 B1 sta SQUARE +000670 1 95 50 sta BOARD,X +000672 1 4C 9A 06 jmp STRV +000675 1 ; +000675 1 ; THIS ROUTINE MOVES PIECE +000675 1 ; TO SQUARE, PARAMETERS +000675 1 ; ARE SAVED IN A staCK TO UNMAKE +000675 1 ; THE MOVE LATER +000675 1 ; +000675 1 BA MOVE: tsx +000676 1 86 B3 stx SP1 ; SWITCH +000678 1 A6 B2 ldx SP2 ; STACKS +00067A 1 9A txs +00067B 1 A5 B1 lda SQUARE +00067D 1 48 pha ; TO SQUARE +00067E 1 A8 tay +00067F 1 A2 1F ldx #$1F +000681 1 D5 50 CHECK: cmp BOARD,X ; CHECK FOR +000683 1 F0 03 beq TAKE ; CAPTURE +000685 1 CA dex +000686 1 10 F9 bpl CHECK +000688 1 A9 CC TAKE: lda #$CC +00068A 1 95 50 sta BOARD,X +00068C 1 8A txa ; CAPTURED +00068D 1 48 pha ; PIECE +00068E 1 A6 B0 ldx PIECE +000690 1 B5 50 lda BOARD,X +000692 1 94 50 sty BOARD,X ; FROM +000694 1 48 pha ; SQUARE +000695 1 8A txa +000696 1 48 pha ; PIECE +000697 1 A5 B6 lda MOVEN +000699 1 48 pha ; MOVEN +00069A 1 BA STRV: tsx +00069B 1 86 B2 stx SP2 ; SWITCH +00069D 1 A6 B3 ldx SP1 ; STACKS +00069F 1 9A txs ; BACK +0006A0 1 60 rts +0006A1 1 ; +0006A1 1 ; CONTINUATION OF SUB STRATGY +0006A1 1 ; -CHECKS FOR CHECK OR CHECKMATE +0006A1 1 ; and ASSIGNS VALUE TO MOVE +0006A1 1 ; +0006A1 1 A4 24 CKMATE: ldy BMAXC ; CAN BLK CAP +0006A3 1 EC 51 0A cpx POINTS ; MY KING? +0006A6 1 D0 04 bne NOCHEK +0006A8 1 A9 00 lda #$00 ; GULP! +0006AA 1 F0 0A beq RETV ; DUMB MOVE! +0006AC 1 ; +0006AC 1 A6 23 NOCHEK: ldx BMOB ; IS BLACK +0006AE 1 D0 06 bne RETV ; UNABLE TO +0006B0 1 A6 3E ldx WMAXP ; MOVE and +0006B2 1 D0 02 bne RETV ; KING IN CH? +0006B4 1 A9 FF lda #$FF ; YES! MATE +0006B6 1 ; +0006B6 1 A2 04 RETV: ldx #$04 ; RESTORE +0006B8 1 86 B5 stx STATE ; STATE=4 +0006BA 1 ; +0006BA 1 ; THE VALUE OF THE MOVE (IN ACCU) +0006BA 1 ; IS COMPARED TO THE BEST MOVE and +0006BA 1 ; REPLACES IT IF IT IS BETTER +0006BA 1 ; +0006BA 1 C5 4A PUSH: cmp BESTV ; IS THIS BEST +0006BC 1 90 0C bcc RETP ; MOVE SO FAR? +0006BE 1 F0 0A beq RETP +0006C0 1 85 4A sta BESTV ; YES! +0006C2 1 A5 B0 lda PIECE ; SAVE IT +0006C4 1 85 4B sta BESTP +0006C6 1 A5 B1 lda SQUARE +0006C8 1 85 49 sta BESTM ; FLASH DISPLAY +0006CA 1 A9 2E RETP: lda #'.' ; print ... instead of flashing disp +0006CC 1 4C 8F 08 jmp syschout ; print . and return +0006CF 1 ; +0006CF 1 ; MAIN PROGRAM TO PLAY CHESS +0006CF 1 ; PLAY FROM OPENING OR THINK +0006CF 1 ; +0006CF 1 A6 2C GO: ldx OMOVE ; OPENING? +0006D1 1 30 1C bmi NOOPEN ; -NO *ADD CHANGE FROM bpl +0006D3 1 A5 49 lda DIS3 ; -YES WAS +0006D5 1 DD 61 0A cmp OPNING,X ; OPPONENT'S +0006D8 1 D0 11 bne END ; MOVE OK? +0006DA 1 CA dex +0006DB 1 BD 61 0A lda OPNING,X ; GET NEXT +0006DE 1 85 4B sta DIS1 ; CANNED +0006E0 1 CA dex ; OPENING MOVE +0006E1 1 BD 61 0A lda OPNING,X +0006E4 1 85 49 sta DIS3 ; DISPLAY IT +0006E6 1 CA dex +0006E7 1 86 2C stx OMOVE ; MOVE IT +0006E9 1 D0 1C bne MV2 ; (jmp) +0006EB 1 ; +0006EB 1 A9 FF END: lda #$FF ; *ADD - STOP CANNED MOVES +0006ED 1 85 2C sta OMOVE ; FLAG OPENING +0006EF 1 A2 0C NOOPEN: ldx #$0C ; FINISHED +0006F1 1 86 B5 stx STATE ; STATE=C +0006F3 1 86 4A stx BESTV ; CLEAR BESTV +0006F5 1 A2 14 ldx #$14 ; GENERATE P +0006F7 1 20 2B 05 jsr GNMX ; MOVES +0006FA 1 ; +0006FA 1 A2 04 ldx #$04 ; STATE=4 +0006FC 1 86 B5 stx STATE ; GENERATE and +0006FE 1 20 29 05 jsr GNMZ ; TEST AVAILABLE +000701 1 ; +000701 1 ; MOVES +000701 1 ; +000701 1 A6 4A ldx BESTV ; GET BEST MOVE +000703 1 E0 0F cpx #$0F ; IF NONE +000705 1 90 12 bcc MATE ; OH OH! +000707 1 ; +000707 1 A6 4B MV2: ldx BESTP ; MOVE +000709 1 B5 50 lda BOARD,X ; THE +00070B 1 85 4A sta BESTV ; BEST +00070D 1 86 B0 stx PIECE ; MOVE +00070F 1 A5 49 lda BESTM +000711 1 85 B1 sta SQUARE ; and DISPLAY +000713 1 20 75 06 jsr MOVE ; IT +000716 1 4C 09 04 jmp CHESS +000719 1 ; +000719 1 A9 FF MATE: lda #$FF ; RESIGN +00071B 1 60 rts ; OR staLEMATE +00071C 1 ; +00071C 1 ; SUBROUTINE TO ENTER THE +00071C 1 ; PLAYER'S MOVE +00071C 1 ; +00071C 1 A2 04 DISMV: ldx #$04 ; ROTATE +00071E 1 06 49 Drol: asl DIS3 ; KEY +000720 1 26 4A rol DIS2 ; INTO +000722 1 CA dex ; DISPLAY +000723 1 D0 F9 bne Drol ; +000725 1 05 49 ora DIS3 +000727 1 85 49 sta DIS3 +000729 1 85 B1 sta SQUARE +00072B 1 60 rts +00072C 1 ; +00072C 1 ; THE FOLLOWING SUBROUTINE ASSIGNS +00072C 1 ; A VALUE TO THE MOVE UNDER +00072C 1 ; CONSIDERATION and RETURNS IT IN +00072C 1 ; THE ACCUMULATOR +00072C 1 ; +00072C 1 +00072C 1 18 STRATGY:clc +00072D 1 A9 80 lda #$80 +00072F 1 65 2B adc WMOB ; PARAMETERS +000731 1 65 3C adc WMAXC ; WITH WHEIGHT +000733 1 65 3D adc WCC ; OF O25 +000735 1 65 21 adc WCAP1 +000737 1 65 2F adc WCAP2 +000739 1 38 sec +00073A 1 E5 40 sbc PMAXC +00073C 1 E5 41 sbc PCC +00073E 1 E5 22 sbc BCAP0 +000740 1 E5 20 sbc BCAP1 +000742 1 E5 2E sbc BCAP2 +000744 1 E5 3F sbc PMOB +000746 1 E5 23 sbc BMOB +000748 1 B0 02 bcs POS ; UNDERFLOW +00074A 1 A9 00 lda #$00 ; PREVENTION +00074C 1 4A POS: lsr +00074D 1 18 clc ; ************** +00074E 1 69 40 adc #$40 +000750 1 65 3C adc WMAXC ; PARAMETERS +000752 1 65 3D adc WCC ; WITH WEIGHT +000754 1 38 sec ; OF 05 +000755 1 E5 24 sbc BMAXC +000757 1 4A lsr ; ************** +000758 1 18 clc +000759 1 69 90 adc #$90 +00075B 1 65 2D adc WCAP0 ; PARAMETERS +00075D 1 65 2D adc WCAP0 ; WITH WEIGHT +00075F 1 65 2D adc WCAP0 ; OF 10 +000761 1 65 2D adc WCAP0 +000763 1 65 21 adc WCAP1 +000765 1 38 sec ; [UNDER OR OVER- +000766 1 E5 24 sbc BMAXC ; FLOW MAY OCCUR +000768 1 E5 24 sbc BMAXC ; FROM THIS +00076A 1 E5 25 sbc BMCC ; secTION] +00076C 1 E5 25 sbc BMCC +00076E 1 E5 20 sbc BCAP1 +000770 1 A6 B1 ldx SQUARE ; *************** +000772 1 E0 33 cpx #$33 +000774 1 F0 16 beq POSN ; POSITION +000776 1 E0 34 cpx #$34 ; BONUS FOR +000778 1 F0 12 beq POSN ; MOVE TO +00077A 1 E0 22 cpx #$22 ; CENTRE +00077C 1 F0 0E beq POSN ; OR +00077E 1 E0 25 cpx #$25 ; OUT OF +000780 1 F0 0A beq POSN ; BACK RANK +000782 1 A6 B0 ldx PIECE +000784 1 F0 09 beq NOPOSN +000786 1 B4 50 ldy BOARD,X +000788 1 C0 10 cpy #$10 +00078A 1 10 03 bpl NOPOSN +00078C 1 18 POSN: clc +00078D 1 69 02 adc #$02 +00078F 1 4C A1 06 NOPOSN: jmp CKMATE ; CONTINUE +000792 1 +000792 1 +000792 1 ;----------------------------------------------------------------- +000792 1 ; The following routines were added to allow text-based board +000792 1 ; DISPLAY over a standard RS-232 port. +000792 1 ; +000792 1 AD 07 04 POUT: lda PAINT +000795 1 D0 01 bne POUT0 +000797 1 60 rts ; return if PAINT flag = 0 +000798 1 20 37 08 POUT0: jsr POUT9 ; print CRLF +00079B 1 20 5B 08 jsr POUT13 ; print copyright +00079E 1 20 42 08 jsr POUT10 ; print column labels +0007A1 1 A0 00 ldy #$00 ; init board location +0007A3 1 20 09 08 jsr POUT5 ; print board horz edge +0007A6 1 A9 7C POUT1: lda #'|' ; print vert edge +0007A8 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE +0007AB 1 A2 1F ldx #$1F +0007AD 1 98 POUT2: tya ; scan the pieces for a location match +0007AE 1 D5 50 cmp BOARD,X ; match found? +0007B0 1 F0 40 beq POUT4 ; yes; print the piece's color and type +0007B2 1 CA dex ; no +0007B3 1 10 F8 bpl POUT2 ; if not the last piece, try again +0007B5 1 98 tya ; empty square +0007B6 1 29 01 and #$01 ; odd or even column? +0007B8 1 85 4C sta temp ; save it +0007BA 1 98 tya ; is the row odd or even +0007BB 1 4A lsr ; shift column right 4 spaces +0007BC 1 4A lsr ; +0007BD 1 4A lsr ; +0007BE 1 4A lsr ; +0007BF 1 29 01 and #$01 ; strip LSB +0007C1 1 18 clc ; +0007C2 1 65 4C adc temp ; combine row & col to determine square color +0007C4 1 29 01 and #$01 ; is board square white or blk? +0007C6 1 D0 03 bne POUT25 ; white, print space +0007C8 1 A9 2A lda #'*' ; black, print * +0007CA 1 +0007CA 1 2C .byte $2c ; used to skip over lda #$20 +0007CB 1 ;jmp POUT25A +0007CB 1 +0007CB 1 A9 20 POUT25: lda #$20 ; ASCII space +0007CD 1 20 8F 08 POUT25A:jsr syschout ; PRINT ONE ASCII CHR - SPACE +0007D0 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE +0007D3 1 C8 POUT3: iny ; +0007D4 1 98 tya ; get row number +0007D5 1 29 08 and #$08 ; have we completed the row? +0007D7 1 F0 CD beq POUT1 ; no, do next column +0007D9 1 A9 7C lda #'|' ; yes, put the right edge on +0007DB 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - | +0007DE 1 20 54 08 jsr POUT12 ; print row number +0007E1 1 20 37 08 jsr POUT9 ; print CRLF +0007E4 1 20 09 08 jsr POUT5 ; print bottom edge of board +0007E7 1 18 clc ; +0007E8 1 98 tya ; +0007E9 1 69 08 adc #$08 ; point y to beginning of next row +0007EB 1 A8 tay ; +0007EC 1 C0 80 cpy #$80 ; was that the last row? +0007EE 1 F0 2B beq POUT8 ; yes, print the LED values +0007F0 1 D0 B4 bne POUT1 ; no, do new row +0007F2 1 +0007F2 1 A5 B7 POUT4: lda REV ; print piece's color & type +0007F4 1 F0 05 beq POUT41 ; +0007F6 1 BD 0D 09 lda cpl+16,X ; +0007F9 1 D0 03 bne POUT42 ; +0007FB 1 BD FD 08 POUT41: lda cpl,x ; +0007FE 1 20 8F 08 POUT42: jsr syschout ; +000801 1 BD 2D 09 lda cph,x ; +000804 1 20 8F 08 jsr syschout ; +000807 1 D0 CA bne POUT3 ; branch always +000809 1 +000809 1 8A POUT5: txa ; print "-----...-----" +00080A 1 48 pha +00080B 1 A2 19 ldx #$19 +00080D 1 A9 2D lda #'-' +00080F 1 20 8F 08 POUT6: jsr syschout ; PRINT ONE ASCII CHR - "-" +000812 1 CA dex +000813 1 D0 FA bne POUT6 +000815 1 68 pla +000816 1 AA tax +000817 1 20 37 08 jsr POUT9 +00081A 1 60 rts +00081B 1 +00081B 1 20 42 08 POUT8: jsr POUT10 ; +00081E 1 A5 4B lda BESTP +000820 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS +000823 1 A9 20 lda #$20 +000825 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE +000828 1 A5 4A lda BESTV +00082A 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS +00082D 1 A9 20 lda #$20 +00082F 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - SPACE +000832 1 A5 49 lda DIS3 +000834 1 20 9B 08 jsr syshexout ; PRINT 1 BYTE AS 2 HEX CHRS +000837 1 +000837 1 A9 0D POUT9: lda #$0D +000839 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - CR +00083C 1 A9 0A lda #$0A +00083E 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - LF +000841 1 60 rts +000842 1 +000842 1 A2 00 POUT10: ldx #$00 ; print the column labels +000844 1 A9 20 POUT11: lda #$20 ; 00 01 02 03 ... 07 +000846 1 20 8F 08 jsr syschout +000849 1 8A txa +00084A 1 20 9B 08 jsr syshexout +00084D 1 E8 inx +00084E 1 E0 08 cpx #$08 +000850 1 D0 F2 bne POUT11 +000852 1 F0 E3 beq POUT9 +000854 1 98 POUT12: tya +000855 1 29 70 and #$70 +000857 1 20 9B 08 jsr syshexout +00085A 1 60 rts +00085B 1 +00085B 1 ; print banner only once, preserve registers A, X, Y +00085B 1 86 F6 POUT13: stx tmp_zpgPt +00085D 1 85 F7 sta tmp_zpgPt+1 +00085F 1 84 F8 sty tmp_zpgPt+2 +000861 1 AD 08 04 lda PRNBANN +000864 1 F0 0B beq NOPRNBANN +000866 1 A9 C1 lda #banner +00086C 1 85 E1 sta mos_StrPtr+1 +00086E 1 20 F3 FF jsr mos_CallPuts +000871 1 NOPRNBANN: +000871 1 A9 00 lda #$00 +000873 1 8D 08 04 sta PRNBANN +000876 1 A6 F6 ldx tmp_zpgPt +000878 1 A5 F7 lda tmp_zpgPt+1 +00087A 1 A4 F8 ldy tmp_zpgPt+2 +00087C 1 60 rts +00087D 1 +00087D 1 ; ldx #$00 ; Print the copyright banner +00087D 1 ;POUT14: lda banner,x +00087D 1 ; beq POUT15 +00087D 1 ; jsr syschout +00087D 1 ; inx +00087D 1 ; bne POUT14 +00087D 1 ;POUT15: rts +00087D 1 +00087D 1 A9 3F KIN: lda #'?' +00087F 1 20 8F 08 jsr syschout ; PRINT ONE ASCII CHR - ? +000882 1 20 8B 08 jsr syskin ; GET A KEYSTROKE FROM SYSTEM +000885 1 20 8F 08 jsr syschout ; echo entered character +000888 1 29 4F and #$4F ; MASK 0-7, and ALpha'S +00088A 1 60 rts +00088B 1 ; +00088B 1 ; 6551 I/O Support Routines +00088B 1 ; +00088B 1 ; +00088B 1 ;Init_6551 lda #$1F ; 19.2K/8/1 +00088B 1 ; sta ACIActl ; control reg +00088B 1 ; lda #$0B ; N parity/echo off/rx int off/ dtr active low +00088B 1 ; sta ACIAcmd ; command reg +00088B 1 ; rts ; done +00088B 1 ; +00088B 1 ; input chr from ACIA1 (waiting) +00088B 1 ; +00088B 1 syskin: +00088B 1 20 ED FF jsr mos_CallGetCh +00088E 1 60 rts +00088F 1 +00088F 1 ;lda ACIAsta ; Serial port status +00088F 1 ;and #$08 ; is recvr full +00088F 1 ;beq syskin ; no char to get +00088F 1 ;lda ACIAdat ; get chr +00088F 1 ;rts ; +00088F 1 ; +00088F 1 ; output to OutPut Port +00088F 1 ; +00088F 1 syschout: ; MKHBCOS: must preserve X, Y and A +00088F 1 86 F6 stx tmp_zpgPt +000891 1 85 F7 sta tmp_zpgPt+1 +000893 1 ;sty tmp_zpgPt+2 +000893 1 20 F0 FF jsr mos_CallPutCh +000896 1 A6 F6 ldx tmp_zpgPt +000898 1 A5 F7 lda tmp_zpgPt+1 +00089A 1 ;ldy tmp_zpgPt+2 +00089A 1 60 rts +00089B 1 ; pha ; save registers +00089B 1 ;ACIA_Out1 lda ACIAsta ; serial port status +00089B 1 ; and #$10 ; is tx buffer empty +00089B 1 ; beq ACIA_Out1 ; no +00089B 1 ; pla ; get chr +00089B 1 ; sta ACIAdat ; put character to Port +00089B 1 ; rts ; done +00089B 1 +00089B 1 48 syshexout: pha ; prints AA hex digits +00089C 1 4A lsr ; MOVE UPPER NIBBLE TO LOWER +00089D 1 4A lsr ; +00089E 1 4A lsr ; +00089F 1 4A lsr ; +0008A0 1 20 A4 08 jsr PrintDig ; +0008A3 1 68 pla ; +0008A4 1 PrintDig: +0008A4 1 84 F8 sty tmp_zpgPt+2 +0008A6 1 29 0F and #$0F ; +0008A8 1 A8 tay ; +0008A9 1 B9 B1 08 lda Hexdigdata,Y ; +0008AC 1 A4 F8 ldy tmp_zpgPt+2 ; +0008AE 1 4C 8F 08 jmp syschout ; +0008B1 1 +0008B1 1 30 31 32 33 Hexdigdata: .byte "0123456789ABCDEF" +0008B5 1 34 35 36 37 +0008B9 1 38 39 41 42 +0008C1 1 4D 69 63 72 banner: .byte "MicroChess (c) 1996-2002 Peter Jennings, peterj@benlo.com" +0008C5 1 6F 43 68 65 +0008C9 1 73 73 20 28 +0008FA 1 0D 0A 00 .byte $0d, $0a, $00 +0008FD 1 57 57 57 57 cpl: .byte "WWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWW" +000901 1 57 57 57 57 +000905 1 57 57 57 57 +00092D 1 4B 51 43 43 cph: .byte "KQCCBBRRPPPPPPPPKQCCBBRRPPPPPPPP" +000931 1 42 42 52 52 +000935 1 50 50 50 50 +00094D 1 00 .byte $00 +00094E 1 ; +00094E 1 ; end of added code +00094E 1 ; +00094E 1 ; BLOCK DATA +00094E 1 +00094E 1 .segment "DATA" +00094E 1 +00094E 1 .ORG $0A20 +000A20 1 +000A20 1 03 04 00 07 SETW: .byte $03, $04, $00, $07, $02, $05, $01, $06 +000A24 1 02 05 01 06 +000A28 1 10 17 11 16 .byte $10, $17, $11, $16, $12, $15, $14, $13 +000A2C 1 12 15 14 13 +000A30 1 73 74 70 77 .byte $73, $74, $70, $77, $72, $75, $71, $76 +000A34 1 72 75 71 76 +000A38 1 60 67 61 66 .byte $60, $67, $61, $66, $62, $65, $64, $63 +000A3C 1 62 65 64 63 +000A40 1 +000A40 1 00 F0 FF 01 MOVEX: .byte $00, $F0, $FF, $01, $10, $11, $0F, $EF, $F1 +000A44 1 10 11 0F EF +000A48 1 F1 +000A49 1 DF E1 EE F2 .byte $DF, $E1, $EE, $F2, $12, $0E, $1F, $21 +000A4D 1 12 0E 1F 21 +000A51 1 +000A51 1 0B 0A 06 06 POINTS: .byte $0B, $0A, $06, $06, $04, $04, $04, $04 +000A55 1 04 04 04 04 +000A59 1 02 02 02 02 .byte $02, $02, $02, $02, $02, $02, $02, $02 +000A5D 1 02 02 02 02 +000A61 1 +000A61 1 99 25 0B 25 OPNING: .byte $99, $25, $0B, $25, $01, $00, $33, $25 +000A65 1 01 00 33 25 +000A69 1 07 36 34 0D .byte $07, $36, $34, $0D, $34, $34, $0E, $52 +000A6D 1 34 34 0E 52 +000A71 1 25 0D 45 35 .byte $25, $0D, $45, $35, $04, $55, $22, $06 +000A75 1 04 55 22 06 +000A79 1 43 33 0F CC .byte $43, $33, $0F, $CC +000A7D 1 +000A7D 1 .segment "KERN" +000A7D 1 +000A7D 1 .ORG $FE00 +00FE00 1 +00FE00 1 AD 00 E0 CHRIN: lda $E000 +00FE03 1 60 rts +00FE04 1 +00FE04 1 8D 00 E0 CHROUT: sta $E000 +00FE07 1 60 rts +00FE08 1 +00FE08 1 ; this function was shamelessly ripped :-) from M.O.S. code (c) by Scott Chidester +00FE08 1 +00FE08 1 STROUT: +00FE08 1 A0 00 ldy #0 ; Non-indexed variant starts at zero, of course +00FE0A 1 A5 E1 lda mos_StrPtr+1 ; Save StrPtr so it isn't modified +00FE0C 1 48 pha +00FE0D 1 PutsLoop: +00FE0D 1 B1 E0 lda (mos_StrPtr),y ; Get the next char in the string +00FE0F 1 F0 0B beq PutsDone ; Zero means end of string +00FE11 1 20 04 FE jsr CHROUT ; Otherwise put the char +00FE14 1 +00FE14 1 ; Update string pointer +00FE14 1 C8 iny ; increment StrPtr-lo +00FE15 1 D0 F6 bne PutsLoop ; No rollover? Loop back for next character +00FE17 1 E6 E1 inc mos_StrPtr+1 ; StrPtr-lo rolled over--carry hi byte +00FE19 1 4C 0D FE jmp PutsLoop ; Now loop back +00FE1C 1 +00FE1C 1 PutsDone: +00FE1C 1 68 pla +00FE1D 1 85 E1 sta mos_StrPtr+1 ; Restore StrPtr +00FE1F 1 60 rts +00FE20 1 +00FE20 1 .segment "VECT" +00FE20 1 +00FE20 1 .ORG $FFED +00FFED 1 +00FFED 1 4C 00 FE jmp CHRIN +00FFF0 1 4C 04 FE jmp CHROUT +00FFF3 1 4C 08 FE jmp STROUT +00FFF6 1 +00FFF6 1 ; +00FFF6 1 ; +00FFF6 1 ; end of file +00FFF6 1 ; +00FFF6 1 diff --git a/microchess.o b/microchess.o deleted file mode 100644 index f69541f5af9ad6ccb4083b679ae61100ea0108c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11613 zcmb7~dvsG(zQ?mq&N)e|NPUblSMP8XaM>$xOYwng=|~$g^bwL{+5*npSu2Pc%N+%V z#~trnx#KGpc?c?%0zM#+LO`?y(w5e00YO?pB8rOmC~6gXXaISM(!0<8ezVrBHGjBn zm&xb*-TU|Z?bkUcX|d{WlP6r{a=FIKSB`v5kgr_%`m=oPy}{+WBj4o`Qva5`lN?DF zNnWkHT>miyaWYi>XqqqmYn&=RGCdpqDl+*bd@nhFj`EsEhY<0(2;FD27S%;;sZa~=Bo zkm;A{$&&TliB~u?a{jB?nL&u^1_WA-s(?1rgb;xZDpR}4fDoMrW*#w_UmZUgj z6NYq=^P96nLWt@X1O_%^$UFl=L|V~N|0WijA`7;QtDFn(ZZh#U`Wwj1E^)2X?z*WWiD74J9MTke4`t_8Z99 zNpYRC&>>{<2Qk3$E;4os8;~Nc(<)wGwGhHOgN6eJgs{%45wv^*LRjb2#UvjZ5F&YA z^jB988T$!yN|DwDl>CDUAp#F;&Lp+L9thF>h^8J?=g9P<@E4JZCp2|^M#$~6;Ty^H zlkhs3oCEJ7V{zb5k)V;aFKFrxzK-1SA_h*8$(N9S zp4`41JCGtXD^Sl(T5;vIkO?8aUdaS9vI;BdT%+M|$%Z8SWu&!MO+>rK10mw;aCZI4 z)XSK;O>SS0{xUN23JSW(u2MB*^6t|qec2nu+~^ilXTWab$BdNTe!yh+w%SdX-hW5AOJgs@L&&NnAv zkOe2<-K6yc5@zWT!a9W;sl(`sy48bU05 z2BkI9e%7si|2Rh$EK)-W59zICq32L&mJT6qSd0$44y((M))EAkm=I#eQUo-Sk!47X zFUL0ZB}c44`=&T%7$K7@;r~jWS_N;DwF%UTkc;ZE0-GGM8g-LvScg27WF4}0ty_Jl z*<{x`vP?Aqp5kMx2!k#`BXZ#x%ArgtFk9NE1S6V4+GIiI( zH2zLb+J$&QPTfsUw(P+?67OOjDY9TM<}r}$d=KmQl6miQJ!Hve7}xtb53ZZ@CSwO# zpNxG0zlpTIR9=3Igb>zOXgFX%2&)GTg$9JMzDC1%6GGhZ4aTlM1jfF_{gomUhjAvG z$butSqfU-EioHl4!`yqx$akpMFT?)h*h3c?Il(pmz&x_wDa5y&1|w$>SAX8Ez7RE# zsh{9&GWIikBN@4XJnK#k<5u5OTx zWc@s}Zy=Y>hp&DLj4jaB*VHDmdLi4N1{=t=&*I=1vZlPE8#bgOIIN-k>CJiNj>7$tVVx)jT%7o zC-)`MZSi@lj~7u7g_rX7edZ?6?IA)!1_kyH;}0fj3*auA(-ntoaHLdU)$oe+;jpWkT;3MsbU$qT>AbIpn<>l`i5F))D z8>*AZ9Y}DInYZ9`$@)(C0c5%h-X!bahW{;@-UY9b$=&e1WPA_2PS&L1Q{?s!boC)w zMlSpi{$euo5e_PsjO}MUnfMsKfs7r%2A7kGPk2F*u}=|SN+v&pA4S6*A-g%I^$ z>CP7fF_KT}QE1 z?Z*^lMFK`%G49m#wN8$UD3m=2OjI58rmy@X) zc$)jn1Ahk@O=5?xC8KNM|D7DM4&(H^jP{Xa&w4|Bautz1ub}@rvgcKJ zi|lEDA4>K#V%~R>JsaQ$kPRC#PmN4&f_IT+DeglP+9x$5eQ8zdbr+J+H;^}kjCRnI(Jl03bSvr)A*0*iuO&yk$$4xC2a-KI z=*gb9;0KXCJ29_8WKSpRT4a3};v32Cw-G;_%bi-3nn>o5Wqcp*gm2&UhktUHQ?eaAqX%zOtwlI;2(J}(2FCF_pE=br!t z89NCdAnSgBFFQq^CeM&(!TfWeAp89YA3YBS$o!ueN2Y&OwNISh_vQr3qlBM9vUjW5W<>| zhFiT5!g>k~IbI0SZ-HtMbqm2sPlH}^%`@;F&w>w=nMLq7lIdFbO=M!R>HM3gXeKjt z@CMnwM0u@G4unWAMSz=ZUxt96y%55B9t{h;5TgABGz`gs5Y~&?2ndmWNi~Qra?T2D zbV=M)pFHuEruxMCHJMxmKZLXrYEkkCAw*X_64R?q^C%eq}7_O03niX2*@R^*RlZ+BGQia$KOyL!bK)K;H@mT zs1uSq4k6}j<;HC@e~o>C5QpAGNB4FN?IqJYO!Y0}1etjY+w&z^w-b5!oyeO?T3y)z zAVlPC1lGKxI>c!*wg-u4$j8(0XUX;Nn$F{2^Xd>Hvlj&}B9rf#m&yRKg^ay#{)^+g z$>cutd&$@bSiwQk`cQf8WG{qB?#B#VdCH>-mn`KD-Q_)8w=5)^02{N-rxORiY~zd4Qqja~?`Y9%_(l7UqSSm1@w3x*XAulG2g z1^P`l-*PMEh}(*aDSe~-zoQ&8Y2viih@IlAj#5saZrwmRG2a?SdE0Hb452J6C@7?~ z?C1>2=rpS=D<@B$L^=7s>4USeQ~x3MKS#3lp6KNJDW?pbI0aHXK=xVVQIG!IH6F{^ zFV`B+AZKagZPisd0%x2{Or5XAE)r|Z|3-a%4LH>jmA^je9?;hyjJ92+KT+Xt;qkr75T?oJ;lyGeBOpS2is8RyEfE0(Z+pfL!C?7P^W(z z>Rj7~Iv2GgKerwEW;^mF)j8-AgRtlQk{eLI`SpeIZCQ?l*Bo{j(q7=zNE^R zRQXFfkUyvc`4@E{UwV}qL!V^=JE|2=QHh)*P142Z0qhtAA&$TjH zxX8qN@CV6~_Yv3l0ouFC%!lw7k=94bYx)HUvGV`|(w~5*$*(_!KS%~XLt>u`5Tg1Z zMvQ%-9)02<8Try_zg5 z9*|Ei)D*Z>@-Q~^C@W?<5j~rr*E7i-Q#4Jqio%F8g12R`+RQO zXB(lwsPemwVt+-Yt=`9~_c8jY(u!fuTcPtdT%QqrV5;FO@mEwBc2TLE>d@(v{ucGv z;b3u5Fz60dRqD2UbC;I}jbNz4Uuldhk?*>EjWc|KQ5CjqmW%etmp@$L*Mp(aA#HR> za?DuW*$8JGTOSn)`i;_{T~%q66$Ps*Ji(CK8dJSj=rS# z$xSh82)fL6gK3f#*8&9{6%43iC*Flt8(Mzie!shR@Q_5ake|?A8&;H z&U)>laY3^@SUS3-(kw2mC<)odT~&U6P!ESf<+|LR(MCmZv|MtaH0alhMhC;rTTqin z?Q^E6*@c=tTrUj-hPgvy18ynY{z{*^YQ}q{^N%hH=+4x&U`SqEwMA=;Vym?W&3rN7>%#|2=(T^^}=2WOvB+ z2hETjloNIPgQMJI#umzJu2P=Pv?=$y?NEh0=8B*UbYM6~UZCD@lY3uPIczw9wwqPY zF!f%j-fvRfg*SVg;KG}WR3mc`F+xS$G|WA5>iv*~QdXcwVe;hYG*d?WdD3LBJ#EtD8KWlMms=8j@ZL%H-8*5%1i2gG(xBX_upHZz`y=7C zXU>=&m@;Lm5~HR}j_SV9D8CsFjVh`vau-)r=#KFI-X9LxMWf|aTNMcC#s1Mjz1$xT L>SO)BO4t7ZZ=1@N diff --git a/numbers.bas b/numbers.bas index 1aee208..83d722b 100644 --- a/numbers.bas +++ b/numbers.bas @@ -1,10 +1,10 @@ -10 LET A=0 -15 LET B=0 -20 PRINT A;" "; -30 LET A=A+1 -32 LET B=B+1 -35 IF B>9 THEN GOTO 60 -40 IF A>1000 THEN END -50 GOTO 20 -60 PRINT -70 GOTO 15 +10 LET A=0 +15 LET B=0 +20 PRINT A;" "; +30 LET A=A+1 +32 LET B=B+1 +35 IF B>9 THEN GOTO 60 +40 IF A>1000 THEN END +50 GOTO 20 +60 PRINT +70 GOTO 15 diff --git a/t_adc_bcd_01.65s b/t_adc_bcd_01.65s index 17a2233..6266710 100644 --- a/t_adc_bcd_01.65s +++ b/t_adc_bcd_01.65s @@ -1,99 +1,99 @@ -; ADC, test decimal mode. -; -; NV-BDIZC -; ??1110?? -; -; The results I got on Rockwell 6502 AP -; -; 00 + 00 and C=0 gives 00 and N=0 V=0 Z=1 C=0 (3A) -; 79 + 00 and C=1 gives 80 and N=1 V=1 Z=0 C=0 (F8) -; 24 + 56 and C=0 gives 80 and N=1 V=1 Z=0 C=0 (F8) -; 93 + 82 and C=0 gives 75 and N=0 V=1 Z=0 C=1 (79) -; 89 + 76 and C=0 gives 65 and N=0 V=0 Z=0 C=1 (39) -; 89 + 76 and C=1 gives 66 and N=0 V=0 Z=0 C=1 (39) -; 80 + f0 and C=0 gives d0 and N=1 V=1 Z=0 C=1 (F9) -; 80 + fa and C=0 gives e0 and N=1 V=0 Z=0 C=1 (B9) -; 2f + 4f and C=0 gives 74 and N=0 V=0 Z=0 C=0 (38) -; 6f + 00 and C=1 gives 76 and N=0 V=0 Z=0 C=0 (38) - -RES=$0300 - - *=$0200 - - SED - CLC - LDA #$00 - ADC #$00 - STA RES - PHP - PLA - STA RES+1 - SEC - LDA #$79 - ADC #$00 - STA RES+2 - PHP - PLA - STA RES+3 - CLC - LDA #$24 - ADC #$56 - STA RES+4 - PHP - PLA - STA RES+5 - CLC - LDA #$93 - ADC #$82 - STA RES+6 - PHP - PLA - STA RES+7 - CLC - LDA #$89 - ADC #$76 - STA RES+8 - PHP - PLA - STA RES+9 - SEC - LDA #$89 - ADC #$76 - STA RES+10 - PHP - PLA - STA RES+11 - CLC - LDA #$80 - ADC #$F0 - STA RES+12 - PHP - PLA - STA RES+13 - CLC - LDA #$80 - ADC #$FA - STA RES+14 - PHP - PLA - STA RES+15 - CLC - LDA #$2F - ADC #$4F - STA RES+16 - PHP - PLA - STA RES+17 - SEC - LDA #$6F - ADC #$00 - STA RES+18 - PHP - PLA - STA RES+19 - BRK - - *=$0300 - - .DS 20 +; ADC, test decimal mode. +; +; NV-BDIZC +; ??1110?? +; +; The results I got on Rockwell 6502 AP +; +; 00 + 00 and C=0 gives 00 and N=0 V=0 Z=1 C=0 (3A) +; 79 + 00 and C=1 gives 80 and N=1 V=1 Z=0 C=0 (F8) +; 24 + 56 and C=0 gives 80 and N=1 V=1 Z=0 C=0 (F8) +; 93 + 82 and C=0 gives 75 and N=0 V=1 Z=0 C=1 (79) +; 89 + 76 and C=0 gives 65 and N=0 V=0 Z=0 C=1 (39) +; 89 + 76 and C=1 gives 66 and N=0 V=0 Z=0 C=1 (39) +; 80 + f0 and C=0 gives d0 and N=1 V=1 Z=0 C=1 (F9) +; 80 + fa and C=0 gives e0 and N=1 V=0 Z=0 C=1 (B9) +; 2f + 4f and C=0 gives 74 and N=0 V=0 Z=0 C=0 (38) +; 6f + 00 and C=1 gives 76 and N=0 V=0 Z=0 C=0 (38) + +RES=$0300 + + *=$0200 + + SED + CLC + LDA #$00 + ADC #$00 + STA RES + PHP + PLA + STA RES+1 + SEC + LDA #$79 + ADC #$00 + STA RES+2 + PHP + PLA + STA RES+3 + CLC + LDA #$24 + ADC #$56 + STA RES+4 + PHP + PLA + STA RES+5 + CLC + LDA #$93 + ADC #$82 + STA RES+6 + PHP + PLA + STA RES+7 + CLC + LDA #$89 + ADC #$76 + STA RES+8 + PHP + PLA + STA RES+9 + SEC + LDA #$89 + ADC #$76 + STA RES+10 + PHP + PLA + STA RES+11 + CLC + LDA #$80 + ADC #$F0 + STA RES+12 + PHP + PLA + STA RES+13 + CLC + LDA #$80 + ADC #$FA + STA RES+14 + PHP + PLA + STA RES+15 + CLC + LDA #$2F + ADC #$4F + STA RES+16 + PHP + PLA + STA RES+17 + SEC + LDA #$6F + ADC #$00 + STA RES+18 + PHP + PLA + STA RES+19 + BRK + + *=$0300 + + .DS 20 \ No newline at end of file diff --git a/t_adc_bcd_01.dat b/t_adc_bcd_01.dat index bb09293..52375ca 100644 --- a/t_adc_bcd_01.dat +++ b/t_adc_bcd_01.dat @@ -1,36 +1,36 @@ -; Test ADC BCD mode. -ORG -$0200 -$F8 $18 $A9 $00 $69 $00 $8D $00 -$03 $08 $68 $8D $01 $03 $38 $A9 -$79 $69 $00 $8D $02 $03 $08 $68 -$8D $03 $03 $18 $A9 $24 $69 $56 -$8D $04 $03 $08 $68 $8D $05 $03 -$18 $A9 $93 $69 $82 $8D $06 $03 -$08 $68 $8D $07 $03 $18 $A9 $89 -$69 $76 $8D $08 $03 $08 $68 $8D -$09 $03 $38 $A9 $89 $69 $76 $8D -$0A $03 $08 $68 $8D $0B $03 $18 -$A9 $80 $69 $F0 $8D $0C $03 $08 -$68 $8D $0D $03 $18 $A9 $80 $69 -$FA $8D $0E $03 $08 $68 $8D $0F -$03 $18 $A9 $2F $69 $4F $8D $10 -$03 $08 $68 $8D $11 $03 $38 $A9 -$6F $69 $00 $8D $12 $03 $08 $68 -$8D $13 $03 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 - +; Test ADC BCD mode. +ORG +$0200 +$F8 $18 $A9 $00 $69 $00 $8D $00 +$03 $08 $68 $8D $01 $03 $38 $A9 +$79 $69 $00 $8D $02 $03 $08 $68 +$8D $03 $03 $18 $A9 $24 $69 $56 +$8D $04 $03 $08 $68 $8D $05 $03 +$18 $A9 $93 $69 $82 $8D $06 $03 +$08 $68 $8D $07 $03 $18 $A9 $89 +$69 $76 $8D $08 $03 $08 $68 $8D +$09 $03 $38 $A9 $89 $69 $76 $8D +$0A $03 $08 $68 $8D $0B $03 $18 +$A9 $80 $69 $F0 $8D $0C $03 $08 +$68 $8D $0D $03 $18 $A9 $80 $69 +$FA $8D $0E $03 $08 $68 $8D $0F +$03 $18 $A9 $2F $69 $4F $8D $10 +$03 $08 $68 $8D $11 $03 $38 $A9 +$6F $69 $00 $8D $12 $03 $08 $68 +$8D $13 $03 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 + diff --git a/t_sbc_bcd_01.65s b/t_sbc_bcd_01.65s index c164095..e78c36c 100644 --- a/t_sbc_bcd_01.65s +++ b/t_sbc_bcd_01.65s @@ -1,85 +1,85 @@ -; SBC, test decimal mode. -; -; NV-BDIZC -; ??1110?? -; -; Expected results (I got on Rockwell 6502 AP): -; 00 - 00 and C=0 gives 99 and N=1 V=0 Z=0 C=0 (B8) -; 00 - 00 and C=1 gives 00 and N=0 V=0 Z=1 C=1 (3B) -; 00 - 01 and C=1 gives 99 and N=1 V=0 Z=0 C=0 (B8) -; 0a - 00 and C=1 gives 0a and N=0 V=0 Z=0 C=1 (39) -; 0b - 00 and C=0 gives 0a and N=0 V=0 Z=0 C=1 (39) -; 9a - 00 and C=1 gives 9a and N=1 V=0 Z=0 C=1 (B9) -; 9b - 00 and C=0 gives 9a and N=1 V=0 Z=0 C=1 (B9) -; - - *=$0200 - - SED - CLC - LDA #$00 - SBC #$00 - STA SBT1A - PHP - PLA - STA SBT1F - SEC - LDA #$00 - SBC #$00 - STA SBT2A - PHP - PLA - STA SBT2F - SEC - LDA #$00 - SBC #$01 - STA SBT3A - PHP - PLA - STA SBT3F - SEC - LDA #$0A - SBC #$00 - STA SBT4A - PHP - PLA - STA SBT4F - CLC - LDA #$0B - SBC #$00 - STA SBT5A - PHP - PLA - STA SBT5F - SEC - LDA #$9A - SBC #$00 - STA SBT6A - PHP - PLA - STA SBT6F - CLC - LDA #$9B - SBC #$00 - STA SBT7A - PHP - PLA - STA SBT7F - BRK - - *=$0300 - -SBT1A: .DB 0 -SBT1F: .DB 0 -SBT2A: .DB 0 -SBT2F: .DB 0 -SBT3A: .DB 0 -SBT3F: .DB 0 -SBT4A: .DB 0 -SBT4F: .DB 0 -SBT5A: .DB 0 -SBT5F: .DB 0 -SBT6A: .DB 0 -SBT6F: .DB 0 -SBT7A: .DB 0 +; SBC, test decimal mode. +; +; NV-BDIZC +; ??1110?? +; +; Expected results (I got on Rockwell 6502 AP): +; 00 - 00 and C=0 gives 99 and N=1 V=0 Z=0 C=0 (B8) +; 00 - 00 and C=1 gives 00 and N=0 V=0 Z=1 C=1 (3B) +; 00 - 01 and C=1 gives 99 and N=1 V=0 Z=0 C=0 (B8) +; 0a - 00 and C=1 gives 0a and N=0 V=0 Z=0 C=1 (39) +; 0b - 00 and C=0 gives 0a and N=0 V=0 Z=0 C=1 (39) +; 9a - 00 and C=1 gives 9a and N=1 V=0 Z=0 C=1 (B9) +; 9b - 00 and C=0 gives 9a and N=1 V=0 Z=0 C=1 (B9) +; + + *=$0200 + + SED + CLC + LDA #$00 + SBC #$00 + STA SBT1A + PHP + PLA + STA SBT1F + SEC + LDA #$00 + SBC #$00 + STA SBT2A + PHP + PLA + STA SBT2F + SEC + LDA #$00 + SBC #$01 + STA SBT3A + PHP + PLA + STA SBT3F + SEC + LDA #$0A + SBC #$00 + STA SBT4A + PHP + PLA + STA SBT4F + CLC + LDA #$0B + SBC #$00 + STA SBT5A + PHP + PLA + STA SBT5F + SEC + LDA #$9A + SBC #$00 + STA SBT6A + PHP + PLA + STA SBT6F + CLC + LDA #$9B + SBC #$00 + STA SBT7A + PHP + PLA + STA SBT7F + BRK + + *=$0300 + +SBT1A: .DB 0 +SBT1F: .DB 0 +SBT2A: .DB 0 +SBT2F: .DB 0 +SBT3A: .DB 0 +SBT3F: .DB 0 +SBT4A: .DB 0 +SBT4F: .DB 0 +SBT5A: .DB 0 +SBT5F: .DB 0 +SBT6A: .DB 0 +SBT6F: .DB 0 +SBT7A: .DB 0 SBT7F: .DB 0 \ No newline at end of file diff --git a/t_sbc_bcd_01.dat b/t_sbc_bcd_01.dat index 5ab2019..941c928 100644 --- a/t_sbc_bcd_01.dat +++ b/t_sbc_bcd_01.dat @@ -1,36 +1,36 @@ -; Test BCD mode. -ORG -$0200 -$F8 $18 $A9 $00 $E9 $00 $8D $00 -$03 $08 $68 $8D $01 $03 $38 $A9 -$00 $E9 $00 $8D $02 $03 $08 $68 -$8D $03 $03 $38 $A9 $00 $E9 $01 -$8D $04 $03 $08 $68 $8D $05 $03 -$38 $A9 $0A $E9 $00 $8D $06 $03 -$08 $68 $8D $07 $03 $18 $A9 $0B -$E9 $00 $8D $08 $03 $08 $68 $8D -$09 $03 $38 $A9 $9A $E9 $00 $8D -$0A $03 $08 $68 $8D $0B $03 $18 -$A9 $9B $E9 $00 $8D $0C $03 $08 -$68 $8D $0D $03 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 - +; Test BCD mode. +ORG +$0200 +$F8 $18 $A9 $00 $E9 $00 $8D $00 +$03 $08 $68 $8D $01 $03 $38 $A9 +$00 $E9 $00 $8D $02 $03 $08 $68 +$8D $03 $03 $38 $A9 $00 $E9 $01 +$8D $04 $03 $08 $68 $8D $05 $03 +$38 $A9 $0A $E9 $00 $8D $06 $03 +$08 $68 $8D $07 $03 $18 $A9 $0B +$E9 $00 $8D $08 $03 $08 $68 $8D +$09 $03 $38 $A9 $9A $E9 $00 $8D +$0A $03 $08 $68 $8D $0B $03 $18 +$A9 $9B $E9 $00 $8D $0C $03 $08 +$68 $8D $0D $03 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 + diff --git a/tall.dat b/tall.dat index dec9dd3..5c8c6bc 100644 --- a/tall.dat +++ b/tall.dat @@ -1,109 +1,109 @@ -; Created with BIN2HEX (C) Marek Karcz 2016. All rights reserved. -; 03/09/16 20:30:42 -ADDR -$4000 -ORG -$0000 -ORG -$4000 -$a9 $00 $8d $10 $02 $a9 $55 $8d $00 $02 $a9 $aa $8d $01 $02 $a9 -$ff $8d $02 $02 $a9 $6e $8d $03 $02 $a9 $42 $8d $04 $02 $a9 $33 -$8d $05 $02 $a9 $9d $8d $06 $02 $a9 $7f $8d $07 $02 $a9 $a5 $8d -$08 $02 $a9 $1f $8d $09 $02 $a9 $ce $8d $0a $02 $a9 $29 $8d $0b -$02 $a9 $42 $8d $0c $02 $a9 $6c $8d $0d $02 $a9 $42 $8d $0e $02 -$a9 $55 $a2 $2a $a0 $73 $85 $81 $a9 $01 $85 $61 $a9 $7e $a5 $81 -$8d $10 $09 $a9 $7e $ad $10 $09 $95 $56 $a9 $7e $b5 $56 $84 $60 -$91 $60 $a9 $7e $b1 $60 $9d $ff $07 $a9 $7e $bd $ff $07 $99 $ff -$07 $a9 $7e $b9 $ff $07 $81 $36 $a9 $7e $a1 $36 $86 $50 $a6 $60 -$a4 $50 $8e $13 $09 $a2 $22 $ae $13 $09 $8c $14 $09 $a0 $99 $ac -$14 $09 $94 $2d $96 $77 $a0 $99 $b4 $2d $a2 $22 $b6 $77 $a0 $99 -$bc $a0 $08 $a2 $22 $be $a1 $08 $9d $00 $02 $ad $2a $02 $cd $00 -$02 $f0 $03 $4c $c0 $45 $a9 $fe $8d $10 $02 $a9 $55 $29 $53 $09 -$38 $49 $11 $85 $99 $a9 $b9 $85 $10 $a9 $e7 $85 $11 $a9 $39 $85 -$12 $a5 $99 $25 $10 $05 $11 $45 $12 $a2 $10 $85 $99 $a9 $bc $85 -$20 $a9 $31 $85 $21 $a9 $17 $85 $22 $a5 $99 $35 $10 $15 $11 $55 -$12 $85 $99 $a9 $6f $8d $10 $01 $a9 $3c $8d $11 $01 $a9 $27 $8d -$12 $01 $a5 $99 $2d $10 $01 $0d $11 $01 $4d $12 $01 $85 $99 $a9 -$8a $8d $20 $01 $a9 $47 $8d $21 $01 $a9 $8f $8d $22 $01 $a5 $99 -$3d $10 $01 $1d $11 $01 $5d $12 $01 $a0 $20 $85 $99 $a9 $73 $8d -$30 $01 $a9 $2a $8d $31 $01 $a9 $f1 $8d $32 $01 $a5 $99 $39 $10 -$01 $19 $11 $01 $59 $12 $01 $85 $99 $a9 $70 $85 $30 $a9 $01 $85 -$31 $a9 $71 $85 $32 $a9 $01 $85 $33 $a9 $72 $85 $34 $a9 $01 $85 -$35 $a9 $c5 $8d $70 $01 $a9 $7c $8d $71 $01 $a9 $a1 $8d $72 $01 -$a5 $99 $21 $20 $01 $22 $41 $24 $85 $99 $a9 $60 $85 $40 $a9 $01 -$85 $41 $a9 $61 $85 $42 $a9 $01 $85 $43 $a9 $62 $85 $44 $a9 $01 -$85 $45 $a9 $37 $8d $50 $02 $a9 $23 $8d $51 $02 $a9 $9d $8d $52 -$02 $a5 $99 $a0 $f0 $31 $40 $11 $42 $51 $44 $85 $a9 $a5 $a9 $cd -$01 $02 $f0 $08 $a9 $01 $8d $10 $02 $4c $c0 $45 $a9 $ff $a2 $00 -$85 $90 $e6 $90 $e6 $90 $a5 $90 $a6 $90 $95 $90 $f6 $90 $b5 $90 -$a6 $91 $9d $90 $01 $ee $92 $01 $bd $90 $01 $ae $92 $01 $9d $90 -$01 $fe $90 $01 $bd $90 $01 $ae $93 $01 $9d $70 $01 $de $70 $01 -$bd $70 $01 $ae $74 $01 $9d $70 $01 $ce $73 $01 $bd $70 $01 $ae -$73 $01 $95 $70 $d6 $70 $b5 $70 $a6 $72 $95 $70 $c6 $71 $c6 $71 -$a5 $71 $cd $02 $02 $f0 $08 $a9 $02 $8d $10 $02 $4c $c0 $45 $a9 -$4b $4a $0a $85 $50 $06 $50 $06 $50 $46 $50 $a5 $50 $a6 $50 $09 -$c9 $85 $60 $16 $4c $56 $4c $56 $4c $b5 $4c $a6 $60 $09 $41 $8d -$2e $01 $5e $00 $01 $5e $00 $01 $1e $00 $01 $bd $00 $01 $ae $2e -$01 $09 $81 $9d $00 $01 $4e $36 $01 $4e $36 $01 $0e $36 $01 $bd -$00 $01 $2a $2a $6a $85 $70 $a6 $70 $09 $03 $95 $0c $26 $c0 $66 -$c0 $66 $c0 $b5 $0c $a6 $c0 $85 $d0 $36 $75 $36 $75 $76 $75 $a5 -$d0 $a6 $d0 $9d $00 $01 $2e $b7 $01 $2e $b7 $01 $2e $b7 $01 $6e -$b7 $01 $bd $00 $01 $ae $b7 $01 $8d $dd $01 $3e $00 $01 $7e $00 -$01 $7e $00 $01 $ad $dd $01 $cd $03 $02 $f0 $08 $a9 $03 $8d $10 -$02 $4c $c0 $45 $a9 $e8 $85 $20 $a9 $42 $85 $21 $a9 $00 $09 $03 -$4c $d5 $42 $09 $ff $09 $30 $20 $e1 $42 $09 $42 $6c $20 $00 $09 -$ff $85 $30 $a6 $30 $a9 $00 $60 $95 $0d $a5 $40 $cd $04 $02 $f0 -$08 $a9 $04 $8d $10 $02 $4c $c0 $45 $a9 $35 $aa $ca $ca $e8 $8a -$a8 $88 $88 $c8 $98 $aa $a9 $20 $9a $a2 $10 $ba $8a $85 $40 $a5 -$40 $cd $05 $02 $f0 $08 $a9 $05 $8d $10 $02 $4c $c0 $45 $2a $a9 -$6a $85 $50 $a9 $6b $85 $51 $a9 $a1 $85 $60 $a9 $a2 $85 $61 $a9 -$ff $69 $ff $69 $ff $e9 $ae $85 $40 $a6 $40 $75 $00 $f5 $01 $65 -$60 $e5 $61 $8d $20 $01 $a9 $4d $8d $21 $01 $a9 $23 $6d $20 $01 -$ed $21 $01 $85 $f0 $a6 $f0 $a9 $64 $8d $24 $01 $a9 $62 $8d $25 -$01 $a9 $26 $7d $00 $01 $fd $01 $01 $85 $f1 $a4 $f1 $a9 $e5 $8d -$28 $01 $a9 $e9 $8d $29 $01 $a9 $34 $79 $00 $01 $f9 $01 $01 $85 -$f2 $a6 $f2 $a9 $20 $85 $70 $a9 $01 $85 $71 $a9 $24 $85 $72 $a9 -$01 $85 $73 $61 $41 $e1 $3f $85 $f3 $a4 $f3 $a9 $da $85 $80 $a9 -$00 $85 $81 $a9 $dc $85 $82 $a9 $00 $85 $83 $a9 $aa $71 $80 $f1 -$82 $85 $30 $a5 $30 $cd $06 $02 $f0 $08 $a9 $06 $8d $10 $02 $4c -$c0 $45 $a9 $00 $85 $34 $a9 $ff $8d $30 $01 $a9 $99 $8d $9d $01 -$a9 $db $8d $99 $01 $a9 $2f $85 $32 $a9 $32 $85 $4f $a9 $30 $85 -$33 $a9 $70 $85 $af $a9 $18 $85 $30 $c9 $18 $f0 $02 $29 $00 $09 -$01 $c5 $30 $d0 $02 $29 $00 $a2 $00 $cd $30 $01 $f0 $04 $85 $40 -$a6 $40 $d5 $27 $d0 $06 $09 $84 $85 $41 $a6 $41 $29 $db $dd $00 -$01 $f0 $02 $29 $00 $85 $42 $a4 $42 $29 $00 $d9 $00 $01 $d0 $02 -$09 $0f $85 $43 $a6 $43 $09 $24 $c1 $40 $f0 $02 $09 $7f $85 $44 -$a4 $44 $49 $0f $d1 $33 $d0 $04 $a5 $44 $85 $15 $a5 $15 $cd $07 -$02 $f0 $08 $a9 $07 $8d $10 $02 $4c $c0 $45 $a9 $a5 $85 $20 $8d -$20 $01 $a9 $5a $85 $21 $a2 $a5 $e0 $a5 $f0 $02 $a2 $01 $e4 $20 -$f0 $02 $a2 $02 $ec $20 $01 $f0 $02 $a2 $03 $86 $30 $a4 $30 $c0 -$a5 $f0 $02 $a0 $04 $c4 $20 $f0 $02 $a0 $05 $cc $20 $01 $f0 $02 -$a0 $06 $84 $31 $a5 $31 $24 $20 $d0 $02 $a9 $07 $2c $20 $01 $d0 -$02 $a9 $08 $24 $21 $d0 $02 $85 $42 $a5 $42 $cd $08 $02 $f0 $08 -$a9 $08 $8d $10 $02 $4c $c0 $45 $a9 $54 $85 $32 $a9 $b3 $85 $a1 -$a9 $87 $85 $43 $a2 $a1 $10 $02 $a2 $32 $b4 $00 $10 $04 $a9 $05 -$a6 $a1 $30 $02 $e9 $03 $30 $02 $a9 $41 $49 $30 $85 $32 $75 $00 -$50 $02 $a9 $03 $85 $54 $b6 $00 $75 $51 $50 $02 $a9 $e5 $75 $40 -$70 $05 $99 $01 $00 $65 $55 $70 $02 $a9 $00 $69 $f0 $90 $04 $85 -$60 $65 $43 $90 $02 $a9 $ff $65 $54 $b0 $04 $69 $87 $a6 $60 $b0 -$02 $a9 $00 $95 $73 $a5 $80 $cd $09 $02 $f0 $08 $a9 $09 $8d $10 -$02 $4c $c0 $45 $69 $00 $a9 $99 $69 $87 $18 $ea $90 $04 $69 $60 -$69 $93 $38 $ea $90 $01 $b8 $50 $02 $a9 $00 $69 $ad $ea $85 $30 -$a5 $30 $cd $0a $02 $f0 $08 $a9 $0a $8d $10 $02 $4c $c0 $45 $69 -$01 $a9 $27 $69 $01 $38 $08 $18 $28 $69 $00 $48 $a9 $00 $68 $85 -$30 $a5 $30 $cd $0b $02 $f0 $08 $a9 $0b $8d $10 $02 $4c $c0 $45 -$18 $a9 $42 $90 $04 $85 $33 $b0 $0a $a9 $45 $48 $a9 $61 $48 $38 -$08 $18 $40 $a5 $33 $cd $0c $02 $f0 $08 $a9 $0c $8d $10 $02 $4c -$c0 $45 $69 $01 $78 $f8 $08 $68 $85 $20 $58 $d8 $08 $68 $65 $20 -$85 $21 $a5 $21 $cd $0d $02 $f0 $08 $a9 $0d $8d $10 $02 $4c $c0 -$45 $a9 $41 $85 $60 $e6 $60 $a5 $60 $cd $0e $02 $f0 $08 $a9 $0e -$8d $10 $02 $4c $c0 $45 $a9 $fe $cd $10 $02 $d0 $03 $ee $10 $02 -$00 $00 $a2 $ff $9a $60 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 -ORG -$ff00 -$40 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 -ORG -$fff0 -$00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $ff $00 $ff $00 $ff -EXEC -$4000 +; Created with BIN2HEX (C) Marek Karcz 2016. All rights reserved. +; 03/09/16 20:30:42 +ADDR +$4000 +ORG +$0000 +ORG +$4000 +$a9 $00 $8d $10 $02 $a9 $55 $8d $00 $02 $a9 $aa $8d $01 $02 $a9 +$ff $8d $02 $02 $a9 $6e $8d $03 $02 $a9 $42 $8d $04 $02 $a9 $33 +$8d $05 $02 $a9 $9d $8d $06 $02 $a9 $7f $8d $07 $02 $a9 $a5 $8d +$08 $02 $a9 $1f $8d $09 $02 $a9 $ce $8d $0a $02 $a9 $29 $8d $0b +$02 $a9 $42 $8d $0c $02 $a9 $6c $8d $0d $02 $a9 $42 $8d $0e $02 +$a9 $55 $a2 $2a $a0 $73 $85 $81 $a9 $01 $85 $61 $a9 $7e $a5 $81 +$8d $10 $09 $a9 $7e $ad $10 $09 $95 $56 $a9 $7e $b5 $56 $84 $60 +$91 $60 $a9 $7e $b1 $60 $9d $ff $07 $a9 $7e $bd $ff $07 $99 $ff +$07 $a9 $7e $b9 $ff $07 $81 $36 $a9 $7e $a1 $36 $86 $50 $a6 $60 +$a4 $50 $8e $13 $09 $a2 $22 $ae $13 $09 $8c $14 $09 $a0 $99 $ac +$14 $09 $94 $2d $96 $77 $a0 $99 $b4 $2d $a2 $22 $b6 $77 $a0 $99 +$bc $a0 $08 $a2 $22 $be $a1 $08 $9d $00 $02 $ad $2a $02 $cd $00 +$02 $f0 $03 $4c $c0 $45 $a9 $fe $8d $10 $02 $a9 $55 $29 $53 $09 +$38 $49 $11 $85 $99 $a9 $b9 $85 $10 $a9 $e7 $85 $11 $a9 $39 $85 +$12 $a5 $99 $25 $10 $05 $11 $45 $12 $a2 $10 $85 $99 $a9 $bc $85 +$20 $a9 $31 $85 $21 $a9 $17 $85 $22 $a5 $99 $35 $10 $15 $11 $55 +$12 $85 $99 $a9 $6f $8d $10 $01 $a9 $3c $8d $11 $01 $a9 $27 $8d +$12 $01 $a5 $99 $2d $10 $01 $0d $11 $01 $4d $12 $01 $85 $99 $a9 +$8a $8d $20 $01 $a9 $47 $8d $21 $01 $a9 $8f $8d $22 $01 $a5 $99 +$3d $10 $01 $1d $11 $01 $5d $12 $01 $a0 $20 $85 $99 $a9 $73 $8d +$30 $01 $a9 $2a $8d $31 $01 $a9 $f1 $8d $32 $01 $a5 $99 $39 $10 +$01 $19 $11 $01 $59 $12 $01 $85 $99 $a9 $70 $85 $30 $a9 $01 $85 +$31 $a9 $71 $85 $32 $a9 $01 $85 $33 $a9 $72 $85 $34 $a9 $01 $85 +$35 $a9 $c5 $8d $70 $01 $a9 $7c $8d $71 $01 $a9 $a1 $8d $72 $01 +$a5 $99 $21 $20 $01 $22 $41 $24 $85 $99 $a9 $60 $85 $40 $a9 $01 +$85 $41 $a9 $61 $85 $42 $a9 $01 $85 $43 $a9 $62 $85 $44 $a9 $01 +$85 $45 $a9 $37 $8d $50 $02 $a9 $23 $8d $51 $02 $a9 $9d $8d $52 +$02 $a5 $99 $a0 $f0 $31 $40 $11 $42 $51 $44 $85 $a9 $a5 $a9 $cd +$01 $02 $f0 $08 $a9 $01 $8d $10 $02 $4c $c0 $45 $a9 $ff $a2 $00 +$85 $90 $e6 $90 $e6 $90 $a5 $90 $a6 $90 $95 $90 $f6 $90 $b5 $90 +$a6 $91 $9d $90 $01 $ee $92 $01 $bd $90 $01 $ae $92 $01 $9d $90 +$01 $fe $90 $01 $bd $90 $01 $ae $93 $01 $9d $70 $01 $de $70 $01 +$bd $70 $01 $ae $74 $01 $9d $70 $01 $ce $73 $01 $bd $70 $01 $ae +$73 $01 $95 $70 $d6 $70 $b5 $70 $a6 $72 $95 $70 $c6 $71 $c6 $71 +$a5 $71 $cd $02 $02 $f0 $08 $a9 $02 $8d $10 $02 $4c $c0 $45 $a9 +$4b $4a $0a $85 $50 $06 $50 $06 $50 $46 $50 $a5 $50 $a6 $50 $09 +$c9 $85 $60 $16 $4c $56 $4c $56 $4c $b5 $4c $a6 $60 $09 $41 $8d +$2e $01 $5e $00 $01 $5e $00 $01 $1e $00 $01 $bd $00 $01 $ae $2e +$01 $09 $81 $9d $00 $01 $4e $36 $01 $4e $36 $01 $0e $36 $01 $bd +$00 $01 $2a $2a $6a $85 $70 $a6 $70 $09 $03 $95 $0c $26 $c0 $66 +$c0 $66 $c0 $b5 $0c $a6 $c0 $85 $d0 $36 $75 $36 $75 $76 $75 $a5 +$d0 $a6 $d0 $9d $00 $01 $2e $b7 $01 $2e $b7 $01 $2e $b7 $01 $6e +$b7 $01 $bd $00 $01 $ae $b7 $01 $8d $dd $01 $3e $00 $01 $7e $00 +$01 $7e $00 $01 $ad $dd $01 $cd $03 $02 $f0 $08 $a9 $03 $8d $10 +$02 $4c $c0 $45 $a9 $e8 $85 $20 $a9 $42 $85 $21 $a9 $00 $09 $03 +$4c $d5 $42 $09 $ff $09 $30 $20 $e1 $42 $09 $42 $6c $20 $00 $09 +$ff $85 $30 $a6 $30 $a9 $00 $60 $95 $0d $a5 $40 $cd $04 $02 $f0 +$08 $a9 $04 $8d $10 $02 $4c $c0 $45 $a9 $35 $aa $ca $ca $e8 $8a +$a8 $88 $88 $c8 $98 $aa $a9 $20 $9a $a2 $10 $ba $8a $85 $40 $a5 +$40 $cd $05 $02 $f0 $08 $a9 $05 $8d $10 $02 $4c $c0 $45 $2a $a9 +$6a $85 $50 $a9 $6b $85 $51 $a9 $a1 $85 $60 $a9 $a2 $85 $61 $a9 +$ff $69 $ff $69 $ff $e9 $ae $85 $40 $a6 $40 $75 $00 $f5 $01 $65 +$60 $e5 $61 $8d $20 $01 $a9 $4d $8d $21 $01 $a9 $23 $6d $20 $01 +$ed $21 $01 $85 $f0 $a6 $f0 $a9 $64 $8d $24 $01 $a9 $62 $8d $25 +$01 $a9 $26 $7d $00 $01 $fd $01 $01 $85 $f1 $a4 $f1 $a9 $e5 $8d +$28 $01 $a9 $e9 $8d $29 $01 $a9 $34 $79 $00 $01 $f9 $01 $01 $85 +$f2 $a6 $f2 $a9 $20 $85 $70 $a9 $01 $85 $71 $a9 $24 $85 $72 $a9 +$01 $85 $73 $61 $41 $e1 $3f $85 $f3 $a4 $f3 $a9 $da $85 $80 $a9 +$00 $85 $81 $a9 $dc $85 $82 $a9 $00 $85 $83 $a9 $aa $71 $80 $f1 +$82 $85 $30 $a5 $30 $cd $06 $02 $f0 $08 $a9 $06 $8d $10 $02 $4c +$c0 $45 $a9 $00 $85 $34 $a9 $ff $8d $30 $01 $a9 $99 $8d $9d $01 +$a9 $db $8d $99 $01 $a9 $2f $85 $32 $a9 $32 $85 $4f $a9 $30 $85 +$33 $a9 $70 $85 $af $a9 $18 $85 $30 $c9 $18 $f0 $02 $29 $00 $09 +$01 $c5 $30 $d0 $02 $29 $00 $a2 $00 $cd $30 $01 $f0 $04 $85 $40 +$a6 $40 $d5 $27 $d0 $06 $09 $84 $85 $41 $a6 $41 $29 $db $dd $00 +$01 $f0 $02 $29 $00 $85 $42 $a4 $42 $29 $00 $d9 $00 $01 $d0 $02 +$09 $0f $85 $43 $a6 $43 $09 $24 $c1 $40 $f0 $02 $09 $7f $85 $44 +$a4 $44 $49 $0f $d1 $33 $d0 $04 $a5 $44 $85 $15 $a5 $15 $cd $07 +$02 $f0 $08 $a9 $07 $8d $10 $02 $4c $c0 $45 $a9 $a5 $85 $20 $8d +$20 $01 $a9 $5a $85 $21 $a2 $a5 $e0 $a5 $f0 $02 $a2 $01 $e4 $20 +$f0 $02 $a2 $02 $ec $20 $01 $f0 $02 $a2 $03 $86 $30 $a4 $30 $c0 +$a5 $f0 $02 $a0 $04 $c4 $20 $f0 $02 $a0 $05 $cc $20 $01 $f0 $02 +$a0 $06 $84 $31 $a5 $31 $24 $20 $d0 $02 $a9 $07 $2c $20 $01 $d0 +$02 $a9 $08 $24 $21 $d0 $02 $85 $42 $a5 $42 $cd $08 $02 $f0 $08 +$a9 $08 $8d $10 $02 $4c $c0 $45 $a9 $54 $85 $32 $a9 $b3 $85 $a1 +$a9 $87 $85 $43 $a2 $a1 $10 $02 $a2 $32 $b4 $00 $10 $04 $a9 $05 +$a6 $a1 $30 $02 $e9 $03 $30 $02 $a9 $41 $49 $30 $85 $32 $75 $00 +$50 $02 $a9 $03 $85 $54 $b6 $00 $75 $51 $50 $02 $a9 $e5 $75 $40 +$70 $05 $99 $01 $00 $65 $55 $70 $02 $a9 $00 $69 $f0 $90 $04 $85 +$60 $65 $43 $90 $02 $a9 $ff $65 $54 $b0 $04 $69 $87 $a6 $60 $b0 +$02 $a9 $00 $95 $73 $a5 $80 $cd $09 $02 $f0 $08 $a9 $09 $8d $10 +$02 $4c $c0 $45 $69 $00 $a9 $99 $69 $87 $18 $ea $90 $04 $69 $60 +$69 $93 $38 $ea $90 $01 $b8 $50 $02 $a9 $00 $69 $ad $ea $85 $30 +$a5 $30 $cd $0a $02 $f0 $08 $a9 $0a $8d $10 $02 $4c $c0 $45 $69 +$01 $a9 $27 $69 $01 $38 $08 $18 $28 $69 $00 $48 $a9 $00 $68 $85 +$30 $a5 $30 $cd $0b $02 $f0 $08 $a9 $0b $8d $10 $02 $4c $c0 $45 +$18 $a9 $42 $90 $04 $85 $33 $b0 $0a $a9 $45 $48 $a9 $61 $48 $38 +$08 $18 $40 $a5 $33 $cd $0c $02 $f0 $08 $a9 $0c $8d $10 $02 $4c +$c0 $45 $69 $01 $78 $f8 $08 $68 $85 $20 $58 $d8 $08 $68 $65 $20 +$85 $21 $a5 $21 $cd $0d $02 $f0 $08 $a9 $0d $8d $10 $02 $4c $c0 +$45 $a9 $41 $85 $60 $e6 $60 $a5 $60 $cd $0e $02 $f0 $08 $a9 $0e +$8d $10 $02 $4c $c0 $45 $a9 $fe $cd $10 $02 $d0 $03 $ee $10 $02 +$00 $00 $a2 $ff $9a $60 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 +ORG +$ff00 +$40 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 +ORG +$fff0 +$00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $ff $00 $ff $00 $ff +EXEC +$4000 diff --git a/tb.dat b/tb.dat index 45d7737..7aaf646 100644 --- a/tb.dat +++ b/tb.dat @@ -1,398 +1,398 @@ -ADDR -$0CF0 -; Program disassembly from $0400 to $1000 2/20/2016 -; Tiny Basic port for VM6502 emulator. -; Exec address: $0CF0 -ORG -$0400 -; Enable ROM and IO emulation. -ENROM -ENIO -; Set char IO address -IOADDR -$E000 -; Code/Data -$4C, $85, $04, $4C, $BD, $04, $4C, $2C -$0F, $4C, $31, $0F, $EA, $18, $60, $5F -$18, $80, $00, $20, $86, $C3, $90, $05 -$86, $C3, $91, $C2, $60, $B1, $C2, $A0 -$00, $60, $62, $05, $64, $05, $D8, $05 -$05, $06, $33, $06, $FD, $05, $9F, $07 -$42, $0B, $3F, $0B, $7A, $07, $FC, $08 -$95, $07, $9F, $07, $9F, $07, $BD, $0A -$C1, $0A, $8A, $0A, $9B, $0A, $E9, $0A -$61, $07, $51, $07, $41, $0A, $52, $0A -$4F, $0A, $62, $0A, $E7, $09, $CD, $06 -$06, $07, $9F, $07, $15, $08, $A7, $07 -$B7, $06, $BF, $06, $83, $08, $A1, $06 -$9F, $07, $9F, $07, $A8, $08, $4F, $0B -$4D, $0B, $07, $09, $AA, $04, $37, $07 -$BD, $04, $1B, $0B, $B1, $0A, $20, $41 -$54, $20, $80, $70, $0B, $A9, $00, $85 -$20, $85, $22, $A9, $1C, $85, $21, $85 -$23, $A0, $01, $B1, $22, $AA, $49, $FF -$91, $22, $D1, $22, $08, $8A, $91, $22 -$E6, $22, $D0, $02, $E6, $23, $28, $F0 -$EA, $88, $D8, $A5, $20, $6D, $13, $04 -$85, $24, $98, $65, $21, $85, $25, $98 -$91, $20, $C8, $91, $20, $A5, $22, $85 -$C6, $85, $26, $A5, $23, $85, $C7, $85 -$27, $20, $87, $08, $AD, $83, $04, $85 -$2A, $AD, $84, $04, $85, $2B, $A9, $80 -$85, $C1, $A9, $30, $85, $C0, $A2, $00 -$86, $BE, $86, $C2, $CA, $9A, $D8, $20 -$F9, $06, $20, $F2, $04, $4C, $E6, $04 -$83, $65, $C9, $30, $B0, $7B, $C9, $08 -$90, $0C, $0A, $AA, $BD, $1F, $04, $48 -$BD, $1E, $04, $48, $08, $40, $65, $C1 -$AA, $B1, $C1, $48, $B5, $00, $91, $C1 -$68, $95, $00, $60, $20, $87, $08, $A9 -$21, $20, $09, $04, $A5, $2A, $38, $ED -$83, $04, $AA, $A5, $2B, $ED, $84, $04 -$20, $A0, $07, $A5, $BE, $F0, $12, $A9 -$7E, $85, $2A, $A9, $20, $85, $2B, $20 -$A1, $06, $A6, $28, $A5, $29, $20, $A0 -$07, $A9, $07, $20, $09, $04, $20, $87 -$08, $A5, $26, $85, $C6, $A5, $27, $85 -$C7, $4C, $CC, $04, $A2, $7C, $E4, $C1 -$90, $BA, $A6, $C1, $E6, $C1, $E6, $C1 -$18, $60, $C6, $BD, $A5, $BD, $F0, $AC -$A5, $BC, $85, $2A, $A5, $BD, $85, $2B -$60, $C9, $40, $B0, $43, $48, $20, $F9 -$06, $6D, $83, $04, $85, $BC, $68, $48 -$29, $07, $6D, $84, $04, $85, $BD, $68 -$29, $08, $D0, $DC, $A5, $BC, $A6, $2A -$85, $2A, $86, $BC, $A5, $BD, $A6, $2B -$85, $2B, $86, $BD, $A5, $C6, $E9, $01 -$85, $C6, $B0, $02, $C6, $C7, $C5, $24 -$A5, $C7, $E5, $25, $90, $AA, $A5, $BC -$91, $C6, $C8, $A5, $BD, $91, $C6, $60 -$48, $4A, $4A, $4A, $4A, $29, $0E, $AA -$68, $C9, $60, $29, $1F, $B0, $02, $09 -$E0, $18, $F0, $07, $65, $2A, $85, $BC -$98, $65, $2B, $85, $BD, $4C, $FC, $04 -$A5, $2C, $85, $B8, $A5, $2D, $85, $B9 -$20, $25, $06, $20, $14, $06, $51, $2A -$AA, $20, $F9, $06, $8A, $F0, $F1, $0A -$F0, $12, $A5, $B8, $85, $2C, $A5, $B9 -$85, $2D, $4C, $64, $05, $20, $25, $06 -$C9, $0D, $D0, $F6, $60, $20, $25, $06 -$C9, $5B, $B0, $EE, $C9, $41, $90, $EA -$0A, $20, $87, $07, $A0, $00, $B1, $2C -$E6, $2C, $D0, $02, $E6, $2D, $C9, $0D -$18, $60, $20, $14, $06, $B1, $2C, $C9 -$20, $F0, $F7, $C9, $3A, $18, $10, $02 -$C9, $30, $60, $20, $25, $06, $90, $C2 -$84, $BC, $84, $BD, $A5, $BC, $A6, $BD -$06, $BC, $26, $BD, $06, $BC, $26, $BD -$18, $65, $BC, $85, $BC, $8A, $65, $BD -$06, $BC, $2A, $85, $BD, $20, $14, $06 -$29, $0F, $65, $BC, $85, $BC, $98, $65 -$BD, $85, $BD, $20, $25, $06, $B0, $D4 -$4C, $80, $07, $20, $FC, $08, $A5, $BC -$05, $BD, $F0, $48, $A5, $20, $85, $2C -$A5, $21, $85, $2D, $20, $6D, $07, $F0 -$12, $A5, $28, $C5, $BC, $A5, $29, $E5 -$BD, $B0, $08, $20, $14, $06, $D0, $FB -$4C, $7C, $06, $A5, $28, $45, $BC, $D0 -$04, $A5, $29, $45, $BD, $60, $20, $A6 -$06, $20, $F9, $06, $10, $F8, $E6, $BF -$30, $03, $4C, $09, $04, $C6, $BF, $60 -$C9, $22, $F0, $FB, $20, $A6, $06, $20 -$14, $06, $D0, $F4, $4C, $14, $05, $A9 -$20, $20, $A6, $06, $A5, $BF, $29, $87 -$30, $E5, $D0, $F3, $60, $A2, $7B, $20 -$56, $05, $E6, $C1, $E6, $C1, $E6, $C1 -$38, $B5, $03, $F5, $00, $95, $00, $B5 -$04, $F5, $01, $50, $04, $49, $80, $09 -$01, $30, $0A, $D0, $04, $15, $00, $F0 -$02, $56, $02, $56, $02, $56, $02, $90 -$0C, $A0, $00, $B1, $2A, $E6, $2A, $D0 -$02, $E6, $2B, $09, $00, $60, $A5, $BE -$F0, $28, $20, $14, $06, $D0, $FB, $20 -$6D, $07, $F0, $1B, $20, $4C, $07, $20 -$0C, $04, $B0, $09, $A5, $C4, $85, $2A -$A5, $C5, $85, $2B, $60, $AD, $83, $04 -$85, $2A, $AD, $84, $04, $85, $2B, $4C -$14, $05, $85, $BF, $4C, $49, $05, $A5 -$20, $85, $2C, $A5, $21, $85, $2D, $20 -$6D, $07, $F0, $EB, $A5, $2A, $85, $C4 -$A5, $2B, $85, $C5, $A9, $01, $85, $BE -$60, $20, $6B, $06, $F0, $BE, $A5, $BC -$85, $28, $A5, $BD, $85, $29, $4C, $14 -$05, $20, $FD, $0A, $20, $FA, $0A, $20 -$74, $06, $D0, $EA, $60, $20, $14, $06 -$85, $28, $20, $14, $06, $85, $29, $05 -$28, $60, $20, $FC, $08, $20, $80, $07 -$A5, $BD, $20, $87, $07, $A5, $BC, $A6 -$C1, $CA, $95, $00, $86, $C1, $E4, $C0 -$D0, $0D, $4C, $14, $05, $A6, $C1, $E0 -$80, $10, $F7, $B5, $00, $E6, $C1, $60 -$85, $BD, $86, $BC, $4C, $B8, $07, $A6 -$C1, $B5, $01, $10, $08, $20, $41, $0A -$A9, $2D, $20, $A6, $06, $20, $FC, $08 -$A9, $1F, $85, $B8, $85, $BA, $A9, $2A -$85, $B9, $85, $BB, $A6, $BC, $A4, $BD -$38, $E6, $B8, $8A, $E9, $10, $AA, $98 -$E9, $27, $A8, $B0, $F4, $C6, $B9, $8A -$69, $E8, $AA, $98, $69, $03, $A8, $90 -$F4, $8A, $38, $E6, $BA, $E9, $64, $B0 -$F9, $88, $10, $F6, $C6, $BB, $69, $0A -$90, $FA, $09, $30, $85, $BC, $A9, $20 -$85, $BD, $A2, $FB, $86, $C3, $B5, $BD -$05, $BD, $C9, $20, $F0, $09, $A0, $30 -$84, $BD, $05, $BD, $20, $A6, $06, $A6 -$C3, $E8, $D0, $E8, $60, $A5, $2D, $48 -$A5, $2C, $48, $A5, $20, $85, $2C, $A5 -$21, $85, $2D, $A5, $24, $A6, $25, $20 -$5B, $08, $F0, $03, $20, $5B, $08, $A5 -$2C, $38, $E5, $B6, $A5, $2D, $E5, $B7 -$B0, $42, $20, $6D, $07, $F0, $3D, $A6 -$28, $A5, $29, $20, $A0, $07, $A9, $20 -$20, $A6, $06, $20, $0C, $04, $B0, $2C -$20, $14, $06, $D0, $F3, $20, $83, $08 -$4C, $2F, $08, $85, $B6, $E6, $B6, $D0 -$01, $E8, $86, $B7, $A4, $C1, $C0, $80 -$F0, $18, $20, $6B, $06, $A5, $2C, $A6 -$2D, $38, $E9, $02, $B0, $01, $CA, $85 -$2C, $4C, $48, $0B, $68, $85, $2C, $68 -$85, $2D, $60, $A5, $BF, $30, $FB, $A9 -$0D, $20, $09, $04, $AD, $11, $04, $29 -$7F, $85, $BF, $F0, $07, $20, $64, $0B -$C6, $BF, $D0, $F9, $A9, $0A, $4C, $61 -$0B, $AC, $12, $04, $84, $BF, $B0, $0B -$A9, $30, $85, $2C, $85, $C0, $84, $2D -$20, $80, $07, $45, $80, $85, $80, $20 -$06, $04, $A0, $00, $A6, $C0, $29, $7F -$F0, $F1, $C9, $7F, $F0, $ED, $C9, $13 -$F0, $DA, $C9, $0A, $F0, $D3, $CD, $10 -$04, $F0, $09, $CD, $0F, $04, $D0, $0A -$E0, $30, $D0, $16, $A6, $2C, $84, $BF -$A9, $0D, $E4, $C1, $30, $08, $A9, $07 -$20, $A6, $06, $4C, $B3, $08, $95, $00 -$E8, $E8, $CA, $86, $C0, $C9, $0D, $D0 -$BA, $20, $83, $08, $20, $95, $07, $85 -$BC, $20, $95, $07, $85, $BD, $60, $20 -$D6, $0A, $20, $6B, $06, $08, $20, $6D -$08, $85, $B8, $86, $B9, $A5, $BC, $85 -$B6, $A5, $BD, $85, $B7, $A2, $00, $28 -$D0, $0B, $20, $6D, $07, $CA, $CA, $CA -$20, $14, $06, $D0, $FA, $84, $28, $84 -$29, $20, $D6, $0A, $A9, $0D, $D1, $2C -$F0, $11, $E8, $E8, $E8, $E8, $C8, $D1 -$2C, $D0, $FA, $A5, $B6, $85, $28, $A5 -$B7, $85, $29, $A5, $B8, $85, $BC, $A5 -$B9, $85, $BD, $18, $A0, $00, $8A, $F0 -$6E, $10, $29, $65, $2E, $85, $B8, $A5 -$2F, $E9, $00, $85, $B9, $B1, $2E, $91 -$B8, $A6, $2E, $E4, $24, $D0, $06, $A5 -$2F, $C5, $25, $F0, $4A, $E8, $86, $2E -$D0, $02, $E6, $2F, $E6, $B8, $D0, $E5 -$E6, $B9, $D0, $E1, $65, $24, $85, $B8 -$85, $2E, $98, $65, $25, $85, $B9, $85 -$2F, $A5, $2E, $E5, $C6, $A5, $2F, $E5 -$C7, $90, $05, $C6, $2A, $4C, $14, $05 -$B1, $24, $91, $2E, $A6, $24, $D0, $02 -$C6, $25, $C6, $24, $A6, $2E, $D0, $02 -$C6, $2F, $CA, $86, $2E, $E4, $BC, $D0 -$E7, $A6, $2F, $E4, $BD, $D0, $E1, $A5 -$B8, $85, $24, $A5, $B9, $85, $25, $A5 -$28, $05, $29, $F0, $17, $A5, $28, $91 -$BC, $C8, $A5, $29, $91, $BC, $C8, $84 -$B6, $20, $14, $06, $08, $A4, $B6, $91 -$BC, $28, $D0, $F2, $4C, $CC, $04, $20 -$54, $05, $B5, $03, $29, $80, $F0, $02 -$A9, $FF, $85, $BC, $85, $BD, $48, $75 -$02, $95, $02, $68, $48, $75, $03, $95 -$03, $68, $55, $01, $85, $BB, $10, $03 -$20, $43, $0A, $A0, $11, $B5, $00, $15 -$01, $D0, $03, $4C, $14, $05, $38, $A5 -$BC, $F5, $00, $48, $A5, $BD, $F5, $01 -$48, $45, $BD, $30, $0A, $68, $85, $BD -$68, $85, $BC, $38, $4C, $32, $0A, $68 -$68, $18, $36, $02, $36, $03, $26, $BC -$26, $BD, $88, $D0, $D9, $A5, $BB, $10 -$0D, $A6, $C1, $38, $98, $F5, $00, $95 -$00, $98, $F5, $01, $95, $01, $60, $20 -$41, $0A, $20, $54, $05, $B5, $00, $75 -$02, $95, $02, $B5, $01, $75, $03, $95 -$03, $60, $20, $54, $05, $A0, $10, $B5 -$02, $85, $BC, $B5, $03, $85, $BD, $16 -$02, $36, $03, $26, $BC, $26, $BD, $90 -$0D, $18, $B5, $02, $75, $00, $95, $02 -$B5, $03, $75, $01, $95, $03, $88, $D0 -$E6, $60, $20, $95, $07, $AA, $B5, $00 -$B4, $01, $C6, $C1, $A6, $C1, $94, $00 -$4C, $87, $07, $A2, $7D, $20, $56, $05 -$B5, $01, $48, $B5, $00, $48, $20, $95 -$07, $AA, $68, $95, $00, $68, $95, $01 -$60, $20, $FD, $0A, $A5, $BC, $85, $2A -$A5, $BD, $85, $2B, $60, $A2, $2C, $D0 -$02, $A2, $2E, $B5, $00, $C9, $80, $B0 -$0D, $B5, $01, $D0, $09, $A5, $2C, $85 -$2E, $A5, $2D, $85, $2F, $60, $A5, $2C -$A4, $2E, $84, $2C, $85, $2E, $A5, $2D -$A4, $2F, $84, $2D, $85, $2F, $A0, $00 -$60, $A5, $28, $85, $BC, $A5, $29, $85 -$BD, $20, $9C, $05, $A5, $C6, $85, $26 -$A5, $C7, $85, $27, $60, $B1, $C6, $85 -$BC, $20, $08, $0B, $B1, $C6, $85, $BD -$E6, $C6, $D0, $02, $E6, $C7, $A5, $22 -$C5, $C6, $A5, $23, $E5, $C7, $B0, $E4 -$4C, $14, $05, $20, $24, $0B, $85, $BC -$98, $4C, $82, $07, $20, $FC, $08, $A5 -$BC, $85, $B6, $20, $FC, $08, $A5, $BD -$85, $B7, $A4, $BC, $20, $FC, $08, $A6 -$B7, $A5, $B6, $18, $6C, $BC, $00, $20 -$42, $0B, $20, $F9, $06, $4C, $87, $07 -$86, $2D, $E0, $00, $60, $A0, $02, $84 -$BC, $A0, $29, $84, $BD, $A0, $00, $B1 -$BC, $C9, $08, $D0, $03, $4C, $0B, $0A -$60, $20, $09, $04, $A9, $FF, $2C, $11 -$04, $30, $02, $A9, $00, $4C, $09, $04 -$24, $3A, $91, $27, $10, $E1, $59, $C5 -$2A, $56, $10, $11, $2C, $8B, $4C, $45 -$D4, $A0, $80, $BD, $30, $BC, $E0, $13 -$1D, $94, $47, $CF, $88, $54, $CF, $30 -$BC, $E0, $10, $11, $16, $80, $53, $55 -$C2, $30, $BC, $E0, $14, $16, $90, $50 -$D2, $83, $49, $4E, $D4, $E5, $71, $88 -$BB, $E1, $1D, $8F, $A2, $21, $58, $6F -$83, $AC, $22, $55, $83, $BA, $24, $93 -$E0, $23, $1D, $30, $BC, $20, $48, $91 -$49, $C6, $30, $BC, $31, $34, $30, $BC -$84, $54, $48, $45, $CE, $1C, $1D, $38 -$0D, $9A, $49, $4E, $50, $55, $D4, $A0 -$10, $E7, $24, $3F, $20, $91, $27, $E1 -$59, $81, $AC, $30, $BC, $13, $11, $82 -$AC, $4D, $E0, $1D, $89, $52, $45, $54 -$55, $52, $CE, $E0, $15, $1D, $85, $45 -$4E, $C4, $E0, $2D, $98, $4C, $49, $53 -$D4, $EC, $24, $00, $00, $00, $00, $0A -$80, $1F, $24, $93, $23, $1D, $30, $BC -$E1, $50, $80, $AC, $59, $85, $52, $55 -$CE, $38, $0A, $86, $43, $4C, $45, $41 -$D2, $2B, $84, $52, $45, $CD, $1D, $A0 -$80, $BD, $38, $14, $85, $AD, $30, $D3 -$17, $64, $81, $AB, $30, $D3, $85, $AB -$30, $D3, $18, $5A, $85, $AD, $30, $D3 -$19, $54, $2F, $30, $E2, $85, $AA, $30 -$E2, $1A, $5A, $85, $AF, $30, $E2, $1B -$54, $2F, $98, $52, $4E, $C4, $0A, $80 -$80, $12, $0A, $09, $29, $1A, $0A, $1A -$85, $18, $13, $09, $80, $12, $01, $0B -$31, $30, $61, $72, $0B, $04, $02, $03 -$05, $03, $1B, $1A, $19, $0B, $09, $06 -$0A, $00, $00, $1C, $17, $2F, $8F, $55 -$53, $D2, $80, $A8, $30, $BC, $31, $2A -$31, $2A, $80, $A9, $2E, $2F, $A2, $12 -$2F, $C1, $2F, $80, $A8, $30, $BC, $80 -$A9, $2F, $83, $AC, $38, $BC, $0B, $2F -$80, $A8, $52, $2F, $84, $BD, $09, $02 -$2F, $8E, $BC, $84, $BD, $09, $93, $2F -$84, $BE, $09, $05, $2F, $09, $91, $2F -$80, $BE, $84, $BD, $09, $06, $2F, $84 -$BC, $09, $95, $2F, $09, $04, $2F, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$20, $0D, $0F, $A0, $00, $20, $1D, $0F -$20, $2C, $0F, $C9, $43, $D0, $03, $4C -$85, $04, $C9, $57, $D0, $03, $4C, $BD -$04, $A2, $2F, $20, $1D, $0F, $4C, $F8 -$0C, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$4D, $4B, $48, $42, $43, $2D, $38, $2D -$52, $32, $20, $54, $49, $4E, $59, $20 -$42, $41, $53, $49, $43, $20, $36, $35 -$30, $32, $20, $50, $4F, $52, $54, $0D -$0A, $56, $65, $72, $73, $69, $6F, $6E -$3A, $20, $31, $2E, $30, $2E, $33, $2C -$20, $32, $2F, $32, $30, $2F, $32, $30 -$31, $36, $0D, $0A, $28, $4E, $4F, $54 -$45, $3A, $20, $55, $73, $65, $20, $55 -$50, $50, $45, $52, $20, $43, $41, $53 -$45, $2E, $29, $0D, $0A, $42, $6F, $6F -$74, $20, $28, $5B, $43, $5D, $6F, $6C -$64, $2F, $5B, $57, $5D, $61, $72, $6D -$29, $3F, $20, $07, $FF, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$86, $C3, $B1, $C2, $48, $C8, $B1, $C2 -$AA, $68, $A8, $8A, $60, $A2, $19, $A9 -$0D, $20, $31, $0F, $A9, $0A, $20, $31 -$0F, $CA, $D0, $FA, $60, $B9, $00, $0E -$C9, $FF, $F0, $07, $20, $31, $0F, $C8 -$4C, $1D, $0F, $60, $AD, $00, $E0, $F0 -$FB, $85, $FE, $C9, $FF, $F0, $1E, $C9 -$00, $F0, $1A, $C9, $91, $F0, $16, $C9 -$93, $F0, $12, $C9, $80, $F0, $0E, $4C -$50, $0F, $20, $F0, $FF, $A5, $FE, $60 -$A5, $FE, $8D, $00, $E0, $60, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 +ADDR +$0CF0 +; Program disassembly from $0400 to $1000 2/20/2016 +; Tiny Basic port for VM6502 emulator. +; Exec address: $0CF0 +ORG +$0400 +; Enable ROM and IO emulation. +ENROM +ENIO +; Set char IO address +IOADDR +$E000 +; Code/Data +$4C, $85, $04, $4C, $BD, $04, $4C, $2C +$0F, $4C, $31, $0F, $EA, $18, $60, $5F +$18, $80, $00, $20, $86, $C3, $90, $05 +$86, $C3, $91, $C2, $60, $B1, $C2, $A0 +$00, $60, $62, $05, $64, $05, $D8, $05 +$05, $06, $33, $06, $FD, $05, $9F, $07 +$42, $0B, $3F, $0B, $7A, $07, $FC, $08 +$95, $07, $9F, $07, $9F, $07, $BD, $0A +$C1, $0A, $8A, $0A, $9B, $0A, $E9, $0A +$61, $07, $51, $07, $41, $0A, $52, $0A +$4F, $0A, $62, $0A, $E7, $09, $CD, $06 +$06, $07, $9F, $07, $15, $08, $A7, $07 +$B7, $06, $BF, $06, $83, $08, $A1, $06 +$9F, $07, $9F, $07, $A8, $08, $4F, $0B +$4D, $0B, $07, $09, $AA, $04, $37, $07 +$BD, $04, $1B, $0B, $B1, $0A, $20, $41 +$54, $20, $80, $70, $0B, $A9, $00, $85 +$20, $85, $22, $A9, $1C, $85, $21, $85 +$23, $A0, $01, $B1, $22, $AA, $49, $FF +$91, $22, $D1, $22, $08, $8A, $91, $22 +$E6, $22, $D0, $02, $E6, $23, $28, $F0 +$EA, $88, $D8, $A5, $20, $6D, $13, $04 +$85, $24, $98, $65, $21, $85, $25, $98 +$91, $20, $C8, $91, $20, $A5, $22, $85 +$C6, $85, $26, $A5, $23, $85, $C7, $85 +$27, $20, $87, $08, $AD, $83, $04, $85 +$2A, $AD, $84, $04, $85, $2B, $A9, $80 +$85, $C1, $A9, $30, $85, $C0, $A2, $00 +$86, $BE, $86, $C2, $CA, $9A, $D8, $20 +$F9, $06, $20, $F2, $04, $4C, $E6, $04 +$83, $65, $C9, $30, $B0, $7B, $C9, $08 +$90, $0C, $0A, $AA, $BD, $1F, $04, $48 +$BD, $1E, $04, $48, $08, $40, $65, $C1 +$AA, $B1, $C1, $48, $B5, $00, $91, $C1 +$68, $95, $00, $60, $20, $87, $08, $A9 +$21, $20, $09, $04, $A5, $2A, $38, $ED +$83, $04, $AA, $A5, $2B, $ED, $84, $04 +$20, $A0, $07, $A5, $BE, $F0, $12, $A9 +$7E, $85, $2A, $A9, $20, $85, $2B, $20 +$A1, $06, $A6, $28, $A5, $29, $20, $A0 +$07, $A9, $07, $20, $09, $04, $20, $87 +$08, $A5, $26, $85, $C6, $A5, $27, $85 +$C7, $4C, $CC, $04, $A2, $7C, $E4, $C1 +$90, $BA, $A6, $C1, $E6, $C1, $E6, $C1 +$18, $60, $C6, $BD, $A5, $BD, $F0, $AC +$A5, $BC, $85, $2A, $A5, $BD, $85, $2B +$60, $C9, $40, $B0, $43, $48, $20, $F9 +$06, $6D, $83, $04, $85, $BC, $68, $48 +$29, $07, $6D, $84, $04, $85, $BD, $68 +$29, $08, $D0, $DC, $A5, $BC, $A6, $2A +$85, $2A, $86, $BC, $A5, $BD, $A6, $2B +$85, $2B, $86, $BD, $A5, $C6, $E9, $01 +$85, $C6, $B0, $02, $C6, $C7, $C5, $24 +$A5, $C7, $E5, $25, $90, $AA, $A5, $BC +$91, $C6, $C8, $A5, $BD, $91, $C6, $60 +$48, $4A, $4A, $4A, $4A, $29, $0E, $AA +$68, $C9, $60, $29, $1F, $B0, $02, $09 +$E0, $18, $F0, $07, $65, $2A, $85, $BC +$98, $65, $2B, $85, $BD, $4C, $FC, $04 +$A5, $2C, $85, $B8, $A5, $2D, $85, $B9 +$20, $25, $06, $20, $14, $06, $51, $2A +$AA, $20, $F9, $06, $8A, $F0, $F1, $0A +$F0, $12, $A5, $B8, $85, $2C, $A5, $B9 +$85, $2D, $4C, $64, $05, $20, $25, $06 +$C9, $0D, $D0, $F6, $60, $20, $25, $06 +$C9, $5B, $B0, $EE, $C9, $41, $90, $EA +$0A, $20, $87, $07, $A0, $00, $B1, $2C +$E6, $2C, $D0, $02, $E6, $2D, $C9, $0D +$18, $60, $20, $14, $06, $B1, $2C, $C9 +$20, $F0, $F7, $C9, $3A, $18, $10, $02 +$C9, $30, $60, $20, $25, $06, $90, $C2 +$84, $BC, $84, $BD, $A5, $BC, $A6, $BD +$06, $BC, $26, $BD, $06, $BC, $26, $BD +$18, $65, $BC, $85, $BC, $8A, $65, $BD +$06, $BC, $2A, $85, $BD, $20, $14, $06 +$29, $0F, $65, $BC, $85, $BC, $98, $65 +$BD, $85, $BD, $20, $25, $06, $B0, $D4 +$4C, $80, $07, $20, $FC, $08, $A5, $BC +$05, $BD, $F0, $48, $A5, $20, $85, $2C +$A5, $21, $85, $2D, $20, $6D, $07, $F0 +$12, $A5, $28, $C5, $BC, $A5, $29, $E5 +$BD, $B0, $08, $20, $14, $06, $D0, $FB +$4C, $7C, $06, $A5, $28, $45, $BC, $D0 +$04, $A5, $29, $45, $BD, $60, $20, $A6 +$06, $20, $F9, $06, $10, $F8, $E6, $BF +$30, $03, $4C, $09, $04, $C6, $BF, $60 +$C9, $22, $F0, $FB, $20, $A6, $06, $20 +$14, $06, $D0, $F4, $4C, $14, $05, $A9 +$20, $20, $A6, $06, $A5, $BF, $29, $87 +$30, $E5, $D0, $F3, $60, $A2, $7B, $20 +$56, $05, $E6, $C1, $E6, $C1, $E6, $C1 +$38, $B5, $03, $F5, $00, $95, $00, $B5 +$04, $F5, $01, $50, $04, $49, $80, $09 +$01, $30, $0A, $D0, $04, $15, $00, $F0 +$02, $56, $02, $56, $02, $56, $02, $90 +$0C, $A0, $00, $B1, $2A, $E6, $2A, $D0 +$02, $E6, $2B, $09, $00, $60, $A5, $BE +$F0, $28, $20, $14, $06, $D0, $FB, $20 +$6D, $07, $F0, $1B, $20, $4C, $07, $20 +$0C, $04, $B0, $09, $A5, $C4, $85, $2A +$A5, $C5, $85, $2B, $60, $AD, $83, $04 +$85, $2A, $AD, $84, $04, $85, $2B, $4C +$14, $05, $85, $BF, $4C, $49, $05, $A5 +$20, $85, $2C, $A5, $21, $85, $2D, $20 +$6D, $07, $F0, $EB, $A5, $2A, $85, $C4 +$A5, $2B, $85, $C5, $A9, $01, $85, $BE +$60, $20, $6B, $06, $F0, $BE, $A5, $BC +$85, $28, $A5, $BD, $85, $29, $4C, $14 +$05, $20, $FD, $0A, $20, $FA, $0A, $20 +$74, $06, $D0, $EA, $60, $20, $14, $06 +$85, $28, $20, $14, $06, $85, $29, $05 +$28, $60, $20, $FC, $08, $20, $80, $07 +$A5, $BD, $20, $87, $07, $A5, $BC, $A6 +$C1, $CA, $95, $00, $86, $C1, $E4, $C0 +$D0, $0D, $4C, $14, $05, $A6, $C1, $E0 +$80, $10, $F7, $B5, $00, $E6, $C1, $60 +$85, $BD, $86, $BC, $4C, $B8, $07, $A6 +$C1, $B5, $01, $10, $08, $20, $41, $0A +$A9, $2D, $20, $A6, $06, $20, $FC, $08 +$A9, $1F, $85, $B8, $85, $BA, $A9, $2A +$85, $B9, $85, $BB, $A6, $BC, $A4, $BD +$38, $E6, $B8, $8A, $E9, $10, $AA, $98 +$E9, $27, $A8, $B0, $F4, $C6, $B9, $8A +$69, $E8, $AA, $98, $69, $03, $A8, $90 +$F4, $8A, $38, $E6, $BA, $E9, $64, $B0 +$F9, $88, $10, $F6, $C6, $BB, $69, $0A +$90, $FA, $09, $30, $85, $BC, $A9, $20 +$85, $BD, $A2, $FB, $86, $C3, $B5, $BD +$05, $BD, $C9, $20, $F0, $09, $A0, $30 +$84, $BD, $05, $BD, $20, $A6, $06, $A6 +$C3, $E8, $D0, $E8, $60, $A5, $2D, $48 +$A5, $2C, $48, $A5, $20, $85, $2C, $A5 +$21, $85, $2D, $A5, $24, $A6, $25, $20 +$5B, $08, $F0, $03, $20, $5B, $08, $A5 +$2C, $38, $E5, $B6, $A5, $2D, $E5, $B7 +$B0, $42, $20, $6D, $07, $F0, $3D, $A6 +$28, $A5, $29, $20, $A0, $07, $A9, $20 +$20, $A6, $06, $20, $0C, $04, $B0, $2C +$20, $14, $06, $D0, $F3, $20, $83, $08 +$4C, $2F, $08, $85, $B6, $E6, $B6, $D0 +$01, $E8, $86, $B7, $A4, $C1, $C0, $80 +$F0, $18, $20, $6B, $06, $A5, $2C, $A6 +$2D, $38, $E9, $02, $B0, $01, $CA, $85 +$2C, $4C, $48, $0B, $68, $85, $2C, $68 +$85, $2D, $60, $A5, $BF, $30, $FB, $A9 +$0D, $20, $09, $04, $AD, $11, $04, $29 +$7F, $85, $BF, $F0, $07, $20, $64, $0B +$C6, $BF, $D0, $F9, $A9, $0A, $4C, $61 +$0B, $AC, $12, $04, $84, $BF, $B0, $0B +$A9, $30, $85, $2C, $85, $C0, $84, $2D +$20, $80, $07, $45, $80, $85, $80, $20 +$06, $04, $A0, $00, $A6, $C0, $29, $7F +$F0, $F1, $C9, $7F, $F0, $ED, $C9, $13 +$F0, $DA, $C9, $0A, $F0, $D3, $CD, $10 +$04, $F0, $09, $CD, $0F, $04, $D0, $0A +$E0, $30, $D0, $16, $A6, $2C, $84, $BF +$A9, $0D, $E4, $C1, $30, $08, $A9, $07 +$20, $A6, $06, $4C, $B3, $08, $95, $00 +$E8, $E8, $CA, $86, $C0, $C9, $0D, $D0 +$BA, $20, $83, $08, $20, $95, $07, $85 +$BC, $20, $95, $07, $85, $BD, $60, $20 +$D6, $0A, $20, $6B, $06, $08, $20, $6D +$08, $85, $B8, $86, $B9, $A5, $BC, $85 +$B6, $A5, $BD, $85, $B7, $A2, $00, $28 +$D0, $0B, $20, $6D, $07, $CA, $CA, $CA +$20, $14, $06, $D0, $FA, $84, $28, $84 +$29, $20, $D6, $0A, $A9, $0D, $D1, $2C +$F0, $11, $E8, $E8, $E8, $E8, $C8, $D1 +$2C, $D0, $FA, $A5, $B6, $85, $28, $A5 +$B7, $85, $29, $A5, $B8, $85, $BC, $A5 +$B9, $85, $BD, $18, $A0, $00, $8A, $F0 +$6E, $10, $29, $65, $2E, $85, $B8, $A5 +$2F, $E9, $00, $85, $B9, $B1, $2E, $91 +$B8, $A6, $2E, $E4, $24, $D0, $06, $A5 +$2F, $C5, $25, $F0, $4A, $E8, $86, $2E +$D0, $02, $E6, $2F, $E6, $B8, $D0, $E5 +$E6, $B9, $D0, $E1, $65, $24, $85, $B8 +$85, $2E, $98, $65, $25, $85, $B9, $85 +$2F, $A5, $2E, $E5, $C6, $A5, $2F, $E5 +$C7, $90, $05, $C6, $2A, $4C, $14, $05 +$B1, $24, $91, $2E, $A6, $24, $D0, $02 +$C6, $25, $C6, $24, $A6, $2E, $D0, $02 +$C6, $2F, $CA, $86, $2E, $E4, $BC, $D0 +$E7, $A6, $2F, $E4, $BD, $D0, $E1, $A5 +$B8, $85, $24, $A5, $B9, $85, $25, $A5 +$28, $05, $29, $F0, $17, $A5, $28, $91 +$BC, $C8, $A5, $29, $91, $BC, $C8, $84 +$B6, $20, $14, $06, $08, $A4, $B6, $91 +$BC, $28, $D0, $F2, $4C, $CC, $04, $20 +$54, $05, $B5, $03, $29, $80, $F0, $02 +$A9, $FF, $85, $BC, $85, $BD, $48, $75 +$02, $95, $02, $68, $48, $75, $03, $95 +$03, $68, $55, $01, $85, $BB, $10, $03 +$20, $43, $0A, $A0, $11, $B5, $00, $15 +$01, $D0, $03, $4C, $14, $05, $38, $A5 +$BC, $F5, $00, $48, $A5, $BD, $F5, $01 +$48, $45, $BD, $30, $0A, $68, $85, $BD +$68, $85, $BC, $38, $4C, $32, $0A, $68 +$68, $18, $36, $02, $36, $03, $26, $BC +$26, $BD, $88, $D0, $D9, $A5, $BB, $10 +$0D, $A6, $C1, $38, $98, $F5, $00, $95 +$00, $98, $F5, $01, $95, $01, $60, $20 +$41, $0A, $20, $54, $05, $B5, $00, $75 +$02, $95, $02, $B5, $01, $75, $03, $95 +$03, $60, $20, $54, $05, $A0, $10, $B5 +$02, $85, $BC, $B5, $03, $85, $BD, $16 +$02, $36, $03, $26, $BC, $26, $BD, $90 +$0D, $18, $B5, $02, $75, $00, $95, $02 +$B5, $03, $75, $01, $95, $03, $88, $D0 +$E6, $60, $20, $95, $07, $AA, $B5, $00 +$B4, $01, $C6, $C1, $A6, $C1, $94, $00 +$4C, $87, $07, $A2, $7D, $20, $56, $05 +$B5, $01, $48, $B5, $00, $48, $20, $95 +$07, $AA, $68, $95, $00, $68, $95, $01 +$60, $20, $FD, $0A, $A5, $BC, $85, $2A +$A5, $BD, $85, $2B, $60, $A2, $2C, $D0 +$02, $A2, $2E, $B5, $00, $C9, $80, $B0 +$0D, $B5, $01, $D0, $09, $A5, $2C, $85 +$2E, $A5, $2D, $85, $2F, $60, $A5, $2C +$A4, $2E, $84, $2C, $85, $2E, $A5, $2D +$A4, $2F, $84, $2D, $85, $2F, $A0, $00 +$60, $A5, $28, $85, $BC, $A5, $29, $85 +$BD, $20, $9C, $05, $A5, $C6, $85, $26 +$A5, $C7, $85, $27, $60, $B1, $C6, $85 +$BC, $20, $08, $0B, $B1, $C6, $85, $BD +$E6, $C6, $D0, $02, $E6, $C7, $A5, $22 +$C5, $C6, $A5, $23, $E5, $C7, $B0, $E4 +$4C, $14, $05, $20, $24, $0B, $85, $BC +$98, $4C, $82, $07, $20, $FC, $08, $A5 +$BC, $85, $B6, $20, $FC, $08, $A5, $BD +$85, $B7, $A4, $BC, $20, $FC, $08, $A6 +$B7, $A5, $B6, $18, $6C, $BC, $00, $20 +$42, $0B, $20, $F9, $06, $4C, $87, $07 +$86, $2D, $E0, $00, $60, $A0, $02, $84 +$BC, $A0, $29, $84, $BD, $A0, $00, $B1 +$BC, $C9, $08, $D0, $03, $4C, $0B, $0A +$60, $20, $09, $04, $A9, $FF, $2C, $11 +$04, $30, $02, $A9, $00, $4C, $09, $04 +$24, $3A, $91, $27, $10, $E1, $59, $C5 +$2A, $56, $10, $11, $2C, $8B, $4C, $45 +$D4, $A0, $80, $BD, $30, $BC, $E0, $13 +$1D, $94, $47, $CF, $88, $54, $CF, $30 +$BC, $E0, $10, $11, $16, $80, $53, $55 +$C2, $30, $BC, $E0, $14, $16, $90, $50 +$D2, $83, $49, $4E, $D4, $E5, $71, $88 +$BB, $E1, $1D, $8F, $A2, $21, $58, $6F +$83, $AC, $22, $55, $83, $BA, $24, $93 +$E0, $23, $1D, $30, $BC, $20, $48, $91 +$49, $C6, $30, $BC, $31, $34, $30, $BC +$84, $54, $48, $45, $CE, $1C, $1D, $38 +$0D, $9A, $49, $4E, $50, $55, $D4, $A0 +$10, $E7, $24, $3F, $20, $91, $27, $E1 +$59, $81, $AC, $30, $BC, $13, $11, $82 +$AC, $4D, $E0, $1D, $89, $52, $45, $54 +$55, $52, $CE, $E0, $15, $1D, $85, $45 +$4E, $C4, $E0, $2D, $98, $4C, $49, $53 +$D4, $EC, $24, $00, $00, $00, $00, $0A +$80, $1F, $24, $93, $23, $1D, $30, $BC +$E1, $50, $80, $AC, $59, $85, $52, $55 +$CE, $38, $0A, $86, $43, $4C, $45, $41 +$D2, $2B, $84, $52, $45, $CD, $1D, $A0 +$80, $BD, $38, $14, $85, $AD, $30, $D3 +$17, $64, $81, $AB, $30, $D3, $85, $AB +$30, $D3, $18, $5A, $85, $AD, $30, $D3 +$19, $54, $2F, $30, $E2, $85, $AA, $30 +$E2, $1A, $5A, $85, $AF, $30, $E2, $1B +$54, $2F, $98, $52, $4E, $C4, $0A, $80 +$80, $12, $0A, $09, $29, $1A, $0A, $1A +$85, $18, $13, $09, $80, $12, $01, $0B +$31, $30, $61, $72, $0B, $04, $02, $03 +$05, $03, $1B, $1A, $19, $0B, $09, $06 +$0A, $00, $00, $1C, $17, $2F, $8F, $55 +$53, $D2, $80, $A8, $30, $BC, $31, $2A +$31, $2A, $80, $A9, $2E, $2F, $A2, $12 +$2F, $C1, $2F, $80, $A8, $30, $BC, $80 +$A9, $2F, $83, $AC, $38, $BC, $0B, $2F +$80, $A8, $52, $2F, $84, $BD, $09, $02 +$2F, $8E, $BC, $84, $BD, $09, $93, $2F +$84, $BE, $09, $05, $2F, $09, $91, $2F +$80, $BE, $84, $BD, $09, $06, $2F, $84 +$BC, $09, $95, $2F, $09, $04, $2F, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$20, $0D, $0F, $A0, $00, $20, $1D, $0F +$20, $2C, $0F, $C9, $43, $D0, $03, $4C +$85, $04, $C9, $57, $D0, $03, $4C, $BD +$04, $A2, $2F, $20, $1D, $0F, $4C, $F8 +$0C, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$4D, $4B, $48, $42, $43, $2D, $38, $2D +$52, $32, $20, $54, $49, $4E, $59, $20 +$42, $41, $53, $49, $43, $20, $36, $35 +$30, $32, $20, $50, $4F, $52, $54, $0D +$0A, $56, $65, $72, $73, $69, $6F, $6E +$3A, $20, $31, $2E, $30, $2E, $33, $2C +$20, $32, $2F, $32, $30, $2F, $32, $30 +$31, $36, $0D, $0A, $28, $4E, $4F, $54 +$45, $3A, $20, $55, $73, $65, $20, $55 +$50, $50, $45, $52, $20, $43, $41, $53 +$45, $2E, $29, $0D, $0A, $42, $6F, $6F +$74, $20, $28, $5B, $43, $5D, $6F, $6C +$64, $2F, $5B, $57, $5D, $61, $72, $6D +$29, $3F, $20, $07, $FF, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$86, $C3, $B1, $C2, $48, $C8, $B1, $C2 +$AA, $68, $A8, $8A, $60, $A2, $19, $A9 +$0D, $20, $31, $0F, $A9, $0A, $20, $31 +$0F, $CA, $D0, $FA, $60, $B9, $00, $0E +$C9, $FF, $F0, $07, $20, $31, $0F, $C8 +$4C, $1D, $0F, $60, $AD, $00, $E0, $F0 +$FB, $85, $FE, $C9, $FF, $F0, $1E, $C9 +$00, $F0, $1A, $C9, $91, $F0, $16, $C9 +$93, $F0, $12, $C9, $80, $F0, $0E, $4C +$50, $0F, $20, $F0, $FF, $A5, $FE, $60 +$A5, $FE, $8D, $00, $E0, $60, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 diff --git a/tbe.dat b/tbe.dat index 1669f0b..ae6c60a 100644 --- a/tbe.dat +++ b/tbe.dat @@ -1,423 +1,423 @@ -ADDR -$0CF0 -; Program disassembly from $0400 to $1000 2/20/2016 -; Tiny Basic port for VM6502 emulator. -; Exec address: $0CF0 -;------------------------------------------------------ -ORG -$0400 -;------------------------------------------------------ -; Character I/O emulation address. -;------------------------------------------------------ -IOADDR -$E000 -;------------------------------------------------------ -; Enable character I/O emulation. -;------------------------------------------------------ -ENIO -;------------------------------------------------------ -; Begin of ROM. -;------------------------------------------------------ -ROMBEGIN -$DF00 -;------------------------------------------------------ -; End of ROM. -;------------------------------------------------------ -ROMEND -$FFFF -;------------------------------------------------------ -; Enable ROM (protected read-only memory) emulation. -;------------------------------------------------------ -ENROM -;------------------------------------------------------ -; Auto-execute code from address. -;------------------------------------------------------ -EXEC -$0CF0 -;------------------------------------------------------ -; Code/Data -;------------------------------------------------------ -$4C, $85, $04, $4C, $BD, $04, $4C, $2C -$0F, $4C, $31, $0F, $EA, $18, $60, $5F -$18, $80, $00, $20, $86, $C3, $90, $05 -$86, $C3, $91, $C2, $60, $B1, $C2, $A0 -$00, $60, $62, $05, $64, $05, $D8, $05 -$05, $06, $33, $06, $FD, $05, $9F, $07 -$42, $0B, $3F, $0B, $7A, $07, $FC, $08 -$95, $07, $9F, $07, $9F, $07, $BD, $0A -$C1, $0A, $8A, $0A, $9B, $0A, $E9, $0A -$61, $07, $51, $07, $41, $0A, $52, $0A -$4F, $0A, $62, $0A, $E7, $09, $CD, $06 -$06, $07, $9F, $07, $15, $08, $A7, $07 -$B7, $06, $BF, $06, $83, $08, $A1, $06 -$9F, $07, $9F, $07, $A8, $08, $4F, $0B -$4D, $0B, $07, $09, $AA, $04, $37, $07 -$BD, $04, $1B, $0B, $B1, $0A, $20, $41 -$54, $20, $80, $70, $0B, $A9, $00, $85 -$20, $85, $22, $A9, $1C, $85, $21, $85 -$23, $A0, $01, $B1, $22, $AA, $49, $FF -$91, $22, $D1, $22, $08, $8A, $91, $22 -$E6, $22, $D0, $02, $E6, $23, $28, $F0 -$EA, $88, $D8, $A5, $20, $6D, $13, $04 -$85, $24, $98, $65, $21, $85, $25, $98 -$91, $20, $C8, $91, $20, $A5, $22, $85 -$C6, $85, $26, $A5, $23, $85, $C7, $85 -$27, $20, $87, $08, $AD, $83, $04, $85 -$2A, $AD, $84, $04, $85, $2B, $A9, $80 -$85, $C1, $A9, $30, $85, $C0, $A2, $00 -$86, $BE, $86, $C2, $CA, $9A, $D8, $20 -$F9, $06, $20, $F2, $04, $4C, $E6, $04 -$83, $65, $C9, $30, $B0, $7B, $C9, $08 -$90, $0C, $0A, $AA, $BD, $1F, $04, $48 -$BD, $1E, $04, $48, $08, $40, $65, $C1 -$AA, $B1, $C1, $48, $B5, $00, $91, $C1 -$68, $95, $00, $60, $20, $87, $08, $A9 -$21, $20, $09, $04, $A5, $2A, $38, $ED -$83, $04, $AA, $A5, $2B, $ED, $84, $04 -$20, $A0, $07, $A5, $BE, $F0, $12, $A9 -$7E, $85, $2A, $A9, $20, $85, $2B, $20 -$A1, $06, $A6, $28, $A5, $29, $20, $A0 -$07, $A9, $07, $20, $09, $04, $20, $87 -$08, $A5, $26, $85, $C6, $A5, $27, $85 -$C7, $4C, $CC, $04, $A2, $7C, $E4, $C1 -$90, $BA, $A6, $C1, $E6, $C1, $E6, $C1 -$18, $60, $C6, $BD, $A5, $BD, $F0, $AC -$A5, $BC, $85, $2A, $A5, $BD, $85, $2B -$60, $C9, $40, $B0, $43, $48, $20, $F9 -$06, $6D, $83, $04, $85, $BC, $68, $48 -$29, $07, $6D, $84, $04, $85, $BD, $68 -$29, $08, $D0, $DC, $A5, $BC, $A6, $2A -$85, $2A, $86, $BC, $A5, $BD, $A6, $2B -$85, $2B, $86, $BD, $A5, $C6, $E9, $01 -$85, $C6, $B0, $02, $C6, $C7, $C5, $24 -$A5, $C7, $E5, $25, $90, $AA, $A5, $BC -$91, $C6, $C8, $A5, $BD, $91, $C6, $60 -$48, $4A, $4A, $4A, $4A, $29, $0E, $AA -$68, $C9, $60, $29, $1F, $B0, $02, $09 -$E0, $18, $F0, $07, $65, $2A, $85, $BC -$98, $65, $2B, $85, $BD, $4C, $FC, $04 -$A5, $2C, $85, $B8, $A5, $2D, $85, $B9 -$20, $25, $06, $20, $14, $06, $51, $2A -$AA, $20, $F9, $06, $8A, $F0, $F1, $0A -$F0, $12, $A5, $B8, $85, $2C, $A5, $B9 -$85, $2D, $4C, $64, $05, $20, $25, $06 -$C9, $0D, $D0, $F6, $60, $20, $25, $06 -$C9, $5B, $B0, $EE, $C9, $41, $90, $EA -$0A, $20, $87, $07, $A0, $00, $B1, $2C -$E6, $2C, $D0, $02, $E6, $2D, $C9, $0D -$18, $60, $20, $14, $06, $B1, $2C, $C9 -$20, $F0, $F7, $C9, $3A, $18, $10, $02 -$C9, $30, $60, $20, $25, $06, $90, $C2 -$84, $BC, $84, $BD, $A5, $BC, $A6, $BD -$06, $BC, $26, $BD, $06, $BC, $26, $BD -$18, $65, $BC, $85, $BC, $8A, $65, $BD -$06, $BC, $2A, $85, $BD, $20, $14, $06 -$29, $0F, $65, $BC, $85, $BC, $98, $65 -$BD, $85, $BD, $20, $25, $06, $B0, $D4 -$4C, $80, $07, $20, $FC, $08, $A5, $BC -$05, $BD, $F0, $48, $A5, $20, $85, $2C -$A5, $21, $85, $2D, $20, $6D, $07, $F0 -$12, $A5, $28, $C5, $BC, $A5, $29, $E5 -$BD, $B0, $08, $20, $14, $06, $D0, $FB -$4C, $7C, $06, $A5, $28, $45, $BC, $D0 -$04, $A5, $29, $45, $BD, $60, $20, $A6 -$06, $20, $F9, $06, $10, $F8, $E6, $BF -$30, $03, $4C, $09, $04, $C6, $BF, $60 -$C9, $22, $F0, $FB, $20, $A6, $06, $20 -$14, $06, $D0, $F4, $4C, $14, $05, $A9 -$20, $20, $A6, $06, $A5, $BF, $29, $87 -$30, $E5, $D0, $F3, $60, $A2, $7B, $20 -$56, $05, $E6, $C1, $E6, $C1, $E6, $C1 -$38, $B5, $03, $F5, $00, $95, $00, $B5 -$04, $F5, $01, $50, $04, $49, $80, $09 -$01, $30, $0A, $D0, $04, $15, $00, $F0 -$02, $56, $02, $56, $02, $56, $02, $90 -$0C, $A0, $00, $B1, $2A, $E6, $2A, $D0 -$02, $E6, $2B, $09, $00, $60, $A5, $BE -$F0, $28, $20, $14, $06, $D0, $FB, $20 -$6D, $07, $F0, $1B, $20, $4C, $07, $20 -$0C, $04, $B0, $09, $A5, $C4, $85, $2A -$A5, $C5, $85, $2B, $60, $AD, $83, $04 -$85, $2A, $AD, $84, $04, $85, $2B, $4C -$14, $05, $85, $BF, $4C, $49, $05, $A5 -$20, $85, $2C, $A5, $21, $85, $2D, $20 -$6D, $07, $F0, $EB, $A5, $2A, $85, $C4 -$A5, $2B, $85, $C5, $A9, $01, $85, $BE -$60, $20, $6B, $06, $F0, $BE, $A5, $BC -$85, $28, $A5, $BD, $85, $29, $4C, $14 -$05, $20, $FD, $0A, $20, $FA, $0A, $20 -$74, $06, $D0, $EA, $60, $20, $14, $06 -$85, $28, $20, $14, $06, $85, $29, $05 -$28, $60, $20, $FC, $08, $20, $80, $07 -$A5, $BD, $20, $87, $07, $A5, $BC, $A6 -$C1, $CA, $95, $00, $86, $C1, $E4, $C0 -$D0, $0D, $4C, $14, $05, $A6, $C1, $E0 -$80, $10, $F7, $B5, $00, $E6, $C1, $60 -$85, $BD, $86, $BC, $4C, $B8, $07, $A6 -$C1, $B5, $01, $10, $08, $20, $41, $0A -$A9, $2D, $20, $A6, $06, $20, $FC, $08 -$A9, $1F, $85, $B8, $85, $BA, $A9, $2A -$85, $B9, $85, $BB, $A6, $BC, $A4, $BD -$38, $E6, $B8, $8A, $E9, $10, $AA, $98 -$E9, $27, $A8, $B0, $F4, $C6, $B9, $8A -$69, $E8, $AA, $98, $69, $03, $A8, $90 -$F4, $8A, $38, $E6, $BA, $E9, $64, $B0 -$F9, $88, $10, $F6, $C6, $BB, $69, $0A -$90, $FA, $09, $30, $85, $BC, $A9, $20 -$85, $BD, $A2, $FB, $86, $C3, $B5, $BD -$05, $BD, $C9, $20, $F0, $09, $A0, $30 -$84, $BD, $05, $BD, $20, $A6, $06, $A6 -$C3, $E8, $D0, $E8, $60, $A5, $2D, $48 -$A5, $2C, $48, $A5, $20, $85, $2C, $A5 -$21, $85, $2D, $A5, $24, $A6, $25, $20 -$5B, $08, $F0, $03, $20, $5B, $08, $A5 -$2C, $38, $E5, $B6, $A5, $2D, $E5, $B7 -$B0, $42, $20, $6D, $07, $F0, $3D, $A6 -$28, $A5, $29, $20, $A0, $07, $A9, $20 -$20, $A6, $06, $20, $0C, $04, $B0, $2C -$20, $14, $06, $D0, $F3, $20, $83, $08 -$4C, $2F, $08, $85, $B6, $E6, $B6, $D0 -$01, $E8, $86, $B7, $A4, $C1, $C0, $80 -$F0, $18, $20, $6B, $06, $A5, $2C, $A6 -$2D, $38, $E9, $02, $B0, $01, $CA, $85 -$2C, $4C, $48, $0B, $68, $85, $2C, $68 -$85, $2D, $60, $A5, $BF, $30, $FB, $A9 -$0D, $20, $09, $04, $AD, $11, $04, $29 -$7F, $85, $BF, $F0, $07, $20, $64, $0B -$C6, $BF, $D0, $F9, $A9, $0A, $4C, $61 -$0B, $AC, $12, $04, $84, $BF, $B0, $0B -$A9, $30, $85, $2C, $85, $C0, $84, $2D -$20, $80, $07, $45, $80, $85, $80, $20 -$06, $04, $A0, $00, $A6, $C0, $29, $7F -$F0, $F1, $C9, $7F, $F0, $ED, $C9, $13 -$F0, $DA, $C9, $0A, $F0, $D3, $CD, $10 -$04, $F0, $09, $CD, $0F, $04, $D0, $0A -$E0, $30, $D0, $16, $A6, $2C, $84, $BF -$A9, $0D, $E4, $C1, $30, $08, $A9, $07 -$20, $A6, $06, $4C, $B3, $08, $95, $00 -$E8, $E8, $CA, $86, $C0, $C9, $0D, $D0 -$BA, $20, $83, $08, $20, $95, $07, $85 -$BC, $20, $95, $07, $85, $BD, $60, $20 -$D6, $0A, $20, $6B, $06, $08, $20, $6D -$08, $85, $B8, $86, $B9, $A5, $BC, $85 -$B6, $A5, $BD, $85, $B7, $A2, $00, $28 -$D0, $0B, $20, $6D, $07, $CA, $CA, $CA -$20, $14, $06, $D0, $FA, $84, $28, $84 -$29, $20, $D6, $0A, $A9, $0D, $D1, $2C -$F0, $11, $E8, $E8, $E8, $E8, $C8, $D1 -$2C, $D0, $FA, $A5, $B6, $85, $28, $A5 -$B7, $85, $29, $A5, $B8, $85, $BC, $A5 -$B9, $85, $BD, $18, $A0, $00, $8A, $F0 -$6E, $10, $29, $65, $2E, $85, $B8, $A5 -$2F, $E9, $00, $85, $B9, $B1, $2E, $91 -$B8, $A6, $2E, $E4, $24, $D0, $06, $A5 -$2F, $C5, $25, $F0, $4A, $E8, $86, $2E -$D0, $02, $E6, $2F, $E6, $B8, $D0, $E5 -$E6, $B9, $D0, $E1, $65, $24, $85, $B8 -$85, $2E, $98, $65, $25, $85, $B9, $85 -$2F, $A5, $2E, $E5, $C6, $A5, $2F, $E5 -$C7, $90, $05, $C6, $2A, $4C, $14, $05 -$B1, $24, $91, $2E, $A6, $24, $D0, $02 -$C6, $25, $C6, $24, $A6, $2E, $D0, $02 -$C6, $2F, $CA, $86, $2E, $E4, $BC, $D0 -$E7, $A6, $2F, $E4, $BD, $D0, $E1, $A5 -$B8, $85, $24, $A5, $B9, $85, $25, $A5 -$28, $05, $29, $F0, $17, $A5, $28, $91 -$BC, $C8, $A5, $29, $91, $BC, $C8, $84 -$B6, $20, $14, $06, $08, $A4, $B6, $91 -$BC, $28, $D0, $F2, $4C, $CC, $04, $20 -$54, $05, $B5, $03, $29, $80, $F0, $02 -$A9, $FF, $85, $BC, $85, $BD, $48, $75 -$02, $95, $02, $68, $48, $75, $03, $95 -$03, $68, $55, $01, $85, $BB, $10, $03 -$20, $43, $0A, $A0, $11, $B5, $00, $15 -$01, $D0, $03, $4C, $14, $05, $38, $A5 -$BC, $F5, $00, $48, $A5, $BD, $F5, $01 -$48, $45, $BD, $30, $0A, $68, $85, $BD -$68, $85, $BC, $38, $4C, $32, $0A, $68 -$68, $18, $36, $02, $36, $03, $26, $BC -$26, $BD, $88, $D0, $D9, $A5, $BB, $10 -$0D, $A6, $C1, $38, $98, $F5, $00, $95 -$00, $98, $F5, $01, $95, $01, $60, $20 -$41, $0A, $20, $54, $05, $B5, $00, $75 -$02, $95, $02, $B5, $01, $75, $03, $95 -$03, $60, $20, $54, $05, $A0, $10, $B5 -$02, $85, $BC, $B5, $03, $85, $BD, $16 -$02, $36, $03, $26, $BC, $26, $BD, $90 -$0D, $18, $B5, $02, $75, $00, $95, $02 -$B5, $03, $75, $01, $95, $03, $88, $D0 -$E6, $60, $20, $95, $07, $AA, $B5, $00 -$B4, $01, $C6, $C1, $A6, $C1, $94, $00 -$4C, $87, $07, $A2, $7D, $20, $56, $05 -$B5, $01, $48, $B5, $00, $48, $20, $95 -$07, $AA, $68, $95, $00, $68, $95, $01 -$60, $20, $FD, $0A, $A5, $BC, $85, $2A -$A5, $BD, $85, $2B, $60, $A2, $2C, $D0 -$02, $A2, $2E, $B5, $00, $C9, $80, $B0 -$0D, $B5, $01, $D0, $09, $A5, $2C, $85 -$2E, $A5, $2D, $85, $2F, $60, $A5, $2C -$A4, $2E, $84, $2C, $85, $2E, $A5, $2D -$A4, $2F, $84, $2D, $85, $2F, $A0, $00 -$60, $A5, $28, $85, $BC, $A5, $29, $85 -$BD, $20, $9C, $05, $A5, $C6, $85, $26 -$A5, $C7, $85, $27, $60, $B1, $C6, $85 -$BC, $20, $08, $0B, $B1, $C6, $85, $BD -$E6, $C6, $D0, $02, $E6, $C7, $A5, $22 -$C5, $C6, $A5, $23, $E5, $C7, $B0, $E4 -$4C, $14, $05, $20, $24, $0B, $85, $BC -$98, $4C, $82, $07, $20, $FC, $08, $A5 -$BC, $85, $B6, $20, $FC, $08, $A5, $BD -$85, $B7, $A4, $BC, $20, $FC, $08, $A6 -$B7, $A5, $B6, $18, $6C, $BC, $00, $20 -$42, $0B, $20, $F9, $06, $4C, $87, $07 -$86, $2D, $E0, $00, $60, $A0, $02, $84 -$BC, $A0, $29, $84, $BD, $A0, $00, $B1 -$BC, $C9, $08, $D0, $03, $4C, $0B, $0A -$60, $20, $09, $04, $A9, $FF, $2C, $11 -$04, $30, $02, $A9, $00, $4C, $09, $04 -$24, $3A, $91, $27, $10, $E1, $59, $C5 -$2A, $56, $10, $11, $2C, $8B, $4C, $45 -$D4, $A0, $80, $BD, $30, $BC, $E0, $13 -$1D, $94, $47, $CF, $88, $54, $CF, $30 -$BC, $E0, $10, $11, $16, $80, $53, $55 -$C2, $30, $BC, $E0, $14, $16, $90, $50 -$D2, $83, $49, $4E, $D4, $E5, $71, $88 -$BB, $E1, $1D, $8F, $A2, $21, $58, $6F -$83, $AC, $22, $55, $83, $BA, $24, $93 -$E0, $23, $1D, $30, $BC, $20, $48, $91 -$49, $C6, $30, $BC, $31, $34, $30, $BC -$84, $54, $48, $45, $CE, $1C, $1D, $38 -$0D, $9A, $49, $4E, $50, $55, $D4, $A0 -$10, $E7, $24, $3F, $20, $91, $27, $E1 -$59, $81, $AC, $30, $BC, $13, $11, $82 -$AC, $4D, $E0, $1D, $89, $52, $45, $54 -$55, $52, $CE, $E0, $15, $1D, $85, $45 -$4E, $C4, $E0, $2D, $98, $4C, $49, $53 -$D4, $EC, $24, $00, $00, $00, $00, $0A -$80, $1F, $24, $93, $23, $1D, $30, $BC -$E1, $50, $80, $AC, $59, $85, $52, $55 -$CE, $38, $0A, $86, $43, $4C, $45, $41 -$D2, $2B, $84, $52, $45, $CD, $1D, $A0 -$80, $BD, $38, $14, $85, $AD, $30, $D3 -$17, $64, $81, $AB, $30, $D3, $85, $AB -$30, $D3, $18, $5A, $85, $AD, $30, $D3 -$19, $54, $2F, $30, $E2, $85, $AA, $30 -$E2, $1A, $5A, $85, $AF, $30, $E2, $1B -$54, $2F, $98, $52, $4E, $C4, $0A, $80 -$80, $12, $0A, $09, $29, $1A, $0A, $1A -$85, $18, $13, $09, $80, $12, $01, $0B -$31, $30, $61, $72, $0B, $04, $02, $03 -$05, $03, $1B, $1A, $19, $0B, $09, $06 -$0A, $00, $00, $1C, $17, $2F, $8F, $55 -$53, $D2, $80, $A8, $30, $BC, $31, $2A -$31, $2A, $80, $A9, $2E, $2F, $A2, $12 -$2F, $C1, $2F, $80, $A8, $30, $BC, $80 -$A9, $2F, $83, $AC, $38, $BC, $0B, $2F -$80, $A8, $52, $2F, $84, $BD, $09, $02 -$2F, $8E, $BC, $84, $BD, $09, $93, $2F -$84, $BE, $09, $05, $2F, $09, $91, $2F -$80, $BE, $84, $BD, $09, $06, $2F, $84 -$BC, $09, $95, $2F, $09, $04, $2F, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$20, $0D, $0F, $A0, $00, $20, $1D, $0F -$20, $2C, $0F, $C9, $43, $D0, $03, $4C -$85, $04, $C9, $57, $D0, $03, $4C, $BD -$04, $A2, $2F, $20, $1D, $0F, $4C, $F8 -$0C, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$4D, $4B, $48, $42, $43, $2D, $38, $2D -$52, $32, $20, $54, $49, $4E, $59, $20 -$42, $41, $53, $49, $43, $20, $36, $35 -$30, $32, $20, $50, $4F, $52, $54, $0D -$0A, $56, $65, $72, $73, $69, $6F, $6E -$3A, $20, $31, $2E, $30, $2E, $33, $2C -$20, $32, $2F, $32, $30, $2F, $32, $30 -$31, $36, $0D, $0A, $28, $4E, $4F, $54 -$45, $3A, $20, $55, $73, $65, $20, $55 -$50, $50, $45, $52, $20, $43, $41, $53 -$45, $2E, $29, $0D, $0A, $42, $6F, $6F -$74, $20, $28, $5B, $43, $5D, $6F, $6C -$64, $2F, $5B, $57, $5D, $61, $72, $6D -$29, $3F, $20, $07, $FF, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$86, $C3, $B1, $C2, $48, $C8, $B1, $C2 -$AA, $68, $A8, $8A, $60, $A2, $19, $A9 -$0D, $20, $31, $0F, $A9, $0A, $20, $31 -$0F, $CA, $D0, $FA, $60, $B9, $00, $0E -$C9, $FF, $F0, $07, $20, $31, $0F, $C8 -$4C, $1D, $0F, $60, $AD, $00, $E0, $F0 -$FB, $85, $FE, $C9, $FF, $F0, $1E, $C9 -$00, $F0, $1A, $C9, $91, $F0, $16, $C9 -$93, $F0, $12, $C9, $80, $F0, $0E, $4C -$50, $0F, $20, $F0, $FF, $A5, $FE, $60 -$A5, $FE, $8D, $00, $E0, $60, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 -$00, $00, $00, $00, $00, $00, $00, $00 +ADDR +$0CF0 +; Program disassembly from $0400 to $1000 2/20/2016 +; Tiny Basic port for VM6502 emulator. +; Exec address: $0CF0 +;------------------------------------------------------ +ORG +$0400 +;------------------------------------------------------ +; Character I/O emulation address. +;------------------------------------------------------ +IOADDR +$E000 +;------------------------------------------------------ +; Enable character I/O emulation. +;------------------------------------------------------ +ENIO +;------------------------------------------------------ +; Begin of ROM. +;------------------------------------------------------ +ROMBEGIN +$DF00 +;------------------------------------------------------ +; End of ROM. +;------------------------------------------------------ +ROMEND +$FFFF +;------------------------------------------------------ +; Enable ROM (protected read-only memory) emulation. +;------------------------------------------------------ +ENROM +;------------------------------------------------------ +; Auto-execute code from address. +;------------------------------------------------------ +EXEC +$0CF0 +;------------------------------------------------------ +; Code/Data +;------------------------------------------------------ +$4C, $85, $04, $4C, $BD, $04, $4C, $2C +$0F, $4C, $31, $0F, $EA, $18, $60, $5F +$18, $80, $00, $20, $86, $C3, $90, $05 +$86, $C3, $91, $C2, $60, $B1, $C2, $A0 +$00, $60, $62, $05, $64, $05, $D8, $05 +$05, $06, $33, $06, $FD, $05, $9F, $07 +$42, $0B, $3F, $0B, $7A, $07, $FC, $08 +$95, $07, $9F, $07, $9F, $07, $BD, $0A +$C1, $0A, $8A, $0A, $9B, $0A, $E9, $0A +$61, $07, $51, $07, $41, $0A, $52, $0A +$4F, $0A, $62, $0A, $E7, $09, $CD, $06 +$06, $07, $9F, $07, $15, $08, $A7, $07 +$B7, $06, $BF, $06, $83, $08, $A1, $06 +$9F, $07, $9F, $07, $A8, $08, $4F, $0B +$4D, $0B, $07, $09, $AA, $04, $37, $07 +$BD, $04, $1B, $0B, $B1, $0A, $20, $41 +$54, $20, $80, $70, $0B, $A9, $00, $85 +$20, $85, $22, $A9, $1C, $85, $21, $85 +$23, $A0, $01, $B1, $22, $AA, $49, $FF +$91, $22, $D1, $22, $08, $8A, $91, $22 +$E6, $22, $D0, $02, $E6, $23, $28, $F0 +$EA, $88, $D8, $A5, $20, $6D, $13, $04 +$85, $24, $98, $65, $21, $85, $25, $98 +$91, $20, $C8, $91, $20, $A5, $22, $85 +$C6, $85, $26, $A5, $23, $85, $C7, $85 +$27, $20, $87, $08, $AD, $83, $04, $85 +$2A, $AD, $84, $04, $85, $2B, $A9, $80 +$85, $C1, $A9, $30, $85, $C0, $A2, $00 +$86, $BE, $86, $C2, $CA, $9A, $D8, $20 +$F9, $06, $20, $F2, $04, $4C, $E6, $04 +$83, $65, $C9, $30, $B0, $7B, $C9, $08 +$90, $0C, $0A, $AA, $BD, $1F, $04, $48 +$BD, $1E, $04, $48, $08, $40, $65, $C1 +$AA, $B1, $C1, $48, $B5, $00, $91, $C1 +$68, $95, $00, $60, $20, $87, $08, $A9 +$21, $20, $09, $04, $A5, $2A, $38, $ED +$83, $04, $AA, $A5, $2B, $ED, $84, $04 +$20, $A0, $07, $A5, $BE, $F0, $12, $A9 +$7E, $85, $2A, $A9, $20, $85, $2B, $20 +$A1, $06, $A6, $28, $A5, $29, $20, $A0 +$07, $A9, $07, $20, $09, $04, $20, $87 +$08, $A5, $26, $85, $C6, $A5, $27, $85 +$C7, $4C, $CC, $04, $A2, $7C, $E4, $C1 +$90, $BA, $A6, $C1, $E6, $C1, $E6, $C1 +$18, $60, $C6, $BD, $A5, $BD, $F0, $AC +$A5, $BC, $85, $2A, $A5, $BD, $85, $2B +$60, $C9, $40, $B0, $43, $48, $20, $F9 +$06, $6D, $83, $04, $85, $BC, $68, $48 +$29, $07, $6D, $84, $04, $85, $BD, $68 +$29, $08, $D0, $DC, $A5, $BC, $A6, $2A +$85, $2A, $86, $BC, $A5, $BD, $A6, $2B +$85, $2B, $86, $BD, $A5, $C6, $E9, $01 +$85, $C6, $B0, $02, $C6, $C7, $C5, $24 +$A5, $C7, $E5, $25, $90, $AA, $A5, $BC +$91, $C6, $C8, $A5, $BD, $91, $C6, $60 +$48, $4A, $4A, $4A, $4A, $29, $0E, $AA +$68, $C9, $60, $29, $1F, $B0, $02, $09 +$E0, $18, $F0, $07, $65, $2A, $85, $BC +$98, $65, $2B, $85, $BD, $4C, $FC, $04 +$A5, $2C, $85, $B8, $A5, $2D, $85, $B9 +$20, $25, $06, $20, $14, $06, $51, $2A +$AA, $20, $F9, $06, $8A, $F0, $F1, $0A +$F0, $12, $A5, $B8, $85, $2C, $A5, $B9 +$85, $2D, $4C, $64, $05, $20, $25, $06 +$C9, $0D, $D0, $F6, $60, $20, $25, $06 +$C9, $5B, $B0, $EE, $C9, $41, $90, $EA +$0A, $20, $87, $07, $A0, $00, $B1, $2C +$E6, $2C, $D0, $02, $E6, $2D, $C9, $0D +$18, $60, $20, $14, $06, $B1, $2C, $C9 +$20, $F0, $F7, $C9, $3A, $18, $10, $02 +$C9, $30, $60, $20, $25, $06, $90, $C2 +$84, $BC, $84, $BD, $A5, $BC, $A6, $BD +$06, $BC, $26, $BD, $06, $BC, $26, $BD +$18, $65, $BC, $85, $BC, $8A, $65, $BD +$06, $BC, $2A, $85, $BD, $20, $14, $06 +$29, $0F, $65, $BC, $85, $BC, $98, $65 +$BD, $85, $BD, $20, $25, $06, $B0, $D4 +$4C, $80, $07, $20, $FC, $08, $A5, $BC +$05, $BD, $F0, $48, $A5, $20, $85, $2C +$A5, $21, $85, $2D, $20, $6D, $07, $F0 +$12, $A5, $28, $C5, $BC, $A5, $29, $E5 +$BD, $B0, $08, $20, $14, $06, $D0, $FB +$4C, $7C, $06, $A5, $28, $45, $BC, $D0 +$04, $A5, $29, $45, $BD, $60, $20, $A6 +$06, $20, $F9, $06, $10, $F8, $E6, $BF +$30, $03, $4C, $09, $04, $C6, $BF, $60 +$C9, $22, $F0, $FB, $20, $A6, $06, $20 +$14, $06, $D0, $F4, $4C, $14, $05, $A9 +$20, $20, $A6, $06, $A5, $BF, $29, $87 +$30, $E5, $D0, $F3, $60, $A2, $7B, $20 +$56, $05, $E6, $C1, $E6, $C1, $E6, $C1 +$38, $B5, $03, $F5, $00, $95, $00, $B5 +$04, $F5, $01, $50, $04, $49, $80, $09 +$01, $30, $0A, $D0, $04, $15, $00, $F0 +$02, $56, $02, $56, $02, $56, $02, $90 +$0C, $A0, $00, $B1, $2A, $E6, $2A, $D0 +$02, $E6, $2B, $09, $00, $60, $A5, $BE +$F0, $28, $20, $14, $06, $D0, $FB, $20 +$6D, $07, $F0, $1B, $20, $4C, $07, $20 +$0C, $04, $B0, $09, $A5, $C4, $85, $2A +$A5, $C5, $85, $2B, $60, $AD, $83, $04 +$85, $2A, $AD, $84, $04, $85, $2B, $4C +$14, $05, $85, $BF, $4C, $49, $05, $A5 +$20, $85, $2C, $A5, $21, $85, $2D, $20 +$6D, $07, $F0, $EB, $A5, $2A, $85, $C4 +$A5, $2B, $85, $C5, $A9, $01, $85, $BE +$60, $20, $6B, $06, $F0, $BE, $A5, $BC +$85, $28, $A5, $BD, $85, $29, $4C, $14 +$05, $20, $FD, $0A, $20, $FA, $0A, $20 +$74, $06, $D0, $EA, $60, $20, $14, $06 +$85, $28, $20, $14, $06, $85, $29, $05 +$28, $60, $20, $FC, $08, $20, $80, $07 +$A5, $BD, $20, $87, $07, $A5, $BC, $A6 +$C1, $CA, $95, $00, $86, $C1, $E4, $C0 +$D0, $0D, $4C, $14, $05, $A6, $C1, $E0 +$80, $10, $F7, $B5, $00, $E6, $C1, $60 +$85, $BD, $86, $BC, $4C, $B8, $07, $A6 +$C1, $B5, $01, $10, $08, $20, $41, $0A +$A9, $2D, $20, $A6, $06, $20, $FC, $08 +$A9, $1F, $85, $B8, $85, $BA, $A9, $2A +$85, $B9, $85, $BB, $A6, $BC, $A4, $BD +$38, $E6, $B8, $8A, $E9, $10, $AA, $98 +$E9, $27, $A8, $B0, $F4, $C6, $B9, $8A +$69, $E8, $AA, $98, $69, $03, $A8, $90 +$F4, $8A, $38, $E6, $BA, $E9, $64, $B0 +$F9, $88, $10, $F6, $C6, $BB, $69, $0A +$90, $FA, $09, $30, $85, $BC, $A9, $20 +$85, $BD, $A2, $FB, $86, $C3, $B5, $BD +$05, $BD, $C9, $20, $F0, $09, $A0, $30 +$84, $BD, $05, $BD, $20, $A6, $06, $A6 +$C3, $E8, $D0, $E8, $60, $A5, $2D, $48 +$A5, $2C, $48, $A5, $20, $85, $2C, $A5 +$21, $85, $2D, $A5, $24, $A6, $25, $20 +$5B, $08, $F0, $03, $20, $5B, $08, $A5 +$2C, $38, $E5, $B6, $A5, $2D, $E5, $B7 +$B0, $42, $20, $6D, $07, $F0, $3D, $A6 +$28, $A5, $29, $20, $A0, $07, $A9, $20 +$20, $A6, $06, $20, $0C, $04, $B0, $2C +$20, $14, $06, $D0, $F3, $20, $83, $08 +$4C, $2F, $08, $85, $B6, $E6, $B6, $D0 +$01, $E8, $86, $B7, $A4, $C1, $C0, $80 +$F0, $18, $20, $6B, $06, $A5, $2C, $A6 +$2D, $38, $E9, $02, $B0, $01, $CA, $85 +$2C, $4C, $48, $0B, $68, $85, $2C, $68 +$85, $2D, $60, $A5, $BF, $30, $FB, $A9 +$0D, $20, $09, $04, $AD, $11, $04, $29 +$7F, $85, $BF, $F0, $07, $20, $64, $0B +$C6, $BF, $D0, $F9, $A9, $0A, $4C, $61 +$0B, $AC, $12, $04, $84, $BF, $B0, $0B +$A9, $30, $85, $2C, $85, $C0, $84, $2D +$20, $80, $07, $45, $80, $85, $80, $20 +$06, $04, $A0, $00, $A6, $C0, $29, $7F +$F0, $F1, $C9, $7F, $F0, $ED, $C9, $13 +$F0, $DA, $C9, $0A, $F0, $D3, $CD, $10 +$04, $F0, $09, $CD, $0F, $04, $D0, $0A +$E0, $30, $D0, $16, $A6, $2C, $84, $BF +$A9, $0D, $E4, $C1, $30, $08, $A9, $07 +$20, $A6, $06, $4C, $B3, $08, $95, $00 +$E8, $E8, $CA, $86, $C0, $C9, $0D, $D0 +$BA, $20, $83, $08, $20, $95, $07, $85 +$BC, $20, $95, $07, $85, $BD, $60, $20 +$D6, $0A, $20, $6B, $06, $08, $20, $6D +$08, $85, $B8, $86, $B9, $A5, $BC, $85 +$B6, $A5, $BD, $85, $B7, $A2, $00, $28 +$D0, $0B, $20, $6D, $07, $CA, $CA, $CA +$20, $14, $06, $D0, $FA, $84, $28, $84 +$29, $20, $D6, $0A, $A9, $0D, $D1, $2C +$F0, $11, $E8, $E8, $E8, $E8, $C8, $D1 +$2C, $D0, $FA, $A5, $B6, $85, $28, $A5 +$B7, $85, $29, $A5, $B8, $85, $BC, $A5 +$B9, $85, $BD, $18, $A0, $00, $8A, $F0 +$6E, $10, $29, $65, $2E, $85, $B8, $A5 +$2F, $E9, $00, $85, $B9, $B1, $2E, $91 +$B8, $A6, $2E, $E4, $24, $D0, $06, $A5 +$2F, $C5, $25, $F0, $4A, $E8, $86, $2E +$D0, $02, $E6, $2F, $E6, $B8, $D0, $E5 +$E6, $B9, $D0, $E1, $65, $24, $85, $B8 +$85, $2E, $98, $65, $25, $85, $B9, $85 +$2F, $A5, $2E, $E5, $C6, $A5, $2F, $E5 +$C7, $90, $05, $C6, $2A, $4C, $14, $05 +$B1, $24, $91, $2E, $A6, $24, $D0, $02 +$C6, $25, $C6, $24, $A6, $2E, $D0, $02 +$C6, $2F, $CA, $86, $2E, $E4, $BC, $D0 +$E7, $A6, $2F, $E4, $BD, $D0, $E1, $A5 +$B8, $85, $24, $A5, $B9, $85, $25, $A5 +$28, $05, $29, $F0, $17, $A5, $28, $91 +$BC, $C8, $A5, $29, $91, $BC, $C8, $84 +$B6, $20, $14, $06, $08, $A4, $B6, $91 +$BC, $28, $D0, $F2, $4C, $CC, $04, $20 +$54, $05, $B5, $03, $29, $80, $F0, $02 +$A9, $FF, $85, $BC, $85, $BD, $48, $75 +$02, $95, $02, $68, $48, $75, $03, $95 +$03, $68, $55, $01, $85, $BB, $10, $03 +$20, $43, $0A, $A0, $11, $B5, $00, $15 +$01, $D0, $03, $4C, $14, $05, $38, $A5 +$BC, $F5, $00, $48, $A5, $BD, $F5, $01 +$48, $45, $BD, $30, $0A, $68, $85, $BD +$68, $85, $BC, $38, $4C, $32, $0A, $68 +$68, $18, $36, $02, $36, $03, $26, $BC +$26, $BD, $88, $D0, $D9, $A5, $BB, $10 +$0D, $A6, $C1, $38, $98, $F5, $00, $95 +$00, $98, $F5, $01, $95, $01, $60, $20 +$41, $0A, $20, $54, $05, $B5, $00, $75 +$02, $95, $02, $B5, $01, $75, $03, $95 +$03, $60, $20, $54, $05, $A0, $10, $B5 +$02, $85, $BC, $B5, $03, $85, $BD, $16 +$02, $36, $03, $26, $BC, $26, $BD, $90 +$0D, $18, $B5, $02, $75, $00, $95, $02 +$B5, $03, $75, $01, $95, $03, $88, $D0 +$E6, $60, $20, $95, $07, $AA, $B5, $00 +$B4, $01, $C6, $C1, $A6, $C1, $94, $00 +$4C, $87, $07, $A2, $7D, $20, $56, $05 +$B5, $01, $48, $B5, $00, $48, $20, $95 +$07, $AA, $68, $95, $00, $68, $95, $01 +$60, $20, $FD, $0A, $A5, $BC, $85, $2A +$A5, $BD, $85, $2B, $60, $A2, $2C, $D0 +$02, $A2, $2E, $B5, $00, $C9, $80, $B0 +$0D, $B5, $01, $D0, $09, $A5, $2C, $85 +$2E, $A5, $2D, $85, $2F, $60, $A5, $2C +$A4, $2E, $84, $2C, $85, $2E, $A5, $2D +$A4, $2F, $84, $2D, $85, $2F, $A0, $00 +$60, $A5, $28, $85, $BC, $A5, $29, $85 +$BD, $20, $9C, $05, $A5, $C6, $85, $26 +$A5, $C7, $85, $27, $60, $B1, $C6, $85 +$BC, $20, $08, $0B, $B1, $C6, $85, $BD +$E6, $C6, $D0, $02, $E6, $C7, $A5, $22 +$C5, $C6, $A5, $23, $E5, $C7, $B0, $E4 +$4C, $14, $05, $20, $24, $0B, $85, $BC +$98, $4C, $82, $07, $20, $FC, $08, $A5 +$BC, $85, $B6, $20, $FC, $08, $A5, $BD +$85, $B7, $A4, $BC, $20, $FC, $08, $A6 +$B7, $A5, $B6, $18, $6C, $BC, $00, $20 +$42, $0B, $20, $F9, $06, $4C, $87, $07 +$86, $2D, $E0, $00, $60, $A0, $02, $84 +$BC, $A0, $29, $84, $BD, $A0, $00, $B1 +$BC, $C9, $08, $D0, $03, $4C, $0B, $0A +$60, $20, $09, $04, $A9, $FF, $2C, $11 +$04, $30, $02, $A9, $00, $4C, $09, $04 +$24, $3A, $91, $27, $10, $E1, $59, $C5 +$2A, $56, $10, $11, $2C, $8B, $4C, $45 +$D4, $A0, $80, $BD, $30, $BC, $E0, $13 +$1D, $94, $47, $CF, $88, $54, $CF, $30 +$BC, $E0, $10, $11, $16, $80, $53, $55 +$C2, $30, $BC, $E0, $14, $16, $90, $50 +$D2, $83, $49, $4E, $D4, $E5, $71, $88 +$BB, $E1, $1D, $8F, $A2, $21, $58, $6F +$83, $AC, $22, $55, $83, $BA, $24, $93 +$E0, $23, $1D, $30, $BC, $20, $48, $91 +$49, $C6, $30, $BC, $31, $34, $30, $BC +$84, $54, $48, $45, $CE, $1C, $1D, $38 +$0D, $9A, $49, $4E, $50, $55, $D4, $A0 +$10, $E7, $24, $3F, $20, $91, $27, $E1 +$59, $81, $AC, $30, $BC, $13, $11, $82 +$AC, $4D, $E0, $1D, $89, $52, $45, $54 +$55, $52, $CE, $E0, $15, $1D, $85, $45 +$4E, $C4, $E0, $2D, $98, $4C, $49, $53 +$D4, $EC, $24, $00, $00, $00, $00, $0A +$80, $1F, $24, $93, $23, $1D, $30, $BC +$E1, $50, $80, $AC, $59, $85, $52, $55 +$CE, $38, $0A, $86, $43, $4C, $45, $41 +$D2, $2B, $84, $52, $45, $CD, $1D, $A0 +$80, $BD, $38, $14, $85, $AD, $30, $D3 +$17, $64, $81, $AB, $30, $D3, $85, $AB +$30, $D3, $18, $5A, $85, $AD, $30, $D3 +$19, $54, $2F, $30, $E2, $85, $AA, $30 +$E2, $1A, $5A, $85, $AF, $30, $E2, $1B +$54, $2F, $98, $52, $4E, $C4, $0A, $80 +$80, $12, $0A, $09, $29, $1A, $0A, $1A +$85, $18, $13, $09, $80, $12, $01, $0B +$31, $30, $61, $72, $0B, $04, $02, $03 +$05, $03, $1B, $1A, $19, $0B, $09, $06 +$0A, $00, $00, $1C, $17, $2F, $8F, $55 +$53, $D2, $80, $A8, $30, $BC, $31, $2A +$31, $2A, $80, $A9, $2E, $2F, $A2, $12 +$2F, $C1, $2F, $80, $A8, $30, $BC, $80 +$A9, $2F, $83, $AC, $38, $BC, $0B, $2F +$80, $A8, $52, $2F, $84, $BD, $09, $02 +$2F, $8E, $BC, $84, $BD, $09, $93, $2F +$84, $BE, $09, $05, $2F, $09, $91, $2F +$80, $BE, $84, $BD, $09, $06, $2F, $84 +$BC, $09, $95, $2F, $09, $04, $2F, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$20, $0D, $0F, $A0, $00, $20, $1D, $0F +$20, $2C, $0F, $C9, $43, $D0, $03, $4C +$85, $04, $C9, $57, $D0, $03, $4C, $BD +$04, $A2, $2F, $20, $1D, $0F, $4C, $F8 +$0C, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$4D, $4B, $48, $42, $43, $2D, $38, $2D +$52, $32, $20, $54, $49, $4E, $59, $20 +$42, $41, $53, $49, $43, $20, $36, $35 +$30, $32, $20, $50, $4F, $52, $54, $0D +$0A, $56, $65, $72, $73, $69, $6F, $6E +$3A, $20, $31, $2E, $30, $2E, $33, $2C +$20, $32, $2F, $32, $30, $2F, $32, $30 +$31, $36, $0D, $0A, $28, $4E, $4F, $54 +$45, $3A, $20, $55, $73, $65, $20, $55 +$50, $50, $45, $52, $20, $43, $41, $53 +$45, $2E, $29, $0D, $0A, $42, $6F, $6F +$74, $20, $28, $5B, $43, $5D, $6F, $6C +$64, $2F, $5B, $57, $5D, $61, $72, $6D +$29, $3F, $20, $07, $FF, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$86, $C3, $B1, $C2, $48, $C8, $B1, $C2 +$AA, $68, $A8, $8A, $60, $A2, $19, $A9 +$0D, $20, $31, $0F, $A9, $0A, $20, $31 +$0F, $CA, $D0, $FA, $60, $B9, $00, $0E +$C9, $FF, $F0, $07, $20, $31, $0F, $C8 +$4C, $1D, $0F, $60, $AD, $00, $E0, $F0 +$FB, $85, $FE, $C9, $FF, $F0, $1E, $C9 +$00, $F0, $1A, $C9, $91, $F0, $16, $C9 +$93, $F0, $12, $C9, $80, $F0, $0E, $4C +$50, $0F, $20, $F0, $FF, $A5, $FE, $60 +$A5, $FE, $8D, $00, $E0, $60, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 +$00, $00, $00, $00, $00, $00, $00, $00 diff --git a/test_char_io_01.65s b/test_char_io_01.65s index 18a4bd6..343d122 100644 --- a/test_char_io_01.65s +++ b/test_char_io_01.65s @@ -1,50 +1,50 @@ -; Basic test of char I/O emulation - - .ORG $0200 - -CHRGET = $E000 -PUTCH = $E000 -TXTBUF = $0400 -CR = $0D -NL = $0A - -START: LDX #$00 -PR1: LDA PROMPT,X ;print prompt - BEQ L0 - STA PUTCH - INX - BNE PR1 -L0: LDX #$00 -GETTXT: LDA CHRGET ;get text from input - BEQ GETTXT - CMP #CR - BEQ L1 - CMP #NL - BEQ L1 - STA PUTCH ;echo char - STA TXTBUF,X ;store char - INX - BNE GETTXT -L1: LDA #NL ; add line break - STA TXTBUF,X - STA PUTCH - INX - LDA #CR - STA TXTBUF,X - STA PUTCH - INX - LDA #$00 ; add null - STA TXTBUF,X - TAX -PRINT: LDA TXTBUF,X ; print to output - BEQ L2 - STA PUTCH - INX - BNE PRINT -L2: BRK - NOP - JMP START -PROMPT: .DB "Enter text:",0 - - +; Basic test of char I/O emulation + + .ORG $0200 + +CHRGET = $E000 +PUTCH = $E000 +TXTBUF = $0400 +CR = $0D +NL = $0A + +START: LDX #$00 +PR1: LDA PROMPT,X ;print prompt + BEQ L0 + STA PUTCH + INX + BNE PR1 +L0: LDX #$00 +GETTXT: LDA CHRGET ;get text from input + BEQ GETTXT + CMP #CR + BEQ L1 + CMP #NL + BEQ L1 + STA PUTCH ;echo char + STA TXTBUF,X ;store char + INX + BNE GETTXT +L1: LDA #NL ; add line break + STA TXTBUF,X + STA PUTCH + INX + LDA #CR + STA TXTBUF,X + STA PUTCH + INX + LDA #$00 ; add null + STA TXTBUF,X + TAX +PRINT: LDA TXTBUF,X ; print to output + BEQ L2 + STA PUTCH + INX + BNE PRINT +L2: BRK + NOP + JMP START +PROMPT: .DB "Enter text:",0 + + \ No newline at end of file diff --git a/test_char_io_01.dat b/test_char_io_01.dat index 8767d98..7fdc22b 100644 --- a/test_char_io_01.dat +++ b/test_char_io_01.dat @@ -1,15 +1,15 @@ -; I/O test for MKBASIC VM. -ORG -$0200 -$A2 $00 $BD $4E $02 $F0 $06 $8D -$00 $E0 $E8 $D0 $F5 $A2 $00 $AD -$00 $E0 $F0 $FB $C9 $0D $F0 $0D -$C9 $0A $F0 $09 $8D $00 $E0 $9D -$00 $04 $E8 $D0 $EA $A9 $0A $9D -$00 $04 $8D $00 $E0 $E8 $A9 $0D -$9D $00 $04 $8D $00 $E0 $E8 $A9 -$00 $9D $00 $04 $AA $BD $00 $04 -$F0 $06 $8D $00 $E0 $E8 $D0 $F5 -$00 $00 $EA $4C $00 $02 $45 $6E -$74 $65 $72 $20 $74 $65 $78 $74 -$3A $00 $00 $00 $00 $00 $00 $00 +; I/O test for MKBASIC VM. +ORG +$0200 +$A2 $00 $BD $4E $02 $F0 $06 $8D +$00 $E0 $E8 $D0 $F5 $A2 $00 $AD +$00 $E0 $F0 $FB $C9 $0D $F0 $0D +$C9 $0A $F0 $09 $8D $00 $E0 $9D +$00 $04 $E8 $D0 $EA $A9 $0A $9D +$00 $04 $8D $00 $E0 $E8 $A9 $0D +$9D $00 $04 $8D $00 $E0 $E8 $A9 +$00 $9D $00 $04 $AA $BD $00 $04 +$F0 $06 $8D $00 $E0 $E8 $D0 $F5 +$00 $00 $EA $4C $00 $02 $45 $6E +$74 $65 $72 $20 $74 $65 $78 $74 +$3A $00 $00 $00 $00 $00 $00 $00 diff --git a/testall.asm b/testall.asm index a221200..580102e 100644 --- a/testall.asm +++ b/testall.asm @@ -1,954 +1,954 @@ -; Testing 6502 opcodes. -; Copied and adapted from AllSuiteA.asm from project hmc-6502: -; https://code.google.com/archive/p/hmc-6502/ -; EXPECTED FINAL RESULTS: $0210 = FF -; (any other number will be the test that failed) -; To build with cl65: -; cl65 -C testall_cl65.cfg -l --start-addr 16384 -t none -o tall.bin testall.asm -; then load to simulator from debug console with 'L B TALL.BIN' -; and execute with 'X 4000'. - - .segment "CODE1" - - .segment "CODE2" - - .ORG $4000 - -start: -; initialize: - LDA #$00 - STA $0210 - ; store each test's expected - LDA #$55 - STA $0200 - LDA #$AA - STA $0201 - LDA #$FF - STA $0202 - LDA #$6E - STA $0203 - LDA #$42 - STA $0204 - LDA #$33 - STA $0205 - LDA #$9D - STA $0206 - LDA #$7F - STA $0207 - LDA #$A5 - STA $0208 - LDA #$1F - STA $0209 - LDA #$CE - STA $020A - LDA #$29 - STA $020B - LDA #$42 - STA $020C - LDA #$6C - STA $020D - LDA #$42 - STA $020E - - -; expected result: $022A = 0x55 -test00: - LDA #85 - LDX #42 - LDY #115 - STA $81 - LDA #$01 - STA $61 - LDA #$7E - LDA $81 - STA $0910 - LDA #$7E - LDA $0910 - STA $56,X - LDA #$7E - LDA $56,X - STY $60 - STA ($60),Y - LDA #$7E - LDA ($60),Y - STA $07ff,X - LDA #$7E - LDA $07ff,X - STA $07ff,Y - LDA #$7E - LDA $07ff,Y - STA ($36,X) - LDA #$7E - LDA ($36,X) - STX $50 - LDX $60 - LDY $50 - STX $0913 - LDX #$22 - LDX $0913 - STY $0914 - LDY #$99 - LDY $0914 - STY $2D,X - STX $77,Y - LDY #$99 - LDY $2D,X - LDX #$22 - LDX $77,Y - LDY #$99 - LDY $08A0,X - LDX #$22 - LDX $08A1,Y - STA $0200,X - -; CHECK test00: - LDA $022A - CMP $0200 - BEQ test00pass - JMP theend -test00pass: - LDA #$FE - STA $0210 - - -; expected result: $A9 = 0xAA -test01: - ; imm - LDA #85 - AND #83 - ORA #56 - EOR #17 - - ; zpg - STA $99 - LDA #185 - STA $10 - LDA #231 - STA $11 - LDA #57 - STA $12 - LDA $99 - AND $10 - ORA $11 - EOR $12 - - ; zpx - LDX #16 - STA $99 - LDA #188 - STA $20 - LDA #49 - STA $21 - LDA #23 - STA $22 - LDA $99 - AND $10,X - ORA $11,X - EOR $12,X - - ; abs - STA $99 - LDA #111 - STA $0110 - LDA #60 - STA $0111 - LDA #39 - STA $0112 - LDA $99 - AND $0110 - ORA $0111 - EOR $0112 - - ; abx - STA $99 - LDA #138 - STA $0120 - LDA #71 - STA $0121 - LDA #143 - STA $0122 - LDA $99 - AND $0110,X - ORA $0111,X - EOR $0112,X - - ; aby - LDY #32 - STA $99 - LDA #115 - STA $0130 - LDA #42 - STA $0131 - LDA #241 - STA $0132 - LDA $99 - AND $0110,Y - ORA $0111,Y - EOR $0112,Y - - ; idx - STA $99 - LDA #112 - STA $30 - LDA #$01 - STA $31 - LDA #113 - STA $32 - LDA #$01 - STA $33 - LDA #114 - STA $34 - LDA #$01 - STA $35 - LDA #197 - STA $0170 - LDA #124 - STA $0171 - LDA #161 - STA $0172 - LDA $99 - AND ($20,X) - ORA ($22,X) - EOR ($24,X) - - ; idy - STA $99 - LDA #96 - STA $40 - LDA #$01 - STA $41 - LDA #97 - STA $42 - LDA #$01 - STA $43 - LDA #98 - STA $44 - LDA #$01 - STA $45 - LDA #55 - STA $0250 - LDA #35 - STA $0251 - LDA #157 - STA $0252 - LDA $99 - LDY #$F0 - AND ($40),Y - ORA ($42),Y - EOR ($44),Y - - STA $A9 - -; CHECK test01 - LDA $A9 - CMP $0201 - BEQ test02 - LDA #$01 - STA $0210 - JMP theend - - -; expected result: $71 = 0xFF -test02: - LDA #$FF - LDX #$00 - - STA $90 - INC $90 - INC $90 - LDA $90 - LDX $90 - - STA $90,X - INC $90,X - LDA $90,X - LDX $91 - - STA $0190,X - INC $0192 - LDA $0190,X - LDX $0192 - - STA $0190,X - INC $0190,X - LDA $0190,X - LDX $0193 - - STA $0170,X - DEC $0170,X - LDA $0170,X - LDX $0174 - - STA $0170,X - DEC $0173 - LDA $0170,X - LDX $0173 - - STA $70,X - DEC $70,X - LDA $70,X - LDX $72 - - STA $70,X - DEC $71 - DEC $71 - -; CHECK test02 - LDA $71 - CMP $0202 - BEQ test03 - LDA #$02 - STA $0210 - JMP theend - - -; expected result: $01DD = 0x6E -test03: - LDA #$4B - LSR - ASL - - STA $50 - ASL $50 - ASL $50 - LSR $50 - LDA $50 - - LDX $50 - ORA #$C9 - STA $60 - ASL $4C,X - LSR $4C,X - LSR $4C,X - LDA $4C,X - - LDX $60 - ORA #$41 - STA $012E - LSR $0100,X - LSR $0100,X - ASL $0100,X - LDA $0100,X - - LDX $012E - ORA #$81 - STA $0100,X - LSR $0136 - LSR $0136 - ASL $0136 - LDA $0100,X - - ; rol & ror - - ROL - ROL - ROR - STA $70 - - LDX $70 - ORA #$03 - STA $0C,X - ROL $C0 - ROR $C0 - ROR $C0 - LDA $0C,X - - LDX $C0 - STA $D0 - ROL $75,X - ROL $75,X - ROR $75,X - LDA $D0 - - LDX $D0 - STA $0100,X - ROL $01B7 - ROL $01B7 - ROL $01B7 - ROR $01B7 - LDA $0100,X - - LDX $01B7 - STA $01DD - ROL $0100,X - ROR $0100,X - ROR $0100,X - -; CHECK test03 - LDA $01DD - CMP $0203 - BEQ test04 - LDA #$03 - STA $0210 - JMP theend - - -; expected result: $40 = 0x42 -test04: - LDA #$E8 ;originally:#$7C - STA $20 - LDA #$42 ;originally:#$02 - STA $21 - LDA #$00 - ORA #$03 - JMP jump1 - ORA #$FF ; not done -jump1: - ORA #$30 - JSR subr - ORA #$42 - JMP ($0020) - ORA #$FF ; not done -subr: - STA $30 - LDX $30 - LDA #$00 - RTS -final: - STA $0D,X - -; CHECK test04 - LDA $40 - CMP $0204 - BEQ test05 - LDA #$04 - STA $0210 - JMP theend - - -; expected result: $40 = 0x33 -test05: - LDA #$35 - - TAX - DEX - DEX - INX - TXA - - TAY - DEY - DEY - INY - TYA - - TAX - LDA #$20 - TXS - LDX #$10 - TSX - TXA - - STA $40 - -; CHECK test05 - LDA $40 - CMP $0205 - BEQ test06 - LDA #$05 - STA $0210 - JMP theend - - -; expected result: $30 = 9D -test06: - -; RESET TO CARRY FLAG = 0 - ROL - - LDA #$6A - STA $50 - LDA #$6B - STA $51 - LDA #$A1 - STA $60 - LDA #$A2 - STA $61 - - LDA #$FF - ADC #$FF - ADC #$FF - SBC #$AE - - STA $40 - LDX $40 - ADC $00,X - SBC $01,X - - ADC $60 - SBC $61 - - STA $0120 - LDA #$4D - STA $0121 - LDA #$23 - ADC $0120 - SBC $0121 - - STA $F0 - LDX $F0 - LDA #$64 - STA $0124 - LDA #$62 - STA $0125 - LDA #$26 - ADC $0100,X - SBC $0101,X - - STA $F1 - LDY $F1 - LDA #$E5 - STA $0128 - LDA #$E9 - STA $0129 - LDA #$34 - ADC $0100,Y - SBC $0101,Y - - STA $F2 - LDX $F2 - LDA #$20 - STA $70 - LDA #$01 - STA $71 - LDA #$24 - STA $72 - LDA #$01 - STA $73 - ADC ($41,X) - SBC ($3F,X) - - STA $F3 - LDY $F3 - LDA #$DA - STA $80 - LDA #$00 - STA $81 - LDA #$DC - STA $82 - LDA #$00 - STA $83 - LDA #$AA - ADC ($80),Y - SBC ($82),Y - STA $30 - -; CHECK test06 - LDA $30 - CMP $0206 - BEQ test07 - LDA #$06 - STA $0210 - JMP theend - - -; expected result: $15 = 0x7F -test07: - ; prepare memory - LDA #$00 - STA $34 - LDA #$FF - STA $0130 - LDA #$99 - STA $019D - LDA #$DB - STA $0199 - LDA #$2F - STA $32 - LDA #$32 - STA $4F - LDA #$30 - STA $33 - LDA #$70 - STA $AF - LDA #$18 - STA $30 - - ; imm - CMP #$18 - BEQ beq1 ; taken - AND #$00 ; not done -beq1: - ; zpg - ORA #$01 - CMP $30 - BNE bne1 ; taken - AND #$00 ; not done -bne1: - ; abs - LDX #$00 - CMP $0130 - BEQ beq2 ; not taken - STA $40 - LDX $40 -beq2: - ; zpx - CMP $27,X - BNE bne2 ; not taken - ORA #$84 - STA $41 - LDX $41 -bne2: - ; abx - AND #$DB - CMP $0100,X - BEQ beq3 ; taken - AND #$00 ; not done -beq3: - ; aby - STA $42 - LDY $42 - AND #$00 - CMP $0100,Y - BNE bne3 ; taken - ORA #$0F ; not done -bne3: - ; idx - STA $43 - LDX $43 - ORA #$24 - CMP ($40,X) - BEQ beq4 ; not taken - ORA #$7F -beq4: - ; idy - STA $44 - LDY $44 - EOR #$0F - CMP ($33),Y - BNE bne4 ; not taken - LDA $44 - STA $15 -bne4: - -; CHECK test07 - LDA $15 - CMP $0207 - BEQ test08 - LDA #$07 - STA $0210 - JMP theend - - -; expected result: $42 = 0xA5 -test08: - ; prepare memory - LDA #$A5 - STA $20 - STA $0120 - LDA #$5A - STA $21 - - ; cpx imm... - LDX #$A5 - CPX #$A5 - BEQ b1 ; taken - LDX #$01 ; not done -b1: - ; cpx zpg... - CPX $20 - BEQ b2 ; taken - LDX #$02 ; not done -b2: - ; cpx abs... - CPX $0120 - BEQ b3 ; taken - LDX #$03 ; not done -b3: - ; cpy imm... - STX $30 - LDY $30 - CPY #$A5 - BEQ b4 ; taken - LDY #$04 ; not done -b4: - ; cpy zpg... - CPY $20 - BEQ b5 ; taken - LDY #$05 ; not done -b5: - ; cpy abs... - CPY $0120 - BEQ b6 ; taken - LDY #$06 ; not done -b6: - ; bit zpg... - STY $31 - LDA $31 - BIT $20 - BNE b7 ; taken - LDA #$07 ; not done -b7: - ; bit abs... - BIT $0120 - BNE b8 ; taken - LDA #$08 ; not done -b8: - BIT $21 - BNE b9 ; not taken - STA $42 -b9: - -; CHECK test08 - LDA $42 - CMP $0208 - BEQ test09 - LDA #$08 - STA $0210 - JMP theend - - -; expected result: $80 = 0x1F -test09: - ; prepare memory - LDA #$54 - STA $32 - LDA #$B3 - STA $A1 - LDA #$87 - STA $43 - - ; BPL - LDX #$A1 - BPL bpl1 ; not taken - LDX #$32 -bpl1: - LDY $00,X - BPL bpl2 ; taken - LDA #$05 ; not done - LDX $A1 ; not done -bpl2: - - ; BMI - BMI bmi1 ; not taken - SBC #$03 -bmi1: - BMI bmi2 ; taken - LDA #$41 ; not done -bmi2: - - ; BVC - EOR #$30 - STA $32 - ADC $00,X - BVC bvc1 ; not taken - LDA #$03 -bvc1: - STA $54 - LDX $00,Y - ADC $51,X - BVC bvc2 ; taken - LDA #$E5 ; not done -bvc2: - - ; BVS - ADC $40,X - BVS bvs1 ; not taken - STA $0001,Y - ADC $55 -bvs1: - BVS bvs2 ; taken - LDA #$00 -bvs2: - - ; BCC - ADC #$F0 - BCC bcc1 ; not taken - STA $60 - ADC $43 -bcc1: - BCC bcc2 ; taken - LDA #$FF -bcc2: - - ; BCS - ADC $54 - BCS bcs1 ; not taken - ADC #$87 - LDX $60 -bcs1: - BCS bcs2 ; taken - LDA #$00 ; not done -bcs2: - STA $73,X - -; CHECK test09 - LDA $80 - CMP $0209 - BEQ test10 - LDA #$09 - STA $0210 - JMP theend - - -; expected result: $30 = 0xCE -test10: - -; RESET TO CARRY = 0 & OVERFLOW = 0 - ADC #$00 - - LDA #$99 - ADC #$87 - CLC - NOP - BCC t10bcc1 ; taken - ADC #$60 ; not done - ADC #$93 ; not done -t10bcc1: - SEC - NOP - BCC t10bcc2 ; not taken - CLV -t10bcc2: - BVC t10bvc1 ; taken - LDA #$00 ; not done -t10bvc1: - ADC #$AD - NOP - STA $30 - -; CHECK test10 - LDA $30 - CMP $020A - BEQ test11 - LDA #$0A - STA $0210 - JMP theend - - -; expected result: $30 = 0x29 -test11: - -; RESET TO CARRY = 0 & ZERO = 0 - ADC #$01 - - LDA #$27 - ADC #$01 - SEC - PHP - CLC - PLP - ADC #$00 - PHA - LDA #$00 - PLA - STA $30 - -; CHECK test11 - LDA $30 - CMP $020B - BEQ test12 - LDA #$0B - STA $0210 - JMP theend - - -; expected result: $33 = 0x42 -test12: - CLC - LDA #$42 - BCC runstuff - STA $33 - BCS t12end -runstuff: - LDA #$45 - PHA - LDA #$61 - PHA - SEC - PHP - CLC - RTI -t12end: - -; CHECK test12 - LDA $33 - CMP $020C - BEQ test13 - LDA #$0C - STA $0210 - JMP theend - - -; expected result: $21 = 0x6C (simulator) -; $21 = 0x0C (ours) -test13: - -; RESET TO CARRY = 0 & ZERO = 0 - ADC #$01 - - SEI - SED - PHP - PLA - STA $20 - CLI - CLD - PHP - PLA - ADC $20 - STA $21 - -; CHECK test13 - LDA $21 - CMP $020D - BEQ test14 - LDA #$0D - STA $0210 - JMP theend - - -; expect result: $60 = 0x42 -test14: - ; !!! NOTICE: BRK doesn't work in this - ; simulator, so commented instructions - ; are what should be executed... - ;JMP pass_intrp - LDA #$41 - STA $60 - ;RTI - ;pass_intrp: - ;LDA #$FF - ;STA $60 - ;BRK (two bytes) - INC $60 - -; CHECK test14 - LDA $60 - CMP $020E - BEQ suiteafinal - LDA #$0E - STA $0210 - JMP theend - -suiteafinal: - ; IF $0210 == 0xFE, INCREMENT - ; (checking that it didn't - ; happen to wander off and - ; not run our instructions - ; to say which tests failed...) - LDA #$FE - CMP $0210 - BNE theend - INC $0210 -theend: - BRK - BRK - ;JMP theend - LDX #$FF - TXS - RTS - - .segment "KERN" - - .ORG $FF00 - - RTI - - .segment "VECT" - - .ORG $FFFA - - .BYTE $00,$FF,$00,$FF,$00,$FF - +; Testing 6502 opcodes. +; Copied and adapted from AllSuiteA.asm from project hmc-6502: +; https://code.google.com/archive/p/hmc-6502/ +; EXPECTED FINAL RESULTS: $0210 = FF +; (any other number will be the test that failed) +; To build with cl65: +; cl65 -C testall_cl65.cfg -l --start-addr 16384 -t none -o tall.bin testall.asm +; then load to simulator from debug console with 'L B TALL.BIN' +; and execute with 'X 4000'. + + .segment "CODE1" + + .segment "CODE2" + + .ORG $4000 + +start: +; initialize: + LDA #$00 + STA $0210 + ; store each test's expected + LDA #$55 + STA $0200 + LDA #$AA + STA $0201 + LDA #$FF + STA $0202 + LDA #$6E + STA $0203 + LDA #$42 + STA $0204 + LDA #$33 + STA $0205 + LDA #$9D + STA $0206 + LDA #$7F + STA $0207 + LDA #$A5 + STA $0208 + LDA #$1F + STA $0209 + LDA #$CE + STA $020A + LDA #$29 + STA $020B + LDA #$42 + STA $020C + LDA #$6C + STA $020D + LDA #$42 + STA $020E + + +; expected result: $022A = 0x55 +test00: + LDA #85 + LDX #42 + LDY #115 + STA $81 + LDA #$01 + STA $61 + LDA #$7E + LDA $81 + STA $0910 + LDA #$7E + LDA $0910 + STA $56,X + LDA #$7E + LDA $56,X + STY $60 + STA ($60),Y + LDA #$7E + LDA ($60),Y + STA $07ff,X + LDA #$7E + LDA $07ff,X + STA $07ff,Y + LDA #$7E + LDA $07ff,Y + STA ($36,X) + LDA #$7E + LDA ($36,X) + STX $50 + LDX $60 + LDY $50 + STX $0913 + LDX #$22 + LDX $0913 + STY $0914 + LDY #$99 + LDY $0914 + STY $2D,X + STX $77,Y + LDY #$99 + LDY $2D,X + LDX #$22 + LDX $77,Y + LDY #$99 + LDY $08A0,X + LDX #$22 + LDX $08A1,Y + STA $0200,X + +; CHECK test00: + LDA $022A + CMP $0200 + BEQ test00pass + JMP theend +test00pass: + LDA #$FE + STA $0210 + + +; expected result: $A9 = 0xAA +test01: + ; imm + LDA #85 + AND #83 + ORA #56 + EOR #17 + + ; zpg + STA $99 + LDA #185 + STA $10 + LDA #231 + STA $11 + LDA #57 + STA $12 + LDA $99 + AND $10 + ORA $11 + EOR $12 + + ; zpx + LDX #16 + STA $99 + LDA #188 + STA $20 + LDA #49 + STA $21 + LDA #23 + STA $22 + LDA $99 + AND $10,X + ORA $11,X + EOR $12,X + + ; abs + STA $99 + LDA #111 + STA $0110 + LDA #60 + STA $0111 + LDA #39 + STA $0112 + LDA $99 + AND $0110 + ORA $0111 + EOR $0112 + + ; abx + STA $99 + LDA #138 + STA $0120 + LDA #71 + STA $0121 + LDA #143 + STA $0122 + LDA $99 + AND $0110,X + ORA $0111,X + EOR $0112,X + + ; aby + LDY #32 + STA $99 + LDA #115 + STA $0130 + LDA #42 + STA $0131 + LDA #241 + STA $0132 + LDA $99 + AND $0110,Y + ORA $0111,Y + EOR $0112,Y + + ; idx + STA $99 + LDA #112 + STA $30 + LDA #$01 + STA $31 + LDA #113 + STA $32 + LDA #$01 + STA $33 + LDA #114 + STA $34 + LDA #$01 + STA $35 + LDA #197 + STA $0170 + LDA #124 + STA $0171 + LDA #161 + STA $0172 + LDA $99 + AND ($20,X) + ORA ($22,X) + EOR ($24,X) + + ; idy + STA $99 + LDA #96 + STA $40 + LDA #$01 + STA $41 + LDA #97 + STA $42 + LDA #$01 + STA $43 + LDA #98 + STA $44 + LDA #$01 + STA $45 + LDA #55 + STA $0250 + LDA #35 + STA $0251 + LDA #157 + STA $0252 + LDA $99 + LDY #$F0 + AND ($40),Y + ORA ($42),Y + EOR ($44),Y + + STA $A9 + +; CHECK test01 + LDA $A9 + CMP $0201 + BEQ test02 + LDA #$01 + STA $0210 + JMP theend + + +; expected result: $71 = 0xFF +test02: + LDA #$FF + LDX #$00 + + STA $90 + INC $90 + INC $90 + LDA $90 + LDX $90 + + STA $90,X + INC $90,X + LDA $90,X + LDX $91 + + STA $0190,X + INC $0192 + LDA $0190,X + LDX $0192 + + STA $0190,X + INC $0190,X + LDA $0190,X + LDX $0193 + + STA $0170,X + DEC $0170,X + LDA $0170,X + LDX $0174 + + STA $0170,X + DEC $0173 + LDA $0170,X + LDX $0173 + + STA $70,X + DEC $70,X + LDA $70,X + LDX $72 + + STA $70,X + DEC $71 + DEC $71 + +; CHECK test02 + LDA $71 + CMP $0202 + BEQ test03 + LDA #$02 + STA $0210 + JMP theend + + +; expected result: $01DD = 0x6E +test03: + LDA #$4B + LSR + ASL + + STA $50 + ASL $50 + ASL $50 + LSR $50 + LDA $50 + + LDX $50 + ORA #$C9 + STA $60 + ASL $4C,X + LSR $4C,X + LSR $4C,X + LDA $4C,X + + LDX $60 + ORA #$41 + STA $012E + LSR $0100,X + LSR $0100,X + ASL $0100,X + LDA $0100,X + + LDX $012E + ORA #$81 + STA $0100,X + LSR $0136 + LSR $0136 + ASL $0136 + LDA $0100,X + + ; rol & ror + + ROL + ROL + ROR + STA $70 + + LDX $70 + ORA #$03 + STA $0C,X + ROL $C0 + ROR $C0 + ROR $C0 + LDA $0C,X + + LDX $C0 + STA $D0 + ROL $75,X + ROL $75,X + ROR $75,X + LDA $D0 + + LDX $D0 + STA $0100,X + ROL $01B7 + ROL $01B7 + ROL $01B7 + ROR $01B7 + LDA $0100,X + + LDX $01B7 + STA $01DD + ROL $0100,X + ROR $0100,X + ROR $0100,X + +; CHECK test03 + LDA $01DD + CMP $0203 + BEQ test04 + LDA #$03 + STA $0210 + JMP theend + + +; expected result: $40 = 0x42 +test04: + LDA #$E8 ;originally:#$7C + STA $20 + LDA #$42 ;originally:#$02 + STA $21 + LDA #$00 + ORA #$03 + JMP jump1 + ORA #$FF ; not done +jump1: + ORA #$30 + JSR subr + ORA #$42 + JMP ($0020) + ORA #$FF ; not done +subr: + STA $30 + LDX $30 + LDA #$00 + RTS +final: + STA $0D,X + +; CHECK test04 + LDA $40 + CMP $0204 + BEQ test05 + LDA #$04 + STA $0210 + JMP theend + + +; expected result: $40 = 0x33 +test05: + LDA #$35 + + TAX + DEX + DEX + INX + TXA + + TAY + DEY + DEY + INY + TYA + + TAX + LDA #$20 + TXS + LDX #$10 + TSX + TXA + + STA $40 + +; CHECK test05 + LDA $40 + CMP $0205 + BEQ test06 + LDA #$05 + STA $0210 + JMP theend + + +; expected result: $30 = 9D +test06: + +; RESET TO CARRY FLAG = 0 + ROL + + LDA #$6A + STA $50 + LDA #$6B + STA $51 + LDA #$A1 + STA $60 + LDA #$A2 + STA $61 + + LDA #$FF + ADC #$FF + ADC #$FF + SBC #$AE + + STA $40 + LDX $40 + ADC $00,X + SBC $01,X + + ADC $60 + SBC $61 + + STA $0120 + LDA #$4D + STA $0121 + LDA #$23 + ADC $0120 + SBC $0121 + + STA $F0 + LDX $F0 + LDA #$64 + STA $0124 + LDA #$62 + STA $0125 + LDA #$26 + ADC $0100,X + SBC $0101,X + + STA $F1 + LDY $F1 + LDA #$E5 + STA $0128 + LDA #$E9 + STA $0129 + LDA #$34 + ADC $0100,Y + SBC $0101,Y + + STA $F2 + LDX $F2 + LDA #$20 + STA $70 + LDA #$01 + STA $71 + LDA #$24 + STA $72 + LDA #$01 + STA $73 + ADC ($41,X) + SBC ($3F,X) + + STA $F3 + LDY $F3 + LDA #$DA + STA $80 + LDA #$00 + STA $81 + LDA #$DC + STA $82 + LDA #$00 + STA $83 + LDA #$AA + ADC ($80),Y + SBC ($82),Y + STA $30 + +; CHECK test06 + LDA $30 + CMP $0206 + BEQ test07 + LDA #$06 + STA $0210 + JMP theend + + +; expected result: $15 = 0x7F +test07: + ; prepare memory + LDA #$00 + STA $34 + LDA #$FF + STA $0130 + LDA #$99 + STA $019D + LDA #$DB + STA $0199 + LDA #$2F + STA $32 + LDA #$32 + STA $4F + LDA #$30 + STA $33 + LDA #$70 + STA $AF + LDA #$18 + STA $30 + + ; imm + CMP #$18 + BEQ beq1 ; taken + AND #$00 ; not done +beq1: + ; zpg + ORA #$01 + CMP $30 + BNE bne1 ; taken + AND #$00 ; not done +bne1: + ; abs + LDX #$00 + CMP $0130 + BEQ beq2 ; not taken + STA $40 + LDX $40 +beq2: + ; zpx + CMP $27,X + BNE bne2 ; not taken + ORA #$84 + STA $41 + LDX $41 +bne2: + ; abx + AND #$DB + CMP $0100,X + BEQ beq3 ; taken + AND #$00 ; not done +beq3: + ; aby + STA $42 + LDY $42 + AND #$00 + CMP $0100,Y + BNE bne3 ; taken + ORA #$0F ; not done +bne3: + ; idx + STA $43 + LDX $43 + ORA #$24 + CMP ($40,X) + BEQ beq4 ; not taken + ORA #$7F +beq4: + ; idy + STA $44 + LDY $44 + EOR #$0F + CMP ($33),Y + BNE bne4 ; not taken + LDA $44 + STA $15 +bne4: + +; CHECK test07 + LDA $15 + CMP $0207 + BEQ test08 + LDA #$07 + STA $0210 + JMP theend + + +; expected result: $42 = 0xA5 +test08: + ; prepare memory + LDA #$A5 + STA $20 + STA $0120 + LDA #$5A + STA $21 + + ; cpx imm... + LDX #$A5 + CPX #$A5 + BEQ b1 ; taken + LDX #$01 ; not done +b1: + ; cpx zpg... + CPX $20 + BEQ b2 ; taken + LDX #$02 ; not done +b2: + ; cpx abs... + CPX $0120 + BEQ b3 ; taken + LDX #$03 ; not done +b3: + ; cpy imm... + STX $30 + LDY $30 + CPY #$A5 + BEQ b4 ; taken + LDY #$04 ; not done +b4: + ; cpy zpg... + CPY $20 + BEQ b5 ; taken + LDY #$05 ; not done +b5: + ; cpy abs... + CPY $0120 + BEQ b6 ; taken + LDY #$06 ; not done +b6: + ; bit zpg... + STY $31 + LDA $31 + BIT $20 + BNE b7 ; taken + LDA #$07 ; not done +b7: + ; bit abs... + BIT $0120 + BNE b8 ; taken + LDA #$08 ; not done +b8: + BIT $21 + BNE b9 ; not taken + STA $42 +b9: + +; CHECK test08 + LDA $42 + CMP $0208 + BEQ test09 + LDA #$08 + STA $0210 + JMP theend + + +; expected result: $80 = 0x1F +test09: + ; prepare memory + LDA #$54 + STA $32 + LDA #$B3 + STA $A1 + LDA #$87 + STA $43 + + ; BPL + LDX #$A1 + BPL bpl1 ; not taken + LDX #$32 +bpl1: + LDY $00,X + BPL bpl2 ; taken + LDA #$05 ; not done + LDX $A1 ; not done +bpl2: + + ; BMI + BMI bmi1 ; not taken + SBC #$03 +bmi1: + BMI bmi2 ; taken + LDA #$41 ; not done +bmi2: + + ; BVC + EOR #$30 + STA $32 + ADC $00,X + BVC bvc1 ; not taken + LDA #$03 +bvc1: + STA $54 + LDX $00,Y + ADC $51,X + BVC bvc2 ; taken + LDA #$E5 ; not done +bvc2: + + ; BVS + ADC $40,X + BVS bvs1 ; not taken + STA $0001,Y + ADC $55 +bvs1: + BVS bvs2 ; taken + LDA #$00 +bvs2: + + ; BCC + ADC #$F0 + BCC bcc1 ; not taken + STA $60 + ADC $43 +bcc1: + BCC bcc2 ; taken + LDA #$FF +bcc2: + + ; BCS + ADC $54 + BCS bcs1 ; not taken + ADC #$87 + LDX $60 +bcs1: + BCS bcs2 ; taken + LDA #$00 ; not done +bcs2: + STA $73,X + +; CHECK test09 + LDA $80 + CMP $0209 + BEQ test10 + LDA #$09 + STA $0210 + JMP theend + + +; expected result: $30 = 0xCE +test10: + +; RESET TO CARRY = 0 & OVERFLOW = 0 + ADC #$00 + + LDA #$99 + ADC #$87 + CLC + NOP + BCC t10bcc1 ; taken + ADC #$60 ; not done + ADC #$93 ; not done +t10bcc1: + SEC + NOP + BCC t10bcc2 ; not taken + CLV +t10bcc2: + BVC t10bvc1 ; taken + LDA #$00 ; not done +t10bvc1: + ADC #$AD + NOP + STA $30 + +; CHECK test10 + LDA $30 + CMP $020A + BEQ test11 + LDA #$0A + STA $0210 + JMP theend + + +; expected result: $30 = 0x29 +test11: + +; RESET TO CARRY = 0 & ZERO = 0 + ADC #$01 + + LDA #$27 + ADC #$01 + SEC + PHP + CLC + PLP + ADC #$00 + PHA + LDA #$00 + PLA + STA $30 + +; CHECK test11 + LDA $30 + CMP $020B + BEQ test12 + LDA #$0B + STA $0210 + JMP theend + + +; expected result: $33 = 0x42 +test12: + CLC + LDA #$42 + BCC runstuff + STA $33 + BCS t12end +runstuff: + LDA #$45 + PHA + LDA #$61 + PHA + SEC + PHP + CLC + RTI +t12end: + +; CHECK test12 + LDA $33 + CMP $020C + BEQ test13 + LDA #$0C + STA $0210 + JMP theend + + +; expected result: $21 = 0x6C (simulator) +; $21 = 0x0C (ours) +test13: + +; RESET TO CARRY = 0 & ZERO = 0 + ADC #$01 + + SEI + SED + PHP + PLA + STA $20 + CLI + CLD + PHP + PLA + ADC $20 + STA $21 + +; CHECK test13 + LDA $21 + CMP $020D + BEQ test14 + LDA #$0D + STA $0210 + JMP theend + + +; expect result: $60 = 0x42 +test14: + ; !!! NOTICE: BRK doesn't work in this + ; simulator, so commented instructions + ; are what should be executed... + ;JMP pass_intrp + LDA #$41 + STA $60 + ;RTI + ;pass_intrp: + ;LDA #$FF + ;STA $60 + ;BRK (two bytes) + INC $60 + +; CHECK test14 + LDA $60 + CMP $020E + BEQ suiteafinal + LDA #$0E + STA $0210 + JMP theend + +suiteafinal: + ; IF $0210 == 0xFE, INCREMENT + ; (checking that it didn't + ; happen to wander off and + ; not run our instructions + ; to say which tests failed...) + LDA #$FE + CMP $0210 + BNE theend + INC $0210 +theend: + BRK + BRK + ;JMP theend + LDX #$FF + TXS + RTS + + .segment "KERN" + + .ORG $FF00 + + RTI + + .segment "VECT" + + .ORG $FFFA + + .BYTE $00,$FF,$00,$FF,$00,$FF + ;-------------------------- END \ No newline at end of file diff --git a/testall.dat b/testall.dat index 69896ee..29cafa8 100644 --- a/testall.dat +++ b/testall.dat @@ -1,195 +1,195 @@ -; Test 6502 emulation. -ORG -$4000 -$A9 $00 $8D $10 $02 $A9 $55 $8D -$00 $02 $A9 $AA $8D $01 $02 $A9 -$FF $8D $02 $02 $A9 $6E $8D $03 -$02 $A9 $42 $8D $04 $02 $A9 $33 -$8D $05 $02 $A9 $9D $8D $06 $02 -$A9 $7F $8D $07 $02 $A9 $A5 $8D -$08 $02 $A9 $1F $8D $09 $02 $A9 -$CE $8D $0A $02 $A9 $29 $8D $0B -$02 $A9 $42 $8D $0C $02 $A9 $6C -$8D $0D $02 $A9 $42 $8D $0E $02 -$A9 $55 $A2 $2A $A0 $73 $85 $81 -$A9 $01 $85 $61 $A9 $7E $A5 $81 -$8D $10 $09 $A9 $7E $AD $10 $09 -$95 $56 $A9 $7E $B5 $56 $84 $60 -$91 $60 $A9 $7E $B1 $60 $9D $FF -$07 $A9 $7E $BD $FF $07 $99 $FF -$07 $A9 $7E $B9 $FF $07 $81 $36 -$A9 $7E $A1 $36 $86 $50 $A6 $60 -$A4 $50 $8E $13 $09 $A2 $22 $AE -$13 $09 $8C $14 $09 $A0 $99 $AC -$14 $09 $94 $2D $96 $77 $A0 $99 -$B4 $2D $A2 $22 $B6 $77 $A0 $99 -$BC $A0 $08 $A2 $22 $BE $A1 $08 -$9D $00 $02 $AD $2A $02 $CD $00 -$02 $F0 $03 $4C $C0 $45 $A9 $FE -$8D $10 $02 $A9 $55 $29 $53 $09 -$38 $49 $11 $85 $99 $A9 $B9 $85 -$10 $A9 $E7 $85 $11 $A9 $39 $85 -$12 $A5 $99 $25 $10 $05 $11 $45 -$12 $A2 $10 $85 $99 $A9 $BC $85 -$20 $A9 $31 $85 $21 $A9 $17 $85 -$22 $A5 $99 $35 $10 $15 $11 $55 -$12 $85 $99 $A9 $6F $8D $10 $01 -$A9 $3C $8D $11 $01 $A9 $27 $8D -$12 $01 $A5 $99 $2D $10 $01 $0D -$11 $01 $4D $12 $01 $85 $99 $A9 -$8A $8D $20 $01 $A9 $47 $8D $21 -$01 $A9 $8F $8D $22 $01 $A5 $99 -$3D $10 $01 $1D $11 $01 $5D $12 -$01 $A0 $20 $85 $99 $A9 $73 $8D -$30 $01 $A9 $2A $8D $31 $01 $A9 -$F1 $8D $32 $01 $A5 $99 $39 $10 -$01 $19 $11 $01 $59 $12 $01 $85 -$99 $A9 $70 $85 $30 $A9 $01 $85 -$31 $A9 $71 $85 $32 $A9 $01 $85 -$33 $A9 $72 $85 $34 $A9 $01 $85 -$35 $A9 $C5 $8D $70 $01 $A9 $7C -$8D $71 $01 $A9 $A1 $8D $72 $01 -$A5 $99 $21 $20 $01 $22 $41 $24 -$85 $99 $A9 $60 $85 $40 $A9 $01 -$85 $41 $A9 $61 $85 $42 $A9 $01 -$85 $43 $A9 $62 $85 $44 $A9 $01 -$85 $45 $A9 $37 $8D $50 $02 $A9 -$23 $8D $51 $02 $A9 $9D $8D $52 -$02 $A5 $99 $A0 $F0 $31 $40 $11 -$42 $51 $44 $85 $A9 $A5 $A9 $CD -$01 $02 $F0 $08 $A9 $01 $8D $10 -$02 $4C $C0 $45 $A9 $FF $A2 $00 -$85 $90 $E6 $90 $E6 $90 $A5 $90 -$A6 $90 $95 $90 $F6 $90 $B5 $90 -$A6 $91 $9D $90 $01 $EE $92 $01 -$BD $90 $01 $AE $92 $01 $9D $90 -$01 $FE $90 $01 $BD $90 $01 $AE -$93 $01 $9D $70 $01 $DE $70 $01 -$BD $70 $01 $AE $74 $01 $9D $70 -$01 $CE $73 $01 $BD $70 $01 $AE -$73 $01 $95 $70 $D6 $70 $B5 $70 -$A6 $72 $95 $70 $C6 $71 $C6 $71 -$A5 $71 $CD $02 $02 $F0 $08 $A9 -$02 $8D $10 $02 $4C $C0 $45 $A9 -$4B $4A $0A $85 $50 $06 $50 $06 -$50 $46 $50 $A5 $50 $A6 $50 $09 -$C9 $85 $60 $16 $4C $56 $4C $56 -$4C $B5 $4C $A6 $60 $09 $41 $8D -$2E $01 $5E $00 $01 $5E $00 $01 -$1E $00 $01 $BD $00 $01 $AE $2E -$01 $09 $81 $9D $00 $01 $4E $36 -$01 $4E $36 $01 $0E $36 $01 $BD -$00 $01 $2A $2A $6A $85 $70 $A6 -$70 $09 $03 $95 $0C $26 $C0 $66 -$C0 $66 $C0 $B5 $0C $A6 $C0 $85 -$D0 $36 $75 $36 $75 $76 $75 $A5 -$D0 $A6 $D0 $9D $00 $01 $2E $B7 -$01 $2E $B7 $01 $2E $B7 $01 $6E -$B7 $01 $BD $00 $01 $AE $B7 $01 -$8D $DD $01 $3E $00 $01 $7E $00 -$01 $7E $00 $01 $AD $DD $01 $CD -$03 $02 $F0 $08 $A9 $03 $8D $10 -$02 $4C $C0 $45 $A9 $E8 $85 $20 -$A9 $42 $85 $21 $A9 $00 $09 $03 -$4C $D5 $42 $09 $FF $09 $30 $20 -$E1 $42 $09 $42 $6C $20 $00 $09 -$FF $85 $30 $A6 $30 $A9 $00 $60 -$95 $0D $A5 $40 $CD $04 $02 $F0 -$08 $A9 $04 $8D $10 $02 $4C $C0 -$45 $A9 $35 $AA $CA $CA $E8 $8A -$A8 $88 $88 $C8 $98 $AA $A9 $20 -$9A $A2 $10 $BA $8A $85 $40 $A5 -$40 $CD $05 $02 $F0 $08 $A9 $05 -$8D $10 $02 $4C $C0 $45 $2A $A9 -$6A $85 $50 $A9 $6B $85 $51 $A9 -$A1 $85 $60 $A9 $A2 $85 $61 $A9 -$FF $69 $FF $69 $FF $E9 $AE $85 -$40 $A6 $40 $75 $00 $F5 $01 $65 -$60 $E5 $61 $8D $20 $01 $A9 $4D -$8D $21 $01 $A9 $23 $6D $20 $01 -$ED $21 $01 $85 $F0 $A6 $F0 $A9 -$64 $8D $24 $01 $A9 $62 $8D $25 -$01 $A9 $26 $7D $00 $01 $FD $01 -$01 $85 $F1 $A4 $F1 $A9 $E5 $8D -$28 $01 $A9 $E9 $8D $29 $01 $A9 -$34 $79 $00 $01 $F9 $01 $01 $85 -$F2 $A6 $F2 $A9 $20 $85 $70 $A9 -$01 $85 $71 $A9 $24 $85 $72 $A9 -$01 $85 $73 $61 $41 $E1 $3F $85 -$F3 $A4 $F3 $A9 $DA $85 $80 $A9 -$00 $85 $81 $A9 $DC $85 $82 $A9 -$00 $85 $83 $A9 $AA $71 $80 $F1 -$82 $85 $30 $A5 $30 $CD $06 $02 -$F0 $08 $A9 $06 $8D $10 $02 $4C -$C0 $45 $A9 $00 $85 $34 $A9 $FF -$8D $30 $01 $A9 $99 $8D $9D $01 -$A9 $DB $8D $99 $01 $A9 $2F $85 -$32 $A9 $32 $85 $4F $A9 $30 $85 -$33 $A9 $70 $85 $AF $A9 $18 $85 -$30 $C9 $18 $F0 $02 $29 $00 $09 -$01 $C5 $30 $D0 $02 $29 $00 $A2 -$00 $CD $30 $01 $F0 $04 $85 $40 -$A6 $40 $D5 $27 $D0 $06 $09 $84 -$85 $41 $A6 $41 $29 $DB $DD $00 -$01 $F0 $02 $29 $00 $85 $42 $A4 -$42 $29 $00 $D9 $00 $01 $D0 $02 -$09 $0F $85 $43 $A6 $43 $09 $24 -$C1 $40 $F0 $02 $09 $7F $85 $44 -$A4 $44 $49 $0F $D1 $33 $D0 $04 -$A5 $44 $85 $15 $A5 $15 $CD $07 -$02 $F0 $08 $A9 $07 $8D $10 $02 -$4C $C0 $45 $A9 $A5 $85 $20 $8D -$20 $01 $A9 $5A $85 $21 $A2 $A5 -$E0 $A5 $F0 $02 $A2 $01 $E4 $20 -$F0 $02 $A2 $02 $EC $20 $01 $F0 -$02 $A2 $03 $86 $30 $A4 $30 $C0 -$A5 $F0 $02 $A0 $04 $C4 $20 $F0 -$02 $A0 $05 $CC $20 $01 $F0 $02 -$A0 $06 $84 $31 $A5 $31 $24 $20 -$D0 $02 $A9 $07 $2C $20 $01 $D0 -$02 $A9 $08 $24 $21 $D0 $02 $85 -$42 $A5 $42 $CD $08 $02 $F0 $08 -$A9 $08 $8D $10 $02 $4C $C0 $45 -$A9 $54 $85 $32 $A9 $B3 $85 $A1 -$A9 $87 $85 $43 $A2 $A1 $10 $02 -$A2 $32 $B4 $00 $10 $04 $A9 $05 -$A6 $A1 $30 $02 $E9 $03 $30 $02 -$A9 $41 $49 $30 $85 $32 $75 $00 -$50 $02 $A9 $03 $85 $54 $B6 $00 -$75 $51 $50 $02 $A9 $E5 $75 $40 -$70 $05 $99 $01 $00 $65 $55 $70 -$02 $A9 $00 $69 $F0 $90 $04 $85 -$60 $65 $43 $90 $02 $A9 $FF $65 -$54 $B0 $04 $69 $87 $A6 $60 $B0 -$02 $A9 $00 $95 $73 $A5 $80 $CD -$09 $02 $F0 $08 $A9 $09 $8D $10 -$02 $4C $C0 $45 $69 $00 $A9 $99 -$69 $87 $18 $EA $90 $04 $69 $60 -$69 $93 $38 $EA $90 $01 $B8 $50 -$02 $A9 $00 $69 $AD $EA $85 $30 -$A5 $30 $CD $0A $02 $F0 $08 $A9 -$0A $8D $10 $02 $4C $C0 $45 $69 -$01 $A9 $27 $69 $01 $38 $08 $18 -$28 $69 $00 $48 $A9 $00 $68 $85 -$30 $A5 $30 $CD $0B $02 $F0 $08 -$A9 $0B $8D $10 $02 $4C $C0 $45 -$18 $A9 $42 $90 $04 $85 $33 $B0 -$0A $A9 $45 $48 $A9 $61 $48 $38 -$08 $18 $40 $A5 $33 $CD $0C $02 -$F0 $08 $A9 $0C $8D $10 $02 $4C -$C0 $45 $69 $01 $78 $F8 $08 $68 -$85 $20 $58 $D8 $08 $68 $65 $20 -$85 $21 $A5 $21 $CD $0D $02 $F0 -$08 $A9 $0D $8D $10 $02 $4C $C0 -$45 $A9 $41 $85 $60 $E6 $60 $A5 -$60 $CD $0E $02 $F0 $08 $A9 $0E -$8D $10 $02 $4C $C0 $45 $A9 $FE -$CD $10 $02 $D0 $03 $EE $10 $02 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 +; Test 6502 emulation. +ORG +$4000 +$A9 $00 $8D $10 $02 $A9 $55 $8D +$00 $02 $A9 $AA $8D $01 $02 $A9 +$FF $8D $02 $02 $A9 $6E $8D $03 +$02 $A9 $42 $8D $04 $02 $A9 $33 +$8D $05 $02 $A9 $9D $8D $06 $02 +$A9 $7F $8D $07 $02 $A9 $A5 $8D +$08 $02 $A9 $1F $8D $09 $02 $A9 +$CE $8D $0A $02 $A9 $29 $8D $0B +$02 $A9 $42 $8D $0C $02 $A9 $6C +$8D $0D $02 $A9 $42 $8D $0E $02 +$A9 $55 $A2 $2A $A0 $73 $85 $81 +$A9 $01 $85 $61 $A9 $7E $A5 $81 +$8D $10 $09 $A9 $7E $AD $10 $09 +$95 $56 $A9 $7E $B5 $56 $84 $60 +$91 $60 $A9 $7E $B1 $60 $9D $FF +$07 $A9 $7E $BD $FF $07 $99 $FF +$07 $A9 $7E $B9 $FF $07 $81 $36 +$A9 $7E $A1 $36 $86 $50 $A6 $60 +$A4 $50 $8E $13 $09 $A2 $22 $AE +$13 $09 $8C $14 $09 $A0 $99 $AC +$14 $09 $94 $2D $96 $77 $A0 $99 +$B4 $2D $A2 $22 $B6 $77 $A0 $99 +$BC $A0 $08 $A2 $22 $BE $A1 $08 +$9D $00 $02 $AD $2A $02 $CD $00 +$02 $F0 $03 $4C $C0 $45 $A9 $FE +$8D $10 $02 $A9 $55 $29 $53 $09 +$38 $49 $11 $85 $99 $A9 $B9 $85 +$10 $A9 $E7 $85 $11 $A9 $39 $85 +$12 $A5 $99 $25 $10 $05 $11 $45 +$12 $A2 $10 $85 $99 $A9 $BC $85 +$20 $A9 $31 $85 $21 $A9 $17 $85 +$22 $A5 $99 $35 $10 $15 $11 $55 +$12 $85 $99 $A9 $6F $8D $10 $01 +$A9 $3C $8D $11 $01 $A9 $27 $8D +$12 $01 $A5 $99 $2D $10 $01 $0D +$11 $01 $4D $12 $01 $85 $99 $A9 +$8A $8D $20 $01 $A9 $47 $8D $21 +$01 $A9 $8F $8D $22 $01 $A5 $99 +$3D $10 $01 $1D $11 $01 $5D $12 +$01 $A0 $20 $85 $99 $A9 $73 $8D +$30 $01 $A9 $2A $8D $31 $01 $A9 +$F1 $8D $32 $01 $A5 $99 $39 $10 +$01 $19 $11 $01 $59 $12 $01 $85 +$99 $A9 $70 $85 $30 $A9 $01 $85 +$31 $A9 $71 $85 $32 $A9 $01 $85 +$33 $A9 $72 $85 $34 $A9 $01 $85 +$35 $A9 $C5 $8D $70 $01 $A9 $7C +$8D $71 $01 $A9 $A1 $8D $72 $01 +$A5 $99 $21 $20 $01 $22 $41 $24 +$85 $99 $A9 $60 $85 $40 $A9 $01 +$85 $41 $A9 $61 $85 $42 $A9 $01 +$85 $43 $A9 $62 $85 $44 $A9 $01 +$85 $45 $A9 $37 $8D $50 $02 $A9 +$23 $8D $51 $02 $A9 $9D $8D $52 +$02 $A5 $99 $A0 $F0 $31 $40 $11 +$42 $51 $44 $85 $A9 $A5 $A9 $CD +$01 $02 $F0 $08 $A9 $01 $8D $10 +$02 $4C $C0 $45 $A9 $FF $A2 $00 +$85 $90 $E6 $90 $E6 $90 $A5 $90 +$A6 $90 $95 $90 $F6 $90 $B5 $90 +$A6 $91 $9D $90 $01 $EE $92 $01 +$BD $90 $01 $AE $92 $01 $9D $90 +$01 $FE $90 $01 $BD $90 $01 $AE +$93 $01 $9D $70 $01 $DE $70 $01 +$BD $70 $01 $AE $74 $01 $9D $70 +$01 $CE $73 $01 $BD $70 $01 $AE +$73 $01 $95 $70 $D6 $70 $B5 $70 +$A6 $72 $95 $70 $C6 $71 $C6 $71 +$A5 $71 $CD $02 $02 $F0 $08 $A9 +$02 $8D $10 $02 $4C $C0 $45 $A9 +$4B $4A $0A $85 $50 $06 $50 $06 +$50 $46 $50 $A5 $50 $A6 $50 $09 +$C9 $85 $60 $16 $4C $56 $4C $56 +$4C $B5 $4C $A6 $60 $09 $41 $8D +$2E $01 $5E $00 $01 $5E $00 $01 +$1E $00 $01 $BD $00 $01 $AE $2E +$01 $09 $81 $9D $00 $01 $4E $36 +$01 $4E $36 $01 $0E $36 $01 $BD +$00 $01 $2A $2A $6A $85 $70 $A6 +$70 $09 $03 $95 $0C $26 $C0 $66 +$C0 $66 $C0 $B5 $0C $A6 $C0 $85 +$D0 $36 $75 $36 $75 $76 $75 $A5 +$D0 $A6 $D0 $9D $00 $01 $2E $B7 +$01 $2E $B7 $01 $2E $B7 $01 $6E +$B7 $01 $BD $00 $01 $AE $B7 $01 +$8D $DD $01 $3E $00 $01 $7E $00 +$01 $7E $00 $01 $AD $DD $01 $CD +$03 $02 $F0 $08 $A9 $03 $8D $10 +$02 $4C $C0 $45 $A9 $E8 $85 $20 +$A9 $42 $85 $21 $A9 $00 $09 $03 +$4C $D5 $42 $09 $FF $09 $30 $20 +$E1 $42 $09 $42 $6C $20 $00 $09 +$FF $85 $30 $A6 $30 $A9 $00 $60 +$95 $0D $A5 $40 $CD $04 $02 $F0 +$08 $A9 $04 $8D $10 $02 $4C $C0 +$45 $A9 $35 $AA $CA $CA $E8 $8A +$A8 $88 $88 $C8 $98 $AA $A9 $20 +$9A $A2 $10 $BA $8A $85 $40 $A5 +$40 $CD $05 $02 $F0 $08 $A9 $05 +$8D $10 $02 $4C $C0 $45 $2A $A9 +$6A $85 $50 $A9 $6B $85 $51 $A9 +$A1 $85 $60 $A9 $A2 $85 $61 $A9 +$FF $69 $FF $69 $FF $E9 $AE $85 +$40 $A6 $40 $75 $00 $F5 $01 $65 +$60 $E5 $61 $8D $20 $01 $A9 $4D +$8D $21 $01 $A9 $23 $6D $20 $01 +$ED $21 $01 $85 $F0 $A6 $F0 $A9 +$64 $8D $24 $01 $A9 $62 $8D $25 +$01 $A9 $26 $7D $00 $01 $FD $01 +$01 $85 $F1 $A4 $F1 $A9 $E5 $8D +$28 $01 $A9 $E9 $8D $29 $01 $A9 +$34 $79 $00 $01 $F9 $01 $01 $85 +$F2 $A6 $F2 $A9 $20 $85 $70 $A9 +$01 $85 $71 $A9 $24 $85 $72 $A9 +$01 $85 $73 $61 $41 $E1 $3F $85 +$F3 $A4 $F3 $A9 $DA $85 $80 $A9 +$00 $85 $81 $A9 $DC $85 $82 $A9 +$00 $85 $83 $A9 $AA $71 $80 $F1 +$82 $85 $30 $A5 $30 $CD $06 $02 +$F0 $08 $A9 $06 $8D $10 $02 $4C +$C0 $45 $A9 $00 $85 $34 $A9 $FF +$8D $30 $01 $A9 $99 $8D $9D $01 +$A9 $DB $8D $99 $01 $A9 $2F $85 +$32 $A9 $32 $85 $4F $A9 $30 $85 +$33 $A9 $70 $85 $AF $A9 $18 $85 +$30 $C9 $18 $F0 $02 $29 $00 $09 +$01 $C5 $30 $D0 $02 $29 $00 $A2 +$00 $CD $30 $01 $F0 $04 $85 $40 +$A6 $40 $D5 $27 $D0 $06 $09 $84 +$85 $41 $A6 $41 $29 $DB $DD $00 +$01 $F0 $02 $29 $00 $85 $42 $A4 +$42 $29 $00 $D9 $00 $01 $D0 $02 +$09 $0F $85 $43 $A6 $43 $09 $24 +$C1 $40 $F0 $02 $09 $7F $85 $44 +$A4 $44 $49 $0F $D1 $33 $D0 $04 +$A5 $44 $85 $15 $A5 $15 $CD $07 +$02 $F0 $08 $A9 $07 $8D $10 $02 +$4C $C0 $45 $A9 $A5 $85 $20 $8D +$20 $01 $A9 $5A $85 $21 $A2 $A5 +$E0 $A5 $F0 $02 $A2 $01 $E4 $20 +$F0 $02 $A2 $02 $EC $20 $01 $F0 +$02 $A2 $03 $86 $30 $A4 $30 $C0 +$A5 $F0 $02 $A0 $04 $C4 $20 $F0 +$02 $A0 $05 $CC $20 $01 $F0 $02 +$A0 $06 $84 $31 $A5 $31 $24 $20 +$D0 $02 $A9 $07 $2C $20 $01 $D0 +$02 $A9 $08 $24 $21 $D0 $02 $85 +$42 $A5 $42 $CD $08 $02 $F0 $08 +$A9 $08 $8D $10 $02 $4C $C0 $45 +$A9 $54 $85 $32 $A9 $B3 $85 $A1 +$A9 $87 $85 $43 $A2 $A1 $10 $02 +$A2 $32 $B4 $00 $10 $04 $A9 $05 +$A6 $A1 $30 $02 $E9 $03 $30 $02 +$A9 $41 $49 $30 $85 $32 $75 $00 +$50 $02 $A9 $03 $85 $54 $B6 $00 +$75 $51 $50 $02 $A9 $E5 $75 $40 +$70 $05 $99 $01 $00 $65 $55 $70 +$02 $A9 $00 $69 $F0 $90 $04 $85 +$60 $65 $43 $90 $02 $A9 $FF $65 +$54 $B0 $04 $69 $87 $A6 $60 $B0 +$02 $A9 $00 $95 $73 $A5 $80 $CD +$09 $02 $F0 $08 $A9 $09 $8D $10 +$02 $4C $C0 $45 $69 $00 $A9 $99 +$69 $87 $18 $EA $90 $04 $69 $60 +$69 $93 $38 $EA $90 $01 $B8 $50 +$02 $A9 $00 $69 $AD $EA $85 $30 +$A5 $30 $CD $0A $02 $F0 $08 $A9 +$0A $8D $10 $02 $4C $C0 $45 $69 +$01 $A9 $27 $69 $01 $38 $08 $18 +$28 $69 $00 $48 $A9 $00 $68 $85 +$30 $A5 $30 $CD $0B $02 $F0 $08 +$A9 $0B $8D $10 $02 $4C $C0 $45 +$18 $A9 $42 $90 $04 $85 $33 $B0 +$0A $A9 $45 $48 $A9 $61 $48 $38 +$08 $18 $40 $A5 $33 $CD $0C $02 +$F0 $08 $A9 $0C $8D $10 $02 $4C +$C0 $45 $69 $01 $78 $F8 $08 $68 +$85 $20 $58 $D8 $08 $68 $65 $20 +$85 $21 $A5 $21 $CD $0D $02 $F0 +$08 $A9 $0D $8D $10 $02 $4C $C0 +$45 $A9 $41 $85 $60 $E6 $60 $A5 +$60 $CD $0E $02 $F0 $08 $A9 $0E +$8D $10 $02 $4C $C0 $45 $A9 $FE +$CD $10 $02 $D0 $03 $EE $10 $02 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 diff --git a/testall.lst b/testall.lst index 2e7075f..9d9c4b0 100644 --- a/testall.lst +++ b/testall.lst @@ -1,960 +1,960 @@ -ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz -Main file : testall.asm -Current file: testall.asm - -000000r 1 ; Testing 6502 opcodes. -000000r 1 ; Copied and adapted from AllSuiteA.asm from project hmc-6502: -000000r 1 ; https://code.google.com/archive/p/hmc-6502/ -000000r 1 ; EXPECTED FINAL RESULTS: $0210 = FF -000000r 1 ; (any other number will be the test that failed) -000000r 1 ; To build with cl65: -000000r 1 ; cl65 -C testall_cl65.cfg -l --start-addr 16384 -t none -o tall.bin testall.asm -000000r 1 ; then load to simulator from debug console with 'L B TALL.BIN' -000000r 1 ; and execute with 'X 4000'. -000000r 1 -000000r 1 .segment "CODE1" -000000r 1 -000000r 1 .segment "CODE2" -000000r 1 -000000r 1 .ORG $4000 -004000 1 -004000 1 start: -004000 1 ; initialize: -004000 1 A9 00 LDA #$00 -004002 1 8D 10 02 STA $0210 -004005 1 ; store each test's expected -004005 1 A9 55 LDA #$55 -004007 1 8D 00 02 STA $0200 -00400A 1 A9 AA LDA #$AA -00400C 1 8D 01 02 STA $0201 -00400F 1 A9 FF LDA #$FF -004011 1 8D 02 02 STA $0202 -004014 1 A9 6E LDA #$6E -004016 1 8D 03 02 STA $0203 -004019 1 A9 42 LDA #$42 -00401B 1 8D 04 02 STA $0204 -00401E 1 A9 33 LDA #$33 -004020 1 8D 05 02 STA $0205 -004023 1 A9 9D LDA #$9D -004025 1 8D 06 02 STA $0206 -004028 1 A9 7F LDA #$7F -00402A 1 8D 07 02 STA $0207 -00402D 1 A9 A5 LDA #$A5 -00402F 1 8D 08 02 STA $0208 -004032 1 A9 1F LDA #$1F -004034 1 8D 09 02 STA $0209 -004037 1 A9 CE LDA #$CE -004039 1 8D 0A 02 STA $020A -00403C 1 A9 29 LDA #$29 -00403E 1 8D 0B 02 STA $020B -004041 1 A9 42 LDA #$42 -004043 1 8D 0C 02 STA $020C -004046 1 A9 6C LDA #$6C -004048 1 8D 0D 02 STA $020D -00404B 1 A9 42 LDA #$42 -00404D 1 8D 0E 02 STA $020E -004050 1 -004050 1 -004050 1 ; expected result: $022A = 0x55 -004050 1 test00: -004050 1 A9 55 LDA #85 -004052 1 A2 2A LDX #42 -004054 1 A0 73 LDY #115 -004056 1 85 81 STA $81 -004058 1 A9 01 LDA #$01 -00405A 1 85 61 STA $61 -00405C 1 A9 7E LDA #$7E -00405E 1 A5 81 LDA $81 -004060 1 8D 10 09 STA $0910 -004063 1 A9 7E LDA #$7E -004065 1 AD 10 09 LDA $0910 -004068 1 95 56 STA $56,X -00406A 1 A9 7E LDA #$7E -00406C 1 B5 56 LDA $56,X -00406E 1 84 60 STY $60 -004070 1 91 60 STA ($60),Y -004072 1 A9 7E LDA #$7E -004074 1 B1 60 LDA ($60),Y -004076 1 9D FF 07 STA $07ff,X -004079 1 A9 7E LDA #$7E -00407B 1 BD FF 07 LDA $07ff,X -00407E 1 99 FF 07 STA $07ff,Y -004081 1 A9 7E LDA #$7E -004083 1 B9 FF 07 LDA $07ff,Y -004086 1 81 36 STA ($36,X) -004088 1 A9 7E LDA #$7E -00408A 1 A1 36 LDA ($36,X) -00408C 1 86 50 STX $50 -00408E 1 A6 60 LDX $60 -004090 1 A4 50 LDY $50 -004092 1 8E 13 09 STX $0913 -004095 1 A2 22 LDX #$22 -004097 1 AE 13 09 LDX $0913 -00409A 1 8C 14 09 STY $0914 -00409D 1 A0 99 LDY #$99 -00409F 1 AC 14 09 LDY $0914 -0040A2 1 94 2D STY $2D,X -0040A4 1 96 77 STX $77,Y -0040A6 1 A0 99 LDY #$99 -0040A8 1 B4 2D LDY $2D,X -0040AA 1 A2 22 LDX #$22 -0040AC 1 B6 77 LDX $77,Y -0040AE 1 A0 99 LDY #$99 -0040B0 1 BC A0 08 LDY $08A0,X -0040B3 1 A2 22 LDX #$22 -0040B5 1 BE A1 08 LDX $08A1,Y -0040B8 1 9D 00 02 STA $0200,X -0040BB 1 -0040BB 1 ; CHECK test00: -0040BB 1 AD 2A 02 LDA $022A -0040BE 1 CD 00 02 CMP $0200 -0040C1 1 F0 03 BEQ test00pass -0040C3 1 4C C0 45 JMP theend -0040C6 1 test00pass: -0040C6 1 A9 FE LDA #$FE -0040C8 1 8D 10 02 STA $0210 -0040CB 1 -0040CB 1 -0040CB 1 ; expected result: $A9 = 0xAA -0040CB 1 test01: -0040CB 1 ; imm -0040CB 1 A9 55 LDA #85 -0040CD 1 29 53 AND #83 -0040CF 1 09 38 ORA #56 -0040D1 1 49 11 EOR #17 -0040D3 1 -0040D3 1 ; zpg -0040D3 1 85 99 STA $99 -0040D5 1 A9 B9 LDA #185 -0040D7 1 85 10 STA $10 -0040D9 1 A9 E7 LDA #231 -0040DB 1 85 11 STA $11 -0040DD 1 A9 39 LDA #57 -0040DF 1 85 12 STA $12 -0040E1 1 A5 99 LDA $99 -0040E3 1 25 10 AND $10 -0040E5 1 05 11 ORA $11 -0040E7 1 45 12 EOR $12 -0040E9 1 -0040E9 1 ; zpx -0040E9 1 A2 10 LDX #16 -0040EB 1 85 99 STA $99 -0040ED 1 A9 BC LDA #188 -0040EF 1 85 20 STA $20 -0040F1 1 A9 31 LDA #49 -0040F3 1 85 21 STA $21 -0040F5 1 A9 17 LDA #23 -0040F7 1 85 22 STA $22 -0040F9 1 A5 99 LDA $99 -0040FB 1 35 10 AND $10,X -0040FD 1 15 11 ORA $11,X -0040FF 1 55 12 EOR $12,X -004101 1 -004101 1 ; abs -004101 1 85 99 STA $99 -004103 1 A9 6F LDA #111 -004105 1 8D 10 01 STA $0110 -004108 1 A9 3C LDA #60 -00410A 1 8D 11 01 STA $0111 -00410D 1 A9 27 LDA #39 -00410F 1 8D 12 01 STA $0112 -004112 1 A5 99 LDA $99 -004114 1 2D 10 01 AND $0110 -004117 1 0D 11 01 ORA $0111 -00411A 1 4D 12 01 EOR $0112 -00411D 1 -00411D 1 ; abx -00411D 1 85 99 STA $99 -00411F 1 A9 8A LDA #138 -004121 1 8D 20 01 STA $0120 -004124 1 A9 47 LDA #71 -004126 1 8D 21 01 STA $0121 -004129 1 A9 8F LDA #143 -00412B 1 8D 22 01 STA $0122 -00412E 1 A5 99 LDA $99 -004130 1 3D 10 01 AND $0110,X -004133 1 1D 11 01 ORA $0111,X -004136 1 5D 12 01 EOR $0112,X -004139 1 -004139 1 ; aby -004139 1 A0 20 LDY #32 -00413B 1 85 99 STA $99 -00413D 1 A9 73 LDA #115 -00413F 1 8D 30 01 STA $0130 -004142 1 A9 2A LDA #42 -004144 1 8D 31 01 STA $0131 -004147 1 A9 F1 LDA #241 -004149 1 8D 32 01 STA $0132 -00414C 1 A5 99 LDA $99 -00414E 1 39 10 01 AND $0110,Y -004151 1 19 11 01 ORA $0111,Y -004154 1 59 12 01 EOR $0112,Y -004157 1 -004157 1 ; idx -004157 1 85 99 STA $99 -004159 1 A9 70 LDA #112 -00415B 1 85 30 STA $30 -00415D 1 A9 01 LDA #$01 -00415F 1 85 31 STA $31 -004161 1 A9 71 LDA #113 -004163 1 85 32 STA $32 -004165 1 A9 01 LDA #$01 -004167 1 85 33 STA $33 -004169 1 A9 72 LDA #114 -00416B 1 85 34 STA $34 -00416D 1 A9 01 LDA #$01 -00416F 1 85 35 STA $35 -004171 1 A9 C5 LDA #197 -004173 1 8D 70 01 STA $0170 -004176 1 A9 7C LDA #124 -004178 1 8D 71 01 STA $0171 -00417B 1 A9 A1 LDA #161 -00417D 1 8D 72 01 STA $0172 -004180 1 A5 99 LDA $99 -004182 1 21 20 AND ($20,X) -004184 1 01 22 ORA ($22,X) -004186 1 41 24 EOR ($24,X) -004188 1 -004188 1 ; idy -004188 1 85 99 STA $99 -00418A 1 A9 60 LDA #96 -00418C 1 85 40 STA $40 -00418E 1 A9 01 LDA #$01 -004190 1 85 41 STA $41 -004192 1 A9 61 LDA #97 -004194 1 85 42 STA $42 -004196 1 A9 01 LDA #$01 -004198 1 85 43 STA $43 -00419A 1 A9 62 LDA #98 -00419C 1 85 44 STA $44 -00419E 1 A9 01 LDA #$01 -0041A0 1 85 45 STA $45 -0041A2 1 A9 37 LDA #55 -0041A4 1 8D 50 02 STA $0250 -0041A7 1 A9 23 LDA #35 -0041A9 1 8D 51 02 STA $0251 -0041AC 1 A9 9D LDA #157 -0041AE 1 8D 52 02 STA $0252 -0041B1 1 A5 99 LDA $99 -0041B3 1 A0 F0 LDY #$F0 -0041B5 1 31 40 AND ($40),Y -0041B7 1 11 42 ORA ($42),Y -0041B9 1 51 44 EOR ($44),Y -0041BB 1 -0041BB 1 85 A9 STA $A9 -0041BD 1 -0041BD 1 ; CHECK test01 -0041BD 1 A5 A9 LDA $A9 -0041BF 1 CD 01 02 CMP $0201 -0041C2 1 F0 08 BEQ test02 -0041C4 1 A9 01 LDA #$01 -0041C6 1 8D 10 02 STA $0210 -0041C9 1 4C C0 45 JMP theend -0041CC 1 -0041CC 1 -0041CC 1 ; expected result: $71 = 0xFF -0041CC 1 test02: -0041CC 1 A9 FF LDA #$FF -0041CE 1 A2 00 LDX #$00 -0041D0 1 -0041D0 1 85 90 STA $90 -0041D2 1 E6 90 INC $90 -0041D4 1 E6 90 INC $90 -0041D6 1 A5 90 LDA $90 -0041D8 1 A6 90 LDX $90 -0041DA 1 -0041DA 1 95 90 STA $90,X -0041DC 1 F6 90 INC $90,X -0041DE 1 B5 90 LDA $90,X -0041E0 1 A6 91 LDX $91 -0041E2 1 -0041E2 1 9D 90 01 STA $0190,X -0041E5 1 EE 92 01 INC $0192 -0041E8 1 BD 90 01 LDA $0190,X -0041EB 1 AE 92 01 LDX $0192 -0041EE 1 -0041EE 1 9D 90 01 STA $0190,X -0041F1 1 FE 90 01 INC $0190,X -0041F4 1 BD 90 01 LDA $0190,X -0041F7 1 AE 93 01 LDX $0193 -0041FA 1 -0041FA 1 9D 70 01 STA $0170,X -0041FD 1 DE 70 01 DEC $0170,X -004200 1 BD 70 01 LDA $0170,X -004203 1 AE 74 01 LDX $0174 -004206 1 -004206 1 9D 70 01 STA $0170,X -004209 1 CE 73 01 DEC $0173 -00420C 1 BD 70 01 LDA $0170,X -00420F 1 AE 73 01 LDX $0173 -004212 1 -004212 1 95 70 STA $70,X -004214 1 D6 70 DEC $70,X -004216 1 B5 70 LDA $70,X -004218 1 A6 72 LDX $72 -00421A 1 -00421A 1 95 70 STA $70,X -00421C 1 C6 71 DEC $71 -00421E 1 C6 71 DEC $71 -004220 1 -004220 1 ; CHECK test02 -004220 1 A5 71 LDA $71 -004222 1 CD 02 02 CMP $0202 -004225 1 F0 08 BEQ test03 -004227 1 A9 02 LDA #$02 -004229 1 8D 10 02 STA $0210 -00422C 1 4C C0 45 JMP theend -00422F 1 -00422F 1 -00422F 1 ; expected result: $01DD = 0x6E -00422F 1 test03: -00422F 1 A9 4B LDA #$4B -004231 1 4A LSR -004232 1 0A ASL -004233 1 -004233 1 85 50 STA $50 -004235 1 06 50 ASL $50 -004237 1 06 50 ASL $50 -004239 1 46 50 LSR $50 -00423B 1 A5 50 LDA $50 -00423D 1 -00423D 1 A6 50 LDX $50 -00423F 1 09 C9 ORA #$C9 -004241 1 85 60 STA $60 -004243 1 16 4C ASL $4C,X -004245 1 56 4C LSR $4C,X -004247 1 56 4C LSR $4C,X -004249 1 B5 4C LDA $4C,X -00424B 1 -00424B 1 A6 60 LDX $60 -00424D 1 09 41 ORA #$41 -00424F 1 8D 2E 01 STA $012E -004252 1 5E 00 01 LSR $0100,X -004255 1 5E 00 01 LSR $0100,X -004258 1 1E 00 01 ASL $0100,X -00425B 1 BD 00 01 LDA $0100,X -00425E 1 -00425E 1 AE 2E 01 LDX $012E -004261 1 09 81 ORA #$81 -004263 1 9D 00 01 STA $0100,X -004266 1 4E 36 01 LSR $0136 -004269 1 4E 36 01 LSR $0136 -00426C 1 0E 36 01 ASL $0136 -00426F 1 BD 00 01 LDA $0100,X -004272 1 -004272 1 ; rol & ror -004272 1 -004272 1 2A ROL -004273 1 2A ROL -004274 1 6A ROR -004275 1 85 70 STA $70 -004277 1 -004277 1 A6 70 LDX $70 -004279 1 09 03 ORA #$03 -00427B 1 95 0C STA $0C,X -00427D 1 26 C0 ROL $C0 -00427F 1 66 C0 ROR $C0 -004281 1 66 C0 ROR $C0 -004283 1 B5 0C LDA $0C,X -004285 1 -004285 1 A6 C0 LDX $C0 -004287 1 85 D0 STA $D0 -004289 1 36 75 ROL $75,X -00428B 1 36 75 ROL $75,X -00428D 1 76 75 ROR $75,X -00428F 1 A5 D0 LDA $D0 -004291 1 -004291 1 A6 D0 LDX $D0 -004293 1 9D 00 01 STA $0100,X -004296 1 2E B7 01 ROL $01B7 -004299 1 2E B7 01 ROL $01B7 -00429C 1 2E B7 01 ROL $01B7 -00429F 1 6E B7 01 ROR $01B7 -0042A2 1 BD 00 01 LDA $0100,X -0042A5 1 -0042A5 1 AE B7 01 LDX $01B7 -0042A8 1 8D DD 01 STA $01DD -0042AB 1 3E 00 01 ROL $0100,X -0042AE 1 7E 00 01 ROR $0100,X -0042B1 1 7E 00 01 ROR $0100,X -0042B4 1 -0042B4 1 ; CHECK test03 -0042B4 1 AD DD 01 LDA $01DD -0042B7 1 CD 03 02 CMP $0203 -0042BA 1 F0 08 BEQ test04 -0042BC 1 A9 03 LDA #$03 -0042BE 1 8D 10 02 STA $0210 -0042C1 1 4C C0 45 JMP theend -0042C4 1 -0042C4 1 -0042C4 1 ; expected result: $40 = 0x42 -0042C4 1 test04: -0042C4 1 A9 E8 LDA #$E8 ;originally:#$7C -0042C6 1 85 20 STA $20 -0042C8 1 A9 42 LDA #$42 ;originally:#$02 -0042CA 1 85 21 STA $21 -0042CC 1 A9 00 LDA #$00 -0042CE 1 09 03 ORA #$03 -0042D0 1 4C D5 42 JMP jump1 -0042D3 1 09 FF ORA #$FF ; not done -0042D5 1 jump1: -0042D5 1 09 30 ORA #$30 -0042D7 1 20 E1 42 JSR subr -0042DA 1 09 42 ORA #$42 -0042DC 1 6C 20 00 JMP ($0020) -0042DF 1 09 FF ORA #$FF ; not done -0042E1 1 subr: -0042E1 1 85 30 STA $30 -0042E3 1 A6 30 LDX $30 -0042E5 1 A9 00 LDA #$00 -0042E7 1 60 RTS -0042E8 1 final: -0042E8 1 95 0D STA $0D,X -0042EA 1 -0042EA 1 ; CHECK test04 -0042EA 1 A5 40 LDA $40 -0042EC 1 CD 04 02 CMP $0204 -0042EF 1 F0 08 BEQ test05 -0042F1 1 A9 04 LDA #$04 -0042F3 1 8D 10 02 STA $0210 -0042F6 1 4C C0 45 JMP theend -0042F9 1 -0042F9 1 -0042F9 1 ; expected result: $40 = 0x33 -0042F9 1 test05: -0042F9 1 A9 35 LDA #$35 -0042FB 1 -0042FB 1 AA TAX -0042FC 1 CA DEX -0042FD 1 CA DEX -0042FE 1 E8 INX -0042FF 1 8A TXA -004300 1 -004300 1 A8 TAY -004301 1 88 DEY -004302 1 88 DEY -004303 1 C8 INY -004304 1 98 TYA -004305 1 -004305 1 AA TAX -004306 1 A9 20 LDA #$20 -004308 1 9A TXS -004309 1 A2 10 LDX #$10 -00430B 1 BA TSX -00430C 1 8A TXA -00430D 1 -00430D 1 85 40 STA $40 -00430F 1 -00430F 1 ; CHECK test05 -00430F 1 A5 40 LDA $40 -004311 1 CD 05 02 CMP $0205 -004314 1 F0 08 BEQ test06 -004316 1 A9 05 LDA #$05 -004318 1 8D 10 02 STA $0210 -00431B 1 4C C0 45 JMP theend -00431E 1 -00431E 1 -00431E 1 ; expected result: $30 = 9D -00431E 1 test06: -00431E 1 -00431E 1 ; RESET TO CARRY FLAG = 0 -00431E 1 2A ROL -00431F 1 -00431F 1 A9 6A LDA #$6A -004321 1 85 50 STA $50 -004323 1 A9 6B LDA #$6B -004325 1 85 51 STA $51 -004327 1 A9 A1 LDA #$A1 -004329 1 85 60 STA $60 -00432B 1 A9 A2 LDA #$A2 -00432D 1 85 61 STA $61 -00432F 1 -00432F 1 A9 FF LDA #$FF -004331 1 69 FF ADC #$FF -004333 1 69 FF ADC #$FF -004335 1 E9 AE SBC #$AE -004337 1 -004337 1 85 40 STA $40 -004339 1 A6 40 LDX $40 -00433B 1 75 00 ADC $00,X -00433D 1 F5 01 SBC $01,X -00433F 1 -00433F 1 65 60 ADC $60 -004341 1 E5 61 SBC $61 -004343 1 -004343 1 8D 20 01 STA $0120 -004346 1 A9 4D LDA #$4D -004348 1 8D 21 01 STA $0121 -00434B 1 A9 23 LDA #$23 -00434D 1 6D 20 01 ADC $0120 -004350 1 ED 21 01 SBC $0121 -004353 1 -004353 1 85 F0 STA $F0 -004355 1 A6 F0 LDX $F0 -004357 1 A9 64 LDA #$64 -004359 1 8D 24 01 STA $0124 -00435C 1 A9 62 LDA #$62 -00435E 1 8D 25 01 STA $0125 -004361 1 A9 26 LDA #$26 -004363 1 7D 00 01 ADC $0100,X -004366 1 FD 01 01 SBC $0101,X -004369 1 -004369 1 85 F1 STA $F1 -00436B 1 A4 F1 LDY $F1 -00436D 1 A9 E5 LDA #$E5 -00436F 1 8D 28 01 STA $0128 -004372 1 A9 E9 LDA #$E9 -004374 1 8D 29 01 STA $0129 -004377 1 A9 34 LDA #$34 -004379 1 79 00 01 ADC $0100,Y -00437C 1 F9 01 01 SBC $0101,Y -00437F 1 -00437F 1 85 F2 STA $F2 -004381 1 A6 F2 LDX $F2 -004383 1 A9 20 LDA #$20 -004385 1 85 70 STA $70 -004387 1 A9 01 LDA #$01 -004389 1 85 71 STA $71 -00438B 1 A9 24 LDA #$24 -00438D 1 85 72 STA $72 -00438F 1 A9 01 LDA #$01 -004391 1 85 73 STA $73 -004393 1 61 41 ADC ($41,X) -004395 1 E1 3F SBC ($3F,X) -004397 1 -004397 1 85 F3 STA $F3 -004399 1 A4 F3 LDY $F3 -00439B 1 A9 DA LDA #$DA -00439D 1 85 80 STA $80 -00439F 1 A9 00 LDA #$00 -0043A1 1 85 81 STA $81 -0043A3 1 A9 DC LDA #$DC -0043A5 1 85 82 STA $82 -0043A7 1 A9 00 LDA #$00 -0043A9 1 85 83 STA $83 -0043AB 1 A9 AA LDA #$AA -0043AD 1 71 80 ADC ($80),Y -0043AF 1 F1 82 SBC ($82),Y -0043B1 1 85 30 STA $30 -0043B3 1 -0043B3 1 ; CHECK test06 -0043B3 1 A5 30 LDA $30 -0043B5 1 CD 06 02 CMP $0206 -0043B8 1 F0 08 BEQ test07 -0043BA 1 A9 06 LDA #$06 -0043BC 1 8D 10 02 STA $0210 -0043BF 1 4C C0 45 JMP theend -0043C2 1 -0043C2 1 -0043C2 1 ; expected result: $15 = 0x7F -0043C2 1 test07: -0043C2 1 ; prepare memory -0043C2 1 A9 00 LDA #$00 -0043C4 1 85 34 STA $34 -0043C6 1 A9 FF LDA #$FF -0043C8 1 8D 30 01 STA $0130 -0043CB 1 A9 99 LDA #$99 -0043CD 1 8D 9D 01 STA $019D -0043D0 1 A9 DB LDA #$DB -0043D2 1 8D 99 01 STA $0199 -0043D5 1 A9 2F LDA #$2F -0043D7 1 85 32 STA $32 -0043D9 1 A9 32 LDA #$32 -0043DB 1 85 4F STA $4F -0043DD 1 A9 30 LDA #$30 -0043DF 1 85 33 STA $33 -0043E1 1 A9 70 LDA #$70 -0043E3 1 85 AF STA $AF -0043E5 1 A9 18 LDA #$18 -0043E7 1 85 30 STA $30 -0043E9 1 -0043E9 1 ; imm -0043E9 1 C9 18 CMP #$18 -0043EB 1 F0 02 BEQ beq1 ; taken -0043ED 1 29 00 AND #$00 ; not done -0043EF 1 beq1: -0043EF 1 ; zpg -0043EF 1 09 01 ORA #$01 -0043F1 1 C5 30 CMP $30 -0043F3 1 D0 02 BNE bne1 ; taken -0043F5 1 29 00 AND #$00 ; not done -0043F7 1 bne1: -0043F7 1 ; abs -0043F7 1 A2 00 LDX #$00 -0043F9 1 CD 30 01 CMP $0130 -0043FC 1 F0 04 BEQ beq2 ; not taken -0043FE 1 85 40 STA $40 -004400 1 A6 40 LDX $40 -004402 1 beq2: -004402 1 ; zpx -004402 1 D5 27 CMP $27,X -004404 1 D0 06 BNE bne2 ; not taken -004406 1 09 84 ORA #$84 -004408 1 85 41 STA $41 -00440A 1 A6 41 LDX $41 -00440C 1 bne2: -00440C 1 ; abx -00440C 1 29 DB AND #$DB -00440E 1 DD 00 01 CMP $0100,X -004411 1 F0 02 BEQ beq3 ; taken -004413 1 29 00 AND #$00 ; not done -004415 1 beq3: -004415 1 ; aby -004415 1 85 42 STA $42 -004417 1 A4 42 LDY $42 -004419 1 29 00 AND #$00 -00441B 1 D9 00 01 CMP $0100,Y -00441E 1 D0 02 BNE bne3 ; taken -004420 1 09 0F ORA #$0F ; not done -004422 1 bne3: -004422 1 ; idx -004422 1 85 43 STA $43 -004424 1 A6 43 LDX $43 -004426 1 09 24 ORA #$24 -004428 1 C1 40 CMP ($40,X) -00442A 1 F0 02 BEQ beq4 ; not taken -00442C 1 09 7F ORA #$7F -00442E 1 beq4: -00442E 1 ; idy -00442E 1 85 44 STA $44 -004430 1 A4 44 LDY $44 -004432 1 49 0F EOR #$0F -004434 1 D1 33 CMP ($33),Y -004436 1 D0 04 BNE bne4 ; not taken -004438 1 A5 44 LDA $44 -00443A 1 85 15 STA $15 -00443C 1 bne4: -00443C 1 -00443C 1 ; CHECK test07 -00443C 1 A5 15 LDA $15 -00443E 1 CD 07 02 CMP $0207 -004441 1 F0 08 BEQ test08 -004443 1 A9 07 LDA #$07 -004445 1 8D 10 02 STA $0210 -004448 1 4C C0 45 JMP theend -00444B 1 -00444B 1 -00444B 1 ; expected result: $42 = 0xA5 -00444B 1 test08: -00444B 1 ; prepare memory -00444B 1 A9 A5 LDA #$A5 -00444D 1 85 20 STA $20 -00444F 1 8D 20 01 STA $0120 -004452 1 A9 5A LDA #$5A -004454 1 85 21 STA $21 -004456 1 -004456 1 ; cpx imm... -004456 1 A2 A5 LDX #$A5 -004458 1 E0 A5 CPX #$A5 -00445A 1 F0 02 BEQ b1 ; taken -00445C 1 A2 01 LDX #$01 ; not done -00445E 1 b1: -00445E 1 ; cpx zpg... -00445E 1 E4 20 CPX $20 -004460 1 F0 02 BEQ b2 ; taken -004462 1 A2 02 LDX #$02 ; not done -004464 1 b2: -004464 1 ; cpx abs... -004464 1 EC 20 01 CPX $0120 -004467 1 F0 02 BEQ b3 ; taken -004469 1 A2 03 LDX #$03 ; not done -00446B 1 b3: -00446B 1 ; cpy imm... -00446B 1 86 30 STX $30 -00446D 1 A4 30 LDY $30 -00446F 1 C0 A5 CPY #$A5 -004471 1 F0 02 BEQ b4 ; taken -004473 1 A0 04 LDY #$04 ; not done -004475 1 b4: -004475 1 ; cpy zpg... -004475 1 C4 20 CPY $20 -004477 1 F0 02 BEQ b5 ; taken -004479 1 A0 05 LDY #$05 ; not done -00447B 1 b5: -00447B 1 ; cpy abs... -00447B 1 CC 20 01 CPY $0120 -00447E 1 F0 02 BEQ b6 ; taken -004480 1 A0 06 LDY #$06 ; not done -004482 1 b6: -004482 1 ; bit zpg... -004482 1 84 31 STY $31 -004484 1 A5 31 LDA $31 -004486 1 24 20 BIT $20 -004488 1 D0 02 BNE b7 ; taken -00448A 1 A9 07 LDA #$07 ; not done -00448C 1 b7: -00448C 1 ; bit abs... -00448C 1 2C 20 01 BIT $0120 -00448F 1 D0 02 BNE b8 ; taken -004491 1 A9 08 LDA #$08 ; not done -004493 1 b8: -004493 1 24 21 BIT $21 -004495 1 D0 02 BNE b9 ; not taken -004497 1 85 42 STA $42 -004499 1 b9: -004499 1 -004499 1 ; CHECK test08 -004499 1 A5 42 LDA $42 -00449B 1 CD 08 02 CMP $0208 -00449E 1 F0 08 BEQ test09 -0044A0 1 A9 08 LDA #$08 -0044A2 1 8D 10 02 STA $0210 -0044A5 1 4C C0 45 JMP theend -0044A8 1 -0044A8 1 -0044A8 1 ; expected result: $80 = 0x1F -0044A8 1 test09: -0044A8 1 ; prepare memory -0044A8 1 A9 54 LDA #$54 -0044AA 1 85 32 STA $32 -0044AC 1 A9 B3 LDA #$B3 -0044AE 1 85 A1 STA $A1 -0044B0 1 A9 87 LDA #$87 -0044B2 1 85 43 STA $43 -0044B4 1 -0044B4 1 ; BPL -0044B4 1 A2 A1 LDX #$A1 -0044B6 1 10 02 BPL bpl1 ; not taken -0044B8 1 A2 32 LDX #$32 -0044BA 1 bpl1: -0044BA 1 B4 00 LDY $00,X -0044BC 1 10 04 BPL bpl2 ; taken -0044BE 1 A9 05 LDA #$05 ; not done -0044C0 1 A6 A1 LDX $A1 ; not done -0044C2 1 bpl2: -0044C2 1 -0044C2 1 ; BMI -0044C2 1 30 02 BMI bmi1 ; not taken -0044C4 1 E9 03 SBC #$03 -0044C6 1 bmi1: -0044C6 1 30 02 BMI bmi2 ; taken -0044C8 1 A9 41 LDA #$41 ; not done -0044CA 1 bmi2: -0044CA 1 -0044CA 1 ; BVC -0044CA 1 49 30 EOR #$30 -0044CC 1 85 32 STA $32 -0044CE 1 75 00 ADC $00,X -0044D0 1 50 02 BVC bvc1 ; not taken -0044D2 1 A9 03 LDA #$03 -0044D4 1 bvc1: -0044D4 1 85 54 STA $54 -0044D6 1 B6 00 LDX $00,Y -0044D8 1 75 51 ADC $51,X -0044DA 1 50 02 BVC bvc2 ; taken -0044DC 1 A9 E5 LDA #$E5 ; not done -0044DE 1 bvc2: -0044DE 1 -0044DE 1 ; BVS -0044DE 1 75 40 ADC $40,X -0044E0 1 70 05 BVS bvs1 ; not taken -0044E2 1 99 01 00 STA $0001,Y -0044E5 1 65 55 ADC $55 -0044E7 1 bvs1: -0044E7 1 70 02 BVS bvs2 ; taken -0044E9 1 A9 00 LDA #$00 -0044EB 1 bvs2: -0044EB 1 -0044EB 1 ; BCC -0044EB 1 69 F0 ADC #$F0 -0044ED 1 90 04 BCC bcc1 ; not taken -0044EF 1 85 60 STA $60 -0044F1 1 65 43 ADC $43 -0044F3 1 bcc1: -0044F3 1 90 02 BCC bcc2 ; taken -0044F5 1 A9 FF LDA #$FF -0044F7 1 bcc2: -0044F7 1 -0044F7 1 ; BCS -0044F7 1 65 54 ADC $54 -0044F9 1 B0 04 BCS bcs1 ; not taken -0044FB 1 69 87 ADC #$87 -0044FD 1 A6 60 LDX $60 -0044FF 1 bcs1: -0044FF 1 B0 02 BCS bcs2 ; taken -004501 1 A9 00 LDA #$00 ; not done -004503 1 bcs2: -004503 1 95 73 STA $73,X -004505 1 -004505 1 ; CHECK test09 -004505 1 A5 80 LDA $80 -004507 1 CD 09 02 CMP $0209 -00450A 1 F0 08 BEQ test10 -00450C 1 A9 09 LDA #$09 -00450E 1 8D 10 02 STA $0210 -004511 1 4C C0 45 JMP theend -004514 1 -004514 1 -004514 1 ; expected result: $30 = 0xCE -004514 1 test10: -004514 1 -004514 1 ; RESET TO CARRY = 0 & OVERFLOW = 0 -004514 1 69 00 ADC #$00 -004516 1 -004516 1 A9 99 LDA #$99 -004518 1 69 87 ADC #$87 -00451A 1 18 CLC -00451B 1 EA NOP -00451C 1 90 04 BCC t10bcc1 ; taken -00451E 1 69 60 ADC #$60 ; not done -004520 1 69 93 ADC #$93 ; not done -004522 1 t10bcc1: -004522 1 38 SEC -004523 1 EA NOP -004524 1 90 01 BCC t10bcc2 ; not taken -004526 1 B8 CLV -004527 1 t10bcc2: -004527 1 50 02 BVC t10bvc1 ; taken -004529 1 A9 00 LDA #$00 ; not done -00452B 1 t10bvc1: -00452B 1 69 AD ADC #$AD -00452D 1 EA NOP -00452E 1 85 30 STA $30 -004530 1 -004530 1 ; CHECK test10 -004530 1 A5 30 LDA $30 -004532 1 CD 0A 02 CMP $020A -004535 1 F0 08 BEQ test11 -004537 1 A9 0A LDA #$0A -004539 1 8D 10 02 STA $0210 -00453C 1 4C C0 45 JMP theend -00453F 1 -00453F 1 -00453F 1 ; expected result: $30 = 0x29 -00453F 1 test11: -00453F 1 -00453F 1 ; RESET TO CARRY = 0 & ZERO = 0 -00453F 1 69 01 ADC #$01 -004541 1 -004541 1 A9 27 LDA #$27 -004543 1 69 01 ADC #$01 -004545 1 38 SEC -004546 1 08 PHP -004547 1 18 CLC -004548 1 28 PLP -004549 1 69 00 ADC #$00 -00454B 1 48 PHA -00454C 1 A9 00 LDA #$00 -00454E 1 68 PLA -00454F 1 85 30 STA $30 -004551 1 -004551 1 ; CHECK test11 -004551 1 A5 30 LDA $30 -004553 1 CD 0B 02 CMP $020B -004556 1 F0 08 BEQ test12 -004558 1 A9 0B LDA #$0B -00455A 1 8D 10 02 STA $0210 -00455D 1 4C C0 45 JMP theend -004560 1 -004560 1 -004560 1 ; expected result: $33 = 0x42 -004560 1 test12: -004560 1 18 CLC -004561 1 A9 42 LDA #$42 -004563 1 90 04 BCC runstuff -004565 1 85 33 STA $33 -004567 1 B0 0A BCS t12end -004569 1 runstuff: -004569 1 A9 45 LDA #$45 -00456B 1 48 PHA -00456C 1 A9 61 LDA #$61 -00456E 1 48 PHA -00456F 1 38 SEC -004570 1 08 PHP -004571 1 18 CLC -004572 1 40 RTI -004573 1 t12end: -004573 1 -004573 1 ; CHECK test12 -004573 1 A5 33 LDA $33 -004575 1 CD 0C 02 CMP $020C -004578 1 F0 08 BEQ test13 -00457A 1 A9 0C LDA #$0C -00457C 1 8D 10 02 STA $0210 -00457F 1 4C C0 45 JMP theend -004582 1 -004582 1 -004582 1 ; expected result: $21 = 0x6C (simulator) -004582 1 ; $21 = 0x0C (ours) -004582 1 test13: -004582 1 -004582 1 ; RESET TO CARRY = 0 & ZERO = 0 -004582 1 69 01 ADC #$01 -004584 1 -004584 1 78 SEI -004585 1 F8 SED -004586 1 08 PHP -004587 1 68 PLA -004588 1 85 20 STA $20 -00458A 1 58 CLI -00458B 1 D8 CLD -00458C 1 08 PHP -00458D 1 68 PLA -00458E 1 65 20 ADC $20 -004590 1 85 21 STA $21 -004592 1 -004592 1 ; CHECK test13 -004592 1 A5 21 LDA $21 -004594 1 CD 0D 02 CMP $020D -004597 1 F0 08 BEQ test14 -004599 1 A9 0D LDA #$0D -00459B 1 8D 10 02 STA $0210 -00459E 1 4C C0 45 JMP theend -0045A1 1 -0045A1 1 -0045A1 1 ; expect result: $60 = 0x42 -0045A1 1 test14: -0045A1 1 ; !!! NOTICE: BRK doesn't work in this -0045A1 1 ; simulator, so commented instructions -0045A1 1 ; are what should be executed... -0045A1 1 ;JMP pass_intrp -0045A1 1 A9 41 LDA #$41 -0045A3 1 85 60 STA $60 -0045A5 1 ;RTI -0045A5 1 ;pass_intrp: -0045A5 1 ;LDA #$FF -0045A5 1 ;STA $60 -0045A5 1 ;BRK (two bytes) -0045A5 1 E6 60 INC $60 -0045A7 1 -0045A7 1 ; CHECK test14 -0045A7 1 A5 60 LDA $60 -0045A9 1 CD 0E 02 CMP $020E -0045AC 1 F0 08 BEQ suiteafinal -0045AE 1 A9 0E LDA #$0E -0045B0 1 8D 10 02 STA $0210 -0045B3 1 4C C0 45 JMP theend -0045B6 1 -0045B6 1 suiteafinal: -0045B6 1 ; IF $0210 == 0xFE, INCREMENT -0045B6 1 ; (checking that it didn't -0045B6 1 ; happen to wander off and -0045B6 1 ; not run our instructions -0045B6 1 ; to say which tests failed...) -0045B6 1 A9 FE LDA #$FE -0045B8 1 CD 10 02 CMP $0210 -0045BB 1 D0 03 BNE theend -0045BD 1 EE 10 02 INC $0210 -0045C0 1 theend: -0045C0 1 00 BRK -0045C1 1 00 BRK -0045C2 1 ;JMP theend -0045C2 1 A2 FF LDX #$FF -0045C4 1 9A TXS -0045C5 1 60 RTS -0045C6 1 -0045C6 1 .segment "KERN" -0045C6 1 -0045C6 1 .ORG $FF00 -00FF00 1 -00FF00 1 40 RTI -00FF01 1 -00FF01 1 .segment "VECT" -00FF01 1 -00FF01 1 .ORG $FFFA -00FFFA 1 -00FFFA 1 00 FF 00 FF .BYTE $00,$FF,$00,$FF,$00,$FF -00FFFE 1 00 FF -010000 1 -010000 1 ;-------------------------- END -010000 1 +ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz +Main file : testall.asm +Current file: testall.asm + +000000r 1 ; Testing 6502 opcodes. +000000r 1 ; Copied and adapted from AllSuiteA.asm from project hmc-6502: +000000r 1 ; https://code.google.com/archive/p/hmc-6502/ +000000r 1 ; EXPECTED FINAL RESULTS: $0210 = FF +000000r 1 ; (any other number will be the test that failed) +000000r 1 ; To build with cl65: +000000r 1 ; cl65 -C testall_cl65.cfg -l --start-addr 16384 -t none -o tall.bin testall.asm +000000r 1 ; then load to simulator from debug console with 'L B TALL.BIN' +000000r 1 ; and execute with 'X 4000'. +000000r 1 +000000r 1 .segment "CODE1" +000000r 1 +000000r 1 .segment "CODE2" +000000r 1 +000000r 1 .ORG $4000 +004000 1 +004000 1 start: +004000 1 ; initialize: +004000 1 A9 00 LDA #$00 +004002 1 8D 10 02 STA $0210 +004005 1 ; store each test's expected +004005 1 A9 55 LDA #$55 +004007 1 8D 00 02 STA $0200 +00400A 1 A9 AA LDA #$AA +00400C 1 8D 01 02 STA $0201 +00400F 1 A9 FF LDA #$FF +004011 1 8D 02 02 STA $0202 +004014 1 A9 6E LDA #$6E +004016 1 8D 03 02 STA $0203 +004019 1 A9 42 LDA #$42 +00401B 1 8D 04 02 STA $0204 +00401E 1 A9 33 LDA #$33 +004020 1 8D 05 02 STA $0205 +004023 1 A9 9D LDA #$9D +004025 1 8D 06 02 STA $0206 +004028 1 A9 7F LDA #$7F +00402A 1 8D 07 02 STA $0207 +00402D 1 A9 A5 LDA #$A5 +00402F 1 8D 08 02 STA $0208 +004032 1 A9 1F LDA #$1F +004034 1 8D 09 02 STA $0209 +004037 1 A9 CE LDA #$CE +004039 1 8D 0A 02 STA $020A +00403C 1 A9 29 LDA #$29 +00403E 1 8D 0B 02 STA $020B +004041 1 A9 42 LDA #$42 +004043 1 8D 0C 02 STA $020C +004046 1 A9 6C LDA #$6C +004048 1 8D 0D 02 STA $020D +00404B 1 A9 42 LDA #$42 +00404D 1 8D 0E 02 STA $020E +004050 1 +004050 1 +004050 1 ; expected result: $022A = 0x55 +004050 1 test00: +004050 1 A9 55 LDA #85 +004052 1 A2 2A LDX #42 +004054 1 A0 73 LDY #115 +004056 1 85 81 STA $81 +004058 1 A9 01 LDA #$01 +00405A 1 85 61 STA $61 +00405C 1 A9 7E LDA #$7E +00405E 1 A5 81 LDA $81 +004060 1 8D 10 09 STA $0910 +004063 1 A9 7E LDA #$7E +004065 1 AD 10 09 LDA $0910 +004068 1 95 56 STA $56,X +00406A 1 A9 7E LDA #$7E +00406C 1 B5 56 LDA $56,X +00406E 1 84 60 STY $60 +004070 1 91 60 STA ($60),Y +004072 1 A9 7E LDA #$7E +004074 1 B1 60 LDA ($60),Y +004076 1 9D FF 07 STA $07ff,X +004079 1 A9 7E LDA #$7E +00407B 1 BD FF 07 LDA $07ff,X +00407E 1 99 FF 07 STA $07ff,Y +004081 1 A9 7E LDA #$7E +004083 1 B9 FF 07 LDA $07ff,Y +004086 1 81 36 STA ($36,X) +004088 1 A9 7E LDA #$7E +00408A 1 A1 36 LDA ($36,X) +00408C 1 86 50 STX $50 +00408E 1 A6 60 LDX $60 +004090 1 A4 50 LDY $50 +004092 1 8E 13 09 STX $0913 +004095 1 A2 22 LDX #$22 +004097 1 AE 13 09 LDX $0913 +00409A 1 8C 14 09 STY $0914 +00409D 1 A0 99 LDY #$99 +00409F 1 AC 14 09 LDY $0914 +0040A2 1 94 2D STY $2D,X +0040A4 1 96 77 STX $77,Y +0040A6 1 A0 99 LDY #$99 +0040A8 1 B4 2D LDY $2D,X +0040AA 1 A2 22 LDX #$22 +0040AC 1 B6 77 LDX $77,Y +0040AE 1 A0 99 LDY #$99 +0040B0 1 BC A0 08 LDY $08A0,X +0040B3 1 A2 22 LDX #$22 +0040B5 1 BE A1 08 LDX $08A1,Y +0040B8 1 9D 00 02 STA $0200,X +0040BB 1 +0040BB 1 ; CHECK test00: +0040BB 1 AD 2A 02 LDA $022A +0040BE 1 CD 00 02 CMP $0200 +0040C1 1 F0 03 BEQ test00pass +0040C3 1 4C C0 45 JMP theend +0040C6 1 test00pass: +0040C6 1 A9 FE LDA #$FE +0040C8 1 8D 10 02 STA $0210 +0040CB 1 +0040CB 1 +0040CB 1 ; expected result: $A9 = 0xAA +0040CB 1 test01: +0040CB 1 ; imm +0040CB 1 A9 55 LDA #85 +0040CD 1 29 53 AND #83 +0040CF 1 09 38 ORA #56 +0040D1 1 49 11 EOR #17 +0040D3 1 +0040D3 1 ; zpg +0040D3 1 85 99 STA $99 +0040D5 1 A9 B9 LDA #185 +0040D7 1 85 10 STA $10 +0040D9 1 A9 E7 LDA #231 +0040DB 1 85 11 STA $11 +0040DD 1 A9 39 LDA #57 +0040DF 1 85 12 STA $12 +0040E1 1 A5 99 LDA $99 +0040E3 1 25 10 AND $10 +0040E5 1 05 11 ORA $11 +0040E7 1 45 12 EOR $12 +0040E9 1 +0040E9 1 ; zpx +0040E9 1 A2 10 LDX #16 +0040EB 1 85 99 STA $99 +0040ED 1 A9 BC LDA #188 +0040EF 1 85 20 STA $20 +0040F1 1 A9 31 LDA #49 +0040F3 1 85 21 STA $21 +0040F5 1 A9 17 LDA #23 +0040F7 1 85 22 STA $22 +0040F9 1 A5 99 LDA $99 +0040FB 1 35 10 AND $10,X +0040FD 1 15 11 ORA $11,X +0040FF 1 55 12 EOR $12,X +004101 1 +004101 1 ; abs +004101 1 85 99 STA $99 +004103 1 A9 6F LDA #111 +004105 1 8D 10 01 STA $0110 +004108 1 A9 3C LDA #60 +00410A 1 8D 11 01 STA $0111 +00410D 1 A9 27 LDA #39 +00410F 1 8D 12 01 STA $0112 +004112 1 A5 99 LDA $99 +004114 1 2D 10 01 AND $0110 +004117 1 0D 11 01 ORA $0111 +00411A 1 4D 12 01 EOR $0112 +00411D 1 +00411D 1 ; abx +00411D 1 85 99 STA $99 +00411F 1 A9 8A LDA #138 +004121 1 8D 20 01 STA $0120 +004124 1 A9 47 LDA #71 +004126 1 8D 21 01 STA $0121 +004129 1 A9 8F LDA #143 +00412B 1 8D 22 01 STA $0122 +00412E 1 A5 99 LDA $99 +004130 1 3D 10 01 AND $0110,X +004133 1 1D 11 01 ORA $0111,X +004136 1 5D 12 01 EOR $0112,X +004139 1 +004139 1 ; aby +004139 1 A0 20 LDY #32 +00413B 1 85 99 STA $99 +00413D 1 A9 73 LDA #115 +00413F 1 8D 30 01 STA $0130 +004142 1 A9 2A LDA #42 +004144 1 8D 31 01 STA $0131 +004147 1 A9 F1 LDA #241 +004149 1 8D 32 01 STA $0132 +00414C 1 A5 99 LDA $99 +00414E 1 39 10 01 AND $0110,Y +004151 1 19 11 01 ORA $0111,Y +004154 1 59 12 01 EOR $0112,Y +004157 1 +004157 1 ; idx +004157 1 85 99 STA $99 +004159 1 A9 70 LDA #112 +00415B 1 85 30 STA $30 +00415D 1 A9 01 LDA #$01 +00415F 1 85 31 STA $31 +004161 1 A9 71 LDA #113 +004163 1 85 32 STA $32 +004165 1 A9 01 LDA #$01 +004167 1 85 33 STA $33 +004169 1 A9 72 LDA #114 +00416B 1 85 34 STA $34 +00416D 1 A9 01 LDA #$01 +00416F 1 85 35 STA $35 +004171 1 A9 C5 LDA #197 +004173 1 8D 70 01 STA $0170 +004176 1 A9 7C LDA #124 +004178 1 8D 71 01 STA $0171 +00417B 1 A9 A1 LDA #161 +00417D 1 8D 72 01 STA $0172 +004180 1 A5 99 LDA $99 +004182 1 21 20 AND ($20,X) +004184 1 01 22 ORA ($22,X) +004186 1 41 24 EOR ($24,X) +004188 1 +004188 1 ; idy +004188 1 85 99 STA $99 +00418A 1 A9 60 LDA #96 +00418C 1 85 40 STA $40 +00418E 1 A9 01 LDA #$01 +004190 1 85 41 STA $41 +004192 1 A9 61 LDA #97 +004194 1 85 42 STA $42 +004196 1 A9 01 LDA #$01 +004198 1 85 43 STA $43 +00419A 1 A9 62 LDA #98 +00419C 1 85 44 STA $44 +00419E 1 A9 01 LDA #$01 +0041A0 1 85 45 STA $45 +0041A2 1 A9 37 LDA #55 +0041A4 1 8D 50 02 STA $0250 +0041A7 1 A9 23 LDA #35 +0041A9 1 8D 51 02 STA $0251 +0041AC 1 A9 9D LDA #157 +0041AE 1 8D 52 02 STA $0252 +0041B1 1 A5 99 LDA $99 +0041B3 1 A0 F0 LDY #$F0 +0041B5 1 31 40 AND ($40),Y +0041B7 1 11 42 ORA ($42),Y +0041B9 1 51 44 EOR ($44),Y +0041BB 1 +0041BB 1 85 A9 STA $A9 +0041BD 1 +0041BD 1 ; CHECK test01 +0041BD 1 A5 A9 LDA $A9 +0041BF 1 CD 01 02 CMP $0201 +0041C2 1 F0 08 BEQ test02 +0041C4 1 A9 01 LDA #$01 +0041C6 1 8D 10 02 STA $0210 +0041C9 1 4C C0 45 JMP theend +0041CC 1 +0041CC 1 +0041CC 1 ; expected result: $71 = 0xFF +0041CC 1 test02: +0041CC 1 A9 FF LDA #$FF +0041CE 1 A2 00 LDX #$00 +0041D0 1 +0041D0 1 85 90 STA $90 +0041D2 1 E6 90 INC $90 +0041D4 1 E6 90 INC $90 +0041D6 1 A5 90 LDA $90 +0041D8 1 A6 90 LDX $90 +0041DA 1 +0041DA 1 95 90 STA $90,X +0041DC 1 F6 90 INC $90,X +0041DE 1 B5 90 LDA $90,X +0041E0 1 A6 91 LDX $91 +0041E2 1 +0041E2 1 9D 90 01 STA $0190,X +0041E5 1 EE 92 01 INC $0192 +0041E8 1 BD 90 01 LDA $0190,X +0041EB 1 AE 92 01 LDX $0192 +0041EE 1 +0041EE 1 9D 90 01 STA $0190,X +0041F1 1 FE 90 01 INC $0190,X +0041F4 1 BD 90 01 LDA $0190,X +0041F7 1 AE 93 01 LDX $0193 +0041FA 1 +0041FA 1 9D 70 01 STA $0170,X +0041FD 1 DE 70 01 DEC $0170,X +004200 1 BD 70 01 LDA $0170,X +004203 1 AE 74 01 LDX $0174 +004206 1 +004206 1 9D 70 01 STA $0170,X +004209 1 CE 73 01 DEC $0173 +00420C 1 BD 70 01 LDA $0170,X +00420F 1 AE 73 01 LDX $0173 +004212 1 +004212 1 95 70 STA $70,X +004214 1 D6 70 DEC $70,X +004216 1 B5 70 LDA $70,X +004218 1 A6 72 LDX $72 +00421A 1 +00421A 1 95 70 STA $70,X +00421C 1 C6 71 DEC $71 +00421E 1 C6 71 DEC $71 +004220 1 +004220 1 ; CHECK test02 +004220 1 A5 71 LDA $71 +004222 1 CD 02 02 CMP $0202 +004225 1 F0 08 BEQ test03 +004227 1 A9 02 LDA #$02 +004229 1 8D 10 02 STA $0210 +00422C 1 4C C0 45 JMP theend +00422F 1 +00422F 1 +00422F 1 ; expected result: $01DD = 0x6E +00422F 1 test03: +00422F 1 A9 4B LDA #$4B +004231 1 4A LSR +004232 1 0A ASL +004233 1 +004233 1 85 50 STA $50 +004235 1 06 50 ASL $50 +004237 1 06 50 ASL $50 +004239 1 46 50 LSR $50 +00423B 1 A5 50 LDA $50 +00423D 1 +00423D 1 A6 50 LDX $50 +00423F 1 09 C9 ORA #$C9 +004241 1 85 60 STA $60 +004243 1 16 4C ASL $4C,X +004245 1 56 4C LSR $4C,X +004247 1 56 4C LSR $4C,X +004249 1 B5 4C LDA $4C,X +00424B 1 +00424B 1 A6 60 LDX $60 +00424D 1 09 41 ORA #$41 +00424F 1 8D 2E 01 STA $012E +004252 1 5E 00 01 LSR $0100,X +004255 1 5E 00 01 LSR $0100,X +004258 1 1E 00 01 ASL $0100,X +00425B 1 BD 00 01 LDA $0100,X +00425E 1 +00425E 1 AE 2E 01 LDX $012E +004261 1 09 81 ORA #$81 +004263 1 9D 00 01 STA $0100,X +004266 1 4E 36 01 LSR $0136 +004269 1 4E 36 01 LSR $0136 +00426C 1 0E 36 01 ASL $0136 +00426F 1 BD 00 01 LDA $0100,X +004272 1 +004272 1 ; rol & ror +004272 1 +004272 1 2A ROL +004273 1 2A ROL +004274 1 6A ROR +004275 1 85 70 STA $70 +004277 1 +004277 1 A6 70 LDX $70 +004279 1 09 03 ORA #$03 +00427B 1 95 0C STA $0C,X +00427D 1 26 C0 ROL $C0 +00427F 1 66 C0 ROR $C0 +004281 1 66 C0 ROR $C0 +004283 1 B5 0C LDA $0C,X +004285 1 +004285 1 A6 C0 LDX $C0 +004287 1 85 D0 STA $D0 +004289 1 36 75 ROL $75,X +00428B 1 36 75 ROL $75,X +00428D 1 76 75 ROR $75,X +00428F 1 A5 D0 LDA $D0 +004291 1 +004291 1 A6 D0 LDX $D0 +004293 1 9D 00 01 STA $0100,X +004296 1 2E B7 01 ROL $01B7 +004299 1 2E B7 01 ROL $01B7 +00429C 1 2E B7 01 ROL $01B7 +00429F 1 6E B7 01 ROR $01B7 +0042A2 1 BD 00 01 LDA $0100,X +0042A5 1 +0042A5 1 AE B7 01 LDX $01B7 +0042A8 1 8D DD 01 STA $01DD +0042AB 1 3E 00 01 ROL $0100,X +0042AE 1 7E 00 01 ROR $0100,X +0042B1 1 7E 00 01 ROR $0100,X +0042B4 1 +0042B4 1 ; CHECK test03 +0042B4 1 AD DD 01 LDA $01DD +0042B7 1 CD 03 02 CMP $0203 +0042BA 1 F0 08 BEQ test04 +0042BC 1 A9 03 LDA #$03 +0042BE 1 8D 10 02 STA $0210 +0042C1 1 4C C0 45 JMP theend +0042C4 1 +0042C4 1 +0042C4 1 ; expected result: $40 = 0x42 +0042C4 1 test04: +0042C4 1 A9 E8 LDA #$E8 ;originally:#$7C +0042C6 1 85 20 STA $20 +0042C8 1 A9 42 LDA #$42 ;originally:#$02 +0042CA 1 85 21 STA $21 +0042CC 1 A9 00 LDA #$00 +0042CE 1 09 03 ORA #$03 +0042D0 1 4C D5 42 JMP jump1 +0042D3 1 09 FF ORA #$FF ; not done +0042D5 1 jump1: +0042D5 1 09 30 ORA #$30 +0042D7 1 20 E1 42 JSR subr +0042DA 1 09 42 ORA #$42 +0042DC 1 6C 20 00 JMP ($0020) +0042DF 1 09 FF ORA #$FF ; not done +0042E1 1 subr: +0042E1 1 85 30 STA $30 +0042E3 1 A6 30 LDX $30 +0042E5 1 A9 00 LDA #$00 +0042E7 1 60 RTS +0042E8 1 final: +0042E8 1 95 0D STA $0D,X +0042EA 1 +0042EA 1 ; CHECK test04 +0042EA 1 A5 40 LDA $40 +0042EC 1 CD 04 02 CMP $0204 +0042EF 1 F0 08 BEQ test05 +0042F1 1 A9 04 LDA #$04 +0042F3 1 8D 10 02 STA $0210 +0042F6 1 4C C0 45 JMP theend +0042F9 1 +0042F9 1 +0042F9 1 ; expected result: $40 = 0x33 +0042F9 1 test05: +0042F9 1 A9 35 LDA #$35 +0042FB 1 +0042FB 1 AA TAX +0042FC 1 CA DEX +0042FD 1 CA DEX +0042FE 1 E8 INX +0042FF 1 8A TXA +004300 1 +004300 1 A8 TAY +004301 1 88 DEY +004302 1 88 DEY +004303 1 C8 INY +004304 1 98 TYA +004305 1 +004305 1 AA TAX +004306 1 A9 20 LDA #$20 +004308 1 9A TXS +004309 1 A2 10 LDX #$10 +00430B 1 BA TSX +00430C 1 8A TXA +00430D 1 +00430D 1 85 40 STA $40 +00430F 1 +00430F 1 ; CHECK test05 +00430F 1 A5 40 LDA $40 +004311 1 CD 05 02 CMP $0205 +004314 1 F0 08 BEQ test06 +004316 1 A9 05 LDA #$05 +004318 1 8D 10 02 STA $0210 +00431B 1 4C C0 45 JMP theend +00431E 1 +00431E 1 +00431E 1 ; expected result: $30 = 9D +00431E 1 test06: +00431E 1 +00431E 1 ; RESET TO CARRY FLAG = 0 +00431E 1 2A ROL +00431F 1 +00431F 1 A9 6A LDA #$6A +004321 1 85 50 STA $50 +004323 1 A9 6B LDA #$6B +004325 1 85 51 STA $51 +004327 1 A9 A1 LDA #$A1 +004329 1 85 60 STA $60 +00432B 1 A9 A2 LDA #$A2 +00432D 1 85 61 STA $61 +00432F 1 +00432F 1 A9 FF LDA #$FF +004331 1 69 FF ADC #$FF +004333 1 69 FF ADC #$FF +004335 1 E9 AE SBC #$AE +004337 1 +004337 1 85 40 STA $40 +004339 1 A6 40 LDX $40 +00433B 1 75 00 ADC $00,X +00433D 1 F5 01 SBC $01,X +00433F 1 +00433F 1 65 60 ADC $60 +004341 1 E5 61 SBC $61 +004343 1 +004343 1 8D 20 01 STA $0120 +004346 1 A9 4D LDA #$4D +004348 1 8D 21 01 STA $0121 +00434B 1 A9 23 LDA #$23 +00434D 1 6D 20 01 ADC $0120 +004350 1 ED 21 01 SBC $0121 +004353 1 +004353 1 85 F0 STA $F0 +004355 1 A6 F0 LDX $F0 +004357 1 A9 64 LDA #$64 +004359 1 8D 24 01 STA $0124 +00435C 1 A9 62 LDA #$62 +00435E 1 8D 25 01 STA $0125 +004361 1 A9 26 LDA #$26 +004363 1 7D 00 01 ADC $0100,X +004366 1 FD 01 01 SBC $0101,X +004369 1 +004369 1 85 F1 STA $F1 +00436B 1 A4 F1 LDY $F1 +00436D 1 A9 E5 LDA #$E5 +00436F 1 8D 28 01 STA $0128 +004372 1 A9 E9 LDA #$E9 +004374 1 8D 29 01 STA $0129 +004377 1 A9 34 LDA #$34 +004379 1 79 00 01 ADC $0100,Y +00437C 1 F9 01 01 SBC $0101,Y +00437F 1 +00437F 1 85 F2 STA $F2 +004381 1 A6 F2 LDX $F2 +004383 1 A9 20 LDA #$20 +004385 1 85 70 STA $70 +004387 1 A9 01 LDA #$01 +004389 1 85 71 STA $71 +00438B 1 A9 24 LDA #$24 +00438D 1 85 72 STA $72 +00438F 1 A9 01 LDA #$01 +004391 1 85 73 STA $73 +004393 1 61 41 ADC ($41,X) +004395 1 E1 3F SBC ($3F,X) +004397 1 +004397 1 85 F3 STA $F3 +004399 1 A4 F3 LDY $F3 +00439B 1 A9 DA LDA #$DA +00439D 1 85 80 STA $80 +00439F 1 A9 00 LDA #$00 +0043A1 1 85 81 STA $81 +0043A3 1 A9 DC LDA #$DC +0043A5 1 85 82 STA $82 +0043A7 1 A9 00 LDA #$00 +0043A9 1 85 83 STA $83 +0043AB 1 A9 AA LDA #$AA +0043AD 1 71 80 ADC ($80),Y +0043AF 1 F1 82 SBC ($82),Y +0043B1 1 85 30 STA $30 +0043B3 1 +0043B3 1 ; CHECK test06 +0043B3 1 A5 30 LDA $30 +0043B5 1 CD 06 02 CMP $0206 +0043B8 1 F0 08 BEQ test07 +0043BA 1 A9 06 LDA #$06 +0043BC 1 8D 10 02 STA $0210 +0043BF 1 4C C0 45 JMP theend +0043C2 1 +0043C2 1 +0043C2 1 ; expected result: $15 = 0x7F +0043C2 1 test07: +0043C2 1 ; prepare memory +0043C2 1 A9 00 LDA #$00 +0043C4 1 85 34 STA $34 +0043C6 1 A9 FF LDA #$FF +0043C8 1 8D 30 01 STA $0130 +0043CB 1 A9 99 LDA #$99 +0043CD 1 8D 9D 01 STA $019D +0043D0 1 A9 DB LDA #$DB +0043D2 1 8D 99 01 STA $0199 +0043D5 1 A9 2F LDA #$2F +0043D7 1 85 32 STA $32 +0043D9 1 A9 32 LDA #$32 +0043DB 1 85 4F STA $4F +0043DD 1 A9 30 LDA #$30 +0043DF 1 85 33 STA $33 +0043E1 1 A9 70 LDA #$70 +0043E3 1 85 AF STA $AF +0043E5 1 A9 18 LDA #$18 +0043E7 1 85 30 STA $30 +0043E9 1 +0043E9 1 ; imm +0043E9 1 C9 18 CMP #$18 +0043EB 1 F0 02 BEQ beq1 ; taken +0043ED 1 29 00 AND #$00 ; not done +0043EF 1 beq1: +0043EF 1 ; zpg +0043EF 1 09 01 ORA #$01 +0043F1 1 C5 30 CMP $30 +0043F3 1 D0 02 BNE bne1 ; taken +0043F5 1 29 00 AND #$00 ; not done +0043F7 1 bne1: +0043F7 1 ; abs +0043F7 1 A2 00 LDX #$00 +0043F9 1 CD 30 01 CMP $0130 +0043FC 1 F0 04 BEQ beq2 ; not taken +0043FE 1 85 40 STA $40 +004400 1 A6 40 LDX $40 +004402 1 beq2: +004402 1 ; zpx +004402 1 D5 27 CMP $27,X +004404 1 D0 06 BNE bne2 ; not taken +004406 1 09 84 ORA #$84 +004408 1 85 41 STA $41 +00440A 1 A6 41 LDX $41 +00440C 1 bne2: +00440C 1 ; abx +00440C 1 29 DB AND #$DB +00440E 1 DD 00 01 CMP $0100,X +004411 1 F0 02 BEQ beq3 ; taken +004413 1 29 00 AND #$00 ; not done +004415 1 beq3: +004415 1 ; aby +004415 1 85 42 STA $42 +004417 1 A4 42 LDY $42 +004419 1 29 00 AND #$00 +00441B 1 D9 00 01 CMP $0100,Y +00441E 1 D0 02 BNE bne3 ; taken +004420 1 09 0F ORA #$0F ; not done +004422 1 bne3: +004422 1 ; idx +004422 1 85 43 STA $43 +004424 1 A6 43 LDX $43 +004426 1 09 24 ORA #$24 +004428 1 C1 40 CMP ($40,X) +00442A 1 F0 02 BEQ beq4 ; not taken +00442C 1 09 7F ORA #$7F +00442E 1 beq4: +00442E 1 ; idy +00442E 1 85 44 STA $44 +004430 1 A4 44 LDY $44 +004432 1 49 0F EOR #$0F +004434 1 D1 33 CMP ($33),Y +004436 1 D0 04 BNE bne4 ; not taken +004438 1 A5 44 LDA $44 +00443A 1 85 15 STA $15 +00443C 1 bne4: +00443C 1 +00443C 1 ; CHECK test07 +00443C 1 A5 15 LDA $15 +00443E 1 CD 07 02 CMP $0207 +004441 1 F0 08 BEQ test08 +004443 1 A9 07 LDA #$07 +004445 1 8D 10 02 STA $0210 +004448 1 4C C0 45 JMP theend +00444B 1 +00444B 1 +00444B 1 ; expected result: $42 = 0xA5 +00444B 1 test08: +00444B 1 ; prepare memory +00444B 1 A9 A5 LDA #$A5 +00444D 1 85 20 STA $20 +00444F 1 8D 20 01 STA $0120 +004452 1 A9 5A LDA #$5A +004454 1 85 21 STA $21 +004456 1 +004456 1 ; cpx imm... +004456 1 A2 A5 LDX #$A5 +004458 1 E0 A5 CPX #$A5 +00445A 1 F0 02 BEQ b1 ; taken +00445C 1 A2 01 LDX #$01 ; not done +00445E 1 b1: +00445E 1 ; cpx zpg... +00445E 1 E4 20 CPX $20 +004460 1 F0 02 BEQ b2 ; taken +004462 1 A2 02 LDX #$02 ; not done +004464 1 b2: +004464 1 ; cpx abs... +004464 1 EC 20 01 CPX $0120 +004467 1 F0 02 BEQ b3 ; taken +004469 1 A2 03 LDX #$03 ; not done +00446B 1 b3: +00446B 1 ; cpy imm... +00446B 1 86 30 STX $30 +00446D 1 A4 30 LDY $30 +00446F 1 C0 A5 CPY #$A5 +004471 1 F0 02 BEQ b4 ; taken +004473 1 A0 04 LDY #$04 ; not done +004475 1 b4: +004475 1 ; cpy zpg... +004475 1 C4 20 CPY $20 +004477 1 F0 02 BEQ b5 ; taken +004479 1 A0 05 LDY #$05 ; not done +00447B 1 b5: +00447B 1 ; cpy abs... +00447B 1 CC 20 01 CPY $0120 +00447E 1 F0 02 BEQ b6 ; taken +004480 1 A0 06 LDY #$06 ; not done +004482 1 b6: +004482 1 ; bit zpg... +004482 1 84 31 STY $31 +004484 1 A5 31 LDA $31 +004486 1 24 20 BIT $20 +004488 1 D0 02 BNE b7 ; taken +00448A 1 A9 07 LDA #$07 ; not done +00448C 1 b7: +00448C 1 ; bit abs... +00448C 1 2C 20 01 BIT $0120 +00448F 1 D0 02 BNE b8 ; taken +004491 1 A9 08 LDA #$08 ; not done +004493 1 b8: +004493 1 24 21 BIT $21 +004495 1 D0 02 BNE b9 ; not taken +004497 1 85 42 STA $42 +004499 1 b9: +004499 1 +004499 1 ; CHECK test08 +004499 1 A5 42 LDA $42 +00449B 1 CD 08 02 CMP $0208 +00449E 1 F0 08 BEQ test09 +0044A0 1 A9 08 LDA #$08 +0044A2 1 8D 10 02 STA $0210 +0044A5 1 4C C0 45 JMP theend +0044A8 1 +0044A8 1 +0044A8 1 ; expected result: $80 = 0x1F +0044A8 1 test09: +0044A8 1 ; prepare memory +0044A8 1 A9 54 LDA #$54 +0044AA 1 85 32 STA $32 +0044AC 1 A9 B3 LDA #$B3 +0044AE 1 85 A1 STA $A1 +0044B0 1 A9 87 LDA #$87 +0044B2 1 85 43 STA $43 +0044B4 1 +0044B4 1 ; BPL +0044B4 1 A2 A1 LDX #$A1 +0044B6 1 10 02 BPL bpl1 ; not taken +0044B8 1 A2 32 LDX #$32 +0044BA 1 bpl1: +0044BA 1 B4 00 LDY $00,X +0044BC 1 10 04 BPL bpl2 ; taken +0044BE 1 A9 05 LDA #$05 ; not done +0044C0 1 A6 A1 LDX $A1 ; not done +0044C2 1 bpl2: +0044C2 1 +0044C2 1 ; BMI +0044C2 1 30 02 BMI bmi1 ; not taken +0044C4 1 E9 03 SBC #$03 +0044C6 1 bmi1: +0044C6 1 30 02 BMI bmi2 ; taken +0044C8 1 A9 41 LDA #$41 ; not done +0044CA 1 bmi2: +0044CA 1 +0044CA 1 ; BVC +0044CA 1 49 30 EOR #$30 +0044CC 1 85 32 STA $32 +0044CE 1 75 00 ADC $00,X +0044D0 1 50 02 BVC bvc1 ; not taken +0044D2 1 A9 03 LDA #$03 +0044D4 1 bvc1: +0044D4 1 85 54 STA $54 +0044D6 1 B6 00 LDX $00,Y +0044D8 1 75 51 ADC $51,X +0044DA 1 50 02 BVC bvc2 ; taken +0044DC 1 A9 E5 LDA #$E5 ; not done +0044DE 1 bvc2: +0044DE 1 +0044DE 1 ; BVS +0044DE 1 75 40 ADC $40,X +0044E0 1 70 05 BVS bvs1 ; not taken +0044E2 1 99 01 00 STA $0001,Y +0044E5 1 65 55 ADC $55 +0044E7 1 bvs1: +0044E7 1 70 02 BVS bvs2 ; taken +0044E9 1 A9 00 LDA #$00 +0044EB 1 bvs2: +0044EB 1 +0044EB 1 ; BCC +0044EB 1 69 F0 ADC #$F0 +0044ED 1 90 04 BCC bcc1 ; not taken +0044EF 1 85 60 STA $60 +0044F1 1 65 43 ADC $43 +0044F3 1 bcc1: +0044F3 1 90 02 BCC bcc2 ; taken +0044F5 1 A9 FF LDA #$FF +0044F7 1 bcc2: +0044F7 1 +0044F7 1 ; BCS +0044F7 1 65 54 ADC $54 +0044F9 1 B0 04 BCS bcs1 ; not taken +0044FB 1 69 87 ADC #$87 +0044FD 1 A6 60 LDX $60 +0044FF 1 bcs1: +0044FF 1 B0 02 BCS bcs2 ; taken +004501 1 A9 00 LDA #$00 ; not done +004503 1 bcs2: +004503 1 95 73 STA $73,X +004505 1 +004505 1 ; CHECK test09 +004505 1 A5 80 LDA $80 +004507 1 CD 09 02 CMP $0209 +00450A 1 F0 08 BEQ test10 +00450C 1 A9 09 LDA #$09 +00450E 1 8D 10 02 STA $0210 +004511 1 4C C0 45 JMP theend +004514 1 +004514 1 +004514 1 ; expected result: $30 = 0xCE +004514 1 test10: +004514 1 +004514 1 ; RESET TO CARRY = 0 & OVERFLOW = 0 +004514 1 69 00 ADC #$00 +004516 1 +004516 1 A9 99 LDA #$99 +004518 1 69 87 ADC #$87 +00451A 1 18 CLC +00451B 1 EA NOP +00451C 1 90 04 BCC t10bcc1 ; taken +00451E 1 69 60 ADC #$60 ; not done +004520 1 69 93 ADC #$93 ; not done +004522 1 t10bcc1: +004522 1 38 SEC +004523 1 EA NOP +004524 1 90 01 BCC t10bcc2 ; not taken +004526 1 B8 CLV +004527 1 t10bcc2: +004527 1 50 02 BVC t10bvc1 ; taken +004529 1 A9 00 LDA #$00 ; not done +00452B 1 t10bvc1: +00452B 1 69 AD ADC #$AD +00452D 1 EA NOP +00452E 1 85 30 STA $30 +004530 1 +004530 1 ; CHECK test10 +004530 1 A5 30 LDA $30 +004532 1 CD 0A 02 CMP $020A +004535 1 F0 08 BEQ test11 +004537 1 A9 0A LDA #$0A +004539 1 8D 10 02 STA $0210 +00453C 1 4C C0 45 JMP theend +00453F 1 +00453F 1 +00453F 1 ; expected result: $30 = 0x29 +00453F 1 test11: +00453F 1 +00453F 1 ; RESET TO CARRY = 0 & ZERO = 0 +00453F 1 69 01 ADC #$01 +004541 1 +004541 1 A9 27 LDA #$27 +004543 1 69 01 ADC #$01 +004545 1 38 SEC +004546 1 08 PHP +004547 1 18 CLC +004548 1 28 PLP +004549 1 69 00 ADC #$00 +00454B 1 48 PHA +00454C 1 A9 00 LDA #$00 +00454E 1 68 PLA +00454F 1 85 30 STA $30 +004551 1 +004551 1 ; CHECK test11 +004551 1 A5 30 LDA $30 +004553 1 CD 0B 02 CMP $020B +004556 1 F0 08 BEQ test12 +004558 1 A9 0B LDA #$0B +00455A 1 8D 10 02 STA $0210 +00455D 1 4C C0 45 JMP theend +004560 1 +004560 1 +004560 1 ; expected result: $33 = 0x42 +004560 1 test12: +004560 1 18 CLC +004561 1 A9 42 LDA #$42 +004563 1 90 04 BCC runstuff +004565 1 85 33 STA $33 +004567 1 B0 0A BCS t12end +004569 1 runstuff: +004569 1 A9 45 LDA #$45 +00456B 1 48 PHA +00456C 1 A9 61 LDA #$61 +00456E 1 48 PHA +00456F 1 38 SEC +004570 1 08 PHP +004571 1 18 CLC +004572 1 40 RTI +004573 1 t12end: +004573 1 +004573 1 ; CHECK test12 +004573 1 A5 33 LDA $33 +004575 1 CD 0C 02 CMP $020C +004578 1 F0 08 BEQ test13 +00457A 1 A9 0C LDA #$0C +00457C 1 8D 10 02 STA $0210 +00457F 1 4C C0 45 JMP theend +004582 1 +004582 1 +004582 1 ; expected result: $21 = 0x6C (simulator) +004582 1 ; $21 = 0x0C (ours) +004582 1 test13: +004582 1 +004582 1 ; RESET TO CARRY = 0 & ZERO = 0 +004582 1 69 01 ADC #$01 +004584 1 +004584 1 78 SEI +004585 1 F8 SED +004586 1 08 PHP +004587 1 68 PLA +004588 1 85 20 STA $20 +00458A 1 58 CLI +00458B 1 D8 CLD +00458C 1 08 PHP +00458D 1 68 PLA +00458E 1 65 20 ADC $20 +004590 1 85 21 STA $21 +004592 1 +004592 1 ; CHECK test13 +004592 1 A5 21 LDA $21 +004594 1 CD 0D 02 CMP $020D +004597 1 F0 08 BEQ test14 +004599 1 A9 0D LDA #$0D +00459B 1 8D 10 02 STA $0210 +00459E 1 4C C0 45 JMP theend +0045A1 1 +0045A1 1 +0045A1 1 ; expect result: $60 = 0x42 +0045A1 1 test14: +0045A1 1 ; !!! NOTICE: BRK doesn't work in this +0045A1 1 ; simulator, so commented instructions +0045A1 1 ; are what should be executed... +0045A1 1 ;JMP pass_intrp +0045A1 1 A9 41 LDA #$41 +0045A3 1 85 60 STA $60 +0045A5 1 ;RTI +0045A5 1 ;pass_intrp: +0045A5 1 ;LDA #$FF +0045A5 1 ;STA $60 +0045A5 1 ;BRK (two bytes) +0045A5 1 E6 60 INC $60 +0045A7 1 +0045A7 1 ; CHECK test14 +0045A7 1 A5 60 LDA $60 +0045A9 1 CD 0E 02 CMP $020E +0045AC 1 F0 08 BEQ suiteafinal +0045AE 1 A9 0E LDA #$0E +0045B0 1 8D 10 02 STA $0210 +0045B3 1 4C C0 45 JMP theend +0045B6 1 +0045B6 1 suiteafinal: +0045B6 1 ; IF $0210 == 0xFE, INCREMENT +0045B6 1 ; (checking that it didn't +0045B6 1 ; happen to wander off and +0045B6 1 ; not run our instructions +0045B6 1 ; to say which tests failed...) +0045B6 1 A9 FE LDA #$FE +0045B8 1 CD 10 02 CMP $0210 +0045BB 1 D0 03 BNE theend +0045BD 1 EE 10 02 INC $0210 +0045C0 1 theend: +0045C0 1 00 BRK +0045C1 1 00 BRK +0045C2 1 ;JMP theend +0045C2 1 A2 FF LDX #$FF +0045C4 1 9A TXS +0045C5 1 60 RTS +0045C6 1 +0045C6 1 .segment "KERN" +0045C6 1 +0045C6 1 .ORG $FF00 +00FF00 1 +00FF00 1 40 RTI +00FF01 1 +00FF01 1 .segment "VECT" +00FF01 1 +00FF01 1 .ORG $FFFA +00FFFA 1 +00FFFA 1 00 FF 00 FF .BYTE $00,$FF,$00,$FF,$00,$FF +00FFFE 1 00 FF +010000 1 +010000 1 ;-------------------------- END +010000 1 diff --git a/testall_cl65.cfg b/testall_cl65.cfg index 41507e2..fe0e695 100644 --- a/testall_cl65.cfg +++ b/testall_cl65.cfg @@ -1,24 +1,24 @@ -# -# This is configuration file for CL65 linker to produce -# binary image 64 kB long, which is to be loaded from -# address $0000. -# Code segment CODE1, 15 kB starts at $0400. -# Code segment CODE2, 49 kB starts at $4000. -# Kernel jump table segment KERN (250 B) starts at $FF00. -# Vectors segment start at $FFFA. -# -MEMORY { - RAM0: start = $0000, size = $400, fill = yes; - RAM1: start = $0400, size = $3C00, fill = yes; - RAM2: start = $4000, size = $BF00, fill = yes; - ROM0: start = $FF00, size = $FA, fill = yes; - ROM1: start = $FFFA, size = 6; -} - -SEGMENTS { - CODE1: load = RAM1, type = rw; - CODE2: load = RAM2, type = rw; - KERN: load = ROM0, type = ro; - VECT: load = ROM1, type = ro; -} - +# +# This is configuration file for CL65 linker to produce +# binary image 64 kB long, which is to be loaded from +# address $0000. +# Code segment CODE1, 15 kB starts at $0400. +# Code segment CODE2, 49 kB starts at $4000. +# Kernel jump table segment KERN (250 B) starts at $FF00. +# Vectors segment start at $FFFA. +# +MEMORY { + RAM0: start = $0000, size = $400, fill = yes; + RAM1: start = $0400, size = $3C00, fill = yes; + RAM2: start = $4000, size = $BF00, fill = yes; + ROM0: start = $FF00, size = $FA, fill = yes; + ROM1: start = $FFFA, size = 6; +} + +SEGMENTS { + CODE1: load = RAM1, type = rw; + CODE2: load = RAM2, type = rw; + KERN: load = ROM0, type = ro; + VECT: load = ROM1, type = ro; +} + diff --git a/testbcd.dat b/testbcd.dat index eadd04c..8675722 100644 --- a/testbcd.dat +++ b/testbcd.dat @@ -1,69 +1,69 @@ -; Program disassembly from $0400 to $0600 2/9/2016 -; Test BCD mode. -ORG -$0400 -$A0 $01 $8C $04 $03 $A9 $00 $8D -$07 $03 $8D $0A $03 $AD $0A $03 -$29 $0F $8D $0B $03 $AD $0A $03 -$29 $F0 $8D $0F $03 $09 $0F $8D -$10 $03 $AD $07 $03 $29 $0F $8D -$09 $03 $AD $07 $03 $29 $F0 $8D -$08 $03 $20 $5E $04 $20 $47 $05 -$20 $18 $05 $D0 $1D $20 $B1 $04 -$20 $54 $05 $20 $18 $05 $D0 $12 -$EE $07 $03 $D0 $D5 $EE $0A $03 -$D0 $BB $88 $10 $B8 $A9 $00 $8D -$04 $03 $00 $00 $00 $00 $F8 $C0 -$01 $AD $07 $03 $6D $0A $03 $8D -$02 $03 $08 $68 $8D $03 $03 $D8 -$C0 $01 $AD $07 $03 $6D $0A $03 -$8D $05 $03 $08 $68 $8D $06 $03 -$C0 $01 $AD $09 $03 $6D $0B $03 -$C9 $0A $A2 $00 $90 $06 $E8 $69 -$05 $29 $0F $38 $0D $08 $03 $7D -$0F $03 $08 $B0 $04 $C9 $A0 $90 -$03 $69 $5F $38 $8D $00 $03 $08 -$68 $8D $01 $03 $68 $8D $0D $03 -$60 $F8 $C0 $01 $AD $07 $03 $ED -$0A $03 $8D $02 $03 $08 $68 $8D -$03 $03 $D8 $C0 $01 $AD $07 $03 -$ED $0A $03 $8D $05 $03 $08 $68 -$8D $06 $03 $60 $C0 $01 $AD $09 -$03 $ED $0B $03 $A2 $00 $B0 $06 -$E8 $E9 $05 $29 $0F $18 $0D $08 -$03 $FD $0F $03 $B0 $02 $E9 $5F -$8D $00 $03 $60 $C0 $01 $AD $09 -$03 $ED $0B $03 $A2 $00 $B0 $04 -$E8 $29 $0F $18 $0D $08 $03 $FD -$0F $03 $B0 $02 $E9 $5F $E0 $00 -$F0 $02 $E9 $06 $8D $00 $03 $60 -$AD $02 $03 $CD $00 $03 $D0 $26 -$AD $03 $03 $4D $0C $03 $29 $80 -$D0 $1C $AD $03 $03 $4D $0D $03 -$29 $40 $D0 $12 $AD $03 $03 $4D -$0E $03 $29 $02 $D0 $08 $AD $03 -$03 $4D $01 $03 $29 $01 $60 $AD -$0D $03 $8D $0C $03 $AD $06 $03 -$8D $0E $03 $60 $20 $D4 $04 $AD -$06 $03 $8D $0C $03 $8D $0D $03 -$8D $0E $03 $8D $01 $03 $60 $AD -$00 $03 $08 $68 $8D $0C $03 $8D -$0E $03 $60 $20 $F4 $04 $AD $00 -$03 $08 $68 $8D $0C $03 $8D $0E -$03 $AD $06 $03 $8D $0D $03 $8D -$01 $03 $60 $AD $00 $03 $08 $68 -$8D $0C $03 $8D $0E $03 $60 $20 -$D4 $04 $AD $00 $03 $08 $68 $8D -$0C $03 $8D $0E $03 $AD $06 $03 -$8D $0D $03 $8D $01 $03 $60 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 - +; Program disassembly from $0400 to $0600 2/9/2016 +; Test BCD mode. +ORG +$0400 +$A0 $01 $8C $04 $03 $A9 $00 $8D +$07 $03 $8D $0A $03 $AD $0A $03 +$29 $0F $8D $0B $03 $AD $0A $03 +$29 $F0 $8D $0F $03 $09 $0F $8D +$10 $03 $AD $07 $03 $29 $0F $8D +$09 $03 $AD $07 $03 $29 $F0 $8D +$08 $03 $20 $5E $04 $20 $47 $05 +$20 $18 $05 $D0 $1D $20 $B1 $04 +$20 $54 $05 $20 $18 $05 $D0 $12 +$EE $07 $03 $D0 $D5 $EE $0A $03 +$D0 $BB $88 $10 $B8 $A9 $00 $8D +$04 $03 $00 $00 $00 $00 $F8 $C0 +$01 $AD $07 $03 $6D $0A $03 $8D +$02 $03 $08 $68 $8D $03 $03 $D8 +$C0 $01 $AD $07 $03 $6D $0A $03 +$8D $05 $03 $08 $68 $8D $06 $03 +$C0 $01 $AD $09 $03 $6D $0B $03 +$C9 $0A $A2 $00 $90 $06 $E8 $69 +$05 $29 $0F $38 $0D $08 $03 $7D +$0F $03 $08 $B0 $04 $C9 $A0 $90 +$03 $69 $5F $38 $8D $00 $03 $08 +$68 $8D $01 $03 $68 $8D $0D $03 +$60 $F8 $C0 $01 $AD $07 $03 $ED +$0A $03 $8D $02 $03 $08 $68 $8D +$03 $03 $D8 $C0 $01 $AD $07 $03 +$ED $0A $03 $8D $05 $03 $08 $68 +$8D $06 $03 $60 $C0 $01 $AD $09 +$03 $ED $0B $03 $A2 $00 $B0 $06 +$E8 $E9 $05 $29 $0F $18 $0D $08 +$03 $FD $0F $03 $B0 $02 $E9 $5F +$8D $00 $03 $60 $C0 $01 $AD $09 +$03 $ED $0B $03 $A2 $00 $B0 $04 +$E8 $29 $0F $18 $0D $08 $03 $FD +$0F $03 $B0 $02 $E9 $5F $E0 $00 +$F0 $02 $E9 $06 $8D $00 $03 $60 +$AD $02 $03 $CD $00 $03 $D0 $26 +$AD $03 $03 $4D $0C $03 $29 $80 +$D0 $1C $AD $03 $03 $4D $0D $03 +$29 $40 $D0 $12 $AD $03 $03 $4D +$0E $03 $29 $02 $D0 $08 $AD $03 +$03 $4D $01 $03 $29 $01 $60 $AD +$0D $03 $8D $0C $03 $AD $06 $03 +$8D $0E $03 $60 $20 $D4 $04 $AD +$06 $03 $8D $0C $03 $8D $0D $03 +$8D $0E $03 $8D $01 $03 $60 $AD +$00 $03 $08 $68 $8D $0C $03 $8D +$0E $03 $60 $20 $F4 $04 $AD $00 +$03 $08 $68 $8D $0C $03 $8D $0E +$03 $AD $06 $03 $8D $0D $03 $8D +$01 $03 $60 $AD $00 $03 $08 $68 +$8D $0C $03 $8D $0E $03 $60 $20 +$D4 $04 $AD $00 $03 $08 $68 $8D +$0C $03 $8D $0E $03 $AD $06 $03 +$8D $0D $03 $8D $01 $03 $60 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 + diff --git a/tinybasic.dat b/tinybasic.dat index d2f400d..fca0f34 100644 --- a/tinybasic.dat +++ b/tinybasic.dat @@ -1,774 +1,774 @@ -; Tiny Basic for MKBASIC 6502 emulator. -; Run address: $0CF0 -; I/O emulation: $E000 -ORG -$0400 -$4C $85 $04 $4C $BD $04 $4C $2C -$0F $4C $31 $0F $EA $18 $60 $5F -$18 $80 $00 $20 $86 $C3 $90 $05 -$86 $C3 $91 $C2 $60 $B1 $C2 $A0 -$00 $60 $62 $05 $64 $05 $D8 $05 -$05 $06 $33 $06 $FD $05 $9F $07 -$42 $0B $3F $0B $7A $07 $FC $08 -$95 $07 $9F $07 $9F $07 $BD $0A -$C1 $0A $8A $0A $9B $0A $E9 $0A -$61 $07 $51 $07 $41 $0A $52 $0A -$4F $0A $62 $0A $E7 $09 $CD $06 -$06 $07 $9F $07 $15 $08 $A7 $07 -$B7 $06 $BF $06 $83 $08 $A1 $06 -$9F $07 $9F $07 $A8 $08 $4F $0B -$4D $0B $07 $09 $AA $04 $37 $07 -$BD $04 $1B $0B $B1 $0A $20 $41 -$54 $20 $80 $70 $0B $A9 $00 $85 -$20 $85 $22 $A9 $1C $85 $21 $85 -$23 $A0 $01 $B1 $22 $AA $49 $FF -$91 $22 $D1 $22 $08 $8A $91 $22 -$E6 $22 $D0 $02 $E6 $23 $28 $F0 -$EA $88 $D8 $A5 $20 $6D $13 $04 -$85 $24 $98 $65 $21 $85 $25 $98 -$91 $20 $C8 $91 $20 $A5 $22 $85 -$C6 $85 $26 $A5 $23 $85 $C7 $85 -$27 $20 $87 $08 $AD $83 $04 $85 -$2A $AD $84 $04 $85 $2B $A9 $80 -$85 $C1 $A9 $30 $85 $C0 $A2 $00 -$86 $BE $86 $C2 $CA $9A $D8 $20 -$F9 $06 $20 $F2 $04 $4C $E6 $04 -$83 $65 $C9 $30 $B0 $7B $C9 $08 -$90 $0C $0A $AA $BD $1F $04 $48 -$BD $1E $04 $48 $08 $40 $65 $C1 -$AA $B1 $C1 $48 $B5 $00 $91 $C1 -$68 $95 $00 $60 $20 $87 $08 $A9 -$21 $20 $09 $04 $A5 $2A $38 $ED -$83 $04 $AA $A5 $2B $ED $84 $04 -$20 $A0 $07 $A5 $BE $F0 $12 $A9 -$7E $85 $2A $A9 $20 $85 $2B $20 -$A1 $06 $A6 $28 $A5 $29 $20 $A0 -$07 $A9 $07 $20 $09 $04 $20 $87 -$08 $A5 $26 $85 $C6 $A5 $27 $85 -$C7 $4C $CC $04 $A2 $7C $E4 $C1 -$90 $BA $A6 $C1 $E6 $C1 $E6 $C1 -$18 $60 $C6 $BD $A5 $BD $F0 $AC -$A5 $BC $85 $2A $A5 $BD $85 $2B -$60 $C9 $40 $B0 $43 $48 $20 $F9 -$06 $6D $83 $04 $85 $BC $68 $48 -$29 $07 $6D $84 $04 $85 $BD $68 -$29 $08 $D0 $DC $A5 $BC $A6 $2A -$85 $2A $86 $BC $A5 $BD $A6 $2B -$85 $2B $86 $BD $A5 $C6 $E9 $01 -$85 $C6 $B0 $02 $C6 $C7 $C5 $24 -$A5 $C7 $E5 $25 $90 $AA $A5 $BC -$91 $C6 $C8 $A5 $BD $91 $C6 $60 -$48 $4A $4A $4A $4A $29 $0E $AA -$68 $C9 $60 $29 $1F $B0 $02 $09 -$E0 $18 $F0 $07 $65 $2A $85 $BC -$98 $65 $2B $85 $BD $4C $FC $04 -$A5 $2C $85 $B8 $A5 $2D $85 $B9 -$20 $25 $06 $20 $14 $06 $51 $2A -$AA $20 $F9 $06 $8A $F0 $F1 $0A -$F0 $12 $A5 $B8 $85 $2C $A5 $B9 -$85 $2D $4C $64 $05 $20 $25 $06 -$C9 $0D $D0 $F6 $60 $20 $25 $06 -$C9 $5B $B0 $EE $C9 $41 $90 $EA -$0A $20 $87 $07 $A0 $00 $B1 $2C -$E6 $2C $D0 $02 $E6 $2D $C9 $0D -$18 $60 $20 $14 $06 $B1 $2C $C9 -$20 $F0 $F7 $C9 $3A $18 $10 $02 -$C9 $30 $60 $20 $25 $06 $90 $C2 -$84 $BC $84 $BD $A5 $BC $A6 $BD -$06 $BC $26 $BD $06 $BC $26 $BD -$18 $65 $BC $85 $BC $8A $65 $BD -$06 $BC $2A $85 $BD $20 $14 $06 -$29 $0F $65 $BC $85 $BC $98 $65 -$BD $85 $BD $20 $25 $06 $B0 $D4 -$4C $80 $07 $20 $FC $08 $A5 $BC -$05 $BD $F0 $48 $A5 $20 $85 $2C -$A5 $21 $85 $2D $20 $6D $07 $F0 -$12 $A5 $28 $C5 $BC $A5 $29 $E5 -$BD $B0 $08 $20 $14 $06 $D0 $FB -$4C $7C $06 $A5 $28 $45 $BC $D0 -$04 $A5 $29 $45 $BD $60 $20 $A6 -$06 $20 $F9 $06 $10 $F8 $E6 $BF -$30 $03 $4C $09 $04 $C6 $BF $60 -$C9 $22 $F0 $FB $20 $A6 $06 $20 -$14 $06 $D0 $F4 $4C $14 $05 $A9 -$20 $20 $A6 $06 $A5 $BF $29 $87 -$30 $E5 $D0 $F3 $60 $A2 $7B $20 -$56 $05 $E6 $C1 $E6 $C1 $E6 $C1 -$38 $B5 $03 $F5 $00 $95 $00 $B5 -$04 $F5 $01 $50 $04 $49 $80 $09 -$01 $30 $0A $D0 $04 $15 $00 $F0 -$02 $56 $02 $56 $02 $56 $02 $90 -$0C $A0 $00 $B1 $2A $E6 $2A $D0 -$02 $E6 $2B $09 $00 $60 $A5 $BE -$F0 $28 $20 $14 $06 $D0 $FB $20 -$6D $07 $F0 $1B $20 $4C $07 $20 -$0C $04 $B0 $09 $A5 $C4 $85 $2A -$A5 $C5 $85 $2B $60 $AD $83 $04 -$85 $2A $AD $84 $04 $85 $2B $4C -$14 $05 $85 $BF $4C $49 $05 $A5 -$20 $85 $2C $A5 $21 $85 $2D $20 -$6D $07 $F0 $EB $A5 $2A $85 $C4 -$A5 $2B $85 $C5 $A9 $01 $85 $BE -$60 $20 $6B $06 $F0 $BE $A5 $BC -$85 $28 $A5 $BD $85 $29 $4C $14 -$05 $20 $FD $0A $20 $FA $0A $20 -$74 $06 $D0 $EA $60 $20 $14 $06 -$85 $28 $20 $14 $06 $85 $29 $05 -$28 $60 $20 $FC $08 $20 $80 $07 -$A5 $BD $20 $87 $07 $A5 $BC $A6 -$C1 $CA $95 $00 $86 $C1 $E4 $C0 -$D0 $0D $4C $14 $05 $A6 $C1 $E0 -$80 $10 $F7 $B5 $00 $E6 $C1 $60 -$85 $BD $86 $BC $4C $B8 $07 $A6 -$C1 $B5 $01 $10 $08 $20 $41 $0A -$A9 $2D $20 $A6 $06 $20 $FC $08 -$A9 $1F $85 $B8 $85 $BA $A9 $2A -$85 $B9 $85 $BB $A6 $BC $A4 $BD -$38 $E6 $B8 $8A $E9 $10 $AA $98 -$E9 $27 $A8 $B0 $F4 $C6 $B9 $8A -$69 $E8 $AA $98 $69 $03 $A8 $90 -$F4 $8A $38 $E6 $BA $E9 $64 $B0 -$F9 $88 $10 $F6 $C6 $BB $69 $0A -$90 $FA $09 $30 $85 $BC $A9 $20 -$85 $BD $A2 $FB $86 $C3 $B5 $BD -$05 $BD $C9 $20 $F0 $09 $A0 $30 -$84 $BD $05 $BD $20 $A6 $06 $A6 -$C3 $E8 $D0 $E8 $60 $A5 $2D $48 -$A5 $2C $48 $A5 $20 $85 $2C $A5 -$21 $85 $2D $A5 $24 $A6 $25 $20 -$5B $08 $F0 $03 $20 $5B $08 $A5 -$2C $38 $E5 $B6 $A5 $2D $E5 $B7 -$B0 $42 $20 $6D $07 $F0 $3D $A6 -$28 $A5 $29 $20 $A0 $07 $A9 $20 -$20 $A6 $06 $20 $0C $04 $B0 $2C -$20 $14 $06 $D0 $F3 $20 $83 $08 -$4C $2F $08 $85 $B6 $E6 $B6 $D0 -$01 $E8 $86 $B7 $A4 $C1 $C0 $80 -$F0 $18 $20 $6B $06 $A5 $2C $A6 -$2D $38 $E9 $02 $B0 $01 $CA $85 -$2C $4C $48 $0B $68 $85 $2C $68 -$85 $2D $60 $A5 $BF $30 $FB $A9 -$0D $20 $09 $04 $AD $11 $04 $29 -$7F $85 $BF $F0 $07 $20 $64 $0B -$C6 $BF $D0 $F9 $A9 $0A $4C $61 -$0B $AC $12 $04 $84 $BF $B0 $0B -$A9 $30 $85 $2C $85 $C0 $84 $2D -$20 $80 $07 $45 $80 $85 $80 $20 -$06 $04 $A0 $00 $A6 $C0 $29 $7F -$F0 $F1 $C9 $7F $F0 $ED $C9 $13 -$F0 $DA $C9 $0A $F0 $D3 $CD $10 -$04 $F0 $09 $CD $0F $04 $D0 $0A -$E0 $30 $D0 $16 $A6 $2C $84 $BF -$A9 $0D $E4 $C1 $30 $08 $A9 $07 -$20 $A6 $06 $4C $B3 $08 $95 $00 -$E8 $E8 $CA $86 $C0 $C9 $0D $D0 -$BA $20 $83 $08 $20 $95 $07 $85 -$BC $20 $95 $07 $85 $BD $60 $20 -$D6 $0A $20 $6B $06 $08 $20 $6D -$08 $85 $B8 $86 $B9 $A5 $BC $85 -$B6 $A5 $BD $85 $B7 $A2 $00 $28 -$D0 $0B $20 $6D $07 $CA $CA $CA -$20 $14 $06 $D0 $FA $84 $28 $84 -$29 $20 $D6 $0A $A9 $0D $D1 $2C -$F0 $11 $E8 $E8 $E8 $E8 $C8 $D1 -$2C $D0 $FA $A5 $B6 $85 $28 $A5 -$B7 $85 $29 $A5 $B8 $85 $BC $A5 -$B9 $85 $BD $18 $A0 $00 $8A $F0 -$6E $10 $29 $65 $2E $85 $B8 $A5 -$2F $E9 $00 $85 $B9 $B1 $2E $91 -$B8 $A6 $2E $E4 $24 $D0 $06 $A5 -$2F $C5 $25 $F0 $4A $E8 $86 $2E -$D0 $02 $E6 $2F $E6 $B8 $D0 $E5 -$E6 $B9 $D0 $E1 $65 $24 $85 $B8 -$85 $2E $98 $65 $25 $85 $B9 $85 -$2F $A5 $2E $E5 $C6 $A5 $2F $E5 -$C7 $90 $05 $C6 $2A $4C $14 $05 -$B1 $24 $91 $2E $A6 $24 $D0 $02 -$C6 $25 $C6 $24 $A6 $2E $D0 $02 -$C6 $2F $CA $86 $2E $E4 $BC $D0 -$E7 $A6 $2F $E4 $BD $D0 $E1 $A5 -$B8 $85 $24 $A5 $B9 $85 $25 $A5 -$28 $05 $29 $F0 $17 $A5 $28 $91 -$BC $C8 $A5 $29 $91 $BC $C8 $84 -$B6 $20 $14 $06 $08 $A4 $B6 $91 -$BC $28 $D0 $F2 $4C $CC $04 $20 -$54 $05 $B5 $03 $29 $80 $F0 $02 -$A9 $FF $85 $BC $85 $BD $48 $75 -$02 $95 $02 $68 $48 $75 $03 $95 -$03 $68 $55 $01 $85 $BB $10 $03 -$20 $43 $0A $A0 $11 $B5 $00 $15 -$01 $D0 $03 $4C $14 $05 $38 $A5 -$BC $F5 $00 $48 $A5 $BD $F5 $01 -$48 $45 $BD $30 $0A $68 $85 $BD -$68 $85 $BC $38 $4C $32 $0A $68 -$68 $18 $36 $02 $36 $03 $26 $BC -$26 $BD $88 $D0 $D9 $A5 $BB $10 -$0D $A6 $C1 $38 $98 $F5 $00 $95 -$00 $98 $F5 $01 $95 $01 $60 $20 -$41 $0A $20 $54 $05 $B5 $00 $75 -$02 $95 $02 $B5 $01 $75 $03 $95 -$03 $60 $20 $54 $05 $A0 $10 $B5 -$02 $85 $BC $B5 $03 $85 $BD $16 -$02 $36 $03 $26 $BC $26 $BD $90 -$0D $18 $B5 $02 $75 $00 $95 $02 -$B5 $03 $75 $01 $95 $03 $88 $D0 -$E6 $60 $20 $95 $07 $AA $B5 $00 -$B4 $01 $C6 $C1 $A6 $C1 $94 $00 -$4C $87 $07 $A2 $7D $20 $56 $05 -$B5 $01 $48 $B5 $00 $48 $20 $95 -$07 $AA $68 $95 $00 $68 $95 $01 -$60 $20 $FD $0A $A5 $BC $85 $2A -$A5 $BD $85 $2B $60 $A2 $2C $D0 -$02 $A2 $2E $B5 $00 $C9 $80 $B0 -$0D $B5 $01 $D0 $09 $A5 $2C $85 -$2E $A5 $2D $85 $2F $60 $A5 $2C -$A4 $2E $84 $2C $85 $2E $A5 $2D -$A4 $2F $84 $2D $85 $2F $A0 $00 -$60 $A5 $28 $85 $BC $A5 $29 $85 -$BD $20 $9C $05 $A5 $C6 $85 $26 -$A5 $C7 $85 $27 $60 $B1 $C6 $85 -$BC $20 $08 $0B $B1 $C6 $85 $BD -$E6 $C6 $D0 $02 $E6 $C7 $A5 $22 -$C5 $C6 $A5 $23 $E5 $C7 $B0 $E4 -$4C $14 $05 $20 $24 $0B $85 $BC -$98 $4C $82 $07 $20 $FC $08 $A5 -$BC $85 $B6 $20 $FC $08 $A5 $BD -$85 $B7 $A4 $BC $20 $FC $08 $A6 -$B7 $A5 $B6 $18 $6C $BC $00 $20 -$42 $0B $20 $F9 $06 $4C $87 $07 -$86 $2D $E0 $00 $60 $A0 $02 $84 -$BC $A0 $29 $84 $BD $A0 $00 $B1 -$BC $C9 $08 $D0 $03 $4C $0B $0A -$60 $20 $09 $04 $A9 $FF $2C $11 -$04 $30 $02 $A9 $00 $4C $09 $04 -$24 $3A $91 $27 $10 $E1 $59 $C5 -$2A $56 $10 $11 $2C $8B $4C $45 -$D4 $A0 $80 $BD $30 $BC $E0 $13 -$1D $94 $47 $CF $88 $54 $CF $30 -$BC $E0 $10 $11 $16 $80 $53 $55 -$C2 $30 $BC $E0 $14 $16 $90 $50 -$D2 $83 $49 $4E $D4 $E5 $71 $88 -$BB $E1 $1D $8F $A2 $21 $58 $6F -$83 $AC $22 $55 $83 $BA $24 $93 -$E0 $23 $1D $30 $BC $20 $48 $91 -$49 $C6 $30 $BC $31 $34 $30 $BC -$84 $54 $48 $45 $CE $1C $1D $38 -$0D $9A $49 $4E $50 $55 $D4 $A0 -$10 $E7 $24 $3F $20 $91 $27 $E1 -$59 $81 $AC $30 $BC $13 $11 $82 -$AC $4D $E0 $1D $89 $52 $45 $54 -$55 $52 $CE $E0 $15 $1D $85 $45 -$4E $C4 $E0 $2D $98 $4C $49 $53 -$D4 $EC $24 $00 $00 $00 $00 $0A -$80 $1F $24 $93 $23 $1D $30 $BC -$E1 $50 $80 $AC $59 $85 $52 $55 -$CE $38 $0A $86 $43 $4C $45 $41 -$D2 $2B $84 $52 $45 $CD $1D $A0 -$80 $BD $38 $14 $85 $AD $30 $D3 -$17 $64 $81 $AB $30 $D3 $85 $AB -$30 $D3 $18 $5A $85 $AD $30 $D3 -$19 $54 $2F $30 $E2 $85 $AA $30 -$E2 $1A $5A $85 $AF $30 $E2 $1B -$54 $2F $98 $52 $4E $C4 $0A $80 -$80 $12 $0A $09 $29 $1A $0A $1A -$85 $18 $13 $09 $80 $12 $01 $0B -$31 $30 $61 $72 $0B $04 $02 $03 -$05 $03 $1B $1A $19 $0B $09 $06 -$0A $00 $00 $1C $17 $2F $8F $55 -$53 $D2 $80 $A8 $30 $BC $31 $2A -$31 $2A $80 $A9 $2E $2F $A2 $12 -$2F $C1 $2F $80 $A8 $30 $BC $80 -$A9 $2F $83 $AC $38 $BC $0B $2F -$80 $A8 $52 $2F $84 $BD $09 $02 -$2F $8E $BC $84 $BD $09 $93 $2F -$84 $BE $09 $05 $2F $09 $91 $2F -$80 $BE $84 $BD $09 $06 $2F $84 -$BC $09 $95 $2F $09 $04 $2F $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$EA $EA $EA $EA $EA $EA $EA $EA -$EA $EA $EA $EA $EA $20 $0D $0F -$A0 $00 $20 $1D $0F $20 $2C $0F -$C9 $43 $D0 $03 $4C $85 $04 $C9 -$57 $D0 $03 $4C $BD $04 $A2 $2F -$20 $1D $0F $4C $05 $0D $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$4F $4D $45 $47 $41 $20 $4D $49 -$43 $52 $4F $20 $53 $59 $53 $54 -$45 $4D $53 $0D $0A $4D $4B $48 -$42 $43 $2D $38 $2D $52 $31 $20 -$54 $49 $4E $59 $20 $42 $41 $53 -$49 $43 $20 $36 $35 $30 $32 $20 -$50 $4F $52 $54 $0D $0A $56 $65 -$72 $73 $69 $6F $6E $3A $20 $31 -$2E $30 $2E $32 $2C $20 $31 $2F -$31 $31 $2F $32 $30 $31 $32 $0D -$0A $28 $4E $4F $54 $45 $3A $20 -$55 $73 $65 $20 $63 $61 $70 $73 -$20 $66 $6F $72 $20 $42 $61 $73 -$69 $63 $29 $0D $0A $42 $6F $6F -$74 $20 $28 $5B $43 $5D $6F $6C -$64 $2F $5B $57 $5D $61 $72 $6D -$29 $3F $20 $07 $FF $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$86 $C3 $B1 $C2 $48 $C8 $B1 $C2 -$AA $68 $A8 $8A $60 $A2 $19 $A9 -$0D $20 $31 $0F $A9 $0A $20 $31 -$0F $CA $D0 $FA $60 $B9 $00 $0E -$C9 $FF $F0 $07 $20 $31 $0F $C8 -$4C $1D $0F $60 $AD $00 $E0 $F0 -$FB $85 $FE $C9 $FF $F0 $1E $C9 -$00 $F0 $1A $C9 $91 $F0 $16 $C9 -$93 $F0 $12 $C9 $80 $F0 $0E $4C -$50 $0F $20 $F0 $FF $A5 $FE $60 -$A5 $FE $8D $00 $E0 $60 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 -$00 $00 $00 $00 $00 $00 $00 $00 - +; Tiny Basic for MKBASIC 6502 emulator. +; Run address: $0CF0 +; I/O emulation: $E000 +ORG +$0400 +$4C $85 $04 $4C $BD $04 $4C $2C +$0F $4C $31 $0F $EA $18 $60 $5F +$18 $80 $00 $20 $86 $C3 $90 $05 +$86 $C3 $91 $C2 $60 $B1 $C2 $A0 +$00 $60 $62 $05 $64 $05 $D8 $05 +$05 $06 $33 $06 $FD $05 $9F $07 +$42 $0B $3F $0B $7A $07 $FC $08 +$95 $07 $9F $07 $9F $07 $BD $0A +$C1 $0A $8A $0A $9B $0A $E9 $0A +$61 $07 $51 $07 $41 $0A $52 $0A +$4F $0A $62 $0A $E7 $09 $CD $06 +$06 $07 $9F $07 $15 $08 $A7 $07 +$B7 $06 $BF $06 $83 $08 $A1 $06 +$9F $07 $9F $07 $A8 $08 $4F $0B +$4D $0B $07 $09 $AA $04 $37 $07 +$BD $04 $1B $0B $B1 $0A $20 $41 +$54 $20 $80 $70 $0B $A9 $00 $85 +$20 $85 $22 $A9 $1C $85 $21 $85 +$23 $A0 $01 $B1 $22 $AA $49 $FF +$91 $22 $D1 $22 $08 $8A $91 $22 +$E6 $22 $D0 $02 $E6 $23 $28 $F0 +$EA $88 $D8 $A5 $20 $6D $13 $04 +$85 $24 $98 $65 $21 $85 $25 $98 +$91 $20 $C8 $91 $20 $A5 $22 $85 +$C6 $85 $26 $A5 $23 $85 $C7 $85 +$27 $20 $87 $08 $AD $83 $04 $85 +$2A $AD $84 $04 $85 $2B $A9 $80 +$85 $C1 $A9 $30 $85 $C0 $A2 $00 +$86 $BE $86 $C2 $CA $9A $D8 $20 +$F9 $06 $20 $F2 $04 $4C $E6 $04 +$83 $65 $C9 $30 $B0 $7B $C9 $08 +$90 $0C $0A $AA $BD $1F $04 $48 +$BD $1E $04 $48 $08 $40 $65 $C1 +$AA $B1 $C1 $48 $B5 $00 $91 $C1 +$68 $95 $00 $60 $20 $87 $08 $A9 +$21 $20 $09 $04 $A5 $2A $38 $ED +$83 $04 $AA $A5 $2B $ED $84 $04 +$20 $A0 $07 $A5 $BE $F0 $12 $A9 +$7E $85 $2A $A9 $20 $85 $2B $20 +$A1 $06 $A6 $28 $A5 $29 $20 $A0 +$07 $A9 $07 $20 $09 $04 $20 $87 +$08 $A5 $26 $85 $C6 $A5 $27 $85 +$C7 $4C $CC $04 $A2 $7C $E4 $C1 +$90 $BA $A6 $C1 $E6 $C1 $E6 $C1 +$18 $60 $C6 $BD $A5 $BD $F0 $AC +$A5 $BC $85 $2A $A5 $BD $85 $2B +$60 $C9 $40 $B0 $43 $48 $20 $F9 +$06 $6D $83 $04 $85 $BC $68 $48 +$29 $07 $6D $84 $04 $85 $BD $68 +$29 $08 $D0 $DC $A5 $BC $A6 $2A +$85 $2A $86 $BC $A5 $BD $A6 $2B +$85 $2B $86 $BD $A5 $C6 $E9 $01 +$85 $C6 $B0 $02 $C6 $C7 $C5 $24 +$A5 $C7 $E5 $25 $90 $AA $A5 $BC +$91 $C6 $C8 $A5 $BD $91 $C6 $60 +$48 $4A $4A $4A $4A $29 $0E $AA +$68 $C9 $60 $29 $1F $B0 $02 $09 +$E0 $18 $F0 $07 $65 $2A $85 $BC +$98 $65 $2B $85 $BD $4C $FC $04 +$A5 $2C $85 $B8 $A5 $2D $85 $B9 +$20 $25 $06 $20 $14 $06 $51 $2A +$AA $20 $F9 $06 $8A $F0 $F1 $0A +$F0 $12 $A5 $B8 $85 $2C $A5 $B9 +$85 $2D $4C $64 $05 $20 $25 $06 +$C9 $0D $D0 $F6 $60 $20 $25 $06 +$C9 $5B $B0 $EE $C9 $41 $90 $EA +$0A $20 $87 $07 $A0 $00 $B1 $2C +$E6 $2C $D0 $02 $E6 $2D $C9 $0D +$18 $60 $20 $14 $06 $B1 $2C $C9 +$20 $F0 $F7 $C9 $3A $18 $10 $02 +$C9 $30 $60 $20 $25 $06 $90 $C2 +$84 $BC $84 $BD $A5 $BC $A6 $BD +$06 $BC $26 $BD $06 $BC $26 $BD +$18 $65 $BC $85 $BC $8A $65 $BD +$06 $BC $2A $85 $BD $20 $14 $06 +$29 $0F $65 $BC $85 $BC $98 $65 +$BD $85 $BD $20 $25 $06 $B0 $D4 +$4C $80 $07 $20 $FC $08 $A5 $BC +$05 $BD $F0 $48 $A5 $20 $85 $2C +$A5 $21 $85 $2D $20 $6D $07 $F0 +$12 $A5 $28 $C5 $BC $A5 $29 $E5 +$BD $B0 $08 $20 $14 $06 $D0 $FB +$4C $7C $06 $A5 $28 $45 $BC $D0 +$04 $A5 $29 $45 $BD $60 $20 $A6 +$06 $20 $F9 $06 $10 $F8 $E6 $BF +$30 $03 $4C $09 $04 $C6 $BF $60 +$C9 $22 $F0 $FB $20 $A6 $06 $20 +$14 $06 $D0 $F4 $4C $14 $05 $A9 +$20 $20 $A6 $06 $A5 $BF $29 $87 +$30 $E5 $D0 $F3 $60 $A2 $7B $20 +$56 $05 $E6 $C1 $E6 $C1 $E6 $C1 +$38 $B5 $03 $F5 $00 $95 $00 $B5 +$04 $F5 $01 $50 $04 $49 $80 $09 +$01 $30 $0A $D0 $04 $15 $00 $F0 +$02 $56 $02 $56 $02 $56 $02 $90 +$0C $A0 $00 $B1 $2A $E6 $2A $D0 +$02 $E6 $2B $09 $00 $60 $A5 $BE +$F0 $28 $20 $14 $06 $D0 $FB $20 +$6D $07 $F0 $1B $20 $4C $07 $20 +$0C $04 $B0 $09 $A5 $C4 $85 $2A +$A5 $C5 $85 $2B $60 $AD $83 $04 +$85 $2A $AD $84 $04 $85 $2B $4C +$14 $05 $85 $BF $4C $49 $05 $A5 +$20 $85 $2C $A5 $21 $85 $2D $20 +$6D $07 $F0 $EB $A5 $2A $85 $C4 +$A5 $2B $85 $C5 $A9 $01 $85 $BE +$60 $20 $6B $06 $F0 $BE $A5 $BC +$85 $28 $A5 $BD $85 $29 $4C $14 +$05 $20 $FD $0A $20 $FA $0A $20 +$74 $06 $D0 $EA $60 $20 $14 $06 +$85 $28 $20 $14 $06 $85 $29 $05 +$28 $60 $20 $FC $08 $20 $80 $07 +$A5 $BD $20 $87 $07 $A5 $BC $A6 +$C1 $CA $95 $00 $86 $C1 $E4 $C0 +$D0 $0D $4C $14 $05 $A6 $C1 $E0 +$80 $10 $F7 $B5 $00 $E6 $C1 $60 +$85 $BD $86 $BC $4C $B8 $07 $A6 +$C1 $B5 $01 $10 $08 $20 $41 $0A +$A9 $2D $20 $A6 $06 $20 $FC $08 +$A9 $1F $85 $B8 $85 $BA $A9 $2A +$85 $B9 $85 $BB $A6 $BC $A4 $BD +$38 $E6 $B8 $8A $E9 $10 $AA $98 +$E9 $27 $A8 $B0 $F4 $C6 $B9 $8A +$69 $E8 $AA $98 $69 $03 $A8 $90 +$F4 $8A $38 $E6 $BA $E9 $64 $B0 +$F9 $88 $10 $F6 $C6 $BB $69 $0A +$90 $FA $09 $30 $85 $BC $A9 $20 +$85 $BD $A2 $FB $86 $C3 $B5 $BD +$05 $BD $C9 $20 $F0 $09 $A0 $30 +$84 $BD $05 $BD $20 $A6 $06 $A6 +$C3 $E8 $D0 $E8 $60 $A5 $2D $48 +$A5 $2C $48 $A5 $20 $85 $2C $A5 +$21 $85 $2D $A5 $24 $A6 $25 $20 +$5B $08 $F0 $03 $20 $5B $08 $A5 +$2C $38 $E5 $B6 $A5 $2D $E5 $B7 +$B0 $42 $20 $6D $07 $F0 $3D $A6 +$28 $A5 $29 $20 $A0 $07 $A9 $20 +$20 $A6 $06 $20 $0C $04 $B0 $2C +$20 $14 $06 $D0 $F3 $20 $83 $08 +$4C $2F $08 $85 $B6 $E6 $B6 $D0 +$01 $E8 $86 $B7 $A4 $C1 $C0 $80 +$F0 $18 $20 $6B $06 $A5 $2C $A6 +$2D $38 $E9 $02 $B0 $01 $CA $85 +$2C $4C $48 $0B $68 $85 $2C $68 +$85 $2D $60 $A5 $BF $30 $FB $A9 +$0D $20 $09 $04 $AD $11 $04 $29 +$7F $85 $BF $F0 $07 $20 $64 $0B +$C6 $BF $D0 $F9 $A9 $0A $4C $61 +$0B $AC $12 $04 $84 $BF $B0 $0B +$A9 $30 $85 $2C $85 $C0 $84 $2D +$20 $80 $07 $45 $80 $85 $80 $20 +$06 $04 $A0 $00 $A6 $C0 $29 $7F +$F0 $F1 $C9 $7F $F0 $ED $C9 $13 +$F0 $DA $C9 $0A $F0 $D3 $CD $10 +$04 $F0 $09 $CD $0F $04 $D0 $0A +$E0 $30 $D0 $16 $A6 $2C $84 $BF +$A9 $0D $E4 $C1 $30 $08 $A9 $07 +$20 $A6 $06 $4C $B3 $08 $95 $00 +$E8 $E8 $CA $86 $C0 $C9 $0D $D0 +$BA $20 $83 $08 $20 $95 $07 $85 +$BC $20 $95 $07 $85 $BD $60 $20 +$D6 $0A $20 $6B $06 $08 $20 $6D +$08 $85 $B8 $86 $B9 $A5 $BC $85 +$B6 $A5 $BD $85 $B7 $A2 $00 $28 +$D0 $0B $20 $6D $07 $CA $CA $CA +$20 $14 $06 $D0 $FA $84 $28 $84 +$29 $20 $D6 $0A $A9 $0D $D1 $2C +$F0 $11 $E8 $E8 $E8 $E8 $C8 $D1 +$2C $D0 $FA $A5 $B6 $85 $28 $A5 +$B7 $85 $29 $A5 $B8 $85 $BC $A5 +$B9 $85 $BD $18 $A0 $00 $8A $F0 +$6E $10 $29 $65 $2E $85 $B8 $A5 +$2F $E9 $00 $85 $B9 $B1 $2E $91 +$B8 $A6 $2E $E4 $24 $D0 $06 $A5 +$2F $C5 $25 $F0 $4A $E8 $86 $2E +$D0 $02 $E6 $2F $E6 $B8 $D0 $E5 +$E6 $B9 $D0 $E1 $65 $24 $85 $B8 +$85 $2E $98 $65 $25 $85 $B9 $85 +$2F $A5 $2E $E5 $C6 $A5 $2F $E5 +$C7 $90 $05 $C6 $2A $4C $14 $05 +$B1 $24 $91 $2E $A6 $24 $D0 $02 +$C6 $25 $C6 $24 $A6 $2E $D0 $02 +$C6 $2F $CA $86 $2E $E4 $BC $D0 +$E7 $A6 $2F $E4 $BD $D0 $E1 $A5 +$B8 $85 $24 $A5 $B9 $85 $25 $A5 +$28 $05 $29 $F0 $17 $A5 $28 $91 +$BC $C8 $A5 $29 $91 $BC $C8 $84 +$B6 $20 $14 $06 $08 $A4 $B6 $91 +$BC $28 $D0 $F2 $4C $CC $04 $20 +$54 $05 $B5 $03 $29 $80 $F0 $02 +$A9 $FF $85 $BC $85 $BD $48 $75 +$02 $95 $02 $68 $48 $75 $03 $95 +$03 $68 $55 $01 $85 $BB $10 $03 +$20 $43 $0A $A0 $11 $B5 $00 $15 +$01 $D0 $03 $4C $14 $05 $38 $A5 +$BC $F5 $00 $48 $A5 $BD $F5 $01 +$48 $45 $BD $30 $0A $68 $85 $BD +$68 $85 $BC $38 $4C $32 $0A $68 +$68 $18 $36 $02 $36 $03 $26 $BC +$26 $BD $88 $D0 $D9 $A5 $BB $10 +$0D $A6 $C1 $38 $98 $F5 $00 $95 +$00 $98 $F5 $01 $95 $01 $60 $20 +$41 $0A $20 $54 $05 $B5 $00 $75 +$02 $95 $02 $B5 $01 $75 $03 $95 +$03 $60 $20 $54 $05 $A0 $10 $B5 +$02 $85 $BC $B5 $03 $85 $BD $16 +$02 $36 $03 $26 $BC $26 $BD $90 +$0D $18 $B5 $02 $75 $00 $95 $02 +$B5 $03 $75 $01 $95 $03 $88 $D0 +$E6 $60 $20 $95 $07 $AA $B5 $00 +$B4 $01 $C6 $C1 $A6 $C1 $94 $00 +$4C $87 $07 $A2 $7D $20 $56 $05 +$B5 $01 $48 $B5 $00 $48 $20 $95 +$07 $AA $68 $95 $00 $68 $95 $01 +$60 $20 $FD $0A $A5 $BC $85 $2A +$A5 $BD $85 $2B $60 $A2 $2C $D0 +$02 $A2 $2E $B5 $00 $C9 $80 $B0 +$0D $B5 $01 $D0 $09 $A5 $2C $85 +$2E $A5 $2D $85 $2F $60 $A5 $2C +$A4 $2E $84 $2C $85 $2E $A5 $2D +$A4 $2F $84 $2D $85 $2F $A0 $00 +$60 $A5 $28 $85 $BC $A5 $29 $85 +$BD $20 $9C $05 $A5 $C6 $85 $26 +$A5 $C7 $85 $27 $60 $B1 $C6 $85 +$BC $20 $08 $0B $B1 $C6 $85 $BD +$E6 $C6 $D0 $02 $E6 $C7 $A5 $22 +$C5 $C6 $A5 $23 $E5 $C7 $B0 $E4 +$4C $14 $05 $20 $24 $0B $85 $BC +$98 $4C $82 $07 $20 $FC $08 $A5 +$BC $85 $B6 $20 $FC $08 $A5 $BD +$85 $B7 $A4 $BC $20 $FC $08 $A6 +$B7 $A5 $B6 $18 $6C $BC $00 $20 +$42 $0B $20 $F9 $06 $4C $87 $07 +$86 $2D $E0 $00 $60 $A0 $02 $84 +$BC $A0 $29 $84 $BD $A0 $00 $B1 +$BC $C9 $08 $D0 $03 $4C $0B $0A +$60 $20 $09 $04 $A9 $FF $2C $11 +$04 $30 $02 $A9 $00 $4C $09 $04 +$24 $3A $91 $27 $10 $E1 $59 $C5 +$2A $56 $10 $11 $2C $8B $4C $45 +$D4 $A0 $80 $BD $30 $BC $E0 $13 +$1D $94 $47 $CF $88 $54 $CF $30 +$BC $E0 $10 $11 $16 $80 $53 $55 +$C2 $30 $BC $E0 $14 $16 $90 $50 +$D2 $83 $49 $4E $D4 $E5 $71 $88 +$BB $E1 $1D $8F $A2 $21 $58 $6F +$83 $AC $22 $55 $83 $BA $24 $93 +$E0 $23 $1D $30 $BC $20 $48 $91 +$49 $C6 $30 $BC $31 $34 $30 $BC +$84 $54 $48 $45 $CE $1C $1D $38 +$0D $9A $49 $4E $50 $55 $D4 $A0 +$10 $E7 $24 $3F $20 $91 $27 $E1 +$59 $81 $AC $30 $BC $13 $11 $82 +$AC $4D $E0 $1D $89 $52 $45 $54 +$55 $52 $CE $E0 $15 $1D $85 $45 +$4E $C4 $E0 $2D $98 $4C $49 $53 +$D4 $EC $24 $00 $00 $00 $00 $0A +$80 $1F $24 $93 $23 $1D $30 $BC +$E1 $50 $80 $AC $59 $85 $52 $55 +$CE $38 $0A $86 $43 $4C $45 $41 +$D2 $2B $84 $52 $45 $CD $1D $A0 +$80 $BD $38 $14 $85 $AD $30 $D3 +$17 $64 $81 $AB $30 $D3 $85 $AB +$30 $D3 $18 $5A $85 $AD $30 $D3 +$19 $54 $2F $30 $E2 $85 $AA $30 +$E2 $1A $5A $85 $AF $30 $E2 $1B +$54 $2F $98 $52 $4E $C4 $0A $80 +$80 $12 $0A $09 $29 $1A $0A $1A +$85 $18 $13 $09 $80 $12 $01 $0B +$31 $30 $61 $72 $0B $04 $02 $03 +$05 $03 $1B $1A $19 $0B $09 $06 +$0A $00 $00 $1C $17 $2F $8F $55 +$53 $D2 $80 $A8 $30 $BC $31 $2A +$31 $2A $80 $A9 $2E $2F $A2 $12 +$2F $C1 $2F $80 $A8 $30 $BC $80 +$A9 $2F $83 $AC $38 $BC $0B $2F +$80 $A8 $52 $2F $84 $BD $09 $02 +$2F $8E $BC $84 $BD $09 $93 $2F +$84 $BE $09 $05 $2F $09 $91 $2F +$80 $BE $84 $BD $09 $06 $2F $84 +$BC $09 $95 $2F $09 $04 $2F $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$EA $EA $EA $EA $EA $EA $EA $EA +$EA $EA $EA $EA $EA $20 $0D $0F +$A0 $00 $20 $1D $0F $20 $2C $0F +$C9 $43 $D0 $03 $4C $85 $04 $C9 +$57 $D0 $03 $4C $BD $04 $A2 $2F +$20 $1D $0F $4C $05 $0D $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$4F $4D $45 $47 $41 $20 $4D $49 +$43 $52 $4F $20 $53 $59 $53 $54 +$45 $4D $53 $0D $0A $4D $4B $48 +$42 $43 $2D $38 $2D $52 $31 $20 +$54 $49 $4E $59 $20 $42 $41 $53 +$49 $43 $20 $36 $35 $30 $32 $20 +$50 $4F $52 $54 $0D $0A $56 $65 +$72 $73 $69 $6F $6E $3A $20 $31 +$2E $30 $2E $32 $2C $20 $31 $2F +$31 $31 $2F $32 $30 $31 $32 $0D +$0A $28 $4E $4F $54 $45 $3A $20 +$55 $73 $65 $20 $63 $61 $70 $73 +$20 $66 $6F $72 $20 $42 $61 $73 +$69 $63 $29 $0D $0A $42 $6F $6F +$74 $20 $28 $5B $43 $5D $6F $6C +$64 $2F $5B $57 $5D $61 $72 $6D +$29 $3F $20 $07 $FF $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$86 $C3 $B1 $C2 $48 $C8 $B1 $C2 +$AA $68 $A8 $8A $60 $A2 $19 $A9 +$0D $20 $31 $0F $A9 $0A $20 $31 +$0F $CA $D0 $FA $60 $B9 $00 $0E +$C9 $FF $F0 $07 $20 $31 $0F $C8 +$4C $1D $0F $60 $AD $00 $E0 $F0 +$FB $85 $FE $C9 $FF $F0 $1E $C9 +$00 $F0 $1A $C9 $91 $F0 $16 $C9 +$93 $F0 $12 $C9 $80 $F0 $0E $4C +$50 $0F $20 $F0 $FF $A5 $FE $60 +$A5 $FE $8D $00 $E0 $60 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +$00 $00 $00 $00 $00 $00 $00 $00 +