[
  {
    "path": "CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 2.8)\nproject(emudore)\nset(SRC_FILES \"src/c64.cpp\"\n              \"src/cpu.cpp\"\n              \"src/memory.cpp\"\n              \"src/cia1.cpp\"\n              \"src/cia2.cpp\"\n              \"src/vic.cpp\"\n              \"src/io.cpp\"\n              \"src/loader.cpp\"\n              \"src/main.cpp\")\n# GCC and Clang\nif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n  set(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG} -Wall\")\n  set(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE} -Wall\")\n# C++11\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\nendif()\n# r2 debugging support, for now only available on Linux \n# and OSX Debug builds, if you want it enabled on release \n# mode just remove the second part of the expression\nif(CMAKE_BUILD_TYPE MATCHES \"Debug\" AND\n  (CMAKE_SYSTEM_NAME MATCHES \"Linux\" OR CMAKE_SYSTEM_NAME MATCHES \"Darwin\"))\n  add_definitions(-DDEBUGGER_SUPPORT)\n  set(SRC_FILES ${SRC_FILES} \"src/debugger.cpp\")\nendif()         \n# MSVC, using pre-built binaries downloaded from:\n# https://www.libsdl.org/download-2.0.php\nif (MSVC)\n  set(SDL2_PATH \"C:\\\\SDL2\")\n  set(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE} /MT\")\n  set(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG} /MTd\")\n  add_executable (emudore ${SRC_FILES} res/emudore.rc)\n  set_target_properties(emudore PROPERTIES LINK_FLAGS_DEBUG \"/SUBSYSTEM:WINDOWS\")\n  set_target_properties(emudore PROPERTIES LINK_FLAGS_RELEASE \"/SUBSYSTEM:WINDOWS\")\nelse()\n  add_executable (emudore ${SRC_FILES})\nendif()\n# JavaScript and WebAssembly builds with emscripten\nif(CMAKE_SYSTEM_NAME MATCHES \"Emscripten\")\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11 -O2 -s USE_SDL=2 -s DISABLE_EXCEPTION_CATCHING=0 --preload-file assets/roms/\")\n  if(WASM)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -s WASM=1\")\n  endif()\nendif()\n# SDL2 \n# Cmake 2.8 does not provide scripts to find SDL2, adding \n# them to the cmake module path and here for convenience\nif(NOT CMAKE_SYSTEM_NAME MATCHES \"Emscripten\")\n  list(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_LIST_DIR}/cmake\")\n  find_package(SDL2 REQUIRED)\n  include_directories(${SDL2_INCLUDE_DIR})\nendif()\n# link\ntarget_link_libraries(emudore ${SDL2_LIBRARY})\n# copy assets to build directory \nexecute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory\n${CMAKE_SOURCE_DIR}/assets/ ${CMAKE_BINARY_DIR}/assets/)\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "Makefile",
    "content": "release:\n\trm -rf build/*\n\tcd build;cmake -DCMAKE_BUILD_TYPE=Release ..\n\tcd build;make\ndebug:\n\trm -rf build/*\n\tcd build;cmake -DCMAKE_BUILD_TYPE=Debug ..\n\tcd build;make\njs:\n\trm -rf build/*\n\tcd build;cmake -DCMAKE_TOOLCHAIN_FILE=~/emsdk/emscripten/incoming/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release ..\n\tcd build;make\nwasm:\n\trm -rf build/*\n\tcd build;cmake -DCMAKE_TOOLCHAIN_FILE=~/emsdk/emscripten/incoming/cmake/Modules/Platform/Emscripten.cmake -DWASM=1 -DCMAKE_BUILD_TYPE=Release ..\n\tcd build;make\n"
  },
  {
    "path": "README.md",
    "content": "# emudore, a Commodore 64 emulator\n\n![basic](/pics/basic.gif \"basic\")\n\n# What's this?\n\nemudore is a [Commodore 64 emulator](https://en.wikipedia.org/wiki/Commodore_64), \nfully written from the scratch and built on the top of the following technologies:\n\n * [C++11](https://en.wikipedia.org/wiki/C%2B%2B11)\n * [SDL2](https://www.libsdl.org/download-2.0.php)\n\nemudore builds and runs on Linux, Windows (Visual Studio), OSX and even runs in\nyour browser thanks to Emscriptem, it should theoretically work on any platform \nsupported by SDL2 provided a C++11 compiler is available.\n\n# JavaScript and WebAssembly builds\n\nIf you wish to play a bit around without having to go through the hassle of \ncompiling it you can try the web build:\n\n* [emudore (boot into CBM BASIC)](http://marioballano.github.io/emudorejs/)\n* [emudore (load Monopole PRG)](http://marioballano.github.io/emudorejs/?load=samples/monopole.prg)\n\nA [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly) build of emudore is also available, \nplease note that a browser with WebAssembly support is required to run these demos:\n\n* [emudore (boot into CBM BASIC)](http://marioballano.github.io/emudorewa/)\n* [emudore (load Monopole PRG)](http://marioballano.github.io/emudorewa/?load=samples/monopole.prg)\n\n# Why am I writing another C64 emulator?\n\nLong story short: to learn a bit more about computer architecture, graphics, \nC++, etc..  while having some fun!\n\nThe Commodore 64 is regarded as one of the most epic 8-bit computers, it was actually \nthe first computer I ever laid hands on - thanks to my dad :) - and it seemed like a \nsound choice to write an emulator for.\n\n# Does this even work?\n\nWell, yeah, mostly... \n\nThe BASIC ROM runs just fine, and most simple programs run without issues, however, many \nof the more advanced games written in ML do not yet play well due to unimplemented hardware \nfeatures, writing an emulator is a tough task and after all my goal wasn't to write a full \nperfect emulator but to learn in the process of making a simple one, here follow some facts \nyou might be interested in knowing about emudore's implementation:\n\n**emulation is instruction-exact**\n\nThat's right, on every emulation cycle a single instruction is fetched and interpreted, \nthe number of CPU cycles the instruction has taken to execute is used to synchronize the \nrest of the chips in a C64 board. \n\nUnfortunately, this is not the best approach, other emulators are able to execute a single \ninstruction over multiple iterations of their emulation loop and mimic more accurately \nthe behaviour of the real hardware, however, this is an easier approach to implement \nand does not impede the emulation from being relatively accurate.\n\n**illegal opcodes not supported yet**\n\nAs many other architectures the MOS 6510 features a number of undocumented opcodes,\nmost of these are thought to be unintended and usually perform a mix of other opcodes \noperations:\n\n[NMOS 6510 Unintended Opcodes - PDF](http://csdb.dk/getinternalfile.php/135165/NoMoreSecrets-NMOS6510UnintendedOpcodes-20142412.pdf)\n\nNevertheless, some of these unintended opcodes have proven to be useful and are often\nused in games and demos, emudore will need to support these in the future if we ever \nintend to emulate serious games and demos.\n\n**single-threaded**\n\nemudore has been written as a single-threaded program, everything (including graphics) is \nhandled within the same thread, again, this approach has possibly some drawbacks, especially \nin terms of performance, but it greatly simplifies the architecture: things like \nsynchronization of the mainboard chips become easier to implement.\n\n**hardware acceleration and vertical refresh sync**\n\nThe screen is refreshed once at the end of every frame, when the video raster reaches the \nlast visible scanline, this way we're not constantly writing to the host video memory.\n\nAlso, to speed things up a bit I implemented hardware acceleration, we use an accelerated \nrenderer and streaming textures, unfortunately, we need to keep the rendered video frame \nwithin emudore's memory and upload the texture to the GPU on every frame, direct pixel-access\nis not doable straight on the GPU memory.\n\nI also implemented vertical refresh synchronization, at the end of every frame we check \nwhether we are ahead of time compared to a real C64 computer, if that's the case we sleep \nfor a bit and wake up at the point a real C64 would have finished rendering the frame, this\neffectively locks the screen refresh down to ~50Hz (PAL).\n\nThere are two main benefits of implementing vsync: it helps with performance since GPU \noperations are costly and after all we don't want to run at the limit of fps our GPU can \nhandle; also, and more importantly, by doing this we emulate the speed of the real C64 \ncomputer synce the CPU and other chips are synchronized and run within the same thread, if \nwe are on a fast computer visual effects won't look accelerated and games become playable :) \n\n**VIC-II chip**\n\nThe vic-ii is a relatively complex chip, my implementation is not yet complete whatsoever,\nand certain features are more than likely still buggy, for now four out of the five official \ngraphic modes are supported:\n\n * standard character mode \n * multicolor character mode \n * standard bitmap mode \n * multicolor bitmap mode\n\nSmooth scrolling, sprites and raster interrupts have also been implemented and badlines\nare also emulated.\n\nSome things that are left to implement include: sprite double height/width mode, sprite \ncollision interrupts, etc.\n\nA simple approach was taken to emulate the raster beam drawing, pixels drawn to the \nscreen surface are computed at the end of each scan line, this might result in \ncertain graphic effects being badly emulated, bear in mind that timing is of the essence \nin the c64, well-versed programmers master and exploit it to put together amazing\neffects that otherwise wouldn't be feasible.\n\n**beware**\n\nDue to some of the aforementioned facts, expect things to fail, don't even dream\nthe emulation is going to be pixel-exact, certain effects are likely to get badly \nemulated, specially if you're running things like a demo.\n\n# Are you bleedin' serious radare2 is supported?\n\nIndeed, for now it's only suppported on Linux and OSX (debug) builds, you can grab \na fresh copy of radare from [github](https://github.com/radare/radare2)\n\nThen fire the emulator up and connect with radare:\n\n    r2 -w -a 6502 rap://localhost:9999//\n\nFor now radare can just read and modify memory, further support might be coming\ndown the line once [this feature](https://github.com/radare/radare2/issues/4173) \ngets implemented in radare.\n\nSome pictures of radare in action:\n\n![r2mem](/pics/r2_mem.png \"r2mem\") \n![r2dis](/pics/r2_dis.png \"r2dis\")\n\nI hope this feature will come in useful to retrodev reverse engineers :)\n\n# So now .. what?\n\nThere are many features of the currently emulated chips that I haven't implemented \nyet, time permitting my plan is to keep working and learning about other aspects of\nthe C64 technology, also, at some stage I'd love to get the time to work on:\n\n  * Sound support: [SID](https://en.wikipedia.org/wiki/MOS_Technology_SID)\n  * Floppy drive support: [VIC-1541](https://en.wikipedia.org/wiki/Commodore_1541)\n\n# Alright, enough of your jibba-jabba, how do I run this?\n\nIf you are running a Linux Debian-based distro:\n\n    sudo apt-get install g++ cmake libsdl2-dev\n\nThen simply compile and run:\n\n    make release\n    cd build\n    ./emudore\n\n# What C64 programs can I load into this?\n\nFor the time being emudore can load PRGs, you can test: \n\n    ./emudore assets/prg/monopole.prg\n\nemudore can also type BASIC listings for you (special keys not supported yet):\n\n    ./emudore assets/bas/10print.bas \n    (then type RUN at the emulator window)\n\n# Got some more screenshots?\n\nSure.. \n\n![parallax](/pics/parallax.png \"parallax\") ![mario](/pics/mario.png \"mario\") ![pacman](/pics/pacman.png \"pacman\") \n![hitmen](/pics/hitmen.png \"hitmen\") ![montezuma](/pics/montezuma.png \"montezuma\") ![ghostbusters](/pics/ghostbusters.png \"ghostbusters\") \n\n\n# References\n\nIf you are interested in computer archeology, and particularly in the C64, among\nothers, the following resources came in handy to develop (and get inspiration) while \ndeveloping emudore:\n\n * [The C64 Wiki](http://www.c64-wiki.com/)\n * [Programming the Commodore 64: The Definitive Guide](http://www.amazon.co.uk/Programming-Commodore-64-Definitive-Guide/dp/0874550815/)\n * [Commodore: A Company on the Edge (book)](http://www.amazon.co.uk/Commodore-Company-Edge-Brian-Bagnall/dp/0973864966/)\n * [The Ultimate Commodore 64 Talk](https://www.youtube.com/watch?v=ZsRRCnque2E)\n * [Behind the scenes of a C64 demo](https://www.youtube.com/watch?v=So-m4NUzKLw)\n * [Dustlayer's blog](http://dustlayer.com/blog/)\n * [The MOS 6567/6569 video controller (VIC-II) and its application in the Commodore 64](http://www.zimmers.net/cbmpics/cbm/c64/vic-ii.txt)\n\n# Forks \n\nSome people have forked emudore and experimented with it, some notable forks include:\n\n* [Chris Frantz's C64 and NES emulator](https://github.com/cfrantz/emudore)\n* [Scott Hutter's bare metal x86-64 emulator](https://github.com/xlar54/emudore64)\n\n# License\n\nI don't think anybody will ever dare to use this for an actual useful purpose, but just in case, \nthe project is licensed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0)\n"
  },
  {
    "path": "assets/bas/10print.bas",
    "content": "REM source: http://10print.org/\n10 PRINT CHR$(205.5+RND(1)); : GOTO 10\n"
  },
  {
    "path": "assets/bas/bitmap.bas",
    "content": "10 POKE 53272,PEEK(53272)OR8:POKE 53265,PEEK(53265)OR32\n20 FORI=8192TO16191 STEP 8\n30 POKEI,240:POKEI+1,240:POKEI+2,240:POKEI+3,240\n40 POKEI+4,15:POKEI+5,15:POKEI+6,15:POKEI+7,15\n50 NEXT\n60 FORI=1024TO2034:POKEI,251:NEXT\n70 GOTO 70\n"
  },
  {
    "path": "assets/bas/bouncing.bas",
    "content": "REM source: http://www.lemon64.com/manual/\nNEW\n10 POKE 53281,1: PRINT\"*\"\n20 POKE 53280,7: POKE 53281,6\n30 X = 1 : Y = 1\n40 DX = 1 : DY = 1\n50 POKE 1024 + X + 40 * Y, 81\n60 FOR T = 1 TO 10 : NEXT\n70 POKE 1024 + X + 40 * Y, 32\n80 X = X + DX\n90 IF X <= 0 OR X >= 39 THEN DX = -DX\n100 Y = Y + DY\n110 IF Y <= 0 OR Y >= 24 THEN DY = -DY\n120 GOTO 50\n"
  },
  {
    "path": "assets/bas/lowercase.bas",
    "content": "REM SWITCH TO LOWERCASE MODE\nPOKE 53272,23 \n"
  },
  {
    "path": "assets/roms/README.md",
    "content": "The following files have been downloaded from: \n\nftp://www.zimmers.net/pub/cbm/firmware/computers/c64/\n\nPlease, bear in mind that these files might be subject to other licenses\nthan emudore's\n\n# kernal.901227-03.bin\n\n  This 8-kilobyte 2364 ROM is the third and essentially last revision of \n  the Commodore 64 KERNAL. It is the most widely spread version.\n\n# basic.901226-01.bin\n\n  Commodore 64 BASIC V2. The first and essentially only revision, located at \n  $A000-$BFFF. In the 64GS system firmware, the 30 unused bytes at $BF53-$BF70 \n  are filled with $00 instead of $AA. In the Commodore 65 firmware, these bytes \n  are filled with $FF.\n\n# characters.901225-01.bin\n\n  The character generator ROM.\n"
  },
  {
    "path": "assets/tests/6502_functional_test.a65",
    "content": ";\n; 6 5 0 2   F U N C T I O N A L   T E S T\n;\n; Copyright (C) 2012-2015  Klaus Dormann\n;\n; This program is free software: you can redistribute it and/or modify\n; it under the terms of the GNU General Public License as published by\n; the Free Software Foundation, either version 3 of the License, or\n; (at your option) any later version.\n;\n; This program is distributed in the hope that it will be useful,\n; but WITHOUT ANY WARRANTY; without even the implied warranty of\n; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n; GNU General Public License for more details.\n;\n; You should have received a copy of the GNU General Public License\n; along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n\n; This program is designed to test all opcodes of a 6502 emulator using all\n; addressing modes with focus on propper setting of the processor status\n; register bits.\n; \n; version 21-oct-2015\n; contact info at http://2m5.de or email K@2m5.de\n;\n; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/\n; command line switches: -l -m -s2 -w -h0\n;                         |  |  |   |  no page headers in listing\n;                         |  |  |   wide listing (133 char/col)\n;                         |  |  write intel hex file instead of binary\n;                         |  expand macros in listing\n;                         generate pass2 listing\n;\n; No IO - should be run from a monitor with access to registers.\n; To run load intel hex image with a load command, than alter PC to 400 hex\n; (code_segment) and enter a go command.\n; Loop on program counter determines error or successful completion of test.\n; Check listing for relevant traps (jump/branch *).\n; Please note that in early tests some instructions will have to be used before\n; they are actually tested!\n;\n; RESET, NMI or IRQ should not occur and will be trapped if vectors are enabled.\n; Tests documented behavior of the original NMOS 6502 only! No unofficial\n; opcodes. Additional opcodes of newer versions of the CPU (65C02, 65816) will\n; not be tested. Decimal ops will only be tested with valid BCD operands and\n; N V Z flags will be ignored.\n;\n; Debugging hints:\n;     Most of the code is written sequentially. if you hit a trap, check the\n;   immediately preceeding code for the instruction to be tested. Results are\n;   tested first, flags are checked second by pushing them onto the stack and\n;   pulling them to the accumulator after the result was checked. The \"real\"\n;   flags are no longer valid for the tested instruction at this time!\n;     If the tested instruction was indexed, the relevant index (X or Y) must\n;   also be checked. Opposed to the flags, X and Y registers are still valid.\n;\n; versions:\n;   28-jul-2012  1st version distributed for testing\n;   29-jul-2012  fixed references to location 0, now #0\n;                added license - GPLv3\n;   30-jul-2012  added configuration options\n;   01-aug-2012  added trap macro to allow user to change error handling\n;   01-dec-2012  fixed trap in branch field must be a branch\n;   02-mar-2013  fixed PLA flags not tested\n;   19-jul-2013  allowed ROM vectors to be loaded when load_data_direct = 0\n;                added test sequence check to detect if tests jump their fence\n;   23-jul-2013  added RAM integrity check option\n;   16-aug-2013  added error report to standard output option\n;   13-dec-2014  added binary/decimal opcode table switch test\n;   14-dec-2014  improved relative address test\n;   23-aug-2015  added option to disable self modifying tests\n;   24-aug-2015  all self modifying immediate opcodes now execute in data RAM\n;                added small branch offset pretest\n;   21-oct-2015  added option to disable decimal mode ADC & SBC tests\n\n\n; C O N F I G U R A T I O N\n\n;ROM_vectors writable (0=no, 1=yes)\n;if ROM vectors can not be used interrupts will not be trapped\n;as a consequence BRK can not be tested but will be emulated to test RTI\nROM_vectors = 1\n\n;load_data_direct (0=move from code segment, 1=load directly)\n;loading directly is preferred but may not be supported by your platform\n;0 produces only consecutive object code, 1 is not suitable for a binary image\nload_data_direct = 0\n\n;I_flag behavior (0=force enabled, 1=force disabled, 2=prohibit change, 3=allow\n;change) 2 requires extra code and is not recommended. SEI & CLI can only be\n;tested if you allow changing the interrupt status (I_flag = 3)\nI_flag = 3\n\n;configure memory - try to stay away from memory used by the system\n;zero_page memory start address, $50 (80) consecutive Bytes required\n;                                add 2 if I_flag = 2\nzero_page = $a  \n\n;data_segment memory start address, $6A (106) consecutive Bytes required\ndata_segment = $200  \n    if (data_segment & $ff) != 0\n        ERROR ERROR ERROR low byte of data_segment MUST be $00 !!\n    endif  \n\n;code_segment memory start address, 13kB of consecutive space required\n;                                   add 2.5 kB if I_flag = 2\ncode_segment = $400  \n\n;self modifying code may be disabled to allow running in ROM\n;0=part of the code is self modifying and must reside in RAM\n;1=tests disabled: branch range\ndisable_selfmod = 0\n\n;report errors through I/O channel (0=use standard self trap loops, 1=include\n;report.i65 as I/O channel, add 3.5 kB)\nreport = 0\n\n;RAM integrity test option. Checks for undesired RAM writes.\n;set lowest non RAM or RAM mirror address page (-1=disable, 0=64k, $40=16k)\n;leave disabled if a monitor, OS or background interrupt is allowed to alter RAM\nram_top = -1\n\n;disable test decimal mode ADC & SBC, 0=enable, 1=disable,\n;2=disable including decimal flag in processor status\ndisable_decimal = 0\n\n        noopt       ;do not take shortcuts\n\n;macros for error & success traps to allow user modification\n;example:\n;trap    macro\n;        jsr my_error_handler\n;        endm\n;trap_eq macro\n;        bne skip\\?\n;        trap           ;failed equal (zero)\n;skip\\?\n;        endm\n;\n; my_error_handler should pop the calling address from the stack and report it.\n; putting larger portions of code (more than 3 bytes) inside the trap macro\n; may lead to branch range problems for some tests.\n    if report = 0\ntrap    macro\n        jmp *           ;failed anyway\n        endm\ntrap_eq macro\n        beq *           ;failed equal (zero)\n        endm\ntrap_ne macro\n        bne *           ;failed not equal (non zero)\n        endm\ntrap_cs macro\n        bcs *           ;failed carry set\n        endm\ntrap_cc macro\n        bcc *           ;failed carry clear\n        endm\ntrap_mi macro\n        bmi *           ;failed minus (bit 7 set)\n        endm\ntrap_pl macro\n        bpl *           ;failed plus (bit 7 clear)\n        endm\ntrap_vs macro\n        bvs *           ;failed overflow set\n        endm\ntrap_vc macro\n        bvc *           ;failed overflow clear\n        endm\n; please observe that during the test the stack gets invalidated\n; therefore a RTS inside the success macro is not possible\nsuccess macro\n        jmp *           ;test passed, no errors\n        endm\n    endif\n    if report = 1\ntrap    macro\n        jsr report_error\n        endm\ntrap_eq macro\n        bne skip\\?\n        trap           ;failed equal (zero)\nskip\\?\n        endm\ntrap_ne macro\n        beq skip\\?\n        trap            ;failed not equal (non zero)\nskip\\?\n        endm\ntrap_cs macro\n        bcc skip\\?\n        trap            ;failed carry set\nskip\\?\n        endm\ntrap_cc macro\n        bcs skip\\?\n        trap            ;failed carry clear\nskip\\?\n        endm\ntrap_mi macro\n        bpl skip\\?\n        trap            ;failed minus (bit 7 set)\nskip\\?\n        endm\ntrap_pl macro\n        bmi skip\\?\n        trap            ;failed plus (bit 7 clear)\nskip\\?\n        endm\ntrap_vs macro\n        bvc skip\\?\n        trap            ;failed overflow set\nskip\\?\n        endm\ntrap_vc macro\n        bvs skip\\?\n        trap            ;failed overflow clear\nskip\\?\n        endm\n; please observe that during the test the stack gets invalidated\n; therefore a RTS inside the success macro is not possible\nsuccess macro\n        jsr report_success\n        endm\n    endif\n\n\ncarry   equ %00000001   ;flag bits in status\nzero    equ %00000010\nintdis  equ %00000100\ndecmode equ %00001000\nbreak   equ %00010000\nreserv  equ %00100000\noverfl  equ %01000000\nminus   equ %10000000\n\nfc      equ carry\nfz      equ zero\nfzc     equ carry+zero\nfv      equ overfl\nfvz     equ overfl+zero\nfn      equ minus\nfnc     equ minus+carry\nfnz     equ minus+zero\nfnzc    equ minus+zero+carry\nfnv     equ minus+overfl\n\nfao     equ break+reserv    ;bits always on after PHP, BRK\nfai     equ fao+intdis      ;+ forced interrupt disable\nfaod    equ fao+decmode     ;+ ignore decimal\nfaid    equ fai+decmode     ;+ ignore decimal\nm8      equ $ff             ;8 bit mask\nm8i     equ $ff&~intdis     ;8 bit mask - interrupt disable\n\n;macros to allow masking of status bits.\n;masking test of decimal bit\n;masking of interrupt enable/disable on load and compare\n;masking of always on bits after PHP or BRK (unused & break) on compare\n    if disable_decimal < 2\n        if I_flag = 0\nload_flag   macro\n            lda #\\1&m8i         ;force enable interrupts (mask I)\n            endm\ncmp_flag    macro\n            cmp #(\\1|fao)&m8i   ;I_flag is always enabled + always on bits\n            endm\neor_flag    macro\n            eor #(\\1&m8i|fao)   ;mask I, invert expected flags + always on bits\n            endm\n        endif\n        if I_flag = 1\nload_flag   macro\n            lda #\\1|intdis      ;force disable interrupts\n            endm\ncmp_flag    macro\n            cmp #(\\1|fai)&m8    ;I_flag is always disabled + always on bits\n            endm\neor_flag    macro\n            eor #(\\1|fai)       ;invert expected flags + always on bits + I\n            endm\n        endif\n        if I_flag = 2\nload_flag   macro\n            lda #\\1\n            ora flag_I_on       ;restore I-flag\n            and flag_I_off\n            endm\ncmp_flag    macro\n            eor flag_I_on       ;I_flag is never changed\n            cmp #(\\1|fao)&m8i   ;expected flags + always on bits, mask I\n            endm\neor_flag    macro\n            eor flag_I_on       ;I_flag is never changed\n            eor #(\\1&m8i|fao)   ;mask I, invert expected flags + always on bits\n            endm\n        endif\n        if I_flag = 3\nload_flag   macro\n            lda #\\1             ;allow test to change I-flag (no mask)\n            endm\ncmp_flag    macro\n            cmp #(\\1|fao)&m8    ;expected flags + always on bits\n            endm\neor_flag    macro\n            eor #\\1|fao         ;invert expected flags + always on bits\n            endm\n        endif\n    else\n        if I_flag = 0\nload_flag   macro\n            lda #\\1&m8i         ;force enable interrupts (mask I)\n            endm\ncmp_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            cmp #(\\1|faod)&m8i  ;I_flag is always enabled + always on bits\n            endm\neor_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            eor #(\\1&m8i|faod)  ;mask I, invert expected flags + always on bits\n            endm\n        endif\n        if I_flag = 1\nload_flag   macro\n            lda #\\1|intdis      ;force disable interrupts\n            endm\ncmp_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            cmp #(\\1|faid)&m8   ;I_flag is always disabled + always on bits\n            endm\neor_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            eor #(\\1|faid)      ;invert expected flags + always on bits + I\n            endm\n        endif\n        if I_flag = 2\nload_flag   macro\n            lda #\\1\n            ora flag_I_on       ;restore I-flag\n            and flag_I_off\n            endm\ncmp_flag    macro\n            eor flag_I_on       ;I_flag is never changed\n            ora #decmode        ;ignore decimal mode bit\n            cmp #(\\1|faod)&m8i  ;expected flags + always on bits, mask I\n            endm\neor_flag    macro\n            eor flag_I_on       ;I_flag is never changed\n            ora #decmode        ;ignore decimal mode bit\n            eor #(\\1&m8i|faod)  ;mask I, invert expected flags + always on bits\n            endm\n        endif\n        if I_flag = 3\nload_flag   macro\n            lda #\\1             ;allow test to change I-flag (no mask)\n            endm\ncmp_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            cmp #(\\1|faod)&m8   ;expected flags + always on bits\n            endm\neor_flag    macro\n            ora #decmode        ;ignore decimal mode bit\n            eor #\\1|faod        ;invert expected flags + always on bits\n            endm\n        endif\n    endif\n\n;macros to set (register|memory|zeropage) & status\nset_stat    macro       ;setting flags in the processor status register\n            load_flag \\1\n            pha         ;use stack to load status\n            plp\n            endm\n\nset_a       macro       ;precharging accu & status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda #\\1     ;precharge accu\n            plp\n            endm\n\nset_x       macro       ;precharging index & status\n            load_flag \\2\n            pha         ;use stack to load status\n            ldx #\\1     ;precharge index x\n            plp\n            endm\n\nset_y       macro       ;precharging index & status\n            load_flag \\2\n            pha         ;use stack to load status\n            ldy #\\1     ;precharge index y\n            plp\n            endm\n\nset_ax      macro       ;precharging indexed accu & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,x    ;precharge accu\n            plp\n            endm\n\nset_ay      macro       ;precharging indexed accu & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,y    ;precharge accu\n            plp\n            endm\n\nset_z       macro       ;precharging indexed zp & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,x    ;load to zeropage\n            sta zpt\n            plp\n            endm\n\nset_zx      macro       ;precharging zp,x & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,x    ;load to indexed zeropage\n            sta zpt,x\n            plp\n            endm\n\nset_abs     macro       ;precharging indexed memory & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,x    ;load to memory\n            sta abst\n            plp\n            endm\n\nset_absx    macro       ;precharging abs,x & immediate status\n            load_flag \\2\n            pha         ;use stack to load status\n            lda \\1,x    ;load to indexed memory\n            sta abst,x\n            plp\n            endm\n\n;macros to test (register|memory|zeropage) & status & (mask)\ntst_stat    macro       ;testing flags in the processor status register\n            php         ;save status\n            pla         ;use stack to retrieve status\n            pha\n            cmp_flag \\1\n            trap_ne\n            plp         ;restore status\n            endm\n            \ntst_a       macro       ;testing result in accu & flags\n            php         ;save flags\n            cmp #\\1     ;test result\n            trap_ne\n            pla         ;load status\n            pha\n            cmp_flag \\2\n            trap_ne\n            plp         ;restore status\n            endm\n\ntst_x       macro       ;testing result in x index & flags\n            php         ;save flags\n            cpx #\\1     ;test result\n            trap_ne\n            pla         ;load status\n            pha\n            cmp_flag \\2\n            trap_ne\n            plp         ;restore status\n            endm\n\ntst_y       macro       ;testing result in y index & flags\n            php         ;save flags\n            cpy #\\1     ;test result\n            trap_ne\n            pla         ;load status\n            pha\n            cmp_flag \\2\n            trap_ne\n            plp         ;restore status\n            endm\n\ntst_ax      macro       ;indexed testing result in accu & flags\n            php         ;save flags\n            cmp \\1,x    ;test result\n            trap_ne\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,x    ;test flags\n            trap_ne     ;\n            endm\n\ntst_ay      macro       ;indexed testing result in accu & flags\n            php         ;save flags\n            cmp \\1,y    ;test result\n            trap_ne     ;\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,y    ;test flags\n            trap_ne\n            endm\n        \ntst_z       macro       ;indexed testing result in zp & flags\n            php         ;save flags\n            lda zpt\n            cmp \\1,x    ;test result\n            trap_ne\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,x    ;test flags\n            trap_ne\n            endm\n\ntst_zx      macro       ;testing result in zp,x & flags\n            php         ;save flags\n            lda zpt,x\n            cmp \\1,x    ;test result\n            trap_ne\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,x    ;test flags\n            trap_ne\n            endm\n\ntst_abs     macro       ;indexed testing result in memory & flags\n            php         ;save flags\n            lda abst\n            cmp \\1,x    ;test result\n            trap_ne\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,x    ;test flags\n            trap_ne\n            endm\n\ntst_absx    macro       ;testing result in abs,x & flags\n            php         ;save flags\n            lda abst,x\n            cmp \\1,x    ;test result\n            trap_ne\n            pla         ;load status\n            eor_flag \\3\n            cmp \\2,x    ;test flags\n            trap_ne\n            endm\n            \n; RAM integrity test\n;   verifies that none of the previous tests has altered RAM outside of the\n;   designated write areas.\n;   uses zpt word as indirect pointer, zpt+2 word as checksum\n        if ram_top > -1\ncheck_ram   macro \n            cld\n            lda #0\n            sta zpt         ;set low byte of indirect pointer\n            sta zpt+3       ;checksum high byte\n          if disable_selfmod = 0\n            sta range_adr   ;reset self modifying code\n          endif\n            clc\n            ldx #zp_bss-zero_page ;zeropage - write test area\nccs3\\?      adc zero_page,x\n            bcc ccs2\\?\n            inc zpt+3       ;carry to high byte\n            clc\nccs2\\?      inx\n            bne ccs3\\?\n            ldx #hi(abs1)   ;set high byte of indirect pointer\n            stx zpt+1\n            ldy #lo(abs1)   ;data after write & execute test area\nccs5\\?      adc (zpt),y\n            bcc ccs4\\?\n            inc zpt+3       ;carry to high byte\n            clc\nccs4\\?      iny\n            bne ccs5\\?\n            inx             ;advance RAM high address\n            stx zpt+1\n            cpx #ram_top\n            bne ccs5\\?\n            sta zpt+2       ;checksum low is\n            cmp ram_chksm   ;checksum low expected\n            trap_ne         ;checksum mismatch\n            lda zpt+3       ;checksum high is\n            cmp ram_chksm+1 ;checksum high expected\n            trap_ne         ;checksum mismatch\n            endm            \n        else\ncheck_ram   macro\n            ;RAM check disabled - RAM size not set\n            endm\n        endif\n\nnext_test   macro           ;make sure, tests don't jump the fence\n            lda test_case   ;previous test\n            cmp #test_num\n            trap_ne         ;test is out of sequence\ntest_num = test_num + 1\n            lda #test_num   ;*** next tests' number\n            sta test_case\n            ;check_ram       ;uncomment to find altered RAM after each test\n            endm\n\n    if load_data_direct = 1\n        data\n    else\n        bss                 ;uninitialized segment, copy of data at end of code!\n    endif\n        org zero_page\n;break test interrupt save\nirq_a   ds  1               ;a register\nirq_x   ds  1               ;x register\n    if I_flag = 2\n;masking for I bit in status\nflag_I_on   ds  1           ;or mask to load flags   \nflag_I_off  ds  1           ;and mask to load flags\n    endif\nzpt                         ;5 bytes store/modify test area\n;add/subtract operand generation and result/flag prediction\nadfc    ds  1               ;carry flag before op\nad1     ds  1               ;operand 1 - accumulator\nad2     ds  1               ;operand 2 - memory / immediate\nadrl    ds  1               ;expected result bits 0-7\nadrh    ds  1               ;expected result bit 8 (carry)\nadrf    ds  1               ;expected flags NV0000ZC (only binary mode)\nsb2     ds  1               ;operand 2 complemented for subtract\nzp_bss\nzp1     db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\nzp7f    db  $7f             ;test pattern for compare  \n;logical zeropage operands\nzpOR    db  0,$1f,$71,$80   ;test pattern for OR\nzpAN    db  $0f,$ff,$7f,$80 ;test pattern for AND\nzpEO    db  $ff,$0f,$8f,$8f ;test pattern for EOR\n;indirect addressing pointers\nind1    dw  abs1            ;indirect pointer to pattern in absolute memory\n        dw  abs1+1\n        dw  abs1+2\n        dw  abs1+3\n        dw  abs7f\ninw1    dw  abs1-$f8        ;indirect pointer for wrap-test pattern\nindt    dw  abst            ;indirect pointer to store area in absolute memory\n        dw  abst+1\n        dw  abst+2\n        dw  abst+3\ninwt    dw  abst-$f8        ;indirect pointer for wrap-test store\nindAN   dw  absAN           ;indirect pointer to AND pattern in absolute memory\n        dw  absAN+1\n        dw  absAN+2\n        dw  absAN+3\nindEO   dw  absEO           ;indirect pointer to EOR pattern in absolute memory\n        dw  absEO+1\n        dw  absEO+2\n        dw  absEO+3\nindOR   dw  absOR           ;indirect pointer to OR pattern in absolute memory\n        dw  absOR+1\n        dw  absOR+2\n        dw  absOR+3\n;add/subtract indirect pointers\nadi2    dw  ada2            ;indirect pointer to operand 2 in absolute memory\nsbi2    dw  sba2            ;indirect pointer to complemented operand 2 (SBC)\nadiy2   dw  ada2-$ff        ;with offset for indirect indexed\nsbiy2   dw  sba2-$ff\nzp_bss_end\n   \n        org data_segment\ntest_case   ds  1           ;current test number\nram_chksm   ds  2           ;checksum for RAM integrity test\n;add/subtract operand copy - abs tests write area\nabst                        ;5 bytes store/modify test area\nada2    ds  1               ;operand 2\nsba2    ds  1               ;operand 2 complemented for subtract\n        ds  3               ;fill remaining bytes\ndata_bss\n    if load_data_direct = 1\nex_andi and #0              ;execute immediate opcodes\n        rts\nex_eori eor #0              ;execute immediate opcodes\n        rts\nex_orai ora #0              ;execute immediate opcodes\n        rts\nex_adci adc #0              ;execute immediate opcodes\n        rts\nex_sbci sbc #0              ;execute immediate opcodes\n        rts\n    else\nex_andi ds  3\nex_eori ds  3\nex_orai ds  3\nex_adci ds  3\nex_sbci ds  3\n    endif\nabs1    db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\nabs7f   db  $7f             ;test pattern for compare\n;loads\nfLDx    db  fn,fn,0,fz      ;expected flags for load\n;shifts\nrASL                        ;expected result ASL & ROL -carry  \nrROL    db  $86,$04,$82,0   ; \"\nrROLc   db  $87,$05,$83,1   ;expected result ROL +carry\nrLSR                        ;expected result LSR & ROR -carry\nrROR    db  $61,$41,$20,0   ; \"\nrRORc   db  $e1,$c1,$a0,$80 ;expected result ROR +carry\nfASL                        ;expected flags for shifts\nfROL    db  fnc,fc,fn,fz    ;no carry in\nfROLc   db  fnc,fc,fn,0     ;carry in\nfLSR\nfROR    db  fc,0,fc,fz      ;no carry in\nfRORc   db  fnc,fn,fnc,fn   ;carry in\n;increments (decrements)\nrINC    db  $7f,$80,$ff,0,1 ;expected result for INC/DEC\nfINC    db  0,fn,fn,fz,0    ;expected flags for INC/DEC\n;logical memory operand\nabsOR   db  0,$1f,$71,$80   ;test pattern for OR\nabsAN   db  $0f,$ff,$7f,$80 ;test pattern for AND\nabsEO   db  $ff,$0f,$8f,$8f ;test pattern for EOR\n;logical accu operand\nabsORa  db  0,$f1,$1f,0     ;test pattern for OR\nabsANa  db  $f0,$ff,$ff,$ff ;test pattern for AND\nabsEOa  db  $ff,$f0,$f0,$0f ;test pattern for EOR\n;logical results\nabsrlo  db  0,$ff,$7f,$80\nabsflo  db  fz,fn,0,fn\ndata_bss_end\n\n\n        code\n        org code_segment\nstart   cld\n        ldx #$ff\n        txs\n        lda #0          ;*** test 0 = initialize\n        sta test_case\ntest_num = 0\n\n;stop interrupts before initializing BSS\n    if I_flag = 1\n        sei\n    endif\n    \n;initialize I/O for report channel\n    if report = 1\n        jsr report_init\n    endif\n    \n;pretest small branch offset\n        ldx #5\n        jmp psb_test\npsb_bwok\n        ldy #5\n        bne psb_forw\n        trap        ;branch should be taken\n        dey         ;forward landing zone\n        dey\n        dey\n        dey\n        dey\npsb_forw\n        dey\n        dey\n        dey\n        dey\n        dey\n        beq psb_fwok\n        trap        ;forward offset\n\n        dex         ;backward landing zone\n        dex\n        dex\n        dex\n        dex\npsb_back\n        dex\n        dex\n        dex\n        dex\n        dex\n        beq psb_bwok\n        trap        ;backward offset\npsb_test\n        bne psb_back\n        trap        ;branch should be taken\npsb_fwok\n        \n;initialize BSS segment\n    if load_data_direct != 1\n        ldx #zp_end-zp_init-1\nld_zp   lda zp_init,x\n        sta zp_bss,x\n        dex\n        bpl ld_zp\n        ldx #data_end-data_init-1\nld_data lda data_init,x\n        sta data_bss,x\n        dex\n        bpl ld_data\n      if ROM_vectors = 1\n        ldx #5\nld_vect lda vec_init,x\n        sta vec_bss,x\n        dex\n        bpl ld_vect\n      endif\n    endif\n\n;retain status of interrupt flag\n    if I_flag = 2\n        php\n        pla\n        and #4          ;isolate flag\n        sta flag_I_on   ;or mask\n        eor #lo(~4)     ;reverse\n        sta flag_I_off  ;and mask\n    endif\n        \n;generate checksum for RAM integrity test\n    if ram_top > -1\n        lda #0 \n        sta zpt         ;set low byte of indirect pointer\n        sta ram_chksm+1 ;checksum high byte\n      if disable_selfmod = 0\n        sta range_adr   ;reset self modifying code\n      endif\n        clc\n        ldx #zp_bss-zero_page ;zeropage - write test area\ngcs3    adc zero_page,x\n        bcc gcs2\n        inc ram_chksm+1 ;carry to high byte\n        clc\ngcs2    inx\n        bne gcs3\n        ldx #hi(abs1)   ;set high byte of indirect pointer\n        stx zpt+1\n        ldy #lo(abs1)   ;data after write & execute test area\ngcs5    adc (zpt),y\n        bcc gcs4\n        inc ram_chksm+1 ;carry to high byte\n        clc\ngcs4    iny\n        bne gcs5\n        inx             ;advance RAM high address\n        stx zpt+1\n        cpx #ram_top\n        bne gcs5\n        sta ram_chksm   ;checksum complete\n    endif\n        next_test            \n\n    if disable_selfmod = 0\n;testing relative addressing with BEQ\n        ldy #$fe        ;testing maximum range, not -1/-2 (invalid/self adr)\nrange_loop\n        dey             ;next relative address\n        tya\n        tax             ;precharge count to end of loop\n        bpl range_fw    ;calculate relative address\n        clc             ;avoid branch self or to relative address of branch\n        adc #2\n        nop             ;offset landing zone - tolerate +/-5 offset to branch\n        nop\n        nop\n        nop\n        nop\nrange_fw\n        nop\n        nop\n        nop\n        nop\n        nop\n        eor #$7f        ;complement except sign\n        sta range_adr   ;load into test target\n        lda #0          ;should set zero flag in status register\n        jmp range_op\n        \n        dex             ; offset landing zone - backward branch too far\n        dex\n        dex\n        dex\n        dex\n        ;relative address target field with branch under test in the middle\n        dex             ;-128 - max backward\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-120\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-110\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-100\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-90\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-80\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-70\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-60\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-50\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-40\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-30\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-20\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-10\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;-3\nrange_op                ;test target with zero flag=0, z=1 if previous dex\nrange_adr   = *+1       ;modifiable relative address\n        beq *+64        ;+64 if called without modification\n        dex             ;+0\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+10\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+20\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+30\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+40\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+50\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+60\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+70\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+80\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+90\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+100\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+110\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex             ;+120\n        dex\n        dex\n        dex\n        dex\n        dex\n        dex\n        nop             ;offset landing zone - forward branch too far\n        nop\n        nop\n        nop\n        nop\n        beq range_ok    ;+127 - max forward\n        trap            ; bad range\n        nop             ;offset landing zone - tolerate +/-5 offset to branch\n        nop\n        nop\n        nop\n        nop\nrange_ok\n        nop\n        nop\n        nop\n        nop\n        nop\n        cpy #0\n        beq range_end   \n        jmp range_loop\nrange_end               ;range test successful\n    endif\n        next_test\n\n;partial test BNE & CMP, CPX, CPY immediate\n        cpy #1          ;testing BNE true\n        bne test_bne\n        trap \ntest_bne\n        lda #0 \n        cmp #0          ;test compare immediate \n        trap_ne\n        trap_cc\n        trap_mi\n        cmp #1\n        trap_eq \n        trap_cs\n        trap_pl\n        tax \n        cpx #0          ;test compare x immediate\n        trap_ne\n        trap_cc\n        trap_mi\n        cpx #1\n        trap_eq \n        trap_cs\n        trap_pl\n        tay \n        cpy #0          ;test compare y immediate\n        trap_ne\n        trap_cc\n        trap_mi\n        cpy #1\n        trap_eq \n        trap_cs\n        trap_pl\n        next_test\n;testing stack operations PHA PHP PLA PLP\n            \n        ldx #$ff        ;initialize stack\n        txs\n        lda #$55\n        pha\n        lda #$aa\n        pha\n        cmp $1fe        ;on stack ?\n        trap_ne\n        tsx\n        txa             ;overwrite accu\n        cmp #$fd        ;sp decremented?\n        trap_ne\n        pla\n        cmp #$aa        ;successful retreived from stack?\n        trap_ne\n        pla\n        cmp #$55\n        trap_ne\n        cmp $1ff        ;remains on stack?\n        trap_ne\n        tsx\n        cpx #$ff        ;sp incremented?\n        trap_ne\n        next_test\n\n;testing branch decisions BPL BMI BVC BVS BCC BCS BNE BEQ\n        set_stat $ff    ;all on\n        bpl nbr1        ;branches should not be taken\n        bvc nbr2\n        bcc nbr3\n        bne nbr4\n        bmi br1         ;branches should be taken\n        trap \nbr1     bvs br2\n        trap \nbr2     bcs br3\n        trap \nbr3     beq br4\n        trap \nnbr1\n        trap            ;previous bpl taken \nnbr2\n        trap            ;previous bvc taken\nnbr3\n        trap            ;previous bcc taken\nnbr4\n        trap            ;previous bne taken\nbr4     php\n        tsx\n        cpx #$fe        ;sp after php?\n        trap_ne\n        pla\n        cmp_flag $ff    ;returned all flags on?\n        trap_ne\n        tsx\n        cpx #$ff        ;sp after php?\n        trap_ne\n        set_stat 0      ;all off\n        bmi nbr11       ;branches should not be taken\n        bvs nbr12\n        bcs nbr13\n        beq nbr14\n        bpl br11        ;branches should be taken\n        trap \nbr11    bvc br12\n        trap \nbr12    bcc br13\n        trap \nbr13    bne br14\n        trap \nnbr11\n        trap            ;previous bmi taken \nnbr12\n        trap            ;previous bvs taken \nnbr13\n        trap            ;previous bcs taken \nnbr14\n        trap            ;previous beq taken \nbr14    php\n        pla\n        cmp_flag 0      ;flags off except break (pushed by sw) + reserved?\n        trap_ne\n        ;crosscheck flags\n        set_stat zero\n        bne brzs1\n        beq brzs2\nbrzs1\n        trap            ;branch zero/non zero\nbrzs2   bcs brzs3\n        bcc brzs4\nbrzs3\n        trap            ;branch carry/no carry\nbrzs4   bmi brzs5\n        bpl brzs6\nbrzs5\n        trap            ;branch minus/plus\nbrzs6   bvs brzs7\n        bvc brzs8\nbrzs7\n        trap            ;branch overflow/no overflow\nbrzs8\n        set_stat carry\n        beq brcs1\n        bne brcs2\nbrcs1\n        trap            ;branch zero/non zero\nbrcs2   bcc brcs3\n        bcs brcs4\nbrcs3\n        trap            ;branch carry/no carry\nbrcs4   bmi brcs5\n        bpl brcs6\nbrcs5\n        trap            ;branch minus/plus\nbrcs6   bvs brcs7\n        bvc brcs8\nbrcs7\n        trap            ;branch overflow/no overflow\n\nbrcs8\n        set_stat minus\n        beq brmi1\n        bne brmi2\nbrmi1\n        trap            ;branch zero/non zero\nbrmi2   bcs brmi3\n        bcc brmi4\nbrmi3\n        trap            ;branch carry/no carry\nbrmi4   bpl brmi5\n        bmi brmi6\nbrmi5\n        trap            ;branch minus/plus\nbrmi6   bvs brmi7\n        bvc brmi8\nbrmi7\n        trap            ;branch overflow/no overflow\nbrmi8\n        set_stat overfl\n        beq brvs1\n        bne brvs2\nbrvs1\n        trap            ;branch zero/non zero\nbrvs2   bcs brvs3\n        bcc brvs4\nbrvs3\n        trap            ;branch carry/no carry\nbrvs4   bmi brvs5\n        bpl brvs6\nbrvs5\n        trap            ;branch minus/plus\nbrvs6   bvc brvs7\n        bvs brvs8\nbrvs7\n        trap            ;branch overflow/no overflow\nbrvs8\n        set_stat $ff-zero\n        beq brzc1\n        bne brzc2\nbrzc1\n        trap            ;branch zero/non zero\nbrzc2   bcc brzc3\n        bcs brzc4\nbrzc3\n        trap            ;branch carry/no carry\nbrzc4   bpl brzc5\n        bmi brzc6\nbrzc5\n        trap            ;branch minus/plus\nbrzc6   bvc brzc7\n        bvs brzc8\nbrzc7\n        trap            ;branch overflow/no overflow\nbrzc8\n        set_stat $ff-carry\n        bne brcc1\n        beq brcc2\nbrcc1\n        trap            ;branch zero/non zero\nbrcc2   bcs brcc3\n        bcc brcc4\nbrcc3\n        trap            ;branch carry/no carry\nbrcc4   bpl brcc5\n        bmi brcc6\nbrcc5\n        trap            ;branch minus/plus\nbrcc6   bvc brcc7\n        bvs brcc8\nbrcc7\n        trap            ;branch overflow/no overflow\nbrcc8\n        set_stat $ff-minus\n        bne brpl1\n        beq brpl2\nbrpl1\n        trap            ;branch zero/non zero\nbrpl2   bcc brpl3\n        bcs brpl4\nbrpl3\n        trap            ;branch carry/no carry\nbrpl4   bmi brpl5\n        bpl brpl6\nbrpl5\n        trap            ;branch minus/plus\nbrpl6   bvc brpl7\n        bvs brpl8\nbrpl7\n        trap            ;branch overflow/no overflow\nbrpl8\n        set_stat $ff-overfl\n        bne brvc1\n        beq brvc2\nbrvc1\n        trap            ;branch zero/non zero\nbrvc2   bcc brvc3\n        bcs brvc4\nbrvc3\n        trap            ;branch carry/no carry\nbrvc4   bpl brvc5\n        bmi brvc6\nbrvc5\n        trap            ;branch minus/plus\nbrvc6   bvs brvc7\n        bvc brvc8\nbrvc7\n        trap            ;branch overflow/no overflow\nbrvc8\n        next_test\n\n; test PHA does not alter flags or accumulator but PLA does\n        ldx #$55        ;x & y protected\n        ldy #$aa\n        set_a 1,$ff     ;push\n        pha\n        tst_a 1,$ff\n        set_a 0,0\n        pha\n        tst_a 0,0\n        set_a $ff,$ff\n        pha\n        tst_a $ff,$ff\n        set_a 1,0\n        pha\n        tst_a 1,0\n        set_a 0,$ff\n        pha\n        tst_a 0,$ff\n        set_a $ff,0\n        pha\n        tst_a $ff,0\n        set_a 0,$ff     ;pull\n        pla\n        tst_a $ff,$ff-zero\n        set_a $ff,0\n        pla\n        tst_a 0,zero\n        set_a $fe,$ff\n        pla\n        tst_a 1,$ff-zero-minus\n        set_a 0,0\n        pla\n        tst_a $ff,minus\n        set_a $ff,$ff\n        pla\n        tst_a 0,$ff-minus\n        set_a $fe,0\n        pla\n        tst_a 1,0\n        cpx #$55        ;x & y unchanged?\n        trap_ne\n        cpy #$aa\n        trap_ne\n        next_test\n \n; partial pretest EOR #\n        set_a $3c,0\n        eor #$c3\n        tst_a $ff,fn\n        set_a $c3,0\n        eor #$c3\n        tst_a 0,fz\n        next_test\n\n; PC modifying instructions except branches (NOP, JMP, JSR, RTS, BRK, RTI)\n; testing NOP\n        ldx #$24\n        ldy #$42\n        set_a $18,0\n        nop\n        tst_a $18,0\n        cpx #$24\n        trap_ne\n        cpy #$42\n        trap_ne\n        ldx #$db\n        ldy #$bd\n        set_a $e7,$ff\n        nop\n        tst_a $e7,$ff\n        cpx #$db\n        trap_ne\n        cpy #$bd\n        trap_ne\n        next_test\n        \n; jump absolute\n        set_stat $0\n        lda #'F'\n        ldx #'A'\n        ldy #'R'        ;N=0, V=0, Z=0, C=0\n        jmp test_far\n        nop\n        nop\n        trap_ne         ;runover protection\n        inx\n        inx\nfar_ret \n        trap_eq         ;returned flags OK?\n        trap_pl\n        trap_cc\n        trap_vc\n        cmp #('F'^$aa)  ;returned registers OK?\n        trap_ne\n        cpx #('A'+1)\n        trap_ne\n        cpy #('R'-3)\n        trap_ne\n        dex\n        iny\n        iny\n        iny\n        eor #$aa        ;N=0, V=1, Z=0, C=1\n        jmp test_near\n        nop\n        nop\n        trap_ne         ;runover protection\n        inx\n        inx\ntest_near\n        trap_eq         ;passed flags OK?\n        trap_mi\n        trap_cc\n        trap_vc\n        cmp #'F'        ;passed registers OK?\n        trap_ne\n        cpx #'A'\n        trap_ne\n        cpy #'R'\n        trap_ne\n        next_test\n        \n; jump indirect\n        set_stat 0\n        lda #'I'\n        ldx #'N'\n        ldy #'D'        ;N=0, V=0, Z=0, C=0\n        jmp (ptr_tst_ind)\n        nop\n        trap_ne         ;runover protection\n        dey\n        dey\nind_ret \n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        plp\n        trap_eq         ;returned flags OK?\n        trap_pl\n        trap_cc\n        trap_vc\n        cmp #('I'^$aa)  ;returned registers OK?\n        trap_ne\n        cpx #('N'+1)\n        trap_ne\n        cpy #('D'-6)\n        trap_ne\n        tsx             ;SP check\n        cpx #$ff\n        trap_ne\n        next_test\n\n; jump subroutine & return from subroutine\n        set_stat 0\n        lda #'J'\n        ldx #'S'\n        ldy #'R'        ;N=0, V=0, Z=0, C=0\n        jsr test_jsr\njsr_ret = *-1           ;last address of jsr = return address\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        plp\n        trap_eq         ;returned flags OK?\n        trap_pl\n        trap_cc\n        trap_vc\n        cmp #('J'^$aa)  ;returned registers OK?\n        trap_ne\n        cpx #('S'+1)\n        trap_ne\n        cpy #('R'-6)\n        trap_ne\n        tsx             ;sp?\n        cpx #$ff\n        trap_ne\n        next_test\n\n; break & return from interrupt\n    if ROM_vectors = 1\n        set_stat 0\n        lda #'B'\n        ldx #'R'\n        ldy #'K'        ;N=0, V=0, Z=0, C=0\n        brk\n    else\n        lda #hi brk_ret ;emulated break\n        pha\n        lda #lo brk_ret\n        pha\n        lda #fao        ;set break & unused on stack\n        pha\n        set_stat intdis\n        lda #'B'\n        ldx #'R'\n        ldy #'K'        ;N=0, V=0, Z=0, C=0\n        jmp irq_trap\n    endif\n        dey             ;should not be executed\nbrk_ret                 ;address of break return\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        cmp #('B'^$aa)  ;returned registers OK?\n        trap_ne\n        cpx #('R'+1)\n        trap_ne\n        cpy #('K'-6)\n        trap_ne\n        pla             ;returned flags OK (unchanged)?\n        cmp_flag 0\n        trap_ne\n        tsx             ;sp?\n        cpx #$ff\n        trap_ne\n        next_test\n \n; test set and clear flags CLC CLI CLD CLV SEC SEI SED\n        set_stat $ff\n        clc\n        tst_stat $ff-carry\n        sec\n        tst_stat $ff\n    if I_flag = 3\n        cli\n        tst_stat $ff-intdis\n        sei\n        tst_stat $ff\n    endif\n        cld\n        tst_stat $ff-decmode\n        sed\n        tst_stat $ff\n        clv\n        tst_stat $ff-overfl\n        set_stat 0\n        tst_stat 0\n        sec\n        tst_stat carry\n        clc\n        tst_stat 0  \n    if I_flag = 3\n        sei\n        tst_stat intdis\n        cli\n        tst_stat 0\n    endif  \n        sed\n        tst_stat decmode\n        cld\n        tst_stat 0  \n        set_stat overfl\n        tst_stat overfl\n        clv\n        tst_stat 0\n        next_test\n; testing index register increment/decrement and transfer\n; INX INY DEX DEY TAX TXA TAY TYA \n        ldx #$fe\n        set_stat $ff\n        inx             ;ff\n        tst_x $ff,$ff-zero\n        inx             ;00\n        tst_x 0,$ff-minus\n        inx             ;01\n        tst_x 1,$ff-minus-zero\n        dex             ;00\n        tst_x 0,$ff-minus\n        dex             ;ff\n        tst_x $ff,$ff-zero\n        dex             ;fe\n        set_stat 0\n        inx             ;ff\n        tst_x $ff,minus\n        inx             ;00\n        tst_x 0,zero\n        inx             ;01\n        tst_x 1,0\n        dex             ;00\n        tst_x 0,zero\n        dex             ;ff\n        tst_x $ff,minus\n\n        ldy #$fe\n        set_stat $ff\n        iny             ;ff\n        tst_y $ff,$ff-zero\n        iny             ;00\n        tst_y 0,$ff-minus\n        iny             ;01\n        tst_y 1,$ff-minus-zero\n        dey             ;00\n        tst_y 0,$ff-minus\n        dey             ;ff\n        tst_y $ff,$ff-zero\n        dey             ;fe\n        set_stat 0\n        iny             ;ff\n        tst_y $ff,0+minus\n        iny             ;00\n        tst_y 0,zero\n        iny             ;01\n        tst_y 1,0\n        dey             ;00\n        tst_y 0,zero\n        dey             ;ff\n        tst_y $ff,minus\n                \n        ldx #$ff\n        set_stat $ff\n        txa\n        tst_a $ff,$ff-zero\n        php\n        inx             ;00\n        plp\n        txa\n        tst_a 0,$ff-minus\n        php\n        inx             ;01\n        plp\n        txa\n        tst_a 1,$ff-minus-zero\n        set_stat 0\n        txa\n        tst_a 1,0\n        php\n        dex             ;00\n        plp\n        txa\n        tst_a 0,zero\n        php\n        dex             ;ff\n        plp\n        txa\n        tst_a $ff,minus\n                        \n        ldy #$ff\n        set_stat $ff\n        tya\n        tst_a $ff,$ff-zero\n        php\n        iny             ;00\n        plp\n        tya\n        tst_a 0,$ff-minus\n        php\n        iny             ;01\n        plp\n        tya\n        tst_a 1,$ff-minus-zero\n        set_stat 0\n        tya\n        tst_a 1,0\n        php\n        dey             ;00\n        plp\n        tya\n        tst_a 0,zero\n        php\n        dey             ;ff\n        plp\n        tya\n        tst_a $ff,minus\n\n        load_flag $ff\n        pha\n        ldx #$ff        ;ff\n        txa\n        plp             \n        tay\n        tst_y $ff,$ff-zero\n        php\n        inx             ;00\n        txa\n        plp\n        tay\n        tst_y 0,$ff-minus\n        php\n        inx             ;01\n        txa\n        plp\n        tay\n        tst_y 1,$ff-minus-zero\n        load_flag 0\n        pha\n        lda #0\n        txa\n        plp\n        tay\n        tst_y 1,0\n        php\n        dex             ;00\n        txa\n        plp\n        tay\n        tst_y 0,zero\n        php\n        dex             ;ff\n        txa\n        plp\n        tay\n        tst_y $ff,minus\n\n\n        load_flag $ff\n        pha\n        ldy #$ff        ;ff\n        tya\n        plp\n        tax\n        tst_x $ff,$ff-zero\n        php\n        iny             ;00\n        tya\n        plp\n        tax\n        tst_x 0,$ff-minus\n        php\n        iny             ;01\n        tya\n        plp\n        tax\n        tst_x 1,$ff-minus-zero\n        load_flag 0\n        pha\n        lda #0          ;preset status\n        tya\n        plp\n        tax\n        tst_x 1,0\n        php\n        dey             ;00\n        tya\n        plp\n        tax\n        tst_x 0,zero\n        php\n        dey             ;ff\n        tya\n        plp\n        tax\n        tst_x $ff,minus\n        next_test\n     \n;TSX sets NZ - TXS does not\n;  This section also tests for proper stack wrap around.\n        ldx #1          ;01\n        set_stat $ff\n        txs\n        php\n        lda $101\n        cmp_flag $ff\n        trap_ne\n        set_stat 0\n        txs\n        php\n        lda $101\n        cmp_flag 0\n        trap_ne\n        dex             ;00\n        set_stat $ff\n        txs\n        php\n        lda $100\n        cmp_flag $ff\n        trap_ne\n        set_stat 0\n        txs\n        php\n        lda $100\n        cmp_flag 0\n        trap_ne\n        dex             ;ff\n        set_stat $ff\n        txs\n        php\n        lda $1ff\n        cmp_flag $ff\n        trap_ne\n        set_stat 0\n        txs\n        php\n        lda $1ff\n        cmp_flag 0\n        \n        ldx #1\n        txs             ;sp=01\n        set_stat $ff\n        tsx             ;clears Z, N\n        php             ;sp=00\n        cpx #1\n        trap_ne\n        lda $101\n        cmp_flag $ff-minus-zero\n        trap_ne\n        set_stat $ff\n        tsx             ;clears N, sets Z\n        php             ;sp=ff\n        cpx #0\n        trap_ne\n        lda $100\n        cmp_flag $ff-minus\n        trap_ne\n        set_stat $ff\n        tsx             ;clears N, sets Z\n        php             ;sp=fe\n        cpx #$ff\n        trap_ne\n        lda $1ff\n        cmp_flag $ff-zero\n        trap_ne\n        \n        ldx #1\n        txs             ;sp=01\n        set_stat 0\n        tsx             ;clears Z, N\n        php             ;sp=00\n        cpx #1\n        trap_ne\n        lda $101\n        cmp_flag 0\n        trap_ne\n        set_stat 0\n        tsx             ;clears N, sets Z\n        php             ;sp=ff\n        cpx #0\n        trap_ne\n        lda $100\n        cmp_flag zero\n        trap_ne\n        set_stat 0\n        tsx             ;clears N, sets Z\n        php             ;sp=fe\n        cpx #$ff\n        trap_ne\n        lda $1ff\n        cmp_flag minus\n        trap_ne\n        pla             ;sp=ff\n        next_test\n        \n; testing index register load & store LDY LDX STY STX all addressing modes\n; LDX / STX - zp,y / abs,y\n        ldy #3\ntldx    \n        set_stat 0\n        ldx zp1,y\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        plp\n        sta abst,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tldx                  \n\n        ldy #3\ntldx1   \n        set_stat $ff\n        ldx zp1,y\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        plp\n        sta abst,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tldx1                  \n\n        ldy #3\ntldx2   \n        set_stat 0\n        ldx abs1,y\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,y   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tldx2                  \n\n        ldy #3\ntldx3   \n        set_stat $ff\n        ldx abs1,y\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,y   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tldx3\n        \n        ldy #3      ;testing store result\n        ldx #0\ntstx    lda zpt,y\n        eor #$c3\n        cmp zp1,y\n        trap_ne     ;store to zp data\n        stx zpt,y   ;clear                \n        lda abst,y\n        eor #$c3\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstx\n        next_test\n        \n; indexed wraparound test (only zp should wrap)\n        ldy #3+$fa\ntldx4   ldx zp1-$fa&$ff,y   ;wrap on indexed zp\n        txa\n        sta abst-$fa,y      ;no STX abs,y!\n        dey\n        cpy #$fa\n        bcs tldx4                  \n        ldy #3+$fa\ntldx5   ldx abs1-$fa,y      ;no wrap on indexed abs\n        stx zpt-$fa&$ff,y\n        dey\n        cpy #$fa\n        bcs tldx5                  \n        ldy #3      ;testing wraparound result\n        ldx #0\ntstx1   lda zpt,y\n        cmp zp1,y\n        trap_ne     ;store to zp data\n        stx zpt,y   ;clear                \n        lda abst,y\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstx1\n        next_test\n        \n; LDY / STY - zp,x / abs,x\n        ldx #3\ntldy    \n        set_stat 0\n        ldy zp1,x\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        plp\n        sta abst,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,x  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldy                  \n\n        ldx #3\ntldy1   \n        set_stat $ff\n        ldy zp1,x\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        plp\n        sta abst,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,x  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldy1                  \n\n        ldx #3\ntldy2   \n        set_stat 0\n        ldy abs1,x\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,x   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldy2                  \n\n        ldx #3\ntldy3\n        set_stat $ff\n        ldy abs1,x\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,x   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldy3\n\n        ldx #3      ;testing store result\n        ldy #0\ntsty    lda zpt,x\n        eor #$c3\n        cmp zp1,x\n        trap_ne     ;store to zp,x data\n        sty zpt,x   ;clear                \n        lda abst,x\n        eor #$c3\n        cmp abs1,x\n        trap_ne     ;store to abs,x data\n        txa\n        sta abst,x  ;clear                \n        dex\n        bpl tsty\n        next_test\n\n; indexed wraparound test (only zp should wrap)\n        ldx #3+$fa\ntldy4   ldy zp1-$fa&$ff,x   ;wrap on indexed zp\n        tya\n        sta abst-$fa,x      ;no STX abs,x!\n        dex\n        cpx #$fa\n        bcs tldy4                  \n        ldx #3+$fa\ntldy5   ldy abs1-$fa,x      ;no wrap on indexed abs\n        sty zpt-$fa&$ff,x\n        dex\n        cpx #$fa\n        bcs tldy5                  \n        ldx #3      ;testing wraparound result\n        ldy #0\ntsty1   lda zpt,x\n        cmp zp1,x\n        trap_ne     ;store to zp,x data\n        sty zpt,x   ;clear                \n        lda abst,x\n        cmp abs1,x\n        trap_ne     ;store to abs,x data\n        txa\n        sta abst,x  ;clear                \n        dex\n        bpl tsty1\n        next_test\n\n; LDX / STX - zp / abs / #\n        set_stat 0  \n        ldx zp1\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$c3    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldx zp1+1\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$82    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldx zp1+2\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$41    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldx zp1+3\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldx zp1  \n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$c3    ;test result\n        trap_ne     ;\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldx zp1+1\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$82    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx zp1+2\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #$41    ;test result\n        trap_ne     ;\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx zp1+3\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat 0\n        ldx abs1  \n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldx abs1+1\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldx abs1+2\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldx abs1+3\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldx abs1  \n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldx abs1+1\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx abs1+2\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx abs1+3\n        php         ;test stores do not alter flags\n        txa\n        eor #$c3\n        tax\n        plp\n        stx zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tax\n        cpx zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat 0  \n        ldx #$c3\n        php\n        cpx abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldx #$82\n        php\n        cpx abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldx #$41\n        php\n        cpx abs1+2  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldx #0\n        php\n        cpx abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldx #$c3  \n        php\n        cpx abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldx #$82\n        php\n        cpx abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx #$41\n        php\n        cpx abs1+2  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldx #0\n        php\n        cpx abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        ldx #0\n        lda zpt  \n        eor #$c3\n        cmp zp1  \n        trap_ne     ;store to zp data\n        stx zpt     ;clear                \n        lda abst  \n        eor #$c3\n        cmp abs1  \n        trap_ne     ;store to abs data\n        stx abst    ;clear                \n        lda zpt+1\n        eor #$c3\n        cmp zp1+1\n        trap_ne     ;store to zp data\n        stx zpt+1   ;clear                \n        lda abst+1\n        eor #$c3\n        cmp abs1+1\n        trap_ne     ;store to abs data\n        stx abst+1  ;clear                \n        lda zpt+2\n        eor #$c3\n        cmp zp1+2\n        trap_ne     ;store to zp data\n        stx zpt+2   ;clear                \n        lda abst+2\n        eor #$c3\n        cmp abs1+2\n        trap_ne     ;store to abs data\n        stx abst+2  ;clear                \n        lda zpt+3\n        eor #$c3\n        cmp zp1+3\n        trap_ne     ;store to zp data\n        stx zpt+3   ;clear                \n        lda abst+3\n        eor #$c3\n        cmp abs1+3\n        trap_ne     ;store to abs data\n        stx abst+3  ;clear                \n        next_test\n\n; LDY / STY - zp / abs / #\n        set_stat 0\n        ldy zp1  \n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$c3    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldy zp1+1\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$82    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldy zp1+2\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$41    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldy zp1+3\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldy zp1  \n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$c3    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldy zp1+1\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$82   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy zp1+2\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #$41    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy zp1+3\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n        \n        set_stat 0\n        ldy abs1  \n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldy abs1+1\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldy abs1+2\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldy abs1+3\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cpy zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldy abs1  \n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cmp zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldy abs1+1\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cmp zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy abs1+2\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cmp zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy abs1+3\n        php         ;test stores do not alter flags\n        tya\n        eor #$c3\n        tay\n        plp\n        sty zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        tay\n        cmp zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n\n        set_stat 0\n        ldy #$c3  \n        php\n        cpy abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        ldy #$82\n        php\n        cpy abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        ldy #$41\n        php\n        cpy abs1+2  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        ldy #0\n        php\n        cpy abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        ldy #$c3  \n        php\n        cpy abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        ldy #$82\n        php\n        cpy abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy #$41\n        php\n        cpy abs1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        ldy #0\n        php\n        cpy abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n        \n        ldy #0\n        lda zpt  \n        eor #$c3\n        cmp zp1  \n        trap_ne     ;store to zp   data\n        sty zpt     ;clear                \n        lda abst  \n        eor #$c3\n        cmp abs1  \n        trap_ne     ;store to abs   data\n        sty abst    ;clear                \n        lda zpt+1\n        eor #$c3\n        cmp zp1+1\n        trap_ne     ;store to zp+1 data\n        sty zpt+1   ;clear                \n        lda abst+1\n        eor #$c3\n        cmp abs1+1\n        trap_ne     ;store to abs+1 data\n        sty abst+1  ;clear                \n        lda zpt+2\n        eor #$c3\n        cmp zp1+2\n        trap_ne     ;store to zp+2 data\n        sty zpt+2   ;clear                \n        lda abst+2\n        eor #$c3\n        cmp abs1+2\n        trap_ne     ;store to abs+2 data\n        sty abst+2  ;clear                \n        lda zpt+3\n        eor #$c3\n        cmp zp1+3\n        trap_ne     ;store to zp+3 data\n        sty zpt+3   ;clear                \n        lda abst+3\n        eor #$c3\n        cmp abs1+3\n        trap_ne     ;store to abs+3 data\n        sty abst+3  ;clear                \n        next_test\n\n; testing load / store accumulator LDA / STA all addressing modes\n; LDA / STA - zp,x / abs,x\n        ldx #3\ntldax    \n        set_stat 0\n        lda zp1,x\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,x  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldax                  \n\n        ldx #3\ntldax1   \n        set_stat $ff\n        lda zp1,x\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,x   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldax1                  \n\n        ldx #3\ntldax2   \n        set_stat 0\n        lda abs1,x\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,x   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldax2                  \n\n        ldx #3\ntldax3\n        set_stat $ff\n        lda abs1,x\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt,x\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1,x   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,x  ;test flags\n        trap_ne\n        dex\n        bpl tldax3\n\n        ldx #3      ;testing store result\n        ldy #0\ntstax   lda zpt,x\n        eor #$c3\n        cmp zp1,x\n        trap_ne     ;store to zp,x data\n        sty zpt,x   ;clear                \n        lda abst,x\n        eor #$c3\n        cmp abs1,x\n        trap_ne     ;store to abs,x data\n        txa\n        sta abst,x  ;clear                \n        dex\n        bpl tstax\n        next_test\n\n; LDA / STA - (zp),y / abs,y / (zp,x)\n        ldy #3\ntlday    \n        set_stat 0\n        lda (ind1),y\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tlday                  \n\n        ldy #3\ntlday1   \n        set_stat $ff\n        lda (ind1),y\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst,y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tlday1                  \n\n        ldy #3      ;testing store result\n        ldx #0\ntstay   lda abst,y\n        eor #$c3\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay\n\n        ldy #3\ntlday2   \n        set_stat 0\n        lda abs1,y\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta (indt),y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp (ind1),y    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tlday2                  \n\n        ldy #3\ntlday3   \n        set_stat $ff\n        lda abs1,y\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta (indt),y\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp (ind1),y   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dey\n        bpl tlday3\n        \n        ldy #3      ;testing store result\n        ldx #0\ntstay1  lda abst,y\n        eor #$c3\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay1\n        \n        ldx #6\n        ldy #3\ntldax4   \n        set_stat 0\n        lda (ind1,x)\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta (indt,x)\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dex\n        dex\n        dey\n        bpl tldax4                  \n\n        ldx #6\n        ldy #3\ntldax5\n        set_stat $ff\n        lda (ind1,x)\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta (indt,x)\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp abs1,y  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx,y  ;test flags\n        trap_ne\n        dex\n        dex\n        dey\n        bpl tldax5\n\n        ldy #3      ;testing store result\n        ldx #0\ntstay2  lda abst,y\n        eor #$c3\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay2\n        next_test\n\n; indexed wraparound test (only zp should wrap)\n        ldx #3+$fa\ntldax6  lda zp1-$fa&$ff,x   ;wrap on indexed zp\n        sta abst-$fa,x      ;no STX abs,x!\n        dex\n        cpx #$fa\n        bcs tldax6                  \n        ldx #3+$fa\ntldax7  lda abs1-$fa,x      ;no wrap on indexed abs\n        sta zpt-$fa&$ff,x\n        dex\n        cpx #$fa\n        bcs tldax7\n                          \n        ldx #3      ;testing wraparound result\n        ldy #0\ntstax1  lda zpt,x\n        cmp zp1,x\n        trap_ne     ;store to zp,x data\n        sty zpt,x   ;clear                \n        lda abst,x\n        cmp abs1,x\n        trap_ne     ;store to abs,x data\n        txa\n        sta abst,x  ;clear                \n        dex\n        bpl tstax1\n\n        ldy #3+$f8\n        ldx #6+$f8\ntlday4  lda (ind1-$f8&$ff,x) ;wrap on indexed zp indirect\n        sta abst-$f8,y\n        dex\n        dex\n        dey\n        cpy #$f8\n        bcs tlday4\n        ldy #3      ;testing wraparound result\n        ldx #0\ntstay4  lda abst,y\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay4\n        \n        ldy #3+$f8\ntlday5  lda abs1-$f8,y  ;no wrap on indexed abs\n        sta (inwt),y\n        dey\n        cpy #$f8\n        bcs tlday5                  \n        ldy #3      ;testing wraparound result\n        ldx #0\ntstay5  lda abst,y\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay5\n\n        ldy #3+$f8\n        ldx #6+$f8\ntlday6  lda (inw1),y    ;no wrap on zp indirect indexed \n        sta (indt-$f8&$ff,x)\n        dex\n        dex\n        dey\n        cpy #$f8\n        bcs tlday6\n        ldy #3      ;testing wraparound result\n        ldx #0\ntstay6  lda abst,y\n        cmp abs1,y\n        trap_ne     ;store to abs data\n        txa\n        sta abst,y  ;clear                \n        dey\n        bpl tstay6\n        next_test\n\n; LDA / STA - zp / abs / #\n        set_stat 0  \n        lda zp1\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$c3    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        lda zp1+1\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$82    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        lda zp1+2\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$41    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        lda zp1+3\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n        set_stat $ff\n        lda zp1  \n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst  \n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$c3    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        lda zp1+1\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$82    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        lda zp1+2\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #$41    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        lda zp1+3\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta abst+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp #0      ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n        set_stat 0\n        lda abs1  \n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        lda abs1+1\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        lda abs1+2\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        lda abs1+3\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n        set_stat $ff\n        lda abs1  \n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt  \n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1     ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        lda abs1+1\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+1\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+1   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        lda abs1+2\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+2\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+2   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        lda abs1+3\n        php         ;test stores do not alter flags\n        eor #$c3\n        plp\n        sta zpt+3\n        php         ;flags after load/store sequence\n        eor #$c3\n        cmp zp1+3   ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n        set_stat 0  \n        lda #$c3\n        php\n        cmp abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat 0\n        lda #$82\n        php\n        cmp abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat 0\n        lda #$41\n        php\n        cmp abs1+2  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat 0\n        lda #0\n        php\n        cmp abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag 0\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        set_stat $ff\n        lda #$c3  \n        php\n        cmp abs1    ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx    ;test flags\n        trap_ne\n        set_stat $ff\n        lda #$82\n        php\n        cmp abs1+1  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+1  ;test flags\n        trap_ne\n        set_stat $ff\n        lda #$41\n        php\n        cmp abs1+2  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+2  ;test flags\n        trap_ne\n        set_stat $ff\n        lda #0\n        php\n        cmp abs1+3  ;test result\n        trap_ne\n        pla         ;load status\n        eor_flag lo~fnz ;mask bits not altered\n        cmp fLDx+3  ;test flags\n        trap_ne\n\n        ldx #0\n        lda zpt  \n        eor #$c3\n        cmp zp1  \n        trap_ne     ;store to zp data\n        stx zpt     ;clear                \n        lda abst  \n        eor #$c3\n        cmp abs1  \n        trap_ne     ;store to abs data\n        stx abst    ;clear                \n        lda zpt+1\n        eor #$c3\n        cmp zp1+1\n        trap_ne     ;store to zp data\n        stx zpt+1   ;clear                \n        lda abst+1\n        eor #$c3\n        cmp abs1+1\n        trap_ne     ;store to abs data\n        stx abst+1  ;clear                \n        lda zpt+2\n        eor #$c3\n        cmp zp1+2\n        trap_ne     ;store to zp data\n        stx zpt+2   ;clear                \n        lda abst+2\n        eor #$c3\n        cmp abs1+2\n        trap_ne     ;store to abs data\n        stx abst+2  ;clear                \n        lda zpt+3\n        eor #$c3\n        cmp zp1+3\n        trap_ne     ;store to zp data\n        stx zpt+3   ;clear                \n        lda abst+3\n        eor #$c3\n        cmp abs1+3\n        trap_ne     ;store to abs data\n        stx abst+3  ;clear                \n        next_test\n\n; testing bit test & compares BIT CPX CPY CMP all addressing modes\n; BIT - zp / abs\n        set_a $ff,0\n        bit zp1+3   ;00 - should set Z / clear  NV\n        tst_a $ff,fz \n        set_a 1,0\n        bit zp1+2   ;41 - should set V (M6) / clear NZ\n        tst_a 1,fv\n        set_a 1,0\n        bit zp1+1   ;82 - should set N (M7) & Z / clear V\n        tst_a 1,fnz\n        set_a 1,0\n        bit zp1     ;c3 - should set N (M7) & V (M6) / clear Z\n        tst_a 1,fnv\n        \n        set_a $ff,$ff\n        bit zp1+3   ;00 - should set Z / clear  NV\n        tst_a $ff,~fnv \n        set_a 1,$ff\n        bit zp1+2   ;41 - should set V (M6) / clear NZ\n        tst_a 1,~fnz\n        set_a 1,$ff\n        bit zp1+1   ;82 - should set N (M7) & Z / clear V\n        tst_a 1,~fv\n        set_a 1,$ff\n        bit zp1     ;c3 - should set N (M7) & V (M6) / clear Z\n        tst_a 1,~fz\n        \n        set_a $ff,0\n        bit abs1+3  ;00 - should set Z / clear  NV\n        tst_a $ff,fz \n        set_a 1,0\n        bit abs1+2  ;41 - should set V (M6) / clear NZ\n        tst_a 1,fv\n        set_a 1,0\n        bit abs1+1  ;82 - should set N (M7) & Z / clear V\n        tst_a 1,fnz\n        set_a 1,0\n        bit abs1    ;c3 - should set N (M7) & V (M6) / clear Z\n        tst_a 1,fnv\n        \n        set_a $ff,$ff\n        bit abs1+3  ;00 - should set Z / clear  NV\n        tst_a $ff,~fnv \n        set_a 1,$ff\n        bit abs1+2  ;41 - should set V (M6) / clear NZ\n        tst_a 1,~fnz\n        set_a 1,$ff\n        bit abs1+1  ;82 - should set N (M7) & Z / clear V\n        tst_a 1,~fv\n        set_a 1,$ff\n        bit abs1    ;c3 - should set N (M7) & V (M6) / clear Z\n        tst_a 1,~fz\n        next_test\n        \n; CPX - zp / abs / #         \n        set_x $80,0\n        cpx zp7f\n        tst_stat fc\n        dex\n        cpx zp7f\n        tst_stat fzc\n        dex\n        cpx zp7f\n        tst_x $7e,fn\n        set_x $80,$ff\n        cpx zp7f\n        tst_stat ~fnz\n        dex\n        cpx zp7f\n        tst_stat ~fn\n        dex\n        cpx zp7f\n        tst_x $7e,~fzc\n\n        set_x $80,0\n        cpx abs7f\n        tst_stat fc\n        dex\n        cpx abs7f\n        tst_stat fzc\n        dex\n        cpx abs7f\n        tst_x $7e,fn\n        set_x $80,$ff\n        cpx abs7f\n        tst_stat ~fnz\n        dex\n        cpx abs7f\n        tst_stat ~fn\n        dex\n        cpx abs7f\n        tst_x $7e,~fzc\n\n        set_x $80,0\n        cpx #$7f\n        tst_stat fc\n        dex\n        cpx #$7f\n        tst_stat fzc\n        dex\n        cpx #$7f\n        tst_x $7e,fn\n        set_x $80,$ff\n        cpx #$7f\n        tst_stat ~fnz\n        dex\n        cpx #$7f\n        tst_stat ~fn\n        dex\n        cpx #$7f\n        tst_x $7e,~fzc\n        next_test\n\n; CPY - zp / abs / #         \n        set_y $80,0\n        cpy zp7f\n        tst_stat fc\n        dey\n        cpy zp7f\n        tst_stat fzc\n        dey\n        cpy zp7f\n        tst_y $7e,fn\n        set_y $80,$ff\n        cpy zp7f\n        tst_stat ~fnz\n        dey\n        cpy zp7f\n        tst_stat ~fn\n        dey\n        cpy zp7f\n        tst_y $7e,~fzc\n\n        set_y $80,0\n        cpy abs7f\n        tst_stat fc\n        dey\n        cpy abs7f\n        tst_stat fzc\n        dey\n        cpy abs7f\n        tst_y $7e,fn\n        set_y $80,$ff\n        cpy abs7f\n        tst_stat ~fnz\n        dey\n        cpy abs7f\n        tst_stat ~fn\n        dey\n        cpy abs7f\n        tst_y $7e,~fzc\n\n        set_y $80,0\n        cpy #$7f\n        tst_stat fc\n        dey\n        cpy #$7f\n        tst_stat fzc\n        dey\n        cpy #$7f\n        tst_y $7e,fn\n        set_y $80,$ff\n        cpy #$7f\n        tst_stat ~fnz\n        dey\n        cpy #$7f\n        tst_stat ~fn\n        dey\n        cpy #$7f\n        tst_y $7e,~fzc\n        next_test\n\n; CMP - zp / abs / #         \n        set_a $80,0\n        cmp zp7f\n        tst_a $80,fc\n        set_a $7f,0\n        cmp zp7f\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp zp7f\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp zp7f\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp zp7f\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp zp7f\n        tst_a $7e,~fzc\n\n        set_a $80,0\n        cmp abs7f\n        tst_a $80,fc\n        set_a $7f,0\n        cmp abs7f\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp abs7f\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp abs7f\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp abs7f\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp abs7f\n        tst_a $7e,~fzc\n\n        set_a $80,0\n        cmp #$7f\n        tst_a $80,fc\n        set_a $7f,0\n        cmp #$7f\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp #$7f\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp #$7f\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp #$7f\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp #$7f\n        tst_a $7e,~fzc\n\n        ldx #4          ;with indexing by X\n        set_a $80,0\n        cmp zp1,x\n        tst_a $80,fc\n        set_a $7f,0\n        cmp zp1,x\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp zp1,x\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp zp1,x\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp zp1,x\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp zp1,x\n        tst_a $7e,~fzc\n\n        set_a $80,0\n        cmp abs1,x\n        tst_a $80,fc\n        set_a $7f,0\n        cmp abs1,x\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp abs1,x\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp abs1,x\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp abs1,x\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp abs1,x\n        tst_a $7e,~fzc\n\n        ldy #4          ;with indexing by Y\n        ldx #8          ;with indexed indirect\n        set_a $80,0\n        cmp abs1,y\n        tst_a $80,fc\n        set_a $7f,0\n        cmp abs1,y\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp abs1,y\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp abs1,y\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp abs1,y\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp abs1,y\n        tst_a $7e,~fzc\n\n        set_a $80,0\n        cmp (ind1,x)\n        tst_a $80,fc\n        set_a $7f,0\n        cmp (ind1,x)\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp (ind1,x)\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp (ind1,x)\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp (ind1,x)\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp (ind1,x)\n        tst_a $7e,~fzc\n\n        set_a $80,0\n        cmp (ind1),y\n        tst_a $80,fc\n        set_a $7f,0\n        cmp (ind1),y\n        tst_a $7f,fzc\n        set_a $7e,0\n        cmp (ind1),y\n        tst_a $7e,fn\n        set_a $80,$ff\n        cmp (ind1),y\n        tst_a $80,~fnz\n        set_a $7f,$ff\n        cmp (ind1),y\n        tst_a $7f,~fn\n        set_a $7e,$ff\n        cmp (ind1),y\n        tst_a $7e,~fzc\n        next_test\n\n; testing shifts - ASL LSR ROL ROR all addressing modes\n; shifts - accumulator\n        ldx #3\ntasl\n        set_ax zp1,0\n        asl a\n        tst_ax rASL,fASL,0\n        dex\n        bpl tasl\n        ldx #3\ntasl1\n        set_ax zp1,$ff\n        asl a\n        tst_ax rASL,fASL,$ff-fnzc\n        dex\n        bpl tasl1\n\n        ldx #3\ntlsr\n        set_ax zp1,0\n        lsr a\n        tst_ax rLSR,fLSR,0\n        dex\n        bpl tlsr\n        ldx #3\ntlsr1\n        set_ax zp1,$ff\n        lsr a\n        tst_ax rLSR,fLSR,$ff-fnzc\n        dex\n        bpl tlsr1\n\n        ldx #3\ntrol\n        set_ax zp1,0\n        rol a\n        tst_ax rROL,fROL,0\n        dex\n        bpl trol\n        ldx #3\ntrol1\n        set_ax zp1,$ff-fc\n        rol a\n        tst_ax rROL,fROL,$ff-fnzc\n        dex\n        bpl trol1\n\n        ldx #3\ntrolc\n        set_ax zp1,fc\n        rol a\n        tst_ax rROLc,fROLc,0\n        dex\n        bpl trolc\n        ldx #3\ntrolc1\n        set_ax zp1,$ff\n        rol a\n        tst_ax rROLc,fROLc,$ff-fnzc\n        dex\n        bpl trolc1\n\n        ldx #3\ntror\n        set_ax zp1,0\n        ror a\n        tst_ax rROR,fROR,0\n        dex\n        bpl tror\n        ldx #3\ntror1\n        set_ax zp1,$ff-fc\n        ror a\n        tst_ax rROR,fROR,$ff-fnzc\n        dex\n        bpl tror1\n\n        ldx #3\ntrorc\n        set_ax zp1,fc\n        ror a\n        tst_ax rRORc,fRORc,0\n        dex\n        bpl trorc\n        ldx #3\ntrorc1\n        set_ax zp1,$ff\n        ror a\n        tst_ax rRORc,fRORc,$ff-fnzc\n        dex\n        bpl trorc1\n        next_test\n\n; shifts - zeropage\n        ldx #3\ntasl2\n        set_z zp1,0\n        asl zpt\n        tst_z rASL,fASL,0\n        dex\n        bpl tasl2\n        ldx #3\ntasl3\n        set_z zp1,$ff\n        asl zpt\n        tst_z rASL,fASL,$ff-fnzc\n        dex\n        bpl tasl3\n\n        ldx #3\ntlsr2\n        set_z zp1,0\n        lsr zpt\n        tst_z rLSR,fLSR,0\n        dex\n        bpl tlsr2\n        ldx #3\ntlsr3\n        set_z zp1,$ff\n        lsr zpt\n        tst_z rLSR,fLSR,$ff-fnzc\n        dex\n        bpl tlsr3\n\n        ldx #3\ntrol2\n        set_z zp1,0\n        rol zpt\n        tst_z rROL,fROL,0\n        dex\n        bpl trol2\n        ldx #3\ntrol3\n        set_z zp1,$ff-fc\n        rol zpt\n        tst_z rROL,fROL,$ff-fnzc\n        dex\n        bpl trol3\n\n        ldx #3\ntrolc2\n        set_z zp1,fc\n        rol zpt\n        tst_z rROLc,fROLc,0\n        dex\n        bpl trolc2\n        ldx #3\ntrolc3\n        set_z zp1,$ff\n        rol zpt\n        tst_z rROLc,fROLc,$ff-fnzc\n        dex\n        bpl trolc3\n\n        ldx #3\ntror2\n        set_z zp1,0\n        ror zpt\n        tst_z rROR,fROR,0\n        dex\n        bpl tror2\n        ldx #3\ntror3\n        set_z zp1,$ff-fc\n        ror zpt\n        tst_z rROR,fROR,$ff-fnzc\n        dex\n        bpl tror3\n\n        ldx #3\ntrorc2\n        set_z zp1,fc\n        ror zpt\n        tst_z rRORc,fRORc,0\n        dex\n        bpl trorc2\n        ldx #3\ntrorc3\n        set_z zp1,$ff\n        ror zpt\n        tst_z rRORc,fRORc,$ff-fnzc\n        dex\n        bpl trorc3\n        next_test\n\n; shifts - absolute\n        ldx #3\ntasl4\n        set_abs zp1,0\n        asl abst\n        tst_abs rASL,fASL,0\n        dex\n        bpl tasl4\n        ldx #3\ntasl5\n        set_abs zp1,$ff\n        asl abst\n        tst_abs rASL,fASL,$ff-fnzc\n        dex\n        bpl tasl5\n\n        ldx #3\ntlsr4\n        set_abs zp1,0\n        lsr abst\n        tst_abs rLSR,fLSR,0\n        dex\n        bpl tlsr4\n        ldx #3\ntlsr5\n        set_abs zp1,$ff\n        lsr abst\n        tst_abs rLSR,fLSR,$ff-fnzc\n        dex\n        bpl tlsr5\n\n        ldx #3\ntrol4\n        set_abs zp1,0\n        rol abst\n        tst_abs rROL,fROL,0\n        dex\n        bpl trol4\n        ldx #3\ntrol5\n        set_abs zp1,$ff-fc\n        rol abst\n        tst_abs rROL,fROL,$ff-fnzc\n        dex\n        bpl trol5\n\n        ldx #3\ntrolc4\n        set_abs zp1,fc\n        rol abst\n        tst_abs rROLc,fROLc,0\n        dex\n        bpl trolc4\n        ldx #3\ntrolc5\n        set_abs zp1,$ff\n        rol abst\n        tst_abs rROLc,fROLc,$ff-fnzc\n        dex\n        bpl trolc5\n\n        ldx #3\ntror4\n        set_abs zp1,0\n        ror abst\n        tst_abs rROR,fROR,0\n        dex\n        bpl tror4\n        ldx #3\ntror5\n        set_abs zp1,$ff-fc\n        ror abst\n        tst_abs rROR,fROR,$ff-fnzc\n        dex\n        bpl tror5\n\n        ldx #3\ntrorc4\n        set_abs zp1,fc\n        ror abst\n        tst_abs rRORc,fRORc,0\n        dex\n        bpl trorc4\n        ldx #3\ntrorc5\n        set_abs zp1,$ff\n        ror abst\n        tst_abs rRORc,fRORc,$ff-fnzc\n        dex\n        bpl trorc5\n        next_test\n\n; shifts - zp indexed\n        ldx #3\ntasl6\n        set_zx zp1,0\n        asl zpt,x\n        tst_zx rASL,fASL,0\n        dex\n        bpl tasl6\n        ldx #3\ntasl7\n        set_zx zp1,$ff\n        asl zpt,x\n        tst_zx rASL,fASL,$ff-fnzc\n        dex\n        bpl tasl7\n\n        ldx #3\ntlsr6\n        set_zx zp1,0\n        lsr zpt,x\n        tst_zx rLSR,fLSR,0\n        dex\n        bpl tlsr6\n        ldx #3\ntlsr7\n        set_zx zp1,$ff\n        lsr zpt,x\n        tst_zx rLSR,fLSR,$ff-fnzc\n        dex\n        bpl tlsr7\n\n        ldx #3\ntrol6\n        set_zx zp1,0\n        rol zpt,x\n        tst_zx rROL,fROL,0\n        dex\n        bpl trol6\n        ldx #3\ntrol7\n        set_zx zp1,$ff-fc\n        rol zpt,x\n        tst_zx rROL,fROL,$ff-fnzc\n        dex\n        bpl trol7\n\n        ldx #3\ntrolc6\n        set_zx zp1,fc\n        rol zpt,x\n        tst_zx rROLc,fROLc,0\n        dex\n        bpl trolc6\n        ldx #3\ntrolc7\n        set_zx zp1,$ff\n        rol zpt,x\n        tst_zx rROLc,fROLc,$ff-fnzc\n        dex\n        bpl trolc7\n\n        ldx #3\ntror6\n        set_zx zp1,0\n        ror zpt,x\n        tst_zx rROR,fROR,0\n        dex\n        bpl tror6\n        ldx #3\ntror7\n        set_zx zp1,$ff-fc\n        ror zpt,x\n        tst_zx rROR,fROR,$ff-fnzc\n        dex\n        bpl tror7\n\n        ldx #3\ntrorc6\n        set_zx zp1,fc\n        ror zpt,x\n        tst_zx rRORc,fRORc,0\n        dex\n        bpl trorc6\n        ldx #3\ntrorc7\n        set_zx zp1,$ff\n        ror zpt,x\n        tst_zx rRORc,fRORc,$ff-fnzc\n        dex\n        bpl trorc7\n        next_test\n        \n; shifts - abs indexed\n        ldx #3\ntasl8\n        set_absx zp1,0\n        asl abst,x\n        tst_absx rASL,fASL,0\n        dex\n        bpl tasl8\n        ldx #3\ntasl9\n        set_absx zp1,$ff\n        asl abst,x\n        tst_absx rASL,fASL,$ff-fnzc\n        dex\n        bpl tasl9\n\n        ldx #3\ntlsr8\n        set_absx zp1,0\n        lsr abst,x\n        tst_absx rLSR,fLSR,0\n        dex\n        bpl tlsr8\n        ldx #3\ntlsr9\n        set_absx zp1,$ff\n        lsr abst,x\n        tst_absx rLSR,fLSR,$ff-fnzc\n        dex\n        bpl tlsr9\n\n        ldx #3\ntrol8\n        set_absx zp1,0\n        rol abst,x\n        tst_absx rROL,fROL,0\n        dex\n        bpl trol8\n        ldx #3\ntrol9\n        set_absx zp1,$ff-fc\n        rol abst,x\n        tst_absx rROL,fROL,$ff-fnzc\n        dex\n        bpl trol9\n\n        ldx #3\ntrolc8\n        set_absx zp1,fc\n        rol abst,x\n        tst_absx rROLc,fROLc,0\n        dex\n        bpl trolc8\n        ldx #3\ntrolc9\n        set_absx zp1,$ff\n        rol abst,x\n        tst_absx rROLc,fROLc,$ff-fnzc\n        dex\n        bpl trolc9\n\n        ldx #3\ntror8\n        set_absx zp1,0\n        ror abst,x\n        tst_absx rROR,fROR,0\n        dex\n        bpl tror8\n        ldx #3\ntror9\n        set_absx zp1,$ff-fc\n        ror abst,x\n        tst_absx rROR,fROR,$ff-fnzc\n        dex\n        bpl tror9\n\n        ldx #3\ntrorc8\n        set_absx zp1,fc\n        ror abst,x\n        tst_absx rRORc,fRORc,0\n        dex\n        bpl trorc8\n        ldx #3\ntrorc9\n        set_absx zp1,$ff\n        ror abst,x\n        tst_absx rRORc,fRORc,$ff-fnzc\n        dex\n        bpl trorc9\n        next_test\n\n; testing memory increment/decrement - INC DEC all addressing modes\n; zeropage\n        ldx #0\n        lda #$7e\n        sta zpt\ntinc    \n        set_stat 0\n        inc zpt\n        tst_z rINC,fINC,0\n        inx\n        cpx #2\n        bne tinc1\n        lda #$fe\n        sta zpt\ntinc1   cpx #5\n        bne tinc\n        dex\n        inc zpt\ntdec    \n        set_stat 0\n        dec zpt\n        tst_z rINC,fINC,0\n        dex\n        bmi tdec1\n        cpx #1\n        bne tdec\n        lda #$81\n        sta zpt\n        bne tdec\ntdec1\n        ldx #0\n        lda #$7e\n        sta zpt\ntinc10    \n        set_stat $ff\n        inc zpt\n        tst_z rINC,fINC,$ff-fnz\n        inx\n        cpx #2\n        bne tinc11\n        lda #$fe\n        sta zpt\ntinc11  cpx #5\n        bne tinc10\n        dex\n        inc zpt\ntdec10    \n        set_stat $ff\n        dec zpt\n        tst_z rINC,fINC,$ff-fnz\n        dex\n        bmi tdec11\n        cpx #1\n        bne tdec10\n        lda #$81\n        sta zpt\n        bne tdec10\ntdec11\n        next_test\n\n; absolute memory\n        ldx #0\n        lda #$7e\n        sta abst\ntinc2    \n        set_stat 0\n        inc abst\n        tst_abs rINC,fINC,0\n        inx\n        cpx #2\n        bne tinc3\n        lda #$fe\n        sta abst\ntinc3   cpx #5\n        bne tinc2\n        dex\n        inc abst\ntdec2    \n        set_stat 0\n        dec abst\n        tst_abs rINC,fINC,0\n        dex\n        bmi tdec3\n        cpx #1\n        bne tdec2\n        lda #$81\n        sta abst\n        bne tdec2\ntdec3\n        ldx #0\n        lda #$7e\n        sta abst\ntinc12    \n        set_stat $ff\n        inc abst\n        tst_abs rINC,fINC,$ff-fnz\n        inx\n        cpx #2\n        bne tinc13\n        lda #$fe\n        sta abst\ntinc13   cpx #5\n        bne tinc12\n        dex\n        inc abst\ntdec12    \n        set_stat $ff\n        dec abst\n        tst_abs rINC,fINC,$ff-fnz\n        dex\n        bmi tdec13\n        cpx #1\n        bne tdec12\n        lda #$81\n        sta abst\n        bne tdec12\ntdec13\n        next_test\n\n; zeropage indexed\n        ldx #0\n        lda #$7e\ntinc4   sta zpt,x\n        set_stat 0\n        inc zpt,x\n        tst_zx rINC,fINC,0\n        lda zpt,x\n        inx\n        cpx #2\n        bne tinc5\n        lda #$fe\ntinc5   cpx #5\n        bne tinc4\n        dex\n        lda #2\ntdec4   sta zpt,x \n        set_stat 0\n        dec zpt,x\n        tst_zx rINC,fINC,0\n        lda zpt,x\n        dex\n        bmi tdec5\n        cpx #1\n        bne tdec4\n        lda #$81\n        bne tdec4\ntdec5\n        ldx #0\n        lda #$7e\ntinc14  sta zpt,x\n        set_stat $ff\n        inc zpt,x\n        tst_zx rINC,fINC,$ff-fnz\n        lda zpt,x\n        inx\n        cpx #2\n        bne tinc15\n        lda #$fe\ntinc15  cpx #5\n        bne tinc14\n        dex\n        lda #2\ntdec14  sta zpt,x \n        set_stat $ff\n        dec zpt,x\n        tst_zx rINC,fINC,$ff-fnz\n        lda zpt,x\n        dex\n        bmi tdec15\n        cpx #1\n        bne tdec14\n        lda #$81\n        bne tdec14\ntdec15\n        next_test\n\n; memory indexed\n        ldx #0\n        lda #$7e\ntinc6   sta abst,x\n        set_stat 0\n        inc abst,x\n        tst_absx rINC,fINC,0\n        lda abst,x\n        inx\n        cpx #2\n        bne tinc7\n        lda #$fe\ntinc7   cpx #5\n        bne tinc6\n        dex\n        lda #2\ntdec6   sta abst,x \n        set_stat 0\n        dec abst,x\n        tst_absx rINC,fINC,0\n        lda abst,x\n        dex\n        bmi tdec7\n        cpx #1\n        bne tdec6\n        lda #$81\n        bne tdec6\ntdec7\n        ldx #0\n        lda #$7e\ntinc16  sta abst,x\n        set_stat $ff\n        inc abst,x\n        tst_absx rINC,fINC,$ff-fnz\n        lda abst,x\n        inx\n        cpx #2\n        bne tinc17\n        lda #$fe\ntinc17  cpx #5\n        bne tinc16\n        dex\n        lda #2\ntdec16  sta abst,x \n        set_stat $ff\n        dec abst,x\n        tst_absx rINC,fINC,$ff-fnz\n        lda abst,x\n        dex\n        bmi tdec17\n        cpx #1\n        bne tdec16\n        lda #$81\n        bne tdec16\ntdec17\n        next_test\n\n; testing logical instructions - AND EOR ORA all addressing modes\n; AND\n        ldx #3          ;immediate\ntand    lda zpAN,x\n        sta ex_andi+1   ;set AND # operand\n        set_ax  absANa,0\n        jsr ex_andi     ;execute AND # in RAM\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tand\n        ldx #3\ntand1   lda zpAN,x\n        sta ex_andi+1   ;set AND # operand\n        set_ax  absANa,$ff\n        jsr ex_andi     ;execute AND # in RAM\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tand1\n    \n        ldx #3      ;zp\ntand2   lda zpAN,x\n        sta zpt\n        set_ax  absANa,0\n        and zpt\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tand2\n        ldx #3\ntand3   lda zpAN,x\n        sta zpt\n        set_ax  absANa,$ff\n        and zpt\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tand3\n\n        ldx #3      ;abs\ntand4   lda zpAN,x\n        sta abst\n        set_ax  absANa,0\n        and abst\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tand4\n        ldx #3\ntand5   lda zpAN,x\n        sta abst\n        set_ax  absANa,$ff\n        and abst\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tand6\n\n        ldx #3      ;zp,x\ntand6\n        set_ax  absANa,0\n        and zpAN,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tand6\n        ldx #3\ntand7\n        set_ax  absANa,$ff\n        and zpAN,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tand7\n\n        ldx #3      ;abs,x\ntand8\n        set_ax  absANa,0\n        and absAN,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tand8\n        ldx #3\ntand9\n        set_ax  absANa,$ff\n        and absAN,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tand9\n\n        ldy #3      ;abs,y\ntand10\n        set_ay  absANa,0\n        and absAN,y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl tand10\n        ldy #3\ntand11\n        set_ay  absANa,$ff\n        and absAN,y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl tand11\n\n        ldx #6      ;(zp,x)\n        ldy #3\ntand12\n        set_ay  absANa,0\n        and (indAN,x)\n        tst_ay  absrlo,absflo,0\n        dex\n        dex\n        dey\n        bpl tand12\n        ldx #6\n        ldy #3\ntand13\n        set_ay  absANa,$ff\n        and (indAN,x)\n        tst_ay  absrlo,absflo,$ff-fnz\n        dex\n        dex\n        dey\n        bpl tand13\n\n        ldy #3      ;(zp),y\ntand14\n        set_ay  absANa,0\n        and (indAN),y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl tand14\n        ldy #3\ntand15\n        set_ay  absANa,$ff\n        and (indAN),y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl tand15\n        next_test\n\n; EOR\n        ldx #3          ;immediate - self modifying code\nteor    lda zpEO,x\n        sta ex_eori+1   ;set EOR # operand\n        set_ax  absEOa,0\n        jsr ex_eori     ;execute EOR # in RAM\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl teor\n        ldx #3\nteor1   lda zpEO,x\n        sta ex_eori+1   ;set EOR # operand\n        set_ax  absEOa,$ff\n        jsr ex_eori     ;execute EOR # in RAM\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl teor1\n    \n        ldx #3      ;zp\nteor2    lda zpEO,x\n        sta zpt\n        set_ax  absEOa,0\n        eor zpt\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl teor2\n        ldx #3\nteor3   lda zpEO,x\n        sta zpt\n        set_ax  absEOa,$ff\n        eor zpt\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl teor3\n\n        ldx #3      ;abs\nteor4   lda zpEO,x\n        sta abst\n        set_ax  absEOa,0\n        eor abst\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl teor4\n        ldx #3\nteor5   lda zpEO,x\n        sta abst\n        set_ax  absEOa,$ff\n        eor abst\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl teor6\n\n        ldx #3      ;zp,x\nteor6\n        set_ax  absEOa,0\n        eor zpEO,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl teor6\n        ldx #3\nteor7\n        set_ax  absEOa,$ff\n        eor zpEO,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl teor7\n\n        ldx #3      ;abs,x\nteor8\n        set_ax  absEOa,0\n        eor absEO,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl teor8\n        ldx #3\nteor9\n        set_ax  absEOa,$ff\n        eor absEO,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl teor9\n\n        ldy #3      ;abs,y\nteor10\n        set_ay  absEOa,0\n        eor absEO,y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl teor10\n        ldy #3\nteor11\n        set_ay  absEOa,$ff\n        eor absEO,y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl teor11\n\n        ldx #6      ;(zp,x)\n        ldy #3\nteor12\n        set_ay  absEOa,0\n        eor (indEO,x)\n        tst_ay  absrlo,absflo,0\n        dex\n        dex\n        dey\n        bpl teor12\n        ldx #6\n        ldy #3\nteor13\n        set_ay  absEOa,$ff\n        eor (indEO,x)\n        tst_ay  absrlo,absflo,$ff-fnz\n        dex\n        dex\n        dey\n        bpl teor13\n\n        ldy #3      ;(zp),y\nteor14\n        set_ay  absEOa,0\n        eor (indEO),y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl teor14\n        ldy #3\nteor15\n        set_ay  absEOa,$ff\n        eor (indEO),y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl teor15\n        next_test\n\n; OR\n        ldx #3          ;immediate - self modifying code\ntora    lda zpOR,x\n        sta ex_orai+1   ;set ORA # operand\n        set_ax  absORa,0\n        jsr ex_orai     ;execute ORA # in RAM\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tora\n        ldx #3\ntora1   lda zpOR,x\n        sta ex_orai+1   ;set ORA # operand\n        set_ax  absORa,$ff\n        jsr ex_orai     ;execute ORA # in RAM\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tora1\n    \n        ldx #3      ;zp\ntora2   lda zpOR,x\n        sta zpt\n        set_ax  absORa,0\n        ora zpt\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tora2\n        ldx #3\ntora3   lda zpOR,x\n        sta zpt\n        set_ax  absORa,$ff\n        ora zpt\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tora3\n\n        ldx #3      ;abs\ntora4   lda zpOR,x\n        sta abst\n        set_ax  absORa,0\n        ora abst\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tora4\n        ldx #3\ntora5   lda zpOR,x\n        sta abst\n        set_ax  absORa,$ff\n        ora abst\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tora6\n\n        ldx #3      ;zp,x\ntora6\n        set_ax  absORa,0\n        ora zpOR,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tora6\n        ldx #3\ntora7\n        set_ax  absORa,$ff\n        ora zpOR,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tora7\n\n        ldx #3      ;abs,x\ntora8\n        set_ax  absORa,0\n        ora absOR,x\n        tst_ax  absrlo,absflo,0\n        dex\n        bpl tora8\n        ldx #3\ntora9\n        set_ax  absORa,$ff\n        ora absOR,x\n        tst_ax  absrlo,absflo,$ff-fnz\n        dex\n        bpl tora9\n\n        ldy #3      ;abs,y\ntora10\n        set_ay  absORa,0\n        ora absOR,y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl tora10\n        ldy #3\ntora11\n        set_ay  absORa,$ff\n        ora absOR,y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl tora11\n\n        ldx #6      ;(zp,x)\n        ldy #3\ntora12\n        set_ay  absORa,0\n        ora (indOR,x)\n        tst_ay  absrlo,absflo,0\n        dex\n        dex\n        dey\n        bpl tora12\n        ldx #6\n        ldy #3\ntora13\n        set_ay  absORa,$ff\n        ora (indOR,x)\n        tst_ay  absrlo,absflo,$ff-fnz\n        dex\n        dex\n        dey\n        bpl tora13\n\n        ldy #3      ;(zp),y\ntora14\n        set_ay  absORa,0\n        ora (indOR),y\n        tst_ay  absrlo,absflo,0\n        dey\n        bpl tora14\n        ldy #3\ntora15\n        set_ay  absORa,$ff\n        ora (indOR),y\n        tst_ay  absrlo,absflo,$ff-fnz\n        dey\n        bpl tora15\n    if I_flag = 3\n        cli\n    endif                \n        next_test\n\n; full binary add/subtract test\n; iterates through all combinations of operands and carry input\n; uses increments/decrements to predict result & result flags\n        cld\n        ldx #ad2        ;for indexed test\n        ldy #$ff        ;max range\n        lda #0          ;start with adding zeroes & no carry\n        sta adfc        ;carry in - for diag\n        sta ad1         ;operand 1 - accumulator\n        sta ad2         ;operand 2 - memory or immediate\n        sta ada2        ;non zp\n        sta adrl        ;expected result bits 0-7\n        sta adrh        ;expected result bit 8 (carry out)\n        lda #$ff        ;complemented operand 2 for subtract\n        sta sb2\n        sta sba2        ;non zp\n        lda #2          ;expected Z-flag\n        sta adrf\ntadd    clc             ;test with carry clear\n        jsr chkadd\n        inc adfc        ;now with carry\n        inc adrl        ;result +1\n        php             ;save N & Z from low result\n        php\n        pla             ;accu holds expected flags\n        and #$82        ;mask N & Z\n        plp\n        bne tadd1\n        inc adrh        ;result bit 8 - carry\ntadd1   ora adrh        ;merge C to expected flags\n        sta adrf        ;save expected flags except overflow\n        sec             ;test with carry set\n        jsr chkadd\n        dec adfc        ;same for operand +1 but no carry\n        inc ad1\n        bne tadd        ;iterate op1\n        lda #0          ;preset result to op2 when op1 = 0\n        sta adrh\n        inc ada2\n        inc ad2\n        php             ;save NZ as operand 2 becomes the new result\n        pla\n        and #$82        ;mask N00000Z0\n        sta adrf        ;no need to check carry as we are adding to 0\n        dec sb2         ;complement subtract operand 2\n        dec sba2\n        lda ad2         \n        sta adrl\n        bne tadd        ;iterate op2\n    if disable_decimal < 1\n        next_test\n\n; decimal add/subtract test\n; *** WARNING - tests documented behavior only! ***\n;   only valid BCD operands are tested, N V Z flags are ignored\n; iterates through all valid combinations of operands and carry input\n; uses increments/decrements to predict result & carry flag\n        sed \n        ldx #ad2        ;for indexed test\n        ldy #$ff        ;max range\n        lda #$99        ;start with adding 99 to 99 with carry\n        sta ad1         ;operand 1 - accumulator\n        sta ad2         ;operand 2 - memory or immediate\n        sta ada2        ;non zp\n        sta adrl        ;expected result bits 0-7\n        lda #1          ;set carry in & out\n        sta adfc        ;carry in - for diag\n        sta adrh        ;expected result bit 8 (carry out)\n        lda #0          ;complemented operand 2 for subtract\n        sta sb2\n        sta sba2        ;non zp\ntdad    sec             ;test with carry set\n        jsr chkdad\n        dec adfc        ;now with carry clear\n        lda adrl        ;decimal adjust result\n        bne tdad1       ;skip clear carry & preset result 99 (9A-1)\n        dec adrh\n        lda #$99\n        sta adrl\n        bne tdad3\ntdad1   and #$f         ;lower nibble mask\n        bne tdad2       ;no decimal adjust needed\n        dec adrl        ;decimal adjust (?0-6)\n        dec adrl\n        dec adrl\n        dec adrl\n        dec adrl\n        dec adrl\ntdad2   dec adrl        ;result -1\ntdad3   clc             ;test with carry clear\n        jsr chkdad\n        inc adfc        ;same for operand -1 but with carry\n        lda ad1         ;decimal adjust operand 1\n        beq tdad5       ;iterate operand 2\n        and #$f         ;lower nibble mask\n        bne tdad4       ;skip decimal adjust\n        dec ad1         ;decimal adjust (?0-6)\n        dec ad1\n        dec ad1\n        dec ad1\n        dec ad1\n        dec ad1\ntdad4   dec ad1         ;operand 1 -1\n        jmp tdad        ;iterate op1\n\ntdad5   lda #$99        ;precharge op1 max\n        sta ad1\n        lda ad2         ;decimal adjust operand 2\n        beq tdad7       ;end of iteration\n        and #$f         ;lower nibble mask\n        bne tdad6       ;skip decimal adjust\n        dec ad2         ;decimal adjust (?0-6)\n        dec ad2\n        dec ad2\n        dec ad2\n        dec ad2\n        dec ad2\n        inc sb2         ;complemented decimal adjust for subtract (?9+6)\n        inc sb2\n        inc sb2\n        inc sb2\n        inc sb2\n        inc sb2\ntdad6   dec ad2         ;operand 2 -1\n        inc sb2         ;complemented operand for subtract\n        lda sb2\n        sta sba2        ;copy as non zp operand\n        lda ad2\n        sta ada2        ;copy as non zp operand\n        sta adrl        ;new result since op1+carry=00+carry +op2=op2\n        inc adrh        ;result carry\n        bne tdad        ;iterate op2\ntdad7\n        next_test\n\n; decimal/binary switch test\n; tests CLD, SED, PLP, RTI to properly switch between decimal & binary opcode\n;   tables\n        clc\n        cld\n        php\n        lda #$55\n        adc #$55\n        cmp #$aa\n        trap_ne         ;expected binary result after cld\n        clc\n        sed\n        php\n        lda #$55\n        adc #$55\n        cmp #$10\n        trap_ne         ;expected decimal result after sed\n        cld\n        plp\n        lda #$55\n        adc #$55\n        cmp #$10\n        trap_ne         ;expected decimal result after plp D=1\n        plp\n        lda #$55\n        adc #$55\n        cmp #$aa\n        trap_ne         ;expected binary result after plp D=0\n        clc\n        lda #hi bin_rti_ret ;emulated interrupt for rti\n        pha\n        lda #lo bin_rti_ret\n        pha\n        php\n        sed\n        lda #hi dec_rti_ret ;emulated interrupt for rti\n        pha\n        lda #lo dec_rti_ret\n        pha\n        php\n        cld\n        rti\ndec_rti_ret\n        lda #$55\n        adc #$55\n        cmp #$10\n        trap_ne         ;expected decimal result after rti D=1\n        rti\nbin_rti_ret        \n        lda #$55\n        adc #$55\n        cmp #$aa\n        trap_ne         ;expected binary result after rti D=0\n    endif\n    \n        lda test_case\n        cmp #test_num\n        trap_ne         ;previous test is out of sequence\n        lda #$f0        ;mark opcode testing complete\n        sta test_case\n        \n; final RAM integrity test\n;   verifies that none of the previous tests has altered RAM outside of the\n;   designated write areas.\n        check_ram\n; *** DEBUG INFO ***\n; to debug checksum errors uncomment check_ram in the next_test macro to\n; narrow down the responsible opcode.\n; may give false errors when monitor, OS or other background activity is\n; allowed during previous tests.\n\n\n; S U C C E S S ************************************************\n; -------------       \n        success         ;if you get here everything went well\n; -------------       \n; S U C C E S S ************************************************\n        jmp start       ;run again      \n\n    if disable_decimal < 1\n; core subroutine of the decimal add/subtract test\n; *** WARNING - tests documented behavior only! ***\n;   only valid BCD operands are tested, N V Z flags are ignored\n; iterates through all valid combinations of operands and carry input\n; uses increments/decrements to predict result & carry flag\nchkdad\n; decimal ADC / SBC zp\n        php             ;save carry for subtract\n        lda ad1\n        adc ad2         ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sb2         ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad flags\n        plp\n; decimal ADC / SBC abs\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2        ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2        ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC #\n        php             ;save carry for subtract\n        lda ad2\n        sta ex_adci+1   ;set ADC # operand\n        lda ad1\n        jsr ex_adci     ;execute ADC # in RAM\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda sb2\n        sta ex_sbci+1   ;set SBC # operand\n        lda ad1\n        jsr ex_sbci     ;execute SBC # in RAM\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC zp,x\n        php             ;save carry for subtract\n        lda ad1\n        adc 0,x         ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sb2-ad2,x   ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC abs,x\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2-ad2,x  ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2-ad2,x  ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC abs,y\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2-$ff,y  ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2-$ff,y  ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC (zp,x)\n        php             ;save carry for subtract\n        lda ad1\n        adc (lo adi2-ad2,x) ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc (lo sbi2-ad2,x) ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n; decimal ADC / SBC (abs),y\n        php             ;save carry for subtract\n        lda ad1\n        adc (adiy2),y   ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc (sbiy2),y   ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #1          ;mask carry\n        cmp adrh\n        trap_ne         ;bad carry\n        plp\n        rts\n    endif\n\n; core subroutine of the full binary add/subtract test\n; iterates through all combinations of operands and carry input\n; uses increments/decrements to predict result & result flags\nchkadd  lda adrf        ;add V-flag if overflow\n        and #$83        ;keep N-----ZC / clear V\n        pha\n        lda ad1         ;test sign unequal between operands\n        eor ad2\n        bmi ckad1       ;no overflow possible - operands have different sign\n        lda ad1         ;test sign equal between operands and result\n        eor adrl\n        bpl ckad1       ;no overflow occured - operand and result have same sign\n        pla\n        ora #$40        ;set V\n        pha\nckad1   pla\n        sta adrf        ;save expected flags\n; binary ADC / SBC zp\n        php             ;save carry for subtract\n        lda ad1\n        adc ad2         ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sb2         ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC abs\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2        ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2        ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC #\n        php             ;save carry for subtract\n        lda ad2\n        sta ex_adci+1   ;set ADC # operand\n        lda ad1\n        jsr ex_adci     ;execute ADC # in RAM\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda sb2\n        sta ex_sbci+1   ;set SBC # operand\n        lda ad1\n        jsr ex_sbci     ;execute SBC # in RAM\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC zp,x\n        php             ;save carry for subtract\n        lda ad1\n        adc 0,x         ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sb2-ad2,x   ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC abs,x\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2-ad2,x  ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2-ad2,x  ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC abs,y\n        php             ;save carry for subtract\n        lda ad1\n        adc ada2-$ff,y  ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc sba2-$ff,y  ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC (zp,x)\n        php             ;save carry for subtract\n        lda ad1\n        adc (lo adi2-ad2,x) ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc (lo sbi2-ad2,x) ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n; binary ADC / SBC (abs),y\n        php             ;save carry for subtract\n        lda ad1\n        adc (adiy2),y   ;perform add\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        php             ;save carry for next add\n        lda ad1\n        sbc (sbiy2),y   ;perform subtract\n        php          \n        cmp adrl        ;check result\n        trap_ne         ;bad result\n        pla             ;check flags\n        and #$c3        ;mask NV----ZC\n        cmp adrf\n        trap_ne         ;bad flags\n        plp\n        rts\n\n; target for the jump absolute test\n        dey\n        dey\ntest_far\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        plp\n        trap_cs         ;flags loaded?\n        trap_vs\n        trap_mi\n        trap_eq \n        cmp #'F'        ;registers loaded?\n        trap_ne\n        cpx #'A'\n        trap_ne        \n        cpy #('R'-3)\n        trap_ne\n        pha             ;save a,x\n        txa\n        pha\n        tsx\n        cpx #$fd        ;check SP\n        trap_ne\n        pla             ;restore x\n        tax\n        set_stat $ff\n        pla             ;restore a\n        inx             ;return registers with modifications\n        eor #$aa        ;N=1, V=1, Z=0, C=1\n        jmp far_ret\n        \n; target for the jump indirect test\n        align\nptr_tst_ind dw test_ind\nptr_ind_ret dw ind_ret\n        trap            ;runover protection\n        dey\n        dey\ntest_ind\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        plp\n        trap_cs         ;flags loaded?\n        trap_vs\n        trap_mi\n        trap_eq \n        cmp #'I'        ;registers loaded?\n        trap_ne\n        cpx #'N'\n        trap_ne        \n        cpy #('D'-3)\n        trap_ne\n        pha             ;save a,x\n        txa\n        pha\n        tsx\n        cpx #$fd        ;check SP\n        trap_ne\n        pla             ;restore x\n        tax\n        set_stat $ff\n        pla             ;restore a\n        inx             ;return registers with modifications\n        eor #$aa        ;N=1, V=1, Z=0, C=1\n        jmp (ptr_ind_ret)\n        trap            ;runover protection\n\n; target for the jump subroutine test\n        dey\n        dey\ntest_jsr\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        plp\n        trap_cs         ;flags loaded?\n        trap_vs\n        trap_mi\n        trap_eq \n        cmp #'J'        ;registers loaded?\n        trap_ne\n        cpx #'S'\n        trap_ne        \n        cpy #('R'-3)\n        trap_ne\n        pha             ;save a,x\n        txa\n        pha       \n        tsx             ;sp -4? (return addr,a,x)\n        cpx #$fb\n        trap_ne\n        lda $1ff        ;propper return on stack\n        cmp #hi(jsr_ret)\n        trap_ne\n        lda $1fe\n        cmp #lo(jsr_ret)\n        trap_ne\n        set_stat $ff\n        pla             ;pull x,a\n        tax\n        pla\n        inx             ;return registers with modifications\n        eor #$aa        ;N=1, V=1, Z=0, C=1\n        rts\n        trap            ;runover protection\n        \n;trap in case of unexpected IRQ, NMI, BRK, RESET - BRK test target\nnmi_trap\n        trap            ;check stack for conditions at NMI\nres_trap\n        trap            ;unexpected RESET\n        \n        dey\n        dey\nirq_trap                ;BRK test or unextpected BRK or IRQ\n        php             ;either SP or Y count will fail, if we do not hit\n        dey\n        dey\n        dey\n        ;next 4 traps could be caused by unexpected BRK or IRQ\n        ;check stack for BREAK and originating location\n        ;possible jump/branch into weeds (uninitialized space)\n        cmp #'B'        ;registers loaded?\n        trap_ne\n        cpx #'R'\n        trap_ne        \n        cpy #('K'-3)\n        trap_ne\n        sta irq_a       ;save registers during break test\n        stx irq_x\n        tsx             ;test break on stack\n        lda $102,x\n        cmp_flag 0      ;break test should have B=1\n        trap_ne         ; - no break flag on stack\n        pla\n        cmp #fai        ;should have added interrupt disable\n        trap_ne\n        tsx\n        cpx #$fc        ;sp -3? (return addr, flags)\n        trap_ne\n        lda $1ff        ;propper return on stack\n        cmp #hi(brk_ret)\n        trap_ne\n        lda $1fe\n        cmp #lo(brk_ret)\n        trap_ne\n        set_stat $ff\n        ldx irq_x\n        inx             ;return registers with modifications\n        lda irq_a\n        eor #$aa        ;N=1, V=1, Z=0, C=1 but original flags should be restored\n        rti\n        trap            ;runover protection\n        \n    if report = 1\n        include \"report.i65\"\n    endif\n        \n;copy of data to initialize BSS segment\n    if load_data_direct != 1\nzp_init\nzp1_    db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\nzp7f_   db  $7f             ;test pattern for compare\n;logical zeropage operands\nzpOR_   db  0,$1f,$71,$80   ;test pattern for OR\nzpAN_   db  $0f,$ff,$7f,$80 ;test pattern for AND\nzpEO_   db  $ff,$0f,$8f,$8f ;test pattern for EOR\n;indirect addressing pointers\nind1_   dw  abs1            ;indirect pointer to pattern in absolute memory\n        dw  abs1+1\n        dw  abs1+2\n        dw  abs1+3\n        dw  abs7f\ninw1_   dw  abs1-$f8        ;indirect pointer for wrap-test pattern\nindt_   dw  abst            ;indirect pointer to store area in absolute memory\n        dw  abst+1\n        dw  abst+2\n        dw  abst+3\ninwt_   dw  abst-$f8        ;indirect pointer for wrap-test store\nindAN_  dw  absAN           ;indirect pointer to AND pattern in absolute memory\n        dw  absAN+1\n        dw  absAN+2\n        dw  absAN+3\nindEO_  dw  absEO           ;indirect pointer to EOR pattern in absolute memory\n        dw  absEO+1\n        dw  absEO+2\n        dw  absEO+3\nindOR_  dw  absOR           ;indirect pointer to OR pattern in absolute memory\n        dw  absOR+1\n        dw  absOR+2\n        dw  absOR+3\n;add/subtract indirect pointers\nadi2_   dw  ada2            ;indirect pointer to operand 2 in absolute memory\nsbi2_   dw  sba2            ;indirect pointer to complemented operand 2 (SBC)\nadiy2_  dw  ada2-$ff        ;with offset for indirect indexed\nsbiy2_  dw  sba2-$ff\nzp_end\n    if (zp_end - zp_init) != (zp_bss_end - zp_bss)   \n        ;force assembler error if size is different   \n        ERROR ERROR ERROR   ;mismatch between bss and zeropage data\n    endif \ndata_init\nex_and_ and #0              ;execute immediate opcodes\n        rts\nex_eor_ eor #0              ;execute immediate opcodes\n        rts\nex_ora_ ora #0              ;execute immediate opcodes\n        rts\nex_adc_ adc #0              ;execute immediate opcodes\n        rts\nex_sbc_ sbc #0              ;execute immediate opcodes\n        rts\nabs1_   db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\nabs7f_  db  $7f             ;test pattern for compare\n;loads\nfLDx_   db  fn,fn,0,fz      ;expected flags for load\n;shifts\nrASL_                       ;expected result ASL & ROL -carry\nrROL_   db  $86,$04,$82,0   ; \"\nrROLc_  db  $87,$05,$83,1   ;expected result ROL +carry\nrLSR_                       ;expected result LSR & ROR -carry\nrROR_   db  $61,$41,$20,0   ; \"\nrRORc_  db  $e1,$c1,$a0,$80 ;expected result ROR +carry\nfASL_                       ;expected flags for shifts\nfROL_   db  fnc,fc,fn,fz    ;no carry in\nfROLc_  db  fnc,fc,fn,0     ;carry in\nfLSR_\nfROR_   db  fc,0,fc,fz      ;no carry in\nfRORc_  db  fnc,fn,fnc,fn   ;carry in\n;increments (decrements)\nrINC_   db  $7f,$80,$ff,0,1 ;expected result for INC/DEC\nfINC_   db  0,fn,fn,fz,0    ;expected flags for INC/DEC\n;logical memory operand\nabsOR_  db  0,$1f,$71,$80   ;test pattern for OR\nabsAN_  db  $0f,$ff,$7f,$80 ;test pattern for AND\nabsEO_  db  $ff,$0f,$8f,$8f ;test pattern for EOR\n;logical accu operand\nabsORa_ db  0,$f1,$1f,0     ;test pattern for OR\nabsANa_ db  $f0,$ff,$ff,$ff ;test pattern for AND\nabsEOa_ db  $ff,$f0,$f0,$0f ;test pattern for EOR\n;logical results\nabsrlo_ db  0,$ff,$7f,$80\nabsflo_ db  fz,fn,0,fn\ndata_end\n    if (data_end - data_init) != (data_bss_end - data_bss)\n        ;force assembler error if size is different   \n        ERROR ERROR ERROR   ;mismatch between bss and data\n    endif \n\nvec_init\n        dw  nmi_trap\n        dw  res_trap\n        dw  irq_trap\nvec_bss equ $fffa\n    endif                   ;end of RAM init data\n    \n    if (load_data_direct = 1) & (ROM_vectors = 1)  \n        org $fffa       ;vectors\n        dw  nmi_trap\n        dw  res_trap\n        dw  irq_trap\n    endif\n\n        end start\n            \n"
  },
  {
    "path": "assets/tests/6502_functional_test.lst",
    "content": "AS65 Assembler for R6502 [1.42].  Copyright 1994-2007, Frank A. Kingswood                                                Page    1\n---------------------------------------------------- 6502_functional_test.a65 ----------------------------------------------------\n\n6010 lines read, no errors in pass 1.\n                        ;\n                        ; 6 5 0 2   F U N C T I O N A L   T E S T\n                        ;\n                        ; Copyright (C) 2012-2015  Klaus Dormann\n                        ;\n                        ; This program is free software: you can redistribute it and/or modify\n                        ; it under the terms of the GNU General Public License as published by\n                        ; the Free Software Foundation, either version 3 of the License, or\n                        ; (at your option) any later version.\n                        ;\n                        ; This program is distributed in the hope that it will be useful,\n                        ; but WITHOUT ANY WARRANTY; without even the implied warranty of\n                        ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n                        ; GNU General Public License for more details.\n                        ;\n                        ; You should have received a copy of the GNU General Public License\n                        ; along with this program.  If not, see <http://www.gnu.org/licenses/>.\n                        \n                        \n                        ; This program is designed to test all opcodes of a 6502 emulator using all\n                        ; addressing modes with focus on propper setting of the processor status\n                        ; register bits.\n                        ; \n                        ; version 21-oct-2015\n                        ; contact info at http://2m5.de or email K@2m5.de\n                        ;\n                        ; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/\n                        ; command line switches: -l -m -s2 -w -h0\n                        ;                         |  |  |   |  no page headers in listing\n                        ;                         |  |  |   wide listing (133 char/col)\n                        ;                         |  |  write intel hex file instead of binary\n                        ;                         |  expand macros in listing\n                        ;                         generate pass2 listing\n                        ;\n                        ; No IO - should be run from a monitor with access to registers.\n                        ; To run load intel hex image with a load command, than alter PC to 400 hex\n                        ; (code_segment) and enter a go command.\n                        ; Loop on program counter determines error or successful completion of test.\n                        ; Check listing for relevant traps (jump/branch *).\n                        ; Please note that in early tests some instructions will have to be used before\n                        ; they are actually tested!\n                        ;\n                        ; RESET, NMI or IRQ should not occur and will be trapped if vectors are enabled.\n                        ; Tests documented behavior of the original NMOS 6502 only! No unofficial\n                        ; opcodes. Additional opcodes of newer versions of the CPU (65C02, 65816) will\n                        ; not be tested. Decimal ops will only be tested with valid BCD operands and\n                        ; N V Z flags will be ignored.\n                        ;\n                        ; Debugging hints:\n                        ;     Most of the code is written sequentially. if you hit a trap, check the\n                        ;   immediately preceeding code for the instruction to be tested. Results are\n                        ;   tested first, flags are checked second by pushing them onto the stack and\n                        ;   pulling them to the accumulator after the result was checked. The \"real\"\n                        ;   flags are no longer valid for the tested instruction at this time!\n                        ;     If the tested instruction was indexed, the relevant index (X or Y) must\n                        ;   also be checked. Opposed to the flags, X and Y registers are still valid.\n                        ;\n                        ; versions:\n                        ;   28-jul-2012  1st version distributed for testing\n                        ;   29-jul-2012  fixed references to location 0, now #0\n                        ;                added license - GPLv3\n                        ;   30-jul-2012  added configuration options\n                        ;   01-aug-2012  added trap macro to allow user to change error handling\n                        ;   01-dec-2012  fixed trap in branch field must be a branch\n                        ;   02-mar-2013  fixed PLA flags not tested\n                        ;   19-jul-2013  allowed ROM vectors to be loaded when load_data_direct = 0\n                        ;                added test sequence check to detect if tests jump their fence\n                        ;   23-jul-2013  added RAM integrity check option\n                        ;   16-aug-2013  added error report to standard output option\n                        ;   13-dec-2014  added binary/decimal opcode table switch test\n                        ;   14-dec-2014  improved relative address test\n                        ;   23-aug-2015  added option to disable self modifying tests\n                        ;   24-aug-2015  all self modifying immediate opcodes now execute in data RAM\n                        ;                added small branch offset pretest\n                        ;   21-oct-2015  added option to disable decimal mode ADC & SBC tests\n                        \n                        \n                        ; C O N F I G U R A T I O N\n                        \n                        ;ROM_vectors writable (0=no, 1=yes)\n                        ;if ROM vectors can not be used interrupts will not be trapped\n                        ;as a consequence BRK can not be tested but will be emulated to test RTI\n0001 =                  ROM_vectors = 1\n                        \n                        ;load_data_direct (0=move from code segment, 1=load directly)\n                        ;loading directly is preferred but may not be supported by your platform\n                        ;0 produces only consecutive object code, 1 is not suitable for a binary image\n0000 =                  load_data_direct = 0\n                        \n                        ;I_flag behavior (0=force enabled, 1=force disabled, 2=prohibit change, 3=allow\n                        ;change) 2 requires extra code and is not recommended. SEI & CLI can only be\n                        ;tested if you allow changing the interrupt status (I_flag = 3)\n0003 =                  I_flag = 3\n                        \n                        ;configure memory - try to stay away from memory used by the system\n                        ;zero_page memory start address, $50 (80) consecutive Bytes required\n                        ;                                add 2 if I_flag = 2\n000a =                  zero_page = $a  \n                        \n                        ;data_segment memory start address, $6A (106) consecutive Bytes required\n0200 =                  data_segment = $200  \n                            if (data_segment & $ff) != 0\n                                ERROR ERROR ERROR low byte of data_segment MUST be $00 !!\n                            endif  \n                        \n                        ;code_segment memory start address, 13kB of consecutive space required\n                        ;                                   add 2.5 kB if I_flag = 2\n0400 =                  code_segment = $400  \n                        \n                        ;self modifying code may be disabled to allow running in ROM\n                        ;0=part of the code is self modifying and must reside in RAM\n                        ;1=tests disabled: branch range\n0000 =                  disable_selfmod = 0\n                        \n                        ;report errors through I/O channel (0=use standard self trap loops, 1=include\n                        ;report.i65 as I/O channel, add 3.5 kB)\n0000 =                  report = 0\n                        \n                        ;RAM integrity test option. Checks for undesired RAM writes.\n                        ;set lowest non RAM or RAM mirror address page (-1=disable, 0=64k, $40=16k)\n                        ;leave disabled if a monitor, OS or background interrupt is allowed to alter RAM\nffff =                  ram_top = -1\n                        \n                        ;disable test decimal mode ADC & SBC, 0=enable, 1=disable,\n                        ;2=disable including decimal flag in processor status\n0000 =                  disable_decimal = 0\n                        \n                                noopt       ;do not take shortcuts\n                        \n                        ;macros for error & success traps to allow user modification\n                        ;example:\n                        ;trap    macro\n                        ;        jsr my_error_handler\n                        ;        endm\n                        ;trap_eq macro\n                        ;        bne skip\\?\n                        ;        trap           ;failed equal (zero)\n                        ;skip\\?\n                        ;        endm\n                        ;\n                        ; my_error_handler should pop the calling address from the stack and report it.\n                        ; putting larger portions of code (more than 3 bytes) inside the trap macro\n                        ; may lead to branch range problems for some tests.\n                            if report = 0\n                        trap    macro\n                                jmp *           ;failed anyway\n                                endm\n                        trap_eq macro\n                                beq *           ;failed equal (zero)\n                                endm\n                        trap_ne macro\n                                bne *           ;failed not equal (non zero)\n                                endm\n                        trap_cs macro\n                                bcs *           ;failed carry set\n                                endm\n                        trap_cc macro\n                                bcc *           ;failed carry clear\n                                endm\n                        trap_mi macro\n                                bmi *           ;failed minus (bit 7 set)\n                                endm\n                        trap_pl macro\n                                bpl *           ;failed plus (bit 7 clear)\n                                endm\n                        trap_vs macro\n                                bvs *           ;failed overflow set\n                                endm\n                        trap_vc macro\n                                bvc *           ;failed overflow clear\n                                endm\n                        ; please observe that during the test the stack gets invalidated\n                        ; therefore a RTS inside the success macro is not possible\n                        success macro\n                                jmp *           ;test passed, no errors\n                                endm\n                            endif\n                            if report = 1\n                        trap    macro\n                                jsr report_error\n                                endm\n                        trap_eq macro\n                                bne skip\\?\n                                trap           ;failed equal (zero)\n                        skip\\?\n                                endm\n                        trap_ne macro\n                                beq skip\\?\n                                trap            ;failed not equal (non zero)\n                        skip\\?\n                                endm\n                        trap_cs macro\n                                bcc skip\\?\n                                trap            ;failed carry set\n                        skip\\?\n                                endm\n                        trap_cc macro\n                                bcs skip\\?\n                                trap            ;failed carry clear\n                        skip\\?\n                                endm\n                        trap_mi macro\n                                bpl skip\\?\n                                trap            ;failed minus (bit 7 set)\n                        skip\\?\n                                endm\n                        trap_pl macro\n                                bmi skip\\?\n                                trap            ;failed plus (bit 7 clear)\n                        skip\\?\n                                endm\n                        trap_vs macro\n                                bvc skip\\?\n                                trap            ;failed overflow set\n                        skip\\?\n                                endm\n                        trap_vc macro\n                                bvs skip\\?\n                                trap            ;failed overflow clear\n                        skip\\?\n                                endm\n                        ; please observe that during the test the stack gets invalidated\n                        ; therefore a RTS inside the success macro is not possible\n                        success macro\n                                jsr report_success\n                                endm\n                            endif\n                        \n                        \n0001 =                  carry   equ %00000001   ;flag bits in status\n0002 =                  zero    equ %00000010\n0004 =                  intdis  equ %00000100\n0008 =                  decmode equ %00001000\n0010 =                  break   equ %00010000\n0020 =                  reserv  equ %00100000\n0040 =                  overfl  equ %01000000\n0080 =                  minus   equ %10000000\n                        \n0001 =                  fc      equ carry\n0002 =                  fz      equ zero\n0003 =                  fzc     equ carry+zero\n0040 =                  fv      equ overfl\n0042 =                  fvz     equ overfl+zero\n0080 =                  fn      equ minus\n0081 =                  fnc     equ minus+carry\n0082 =                  fnz     equ minus+zero\n0083 =                  fnzc    equ minus+zero+carry\n00c0 =                  fnv     equ minus+overfl\n                        \n0030 =                  fao     equ break+reserv    ;bits always on after PHP, BRK\n0034 =                  fai     equ fao+intdis      ;+ forced interrupt disable\n0038 =                  faod    equ fao+decmode     ;+ ignore decimal\n003c =                  faid    equ fai+decmode     ;+ ignore decimal\n00ff =                  m8      equ $ff             ;8 bit mask\n00fb =                  m8i     equ $ff&~intdis     ;8 bit mask - interrupt disable\n                        \n                        ;macros to allow masking of status bits.\n                        ;masking test of decimal bit\n                        ;masking of interrupt enable/disable on load and compare\n                        ;masking of always on bits after PHP or BRK (unused & break) on compare\n                            if disable_decimal < 2\n                                if I_flag = 0\n                        load_flag   macro\n                                    lda #\\1&m8i         ;force enable interrupts (mask I)\n                                    endm\n                        cmp_flag    macro\n                                    cmp #(\\1|fao)&m8i   ;I_flag is always enabled + always on bits\n                                    endm\n                        eor_flag    macro\n                                    eor #(\\1&m8i|fao)   ;mask I, invert expected flags + always on bits\n                                    endm\n                                endif\n                                if I_flag = 1\n                        load_flag   macro\n                                    lda #\\1|intdis      ;force disable interrupts\n                                    endm\n                        cmp_flag    macro\n                                    cmp #(\\1|fai)&m8    ;I_flag is always disabled + always on bits\n                                    endm\n                        eor_flag    macro\n                                    eor #(\\1|fai)       ;invert expected flags + always on bits + I\n                                    endm\n                                endif\n                                if I_flag = 2\n                        load_flag   macro\n                                    lda #\\1\n                                    ora flag_I_on       ;restore I-flag\n                                    and flag_I_off\n                                    endm\n                        cmp_flag    macro\n                                    eor flag_I_on       ;I_flag is never changed\n                                    cmp #(\\1|fao)&m8i   ;expected flags + always on bits, mask I\n                                    endm\n                        eor_flag    macro\n                                    eor flag_I_on       ;I_flag is never changed\n                                    eor #(\\1&m8i|fao)   ;mask I, invert expected flags + always on bits\n                                    endm\n                                endif\n                                if I_flag = 3\n                        load_flag   macro\n                                    lda #\\1             ;allow test to change I-flag (no mask)\n                                    endm\n                        cmp_flag    macro\n                                    cmp #(\\1|fao)&m8    ;expected flags + always on bits\n                                    endm\n                        eor_flag    macro\n                                    eor #\\1|fao         ;invert expected flags + always on bits\n                                    endm\n                                endif\n                            else\n                                if I_flag = 0\n                        load_flag   macro\n                                    lda #\\1&m8i         ;force enable interrupts (mask I)\n                                    endm\n                        cmp_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    cmp #(\\1|faod)&m8i  ;I_flag is always enabled + always on bits\n                                    endm\n                        eor_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    eor #(\\1&m8i|faod)  ;mask I, invert expected flags + always on bits\n                                    endm\n                                endif\n                                if I_flag = 1\n                        load_flag   macro\n                                    lda #\\1|intdis      ;force disable interrupts\n                                    endm\n                        cmp_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    cmp #(\\1|faid)&m8   ;I_flag is always disabled + always on bits\n                                    endm\n                        eor_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    eor #(\\1|faid)      ;invert expected flags + always on bits + I\n                                    endm\n                                endif\n                                if I_flag = 2\n                        load_flag   macro\n                                    lda #\\1\n                                    ora flag_I_on       ;restore I-flag\n                                    and flag_I_off\n                                    endm\n                        cmp_flag    macro\n                                    eor flag_I_on       ;I_flag is never changed\n                                    ora #decmode        ;ignore decimal mode bit\n                                    cmp #(\\1|faod)&m8i  ;expected flags + always on bits, mask I\n                                    endm\n                        eor_flag    macro\n                                    eor flag_I_on       ;I_flag is never changed\n                                    ora #decmode        ;ignore decimal mode bit\n                                    eor #(\\1&m8i|faod)  ;mask I, invert expected flags + always on bits\n                                    endm\n                                endif\n                                if I_flag = 3\n                        load_flag   macro\n                                    lda #\\1             ;allow test to change I-flag (no mask)\n                                    endm\n                        cmp_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    cmp #(\\1|faod)&m8   ;expected flags + always on bits\n                                    endm\n                        eor_flag    macro\n                                    ora #decmode        ;ignore decimal mode bit\n                                    eor #\\1|faod        ;invert expected flags + always on bits\n                                    endm\n                                endif\n                            endif\n                        \n                        ;macros to set (register|memory|zeropage) & status\n                        set_stat    macro       ;setting flags in the processor status register\n                                    load_flag \\1\n                                    pha         ;use stack to load status\n                                    plp\n                                    endm\n                        \n                        set_a       macro       ;precharging accu & status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda #\\1     ;precharge accu\n                                    plp\n                                    endm\n                        \n                        set_x       macro       ;precharging index & status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    ldx #\\1     ;precharge index x\n                                    plp\n                                    endm\n                        \n                        set_y       macro       ;precharging index & status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    ldy #\\1     ;precharge index y\n                                    plp\n                                    endm\n                        \n                        set_ax      macro       ;precharging indexed accu & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,x    ;precharge accu\n                                    plp\n                                    endm\n                        \n                        set_ay      macro       ;precharging indexed accu & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,y    ;precharge accu\n                                    plp\n                                    endm\n                        \n                        set_z       macro       ;precharging indexed zp & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,x    ;load to zeropage\n                                    sta zpt\n                                    plp\n                                    endm\n                        \n                        set_zx      macro       ;precharging zp,x & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,x    ;load to indexed zeropage\n                                    sta zpt,x\n                                    plp\n                                    endm\n                        \n                        set_abs     macro       ;precharging indexed memory & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,x    ;load to memory\n                                    sta abst\n                                    plp\n                                    endm\n                        \n                        set_absx    macro       ;precharging abs,x & immediate status\n                                    load_flag \\2\n                                    pha         ;use stack to load status\n                                    lda \\1,x    ;load to indexed memory\n                                    sta abst,x\n                                    plp\n                                    endm\n                        \n                        ;macros to test (register|memory|zeropage) & status & (mask)\n                        tst_stat    macro       ;testing flags in the processor status register\n                                    php         ;save status\n                                    pla         ;use stack to retrieve status\n                                    pha\n                                    cmp_flag \\1\n                                    trap_ne\n                                    plp         ;restore status\n                                    endm\n                                    \n                        tst_a       macro       ;testing result in accu & flags\n                                    php         ;save flags\n                                    cmp #\\1     ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    pha\n                                    cmp_flag \\2\n                                    trap_ne\n                                    plp         ;restore status\n                                    endm\n                        \n                        tst_x       macro       ;testing result in x index & flags\n                                    php         ;save flags\n                                    cpx #\\1     ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    pha\n                                    cmp_flag \\2\n                                    trap_ne\n                                    plp         ;restore status\n                                    endm\n                        \n                        tst_y       macro       ;testing result in y index & flags\n                                    php         ;save flags\n                                    cpy #\\1     ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    pha\n                                    cmp_flag \\2\n                                    trap_ne\n                                    plp         ;restore status\n                                    endm\n                        \n                        tst_ax      macro       ;indexed testing result in accu & flags\n                                    php         ;save flags\n                                    cmp \\1,x    ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,x    ;test flags\n                                    trap_ne     ;\n                                    endm\n                        \n                        tst_ay      macro       ;indexed testing result in accu & flags\n                                    php         ;save flags\n                                    cmp \\1,y    ;test result\n                                    trap_ne     ;\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,y    ;test flags\n                                    trap_ne\n                                    endm\n                                \n                        tst_z       macro       ;indexed testing result in zp & flags\n                                    php         ;save flags\n                                    lda zpt\n                                    cmp \\1,x    ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,x    ;test flags\n                                    trap_ne\n                                    endm\n                        \n                        tst_zx      macro       ;testing result in zp,x & flags\n                                    php         ;save flags\n                                    lda zpt,x\n                                    cmp \\1,x    ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,x    ;test flags\n                                    trap_ne\n                                    endm\n                        \n                        tst_abs     macro       ;indexed testing result in memory & flags\n                                    php         ;save flags\n                                    lda abst\n                                    cmp \\1,x    ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,x    ;test flags\n                                    trap_ne\n                                    endm\n                        \n                        tst_absx    macro       ;testing result in abs,x & flags\n                                    php         ;save flags\n                                    lda abst,x\n                                    cmp \\1,x    ;test result\n                                    trap_ne\n                                    pla         ;load status\n                                    eor_flag \\3\n                                    cmp \\2,x    ;test flags\n                                    trap_ne\n                                    endm\n                                    \n                        ; RAM integrity test\n                        ;   verifies that none of the previous tests has altered RAM outside of the\n                        ;   designated write areas.\n                        ;   uses zpt word as indirect pointer, zpt+2 word as checksum\n                                if ram_top > -1\n                        check_ram   macro \n                                    cld\n                                    lda #0\n                                    sta zpt         ;set low byte of indirect pointer\n                                    sta zpt+3       ;checksum high byte\n                                  if disable_selfmod = 0\n                                    sta range_adr   ;reset self modifying code\n                                  endif\n                                    clc\n                                    ldx #zp_bss-zero_page ;zeropage - write test area\n                        ccs3\\?      adc zero_page,x\n                                    bcc ccs2\\?\n                                    inc zpt+3       ;carry to high byte\n                                    clc\n                        ccs2\\?      inx\n                                    bne ccs3\\?\n                                    ldx #hi(abs1)   ;set high byte of indirect pointer\n                                    stx zpt+1\n                                    ldy #lo(abs1)   ;data after write & execute test area\n                        ccs5\\?      adc (zpt),y\n                                    bcc ccs4\\?\n                                    inc zpt+3       ;carry to high byte\n                                    clc\n                        ccs4\\?      iny\n                                    bne ccs5\\?\n                                    inx             ;advance RAM high address\n                                    stx zpt+1\n                                    cpx #ram_top\n                                    bne ccs5\\?\n                                    sta zpt+2       ;checksum low is\n                                    cmp ram_chksm   ;checksum low expected\n                                    trap_ne         ;checksum mismatch\n                                    lda zpt+3       ;checksum high is\n                                    cmp ram_chksm+1 ;checksum high expected\n                                    trap_ne         ;checksum mismatch\n                                    endm            \n                                else\n                        check_ram   macro\n                                    ;RAM check disabled - RAM size not set\n                                    endm\n                                endif\n                        \n                        next_test   macro           ;make sure, tests don't jump the fence\n                                    lda test_case   ;previous test\n                                    cmp #test_num\n                                    trap_ne         ;test is out of sequence\n                        test_num = test_num + 1\n                                    lda #test_num   ;*** next tests' number\n                                    sta test_case\n                                    ;check_ram       ;uncomment to find altered RAM after each test\n                                    endm\n                        \n                            if load_data_direct = 1\n                                data\n                            else\n                                bss                 ;uninitialized segment, copy of data at end of code!\n                            endif\n000a =                          org zero_page\n                        ;break test interrupt save\n000a =                  irq_a   ds  1               ;a register\n000b =                  irq_x   ds  1               ;x register\n                            if I_flag = 2\n                        ;masking for I bit in status\n                        flag_I_on   ds  1           ;or mask to load flags   \n                        flag_I_off  ds  1           ;and mask to load flags\n                            endif\n000c =                  zpt                         ;5 bytes store/modify test area\n                        ;add/subtract operand generation and result/flag prediction\n000c =                  adfc    ds  1               ;carry flag before op\n000d =                  ad1     ds  1               ;operand 1 - accumulator\n000e =                  ad2     ds  1               ;operand 2 - memory / immediate\n000f =                  adrl    ds  1               ;expected result bits 0-7\n0010 =                  adrh    ds  1               ;expected result bit 8 (carry)\n0011 =                  adrf    ds  1               ;expected flags NV0000ZC (only binary mode)\n0012 =                  sb2     ds  1               ;operand 2 complemented for subtract\n0013 =                  zp_bss\n0013 =                  zp1     db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\n0017 =                  zp7f    db  $7f             ;test pattern for compare  \n                        ;logical zeropage operands\n0018 =                  zpOR    db  0,$1f,$71,$80   ;test pattern for OR\n001c =                  zpAN    db  $0f,$ff,$7f,$80 ;test pattern for AND\n0020 =                  zpEO    db  $ff,$0f,$8f,$8f ;test pattern for EOR\n                        ;indirect addressing pointers\n0024 =                  ind1    dw  abs1            ;indirect pointer to pattern in absolute memory\n0026 =                          dw  abs1+1\n0028 =                          dw  abs1+2\n002a =                          dw  abs1+3\n002c =                          dw  abs7f\n002e =                  inw1    dw  abs1-$f8        ;indirect pointer for wrap-test pattern\n0030 =                  indt    dw  abst            ;indirect pointer to store area in absolute memory\n0032 =                          dw  abst+1\n0034 =                          dw  abst+2\n0036 =                          dw  abst+3\n0038 =                  inwt    dw  abst-$f8        ;indirect pointer for wrap-test store\n003a =                  indAN   dw  absAN           ;indirect pointer to AND pattern in absolute memory\n003c =                          dw  absAN+1\n003e =                          dw  absAN+2\n0040 =                          dw  absAN+3\n0042 =                  indEO   dw  absEO           ;indirect pointer to EOR pattern in absolute memory\n0044 =                          dw  absEO+1\n0046 =                          dw  absEO+2\n0048 =                          dw  absEO+3\n004a =                  indOR   dw  absOR           ;indirect pointer to OR pattern in absolute memory\n004c =                          dw  absOR+1\n004e =                          dw  absOR+2\n0050 =                          dw  absOR+3\n                        ;add/subtract indirect pointers\n0052 =                  adi2    dw  ada2            ;indirect pointer to operand 2 in absolute memory\n0054 =                  sbi2    dw  sba2            ;indirect pointer to complemented operand 2 (SBC)\n0056 =                  adiy2   dw  ada2-$ff        ;with offset for indirect indexed\n0058 =                  sbiy2   dw  sba2-$ff\n005a =                  zp_bss_end\n                           \n0200 =                          org data_segment\n0200 =                  test_case   ds  1           ;current test number\n0201 =                  ram_chksm   ds  2           ;checksum for RAM integrity test\n                        ;add/subtract operand copy - abs tests write area\n0203 =                  abst                        ;5 bytes store/modify test area\n0203 =                  ada2    ds  1               ;operand 2\n0204 =                  sba2    ds  1               ;operand 2 complemented for subtract\n0205 =                          ds  3               ;fill remaining bytes\n0208 =                  data_bss\n                            if load_data_direct = 1\n                        ex_andi and #0              ;execute immediate opcodes\n                                rts\n                        ex_eori eor #0              ;execute immediate opcodes\n                                rts\n                        ex_orai ora #0              ;execute immediate opcodes\n                                rts\n                        ex_adci adc #0              ;execute immediate opcodes\n                                rts\n                        ex_sbci sbc #0              ;execute immediate opcodes\n                                rts\n                            else\n0208 =                  ex_andi ds  3\n020b =                  ex_eori ds  3\n020e =                  ex_orai ds  3\n0211 =                  ex_adci ds  3\n0214 =                  ex_sbci ds  3\n                            endif\n0217 =                  abs1    db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\n021b =                  abs7f   db  $7f             ;test pattern for compare\n                        ;loads\n021c =                  fLDx    db  fn,fn,0,fz      ;expected flags for load\n                        ;shifts\n0220 =                  rASL                        ;expected result ASL & ROL -carry  \n0220 =                  rROL    db  $86,$04,$82,0   ; \"\n0224 =                  rROLc   db  $87,$05,$83,1   ;expected result ROL +carry\n0228 =                  rLSR                        ;expected result LSR & ROR -carry\n0228 =                  rROR    db  $61,$41,$20,0   ; \"\n022c =                  rRORc   db  $e1,$c1,$a0,$80 ;expected result ROR +carry\n0230 =                  fASL                        ;expected flags for shifts\n0230 =                  fROL    db  fnc,fc,fn,fz    ;no carry in\n0234 =                  fROLc   db  fnc,fc,fn,0     ;carry in\n0238 =                  fLSR\n0238 =                  fROR    db  fc,0,fc,fz      ;no carry in\n023c =                  fRORc   db  fnc,fn,fnc,fn   ;carry in\n                        ;increments (decrements)\n0240 =                  rINC    db  $7f,$80,$ff,0,1 ;expected result for INC/DEC\n0245 =                  fINC    db  0,fn,fn,fz,0    ;expected flags for INC/DEC\n                        ;logical memory operand\n024a =                  absOR   db  0,$1f,$71,$80   ;test pattern for OR\n024e =                  absAN   db  $0f,$ff,$7f,$80 ;test pattern for AND\n0252 =                  absEO   db  $ff,$0f,$8f,$8f ;test pattern for EOR\n                        ;logical accu operand\n0256 =                  absORa  db  0,$f1,$1f,0     ;test pattern for OR\n025a =                  absANa  db  $f0,$ff,$ff,$ff ;test pattern for AND\n025e =                  absEOa  db  $ff,$f0,$f0,$0f ;test pattern for EOR\n                        ;logical results\n0262 =                  absrlo  db  0,$ff,$7f,$80\n0266 =                  absflo  db  fz,fn,0,fn\n026a =                  data_bss_end\n                        \n                        \n                                code\n0400 =                          org code_segment\n0400 : d8               start   cld\n0401 : a2ff                     ldx #$ff\n0403 : 9a                       txs\n0404 : a900                     lda #0          ;*** test 0 = initialize\n0406 : 8d0002                   sta test_case\n0000 =                  test_num = 0\n                        \n                        ;stop interrupts before initializing BSS\n                            if I_flag = 1\n                                sei\n                            endif\n                            \n                        ;initialize I/O for report channel\n                            if report = 1\n                                jsr report_init\n                            endif\n                            \n                        ;pretest small branch offset\n0409 : a205                     ldx #5\n040b : 4c3304                   jmp psb_test\n040e :                  psb_bwok\n040e : a005                     ldy #5\n0410 : d008                     bne psb_forw\n                                trap        ;branch should be taken\n0412 : 4c1204          >        jmp *           ;failed anyway\n                        \n0415 : 88                       dey         ;forward landing zone\n0416 : 88                       dey\n0417 : 88                       dey\n0418 : 88                       dey\n0419 : 88                       dey\n041a :                  psb_forw\n041a : 88                       dey\n041b : 88                       dey\n041c : 88                       dey\n041d : 88                       dey\n041e : 88                       dey\n041f : f017                     beq psb_fwok\n                                trap        ;forward offset\n0421 : 4c2104          >        jmp *           ;failed anyway\n                        \n                        \n0424 : ca                       dex         ;backward landing zone\n0425 : ca                       dex\n0426 : ca                       dex\n0427 : ca                       dex\n0428 : ca                       dex\n0429 :                  psb_back\n0429 : ca                       dex\n042a : ca                       dex\n042b : ca                       dex\n042c : ca                       dex\n042d : ca                       dex\n042e : f0de                     beq psb_bwok\n                                trap        ;backward offset\n0430 : 4c3004          >        jmp *           ;failed anyway\n                        \n0433 :                  psb_test\n0433 : d0f4                     bne psb_back\n                                trap        ;branch should be taken\n0435 : 4c3504          >        jmp *           ;failed anyway\n                        \n0438 :                  psb_fwok\n                                \n                        ;initialize BSS segment\n                            if load_data_direct != 1\n0438 : a246                     ldx #zp_end-zp_init-1\n043a : bddc37           ld_zp   lda zp_init,x\n043d : 9513                     sta zp_bss,x\n043f : ca                       dex\n0440 : 10f8                     bpl ld_zp\n0442 : a261                     ldx #data_end-data_init-1\n0444 : bd2338           ld_data lda data_init,x\n0447 : 9d0802                   sta data_bss,x\n044a : ca                       dex\n044b : 10f7                     bpl ld_data\n                              if ROM_vectors = 1\n044d : a205                     ldx #5\n044f : bd8538           ld_vect lda vec_init,x\n0452 : 9dfaff                   sta vec_bss,x\n0455 : ca                       dex\n0456 : 10f7                     bpl ld_vect\n                              endif\n                            endif\n                        \n                        ;retain status of interrupt flag\n                            if I_flag = 2\n                                php\n                                pla\n                                and #4          ;isolate flag\n                                sta flag_I_on   ;or mask\n                                eor #lo(~4)     ;reverse\n                                sta flag_I_off  ;and mask\n                            endif\n                                \n                        ;generate checksum for RAM integrity test\n                            if ram_top > -1\n                                lda #0 \n                                sta zpt         ;set low byte of indirect pointer\n                                sta ram_chksm+1 ;checksum high byte\n                              if disable_selfmod = 0\n                                sta range_adr   ;reset self modifying code\n                              endif\n                                clc\n                                ldx #zp_bss-zero_page ;zeropage - write test area\n                        gcs3    adc zero_page,x\n                                bcc gcs2\n                                inc ram_chksm+1 ;carry to high byte\n                                clc\n                        gcs2    inx\n                                bne gcs3\n                                ldx #hi(abs1)   ;set high byte of indirect pointer\n                                stx zpt+1\n                                ldy #lo(abs1)   ;data after write & execute test area\n                        gcs5    adc (zpt),y\n                                bcc gcs4\n                                inc ram_chksm+1 ;carry to high byte\n                                clc\n                        gcs4    iny\n                                bne gcs5\n                                inx             ;advance RAM high address\n                                stx zpt+1\n                                cpx #ram_top\n                                bne gcs5\n                                sta ram_chksm   ;checksum complete\n                            endif\n                                next_test            \n0458 : ad0002          >            lda test_case   ;previous test\n045b : c900            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n045d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0001 =                 >test_num = test_num + 1\n045f : a901            >            lda #test_num   ;*** next tests' number\n0461 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                            if disable_selfmod = 0\n                        ;testing relative addressing with BEQ\n0464 : a0fe                     ldy #$fe        ;testing maximum range, not -1/-2 (invalid/self adr)\n0466 :                  range_loop\n0466 : 88                       dey             ;next relative address\n0467 : 98                       tya\n0468 : aa                       tax             ;precharge count to end of loop\n0469 : 1008                     bpl range_fw    ;calculate relative address\n046b : 18                       clc             ;avoid branch self or to relative address of branch\n046c : 6902                     adc #2\n046e : ea                       nop             ;offset landing zone - tolerate +/-5 offset to branch\n046f : ea                       nop\n0470 : ea                       nop\n0471 : ea                       nop\n0472 : ea                       nop\n0473 :                  range_fw\n0473 : ea                       nop\n0474 : ea                       nop\n0475 : ea                       nop\n0476 : ea                       nop\n0477 : ea                       nop\n0478 : 497f                     eor #$7f        ;complement except sign\n047a : 8d0605                   sta range_adr   ;load into test target\n047d : a900                     lda #0          ;should set zero flag in status register\n047f : 4c0505                   jmp range_op\n                                \n0482 : ca                       dex             ; offset landing zone - backward branch too far\n0483 : ca                       dex\n0484 : ca                       dex\n0485 : ca                       dex\n0486 : ca                       dex\n                                ;relative address target field with branch under test in the middle\n0487 : ca                       dex             ;-128 - max backward\n0488 : ca                       dex\n0489 : ca                       dex\n048a : ca                       dex\n048b : ca                       dex\n048c : ca                       dex\n048d : ca                       dex\n048e : ca                       dex\n048f : ca                       dex             ;-120\n0490 : ca                       dex\n0491 : ca                       dex\n0492 : ca                       dex\n0493 : ca                       dex\n0494 : ca                       dex\n0495 : ca                       dex\n0496 : ca                       dex\n0497 : ca                       dex\n0498 : ca                       dex\n0499 : ca                       dex             ;-110\n049a : ca                       dex\n049b : ca                       dex\n049c : ca                       dex\n049d : ca                       dex\n049e : ca                       dex\n049f : ca                       dex\n04a0 : ca                       dex\n04a1 : ca                       dex\n04a2 : ca                       dex\n04a3 : ca                       dex             ;-100\n04a4 : ca                       dex\n04a5 : ca                       dex\n04a6 : ca                       dex\n04a7 : ca                       dex\n04a8 : ca                       dex\n04a9 : ca                       dex\n04aa : ca                       dex\n04ab : ca                       dex\n04ac : ca                       dex\n04ad : ca                       dex             ;-90\n04ae : ca                       dex\n04af : ca                       dex\n04b0 : ca                       dex\n04b1 : ca                       dex\n04b2 : ca                       dex\n04b3 : ca                       dex\n04b4 : ca                       dex\n04b5 : ca                       dex\n04b6 : ca                       dex\n04b7 : ca                       dex             ;-80\n04b8 : ca                       dex\n04b9 : ca                       dex\n04ba : ca                       dex\n04bb : ca                       dex\n04bc : ca                       dex\n04bd : ca                       dex\n04be : ca                       dex\n04bf : ca                       dex\n04c0 : ca                       dex\n04c1 : ca                       dex             ;-70\n04c2 : ca                       dex\n04c3 : ca                       dex\n04c4 : ca                       dex\n04c5 : ca                       dex\n04c6 : ca                       dex\n04c7 : ca                       dex\n04c8 : ca                       dex\n04c9 : ca                       dex\n04ca : ca                       dex\n04cb : ca                       dex             ;-60\n04cc : ca                       dex\n04cd : ca                       dex\n04ce : ca                       dex\n04cf : ca                       dex\n04d0 : ca                       dex\n04d1 : ca                       dex\n04d2 : ca                       dex\n04d3 : ca                       dex\n04d4 : ca                       dex\n04d5 : ca                       dex             ;-50\n04d6 : ca                       dex\n04d7 : ca                       dex\n04d8 : ca                       dex\n04d9 : ca                       dex\n04da : ca                       dex\n04db : ca                       dex\n04dc : ca                       dex\n04dd : ca                       dex\n04de : ca                       dex\n04df : ca                       dex             ;-40\n04e0 : ca                       dex\n04e1 : ca                       dex\n04e2 : ca                       dex\n04e3 : ca                       dex\n04e4 : ca                       dex\n04e5 : ca                       dex\n04e6 : ca                       dex\n04e7 : ca                       dex\n04e8 : ca                       dex\n04e9 : ca                       dex             ;-30\n04ea : ca                       dex\n04eb : ca                       dex\n04ec : ca                       dex\n04ed : ca                       dex\n04ee : ca                       dex\n04ef : ca                       dex\n04f0 : ca                       dex\n04f1 : ca                       dex\n04f2 : ca                       dex\n04f3 : ca                       dex             ;-20\n04f4 : ca                       dex\n04f5 : ca                       dex\n04f6 : ca                       dex\n04f7 : ca                       dex\n04f8 : ca                       dex\n04f9 : ca                       dex\n04fa : ca                       dex\n04fb : ca                       dex\n04fc : ca                       dex\n04fd : ca                       dex             ;-10\n04fe : ca                       dex\n04ff : ca                       dex\n0500 : ca                       dex\n0501 : ca                       dex\n0502 : ca                       dex\n0503 : ca                       dex\n0504 : ca                       dex             ;-3\n0505 :                  range_op                ;test target with zero flag=0, z=1 if previous dex\n0506 =                  range_adr   = *+1       ;modifiable relative address\n0505 : f03e                     beq *+64        ;+64 if called without modification\n0507 : ca                       dex             ;+0\n0508 : ca                       dex\n0509 : ca                       dex\n050a : ca                       dex\n050b : ca                       dex\n050c : ca                       dex\n050d : ca                       dex\n050e : ca                       dex\n050f : ca                       dex\n0510 : ca                       dex\n0511 : ca                       dex             ;+10\n0512 : ca                       dex\n0513 : ca                       dex\n0514 : ca                       dex\n0515 : ca                       dex\n0516 : ca                       dex\n0517 : ca                       dex\n0518 : ca                       dex\n0519 : ca                       dex\n051a : ca                       dex\n051b : ca                       dex             ;+20\n051c : ca                       dex\n051d : ca                       dex\n051e : ca                       dex\n051f : ca                       dex\n0520 : ca                       dex\n0521 : ca                       dex\n0522 : ca                       dex\n0523 : ca                       dex\n0524 : ca                       dex\n0525 : ca                       dex             ;+30\n0526 : ca                       dex\n0527 : ca                       dex\n0528 : ca                       dex\n0529 : ca                       dex\n052a : ca                       dex\n052b : ca                       dex\n052c : ca                       dex\n052d : ca                       dex\n052e : ca                       dex\n052f : ca                       dex             ;+40\n0530 : ca                       dex\n0531 : ca                       dex\n0532 : ca                       dex\n0533 : ca                       dex\n0534 : ca                       dex\n0535 : ca                       dex\n0536 : ca                       dex\n0537 : ca                       dex\n0538 : ca                       dex\n0539 : ca                       dex             ;+50\n053a : ca                       dex\n053b : ca                       dex\n053c : ca                       dex\n053d : ca                       dex\n053e : ca                       dex\n053f : ca                       dex\n0540 : ca                       dex\n0541 : ca                       dex\n0542 : ca                       dex\n0543 : ca                       dex             ;+60\n0544 : ca                       dex\n0545 : ca                       dex\n0546 : ca                       dex\n0547 : ca                       dex\n0548 : ca                       dex\n0549 : ca                       dex\n054a : ca                       dex\n054b : ca                       dex\n054c : ca                       dex\n054d : ca                       dex             ;+70\n054e : ca                       dex\n054f : ca                       dex\n0550 : ca                       dex\n0551 : ca                       dex\n0552 : ca                       dex\n0553 : ca                       dex\n0554 : ca                       dex\n0555 : ca                       dex\n0556 : ca                       dex\n0557 : ca                       dex             ;+80\n0558 : ca                       dex\n0559 : ca                       dex\n055a : ca                       dex\n055b : ca                       dex\n055c : ca                       dex\n055d : ca                       dex\n055e : ca                       dex\n055f : ca                       dex\n0560 : ca                       dex\n0561 : ca                       dex             ;+90\n0562 : ca                       dex\n0563 : ca                       dex\n0564 : ca                       dex\n0565 : ca                       dex\n0566 : ca                       dex\n0567 : ca                       dex\n0568 : ca                       dex\n0569 : ca                       dex\n056a : ca                       dex\n056b : ca                       dex             ;+100\n056c : ca                       dex\n056d : ca                       dex\n056e : ca                       dex\n056f : ca                       dex\n0570 : ca                       dex\n0571 : ca                       dex\n0572 : ca                       dex\n0573 : ca                       dex\n0574 : ca                       dex\n0575 : ca                       dex             ;+110\n0576 : ca                       dex\n0577 : ca                       dex\n0578 : ca                       dex\n0579 : ca                       dex\n057a : ca                       dex\n057b : ca                       dex\n057c : ca                       dex\n057d : ca                       dex\n057e : ca                       dex\n057f : ca                       dex             ;+120\n0580 : ca                       dex\n0581 : ca                       dex\n0582 : ca                       dex\n0583 : ca                       dex\n0584 : ca                       dex\n0585 : ca                       dex\n0586 : ea                       nop             ;offset landing zone - forward branch too far\n0587 : ea                       nop\n0588 : ea                       nop\n0589 : ea                       nop\n058a : ea                       nop\n058b : f008                     beq range_ok    ;+127 - max forward\n                                trap            ; bad range\n058d : 4c8d05          >        jmp *           ;failed anyway\n                        \n0590 : ea                       nop             ;offset landing zone - tolerate +/-5 offset to branch\n0591 : ea                       nop\n0592 : ea                       nop\n0593 : ea                       nop\n0594 : ea                       nop\n0595 :                  range_ok\n0595 : ea                       nop\n0596 : ea                       nop\n0597 : ea                       nop\n0598 : ea                       nop\n0599 : ea                       nop\n059a : c000                     cpy #0\n059c : f003                     beq range_end   \n059e : 4c6604                   jmp range_loop\n05a1 :                  range_end               ;range test successful\n                            endif\n                                next_test\n05a1 : ad0002          >            lda test_case   ;previous test\n05a4 : c901            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n05a6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0002 =                 >test_num = test_num + 1\n05a8 : a902            >            lda #test_num   ;*** next tests' number\n05aa : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ;partial test BNE & CMP, CPX, CPY immediate\n05ad : c001                     cpy #1          ;testing BNE true\n05af : d003                     bne test_bne\n                                trap \n05b1 : 4cb105          >        jmp *           ;failed anyway\n                        \n05b4 :                  test_bne\n05b4 : a900                     lda #0 \n05b6 : c900                     cmp #0          ;test compare immediate \n                                trap_ne\n05b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                trap_cc\n05ba : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_mi\n05bc : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n05be : c901                     cmp #1\n                                trap_eq \n05c0 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_cs\n05c2 : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_pl\n05c4 : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n05c6 : aa                       tax \n05c7 : e000                     cpx #0          ;test compare x immediate\n                                trap_ne\n05c9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                trap_cc\n05cb : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_mi\n05cd : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n05cf : e001                     cpx #1\n                                trap_eq \n05d1 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_cs\n05d3 : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_pl\n05d5 : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n05d7 : a8                       tay \n05d8 : c000                     cpy #0          ;test compare y immediate\n                                trap_ne\n05da : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                trap_cc\n05dc : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_mi\n05de : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n05e0 : c001                     cpy #1\n                                trap_eq \n05e2 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_cs\n05e4 : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_pl\n05e6 : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n                                next_test\n05e8 : ad0002          >            lda test_case   ;previous test\n05eb : c902            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n05ed : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0003 =                 >test_num = test_num + 1\n05ef : a903            >            lda #test_num   ;*** next tests' number\n05f1 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        ;testing stack operations PHA PHP PLA PLP\n                                    \n05f4 : a2ff                     ldx #$ff        ;initialize stack\n05f6 : 9a                       txs\n05f7 : a955                     lda #$55\n05f9 : 48                       pha\n05fa : a9aa                     lda #$aa\n05fc : 48                       pha\n05fd : cdfe01                   cmp $1fe        ;on stack ?\n                                trap_ne\n0600 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0602 : ba                       tsx\n0603 : 8a                       txa             ;overwrite accu\n0604 : c9fd                     cmp #$fd        ;sp decremented?\n                                trap_ne\n0606 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0608 : 68                       pla\n0609 : c9aa                     cmp #$aa        ;successful retreived from stack?\n                                trap_ne\n060b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n060d : 68                       pla\n060e : c955                     cmp #$55\n                                trap_ne\n0610 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0612 : cdff01                   cmp $1ff        ;remains on stack?\n                                trap_ne\n0615 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0617 : ba                       tsx\n0618 : e0ff                     cpx #$ff        ;sp incremented?\n                                trap_ne\n061a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n061c : ad0002          >            lda test_case   ;previous test\n061f : c903            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0621 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0004 =                 >test_num = test_num + 1\n0623 : a904            >            lda #test_num   ;*** next tests' number\n0625 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ;testing branch decisions BPL BMI BVC BVS BCC BCS BNE BEQ\n                                set_stat $ff    ;all on\n                       >            load_flag $ff    \n0628 : a9ff            >            lda #$ff                 ;allow test to change I-flag (no mask)\n                       >\n062a : 48              >            pha         ;use stack to load status\n062b : 28              >            plp\n                        \n062c : 101a                     bpl nbr1        ;branches should not be taken\n062e : 501b                     bvc nbr2\n0630 : 901c                     bcc nbr3\n0632 : d01d                     bne nbr4\n0634 : 3003                     bmi br1         ;branches should be taken\n                                trap \n0636 : 4c3606          >        jmp *           ;failed anyway\n                        \n0639 : 7003             br1     bvs br2\n                                trap \n063b : 4c3b06          >        jmp *           ;failed anyway\n                        \n063e : b003             br2     bcs br3\n                                trap \n0640 : 4c4006          >        jmp *           ;failed anyway\n                        \n0643 : f00f             br3     beq br4\n                                trap \n0645 : 4c4506          >        jmp *           ;failed anyway\n                        \n0648 :                  nbr1\n                                trap            ;previous bpl taken \n0648 : 4c4806          >        jmp *           ;failed anyway\n                        \n064b :                  nbr2\n                                trap            ;previous bvc taken\n064b : 4c4b06          >        jmp *           ;failed anyway\n                        \n064e :                  nbr3\n                                trap            ;previous bcc taken\n064e : 4c4e06          >        jmp *           ;failed anyway\n                        \n0651 :                  nbr4\n                                trap            ;previous bne taken\n0651 : 4c5106          >        jmp *           ;failed anyway\n                        \n0654 : 08               br4     php\n0655 : ba                       tsx\n0656 : e0fe                     cpx #$fe        ;sp after php?\n                                trap_ne\n0658 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n065a : 68                       pla\n                                cmp_flag $ff    ;returned all flags on?\n065b : c9ff            >            cmp #($ff    |fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n065d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n065f : ba                       tsx\n0660 : e0ff                     cpx #$ff        ;sp after php?\n                                trap_ne\n0662 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0      ;all off\n                       >            load_flag 0      \n0664 : a900            >            lda #0                   ;allow test to change I-flag (no mask)\n                       >\n0666 : 48              >            pha         ;use stack to load status\n0667 : 28              >            plp\n                        \n0668 : 301a                     bmi nbr11       ;branches should not be taken\n066a : 701b                     bvs nbr12\n066c : b01c                     bcs nbr13\n066e : f01d                     beq nbr14\n0670 : 1003                     bpl br11        ;branches should be taken\n                                trap \n0672 : 4c7206          >        jmp *           ;failed anyway\n                        \n0675 : 5003             br11    bvc br12\n                                trap \n0677 : 4c7706          >        jmp *           ;failed anyway\n                        \n067a : 9003             br12    bcc br13\n                                trap \n067c : 4c7c06          >        jmp *           ;failed anyway\n                        \n067f : d00f             br13    bne br14\n                                trap \n0681 : 4c8106          >        jmp *           ;failed anyway\n                        \n0684 :                  nbr11\n                                trap            ;previous bmi taken \n0684 : 4c8406          >        jmp *           ;failed anyway\n                        \n0687 :                  nbr12\n                                trap            ;previous bvs taken \n0687 : 4c8706          >        jmp *           ;failed anyway\n                        \n068a :                  nbr13\n                                trap            ;previous bcs taken \n068a : 4c8a06          >        jmp *           ;failed anyway\n                        \n068d :                  nbr14\n                                trap            ;previous beq taken \n068d : 4c8d06          >        jmp *           ;failed anyway\n                        \n0690 : 08               br14    php\n0691 : 68                       pla\n                                cmp_flag 0      ;flags off except break (pushed by sw) + reserved?\n0692 : c930            >            cmp #(0      |fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0694 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                ;crosscheck flags\n                                set_stat zero\n                       >            load_flag zero\n0696 : a902            >            lda #zero             ;allow test to change I-flag (no mask)\n                       >\n0698 : 48              >            pha         ;use stack to load status\n0699 : 28              >            plp\n                        \n069a : d002                     bne brzs1\n069c : f003                     beq brzs2\n069e :                  brzs1\n                                trap            ;branch zero/non zero\n069e : 4c9e06          >        jmp *           ;failed anyway\n                        \n06a1 : b002             brzs2   bcs brzs3\n06a3 : 9003                     bcc brzs4\n06a5 :                  brzs3\n                                trap            ;branch carry/no carry\n06a5 : 4ca506          >        jmp *           ;failed anyway\n                        \n06a8 : 3002             brzs4   bmi brzs5\n06aa : 1003                     bpl brzs6\n06ac :                  brzs5\n                                trap            ;branch minus/plus\n06ac : 4cac06          >        jmp *           ;failed anyway\n                        \n06af : 7002             brzs6   bvs brzs7\n06b1 : 5003                     bvc brzs8\n06b3 :                  brzs7\n                                trap            ;branch overflow/no overflow\n06b3 : 4cb306          >        jmp *           ;failed anyway\n                        \n06b6 :                  brzs8\n                                set_stat carry\n                       >            load_flag carry\n06b6 : a901            >            lda #carry             ;allow test to change I-flag (no mask)\n                       >\n06b8 : 48              >            pha         ;use stack to load status\n06b9 : 28              >            plp\n                        \n06ba : f002                     beq brcs1\n06bc : d003                     bne brcs2\n06be :                  brcs1\n                                trap            ;branch zero/non zero\n06be : 4cbe06          >        jmp *           ;failed anyway\n                        \n06c1 : 9002             brcs2   bcc brcs3\n06c3 : b003                     bcs brcs4\n06c5 :                  brcs3\n                                trap            ;branch carry/no carry\n06c5 : 4cc506          >        jmp *           ;failed anyway\n                        \n06c8 : 3002             brcs4   bmi brcs5\n06ca : 1003                     bpl brcs6\n06cc :                  brcs5\n                                trap            ;branch minus/plus\n06cc : 4ccc06          >        jmp *           ;failed anyway\n                        \n06cf : 7002             brcs6   bvs brcs7\n06d1 : 5003                     bvc brcs8\n06d3 :                  brcs7\n                                trap            ;branch overflow/no overflow\n06d3 : 4cd306          >        jmp *           ;failed anyway\n                        \n                        \n06d6 :                  brcs8\n                                set_stat minus\n                       >            load_flag minus\n06d6 : a980            >            lda #minus             ;allow test to change I-flag (no mask)\n                       >\n06d8 : 48              >            pha         ;use stack to load status\n06d9 : 28              >            plp\n                        \n06da : f002                     beq brmi1\n06dc : d003                     bne brmi2\n06de :                  brmi1\n                                trap            ;branch zero/non zero\n06de : 4cde06          >        jmp *           ;failed anyway\n                        \n06e1 : b002             brmi2   bcs brmi3\n06e3 : 9003                     bcc brmi4\n06e5 :                  brmi3\n                                trap            ;branch carry/no carry\n06e5 : 4ce506          >        jmp *           ;failed anyway\n                        \n06e8 : 1002             brmi4   bpl brmi5\n06ea : 3003                     bmi brmi6\n06ec :                  brmi5\n                                trap            ;branch minus/plus\n06ec : 4cec06          >        jmp *           ;failed anyway\n                        \n06ef : 7002             brmi6   bvs brmi7\n06f1 : 5003                     bvc brmi8\n06f3 :                  brmi7\n                                trap            ;branch overflow/no overflow\n06f3 : 4cf306          >        jmp *           ;failed anyway\n                        \n06f6 :                  brmi8\n                                set_stat overfl\n                       >            load_flag overfl\n06f6 : a940            >            lda #overfl             ;allow test to change I-flag (no mask)\n                       >\n06f8 : 48              >            pha         ;use stack to load status\n06f9 : 28              >            plp\n                        \n06fa : f002                     beq brvs1\n06fc : d003                     bne brvs2\n06fe :                  brvs1\n                                trap            ;branch zero/non zero\n06fe : 4cfe06          >        jmp *           ;failed anyway\n                        \n0701 : b002             brvs2   bcs brvs3\n0703 : 9003                     bcc brvs4\n0705 :                  brvs3\n                                trap            ;branch carry/no carry\n0705 : 4c0507          >        jmp *           ;failed anyway\n                        \n0708 : 3002             brvs4   bmi brvs5\n070a : 1003                     bpl brvs6\n070c :                  brvs5\n                                trap            ;branch minus/plus\n070c : 4c0c07          >        jmp *           ;failed anyway\n                        \n070f : 5002             brvs6   bvc brvs7\n0711 : 7003                     bvs brvs8\n0713 :                  brvs7\n                                trap            ;branch overflow/no overflow\n0713 : 4c1307          >        jmp *           ;failed anyway\n                        \n0716 :                  brvs8\n                                set_stat $ff-zero\n                       >            load_flag $ff-zero\n0716 : a9fd            >            lda #$ff-zero             ;allow test to change I-flag (no mask)\n                       >\n0718 : 48              >            pha         ;use stack to load status\n0719 : 28              >            plp\n                        \n071a : f002                     beq brzc1\n071c : d003                     bne brzc2\n071e :                  brzc1\n                                trap            ;branch zero/non zero\n071e : 4c1e07          >        jmp *           ;failed anyway\n                        \n0721 : 9002             brzc2   bcc brzc3\n0723 : b003                     bcs brzc4\n0725 :                  brzc3\n                                trap            ;branch carry/no carry\n0725 : 4c2507          >        jmp *           ;failed anyway\n                        \n0728 : 1002             brzc4   bpl brzc5\n072a : 3003                     bmi brzc6\n072c :                  brzc5\n                                trap            ;branch minus/plus\n072c : 4c2c07          >        jmp *           ;failed anyway\n                        \n072f : 5002             brzc6   bvc brzc7\n0731 : 7003                     bvs brzc8\n0733 :                  brzc7\n                                trap            ;branch overflow/no overflow\n0733 : 4c3307          >        jmp *           ;failed anyway\n                        \n0736 :                  brzc8\n                                set_stat $ff-carry\n                       >            load_flag $ff-carry\n0736 : a9fe            >            lda #$ff-carry             ;allow test to change I-flag (no mask)\n                       >\n0738 : 48              >            pha         ;use stack to load status\n0739 : 28              >            plp\n                        \n073a : d002                     bne brcc1\n073c : f003                     beq brcc2\n073e :                  brcc1\n                                trap            ;branch zero/non zero\n073e : 4c3e07          >        jmp *           ;failed anyway\n                        \n0741 : b002             brcc2   bcs brcc3\n0743 : 9003                     bcc brcc4\n0745 :                  brcc3\n                                trap            ;branch carry/no carry\n0745 : 4c4507          >        jmp *           ;failed anyway\n                        \n0748 : 1002             brcc4   bpl brcc5\n074a : 3003                     bmi brcc6\n074c :                  brcc5\n                                trap            ;branch minus/plus\n074c : 4c4c07          >        jmp *           ;failed anyway\n                        \n074f : 5002             brcc6   bvc brcc7\n0751 : 7003                     bvs brcc8\n0753 :                  brcc7\n                                trap            ;branch overflow/no overflow\n0753 : 4c5307          >        jmp *           ;failed anyway\n                        \n0756 :                  brcc8\n                                set_stat $ff-minus\n                       >            load_flag $ff-minus\n0756 : a97f            >            lda #$ff-minus             ;allow test to change I-flag (no mask)\n                       >\n0758 : 48              >            pha         ;use stack to load status\n0759 : 28              >            plp\n                        \n075a : d002                     bne brpl1\n075c : f003                     beq brpl2\n075e :                  brpl1\n                                trap            ;branch zero/non zero\n075e : 4c5e07          >        jmp *           ;failed anyway\n                        \n0761 : 9002             brpl2   bcc brpl3\n0763 : b003                     bcs brpl4\n0765 :                  brpl3\n                                trap            ;branch carry/no carry\n0765 : 4c6507          >        jmp *           ;failed anyway\n                        \n0768 : 3002             brpl4   bmi brpl5\n076a : 1003                     bpl brpl6\n076c :                  brpl5\n                                trap            ;branch minus/plus\n076c : 4c6c07          >        jmp *           ;failed anyway\n                        \n076f : 5002             brpl6   bvc brpl7\n0771 : 7003                     bvs brpl8\n0773 :                  brpl7\n                                trap            ;branch overflow/no overflow\n0773 : 4c7307          >        jmp *           ;failed anyway\n                        \n0776 :                  brpl8\n                                set_stat $ff-overfl\n                       >            load_flag $ff-overfl\n0776 : a9bf            >            lda #$ff-overfl             ;allow test to change I-flag (no mask)\n                       >\n0778 : 48              >            pha         ;use stack to load status\n0779 : 28              >            plp\n                        \n077a : d002                     bne brvc1\n077c : f003                     beq brvc2\n077e :                  brvc1\n                                trap            ;branch zero/non zero\n077e : 4c7e07          >        jmp *           ;failed anyway\n                        \n0781 : 9002             brvc2   bcc brvc3\n0783 : b003                     bcs brvc4\n0785 :                  brvc3\n                                trap            ;branch carry/no carry\n0785 : 4c8507          >        jmp *           ;failed anyway\n                        \n0788 : 1002             brvc4   bpl brvc5\n078a : 3003                     bmi brvc6\n078c :                  brvc5\n                                trap            ;branch minus/plus\n078c : 4c8c07          >        jmp *           ;failed anyway\n                        \n078f : 7002             brvc6   bvs brvc7\n0791 : 5003                     bvc brvc8\n0793 :                  brvc7\n                                trap            ;branch overflow/no overflow\n0793 : 4c9307          >        jmp *           ;failed anyway\n                        \n0796 :                  brvc8\n                                next_test\n0796 : ad0002          >            lda test_case   ;previous test\n0799 : c904            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n079b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0005 =                 >test_num = test_num + 1\n079d : a905            >            lda #test_num   ;*** next tests' number\n079f : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; test PHA does not alter flags or accumulator but PLA does\n07a2 : a255                     ldx #$55        ;x & y protected\n07a4 : a0aa                     ldy #$aa\n                                set_a 1,$ff     ;push\n                       >            load_flag $ff     \n07a6 : a9ff            >            lda #$ff                  ;allow test to change I-flag (no mask)\n                       >\n07a8 : 48              >            pha         ;use stack to load status\n07a9 : a901            >            lda #1     ;precharge accu\n07ab : 28              >            plp\n                        \n07ac : 48                       pha\n                                tst_a 1,$ff\n07ad : 08              >            php         ;save flags\n07ae : c901            >            cmp #1     ;test result\n                       >            trap_ne\n07b0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07b2 : 68              >            pla         ;load status\n07b3 : 48              >            pha\n                       >            cmp_flag $ff\n07b4 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n07b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07b8 : 28              >            plp         ;restore status\n                        \n                                set_a 0,0\n                       >            load_flag 0\n07b9 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n07bb : 48              >            pha         ;use stack to load status\n07bc : a900            >            lda #0     ;precharge accu\n07be : 28              >            plp\n                        \n07bf : 48                       pha\n                                tst_a 0,0\n07c0 : 08              >            php         ;save flags\n07c1 : c900            >            cmp #0     ;test result\n                       >            trap_ne\n07c3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07c5 : 68              >            pla         ;load status\n07c6 : 48              >            pha\n                       >            cmp_flag 0\n07c7 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n07c9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07cb : 28              >            plp         ;restore status\n                        \n                                set_a $ff,$ff\n                       >            load_flag $ff\n07cc : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n07ce : 48              >            pha         ;use stack to load status\n07cf : a9ff            >            lda #$ff     ;precharge accu\n07d1 : 28              >            plp\n                        \n07d2 : 48                       pha\n                                tst_a $ff,$ff\n07d3 : 08              >            php         ;save flags\n07d4 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n07d6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07d8 : 68              >            pla         ;load status\n07d9 : 48              >            pha\n                       >            cmp_flag $ff\n07da : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n07dc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07de : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n07df : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n07e1 : 48              >            pha         ;use stack to load status\n07e2 : a901            >            lda #1     ;precharge accu\n07e4 : 28              >            plp\n                        \n07e5 : 48                       pha\n                                tst_a 1,0\n07e6 : 08              >            php         ;save flags\n07e7 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n07e9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07eb : 68              >            pla         ;load status\n07ec : 48              >            pha\n                       >            cmp_flag 0\n07ed : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n07ef : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07f1 : 28              >            plp         ;restore status\n                        \n                                set_a 0,$ff\n                       >            load_flag $ff\n07f2 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n07f4 : 48              >            pha         ;use stack to load status\n07f5 : a900            >            lda #0     ;precharge accu\n07f7 : 28              >            plp\n                        \n07f8 : 48                       pha\n                                tst_a 0,$ff\n07f9 : 08              >            php         ;save flags\n07fa : c900            >            cmp #0     ;test result\n                       >            trap_ne\n07fc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n07fe : 68              >            pla         ;load status\n07ff : 48              >            pha\n                       >            cmp_flag $ff\n0800 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0802 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0804 : 28              >            plp         ;restore status\n                        \n                                set_a $ff,0\n                       >            load_flag 0\n0805 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0807 : 48              >            pha         ;use stack to load status\n0808 : a9ff            >            lda #$ff     ;precharge accu\n080a : 28              >            plp\n                        \n080b : 48                       pha\n                                tst_a $ff,0\n080c : 08              >            php         ;save flags\n080d : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n080f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0811 : 68              >            pla         ;load status\n0812 : 48              >            pha\n                       >            cmp_flag 0\n0813 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0815 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0817 : 28              >            plp         ;restore status\n                        \n                                set_a 0,$ff     ;pull\n                       >            load_flag $ff     \n0818 : a9ff            >            lda #$ff                  ;allow test to change I-flag (no mask)\n                       >\n081a : 48              >            pha         ;use stack to load status\n081b : a900            >            lda #0     ;precharge accu\n081d : 28              >            plp\n                        \n081e : 68                       pla\n                                tst_a $ff,$ff-zero\n081f : 08              >            php         ;save flags\n0820 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n0822 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0824 : 68              >            pla         ;load status\n0825 : 48              >            pha\n                       >            cmp_flag $ff-zero\n0826 : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0828 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n082a : 28              >            plp         ;restore status\n                        \n                                set_a $ff,0\n                       >            load_flag 0\n082b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n082d : 48              >            pha         ;use stack to load status\n082e : a9ff            >            lda #$ff     ;precharge accu\n0830 : 28              >            plp\n                        \n0831 : 68                       pla\n                                tst_a 0,zero\n0832 : 08              >            php         ;save flags\n0833 : c900            >            cmp #0     ;test result\n                       >            trap_ne\n0835 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0837 : 68              >            pla         ;load status\n0838 : 48              >            pha\n                       >            cmp_flag zero\n0839 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n083b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n083d : 28              >            plp         ;restore status\n                        \n                                set_a $fe,$ff\n                       >            load_flag $ff\n083e : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0840 : 48              >            pha         ;use stack to load status\n0841 : a9fe            >            lda #$fe     ;precharge accu\n0843 : 28              >            plp\n                        \n0844 : 68                       pla\n                                tst_a 1,$ff-zero-minus\n0845 : 08              >            php         ;save flags\n0846 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0848 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n084a : 68              >            pla         ;load status\n084b : 48              >            pha\n                       >            cmp_flag $ff-zero-minus\n084c : c97d            >            cmp #($ff-zero-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n084e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0850 : 28              >            plp         ;restore status\n                        \n                                set_a 0,0\n                       >            load_flag 0\n0851 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0853 : 48              >            pha         ;use stack to load status\n0854 : a900            >            lda #0     ;precharge accu\n0856 : 28              >            plp\n                        \n0857 : 68                       pla\n                                tst_a $ff,minus\n0858 : 08              >            php         ;save flags\n0859 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n085b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n085d : 68              >            pla         ;load status\n085e : 48              >            pha\n                       >            cmp_flag minus\n085f : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0861 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0863 : 28              >            plp         ;restore status\n                        \n                                set_a $ff,$ff\n                       >            load_flag $ff\n0864 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0866 : 48              >            pha         ;use stack to load status\n0867 : a9ff            >            lda #$ff     ;precharge accu\n0869 : 28              >            plp\n                        \n086a : 68                       pla\n                                tst_a 0,$ff-minus\n086b : 08              >            php         ;save flags\n086c : c900            >            cmp #0     ;test result\n                       >            trap_ne\n086e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0870 : 68              >            pla         ;load status\n0871 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0872 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0874 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0876 : 28              >            plp         ;restore status\n                        \n                                set_a $fe,0\n                       >            load_flag 0\n0877 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0879 : 48              >            pha         ;use stack to load status\n087a : a9fe            >            lda #$fe     ;precharge accu\n087c : 28              >            plp\n                        \n087d : 68                       pla\n                                tst_a 1,0\n087e : 08              >            php         ;save flags\n087f : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0881 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0883 : 68              >            pla         ;load status\n0884 : 48              >            pha\n                       >            cmp_flag 0\n0885 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0887 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0889 : 28              >            plp         ;restore status\n                        \n088a : e055                     cpx #$55        ;x & y unchanged?\n                                trap_ne\n088c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n088e : c0aa                     cpy #$aa\n                                trap_ne\n0890 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n0892 : ad0002          >            lda test_case   ;previous test\n0895 : c905            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0897 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0006 =                 >test_num = test_num + 1\n0899 : a906            >            lda #test_num   ;*** next tests' number\n089b : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                         \n                        ; partial pretest EOR #\n                                set_a $3c,0\n                       >            load_flag 0\n089e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n08a0 : 48              >            pha         ;use stack to load status\n08a1 : a93c            >            lda #$3c     ;precharge accu\n08a3 : 28              >            plp\n                        \n08a4 : 49c3                     eor #$c3\n                                tst_a $ff,fn\n08a6 : 08              >            php         ;save flags\n08a7 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n08a9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08ab : 68              >            pla         ;load status\n08ac : 48              >            pha\n                       >            cmp_flag fn\n08ad : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n08af : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08b1 : 28              >            plp         ;restore status\n                        \n                                set_a $c3,0\n                       >            load_flag 0\n08b2 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n08b4 : 48              >            pha         ;use stack to load status\n08b5 : a9c3            >            lda #$c3     ;precharge accu\n08b7 : 28              >            plp\n                        \n08b8 : 49c3                     eor #$c3\n                                tst_a 0,fz\n08ba : 08              >            php         ;save flags\n08bb : c900            >            cmp #0     ;test result\n                       >            trap_ne\n08bd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08bf : 68              >            pla         ;load status\n08c0 : 48              >            pha\n                       >            cmp_flag fz\n08c1 : c932            >            cmp #(fz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n08c3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08c5 : 28              >            plp         ;restore status\n                        \n                                next_test\n08c6 : ad0002          >            lda test_case   ;previous test\n08c9 : c906            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n08cb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0007 =                 >test_num = test_num + 1\n08cd : a907            >            lda #test_num   ;*** next tests' number\n08cf : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; PC modifying instructions except branches (NOP, JMP, JSR, RTS, BRK, RTI)\n                        ; testing NOP\n08d2 : a224                     ldx #$24\n08d4 : a042                     ldy #$42\n                                set_a $18,0\n                       >            load_flag 0\n08d6 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n08d8 : 48              >            pha         ;use stack to load status\n08d9 : a918            >            lda #$18     ;precharge accu\n08db : 28              >            plp\n                        \n08dc : ea                       nop\n                                tst_a $18,0\n08dd : 08              >            php         ;save flags\n08de : c918            >            cmp #$18     ;test result\n                       >            trap_ne\n08e0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08e2 : 68              >            pla         ;load status\n08e3 : 48              >            pha\n                       >            cmp_flag 0\n08e4 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n08e6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n08e8 : 28              >            plp         ;restore status\n                        \n08e9 : e024                     cpx #$24\n                                trap_ne\n08eb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n08ed : c042                     cpy #$42\n                                trap_ne\n08ef : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n08f1 : a2db                     ldx #$db\n08f3 : a0bd                     ldy #$bd\n                                set_a $e7,$ff\n                       >            load_flag $ff\n08f5 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n08f7 : 48              >            pha         ;use stack to load status\n08f8 : a9e7            >            lda #$e7     ;precharge accu\n08fa : 28              >            plp\n                        \n08fb : ea                       nop\n                                tst_a $e7,$ff\n08fc : 08              >            php         ;save flags\n08fd : c9e7            >            cmp #$e7     ;test result\n                       >            trap_ne\n08ff : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0901 : 68              >            pla         ;load status\n0902 : 48              >            pha\n                       >            cmp_flag $ff\n0903 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0905 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0907 : 28              >            plp         ;restore status\n                        \n0908 : e0db                     cpx #$db\n                                trap_ne\n090a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n090c : c0bd                     cpy #$bd\n                                trap_ne\n090e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n0910 : ad0002          >            lda test_case   ;previous test\n0913 : c907            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0915 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0008 =                 >test_num = test_num + 1\n0917 : a908            >            lda #test_num   ;*** next tests' number\n0919 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; jump absolute\n                                set_stat $0\n                       >            load_flag $0\n091c : a900            >            lda #$0             ;allow test to change I-flag (no mask)\n                       >\n091e : 48              >            pha         ;use stack to load status\n091f : 28              >            plp\n                        \n0920 : a946                     lda #'F'\n0922 : a241                     ldx #'A'\n0924 : a052                     ldy #'R'        ;N=0, V=0, Z=0, C=0\n0926 : 4ce936                   jmp test_far\n0929 : ea                       nop\n092a : ea                       nop\n                                trap_ne         ;runover protection\n092b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n092d : e8                       inx\n092e : e8                       inx\n092f :                  far_ret \n                                trap_eq         ;returned flags OK?\n092f : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_pl\n0931 : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n                                trap_cc\n0933 : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_vc\n0935 : 50fe            >        bvc *           ;failed overflow clear\n                        \n0937 : c9ec                     cmp #('F'^$aa)  ;returned registers OK?\n                                trap_ne\n0939 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n093b : e042                     cpx #('A'+1)\n                                trap_ne\n093d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n093f : c04f                     cpy #('R'-3)\n                                trap_ne\n0941 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0943 : ca                       dex\n0944 : c8                       iny\n0945 : c8                       iny\n0946 : c8                       iny\n0947 : 49aa                     eor #$aa        ;N=0, V=1, Z=0, C=1\n0949 : 4c5209                   jmp test_near\n094c : ea                       nop\n094d : ea                       nop\n                                trap_ne         ;runover protection\n094e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0950 : e8                       inx\n0951 : e8                       inx\n0952 :                  test_near\n                                trap_eq         ;passed flags OK?\n0952 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_mi\n0954 : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n                                trap_cc\n0956 : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_vc\n0958 : 50fe            >        bvc *           ;failed overflow clear\n                        \n095a : c946                     cmp #'F'        ;passed registers OK?\n                                trap_ne\n095c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n095e : e041                     cpx #'A'\n                                trap_ne\n0960 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0962 : c052                     cpy #'R'\n                                trap_ne\n0964 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n0966 : ad0002          >            lda test_case   ;previous test\n0969 : c908            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n096b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0009 =                 >test_num = test_num + 1\n096d : a909            >            lda #test_num   ;*** next tests' number\n096f : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; jump indirect\n                                set_stat 0\n                       >            load_flag 0\n0972 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0974 : 48              >            pha         ;use stack to load status\n0975 : 28              >            plp\n                        \n0976 : a949                     lda #'I'\n0978 : a24e                     ldx #'N'\n097a : a044                     ldy #'D'        ;N=0, V=0, Z=0, C=0\n097c : 6c1837                   jmp (ptr_tst_ind)\n097f : ea                       nop\n                                trap_ne         ;runover protection\n0980 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0982 : 88                       dey\n0983 : 88                       dey\n0984 :                  ind_ret \n0984 : 08                       php             ;either SP or Y count will fail, if we do not hit\n0985 : 88                       dey\n0986 : 88                       dey\n0987 : 88                       dey\n0988 : 28                       plp\n                                trap_eq         ;returned flags OK?\n0989 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_pl\n098b : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n                                trap_cc\n098d : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_vc\n098f : 50fe            >        bvc *           ;failed overflow clear\n                        \n0991 : c9e3                     cmp #('I'^$aa)  ;returned registers OK?\n                                trap_ne\n0993 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0995 : e04f                     cpx #('N'+1)\n                                trap_ne\n0997 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0999 : c03e                     cpy #('D'-6)\n                                trap_ne\n099b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n099d : ba                       tsx             ;SP check\n099e : e0ff                     cpx #$ff\n                                trap_ne\n09a0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n09a2 : ad0002          >            lda test_case   ;previous test\n09a5 : c909            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n09a7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000a =                 >test_num = test_num + 1\n09a9 : a90a            >            lda #test_num   ;*** next tests' number\n09ab : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; jump subroutine & return from subroutine\n                                set_stat 0\n                       >            load_flag 0\n09ae : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n09b0 : 48              >            pha         ;use stack to load status\n09b1 : 28              >            plp\n                        \n09b2 : a94a                     lda #'J'\n09b4 : a253                     ldx #'S'\n09b6 : a052                     ldy #'R'        ;N=0, V=0, Z=0, C=0\n09b8 : 205437                   jsr test_jsr\n09ba =                  jsr_ret = *-1           ;last address of jsr = return address\n09bb : 08                       php             ;either SP or Y count will fail, if we do not hit\n09bc : 88                       dey\n09bd : 88                       dey\n09be : 88                       dey\n09bf : 28                       plp\n                                trap_eq         ;returned flags OK?\n09c0 : f0fe            >        beq *           ;failed equal (zero)\n                        \n                                trap_pl\n09c2 : 10fe            >        bpl *           ;failed plus (bit 7 clear)\n                        \n                                trap_cc\n09c4 : 90fe            >        bcc *           ;failed carry clear\n                        \n                                trap_vc\n09c6 : 50fe            >        bvc *           ;failed overflow clear\n                        \n09c8 : c9e0                     cmp #('J'^$aa)  ;returned registers OK?\n                                trap_ne\n09ca : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n09cc : e054                     cpx #('S'+1)\n                                trap_ne\n09ce : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n09d0 : c04c                     cpy #('R'-6)\n                                trap_ne\n09d2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n09d4 : ba                       tsx             ;sp?\n09d5 : e0ff                     cpx #$ff\n                                trap_ne\n09d7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n09d9 : ad0002          >            lda test_case   ;previous test\n09dc : c90a            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n09de : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000b =                 >test_num = test_num + 1\n09e0 : a90b            >            lda #test_num   ;*** next tests' number\n09e2 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; break & return from interrupt\n                            if ROM_vectors = 1\n                                set_stat 0\n                       >            load_flag 0\n09e5 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n09e7 : 48              >            pha         ;use stack to load status\n09e8 : 28              >            plp\n                        \n09e9 : a942                     lda #'B'\n09eb : a252                     ldx #'R'\n09ed : a04b                     ldy #'K'        ;N=0, V=0, Z=0, C=0\n09ef : 00                       brk\n                            else\n                                lda #hi brk_ret ;emulated break\n                                pha\n                                lda #lo brk_ret\n                                pha\n                                lda #fao        ;set break & unused on stack\n                                pha\n                                set_stat intdis\n                                lda #'B'\n                                ldx #'R'\n                                ldy #'K'        ;N=0, V=0, Z=0, C=0\n                                jmp irq_trap\n                            endif\n09f0 : 88                       dey             ;should not be executed\n09f1 :                  brk_ret                 ;address of break return\n09f1 : 08                       php             ;either SP or Y count will fail, if we do not hit\n09f2 : 88                       dey\n09f3 : 88                       dey\n09f4 : 88                       dey\n09f5 : c9e8                     cmp #('B'^$aa)  ;returned registers OK?\n                                trap_ne\n09f7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n09f9 : e053                     cpx #('R'+1)\n                                trap_ne\n09fb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n09fd : c045                     cpy #('K'-6)\n                                trap_ne\n09ff : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0a01 : 68                       pla             ;returned flags OK (unchanged)?\n                                cmp_flag 0\n0a02 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0a04 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0a06 : ba                       tsx             ;sp?\n0a07 : e0ff                     cpx #$ff\n                                trap_ne\n0a09 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                next_test\n0a0b : ad0002          >            lda test_case   ;previous test\n0a0e : c90b            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0a10 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000c =                 >test_num = test_num + 1\n0a12 : a90c            >            lda #test_num   ;*** next tests' number\n0a14 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                         \n                        ; test set and clear flags CLC CLI CLD CLV SEC SEI SED\n                                set_stat $ff\n                       >            load_flag $ff\n0a17 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0a19 : 48              >            pha         ;use stack to load status\n0a1a : 28              >            plp\n                        \n0a1b : 18                       clc\n                                tst_stat $ff-carry\n0a1c : 08              >            php         ;save status\n0a1d : 68              >            pla         ;use stack to retrieve status\n0a1e : 48              >            pha\n                       >            cmp_flag $ff-carry\n0a1f : c9fe            >            cmp #($ff-carry|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a21 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a23 : 28              >            plp         ;restore status\n                        \n0a24 : 38                       sec\n                                tst_stat $ff\n0a25 : 08              >            php         ;save status\n0a26 : 68              >            pla         ;use stack to retrieve status\n0a27 : 48              >            pha\n                       >            cmp_flag $ff\n0a28 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a2a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a2c : 28              >            plp         ;restore status\n                        \n                            if I_flag = 3\n0a2d : 58                       cli\n                                tst_stat $ff-intdis\n0a2e : 08              >            php         ;save status\n0a2f : 68              >            pla         ;use stack to retrieve status\n0a30 : 48              >            pha\n                       >            cmp_flag $ff-intdis\n0a31 : c9fb            >            cmp #($ff-intdis|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a33 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a35 : 28              >            plp         ;restore status\n                        \n0a36 : 78                       sei\n                                tst_stat $ff\n0a37 : 08              >            php         ;save status\n0a38 : 68              >            pla         ;use stack to retrieve status\n0a39 : 48              >            pha\n                       >            cmp_flag $ff\n0a3a : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a3c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a3e : 28              >            plp         ;restore status\n                        \n                            endif\n0a3f : d8                       cld\n                                tst_stat $ff-decmode\n0a40 : 08              >            php         ;save status\n0a41 : 68              >            pla         ;use stack to retrieve status\n0a42 : 48              >            pha\n                       >            cmp_flag $ff-decmode\n0a43 : c9f7            >            cmp #($ff-decmode|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a45 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a47 : 28              >            plp         ;restore status\n                        \n0a48 : f8                       sed\n                                tst_stat $ff\n0a49 : 08              >            php         ;save status\n0a4a : 68              >            pla         ;use stack to retrieve status\n0a4b : 48              >            pha\n                       >            cmp_flag $ff\n0a4c : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a4e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a50 : 28              >            plp         ;restore status\n                        \n0a51 : b8                       clv\n                                tst_stat $ff-overfl\n0a52 : 08              >            php         ;save status\n0a53 : 68              >            pla         ;use stack to retrieve status\n0a54 : 48              >            pha\n                       >            cmp_flag $ff-overfl\n0a55 : c9bf            >            cmp #($ff-overfl|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a57 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a59 : 28              >            plp         ;restore status\n                        \n                                set_stat 0\n                       >            load_flag 0\n0a5a : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0a5c : 48              >            pha         ;use stack to load status\n0a5d : 28              >            plp\n                        \n                                tst_stat 0\n0a5e : 08              >            php         ;save status\n0a5f : 68              >            pla         ;use stack to retrieve status\n0a60 : 48              >            pha\n                       >            cmp_flag 0\n0a61 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a63 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a65 : 28              >            plp         ;restore status\n                        \n0a66 : 38                       sec\n                                tst_stat carry\n0a67 : 08              >            php         ;save status\n0a68 : 68              >            pla         ;use stack to retrieve status\n0a69 : 48              >            pha\n                       >            cmp_flag carry\n0a6a : c931            >            cmp #(carry|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a6c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a6e : 28              >            plp         ;restore status\n                        \n0a6f : 18                       clc\n                                tst_stat 0  \n0a70 : 08              >            php         ;save status\n0a71 : 68              >            pla         ;use stack to retrieve status\n0a72 : 48              >            pha\n                       >            cmp_flag 0  \n0a73 : c930            >            cmp #(0  |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a75 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a77 : 28              >            plp         ;restore status\n                        \n                            if I_flag = 3\n0a78 : 78                       sei\n                                tst_stat intdis\n0a79 : 08              >            php         ;save status\n0a7a : 68              >            pla         ;use stack to retrieve status\n0a7b : 48              >            pha\n                       >            cmp_flag intdis\n0a7c : c934            >            cmp #(intdis|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a7e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a80 : 28              >            plp         ;restore status\n                        \n0a81 : 58                       cli\n                                tst_stat 0\n0a82 : 08              >            php         ;save status\n0a83 : 68              >            pla         ;use stack to retrieve status\n0a84 : 48              >            pha\n                       >            cmp_flag 0\n0a85 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a87 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a89 : 28              >            plp         ;restore status\n                        \n                            endif  \n0a8a : f8                       sed\n                                tst_stat decmode\n0a8b : 08              >            php         ;save status\n0a8c : 68              >            pla         ;use stack to retrieve status\n0a8d : 48              >            pha\n                       >            cmp_flag decmode\n0a8e : c938            >            cmp #(decmode|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a90 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a92 : 28              >            plp         ;restore status\n                        \n0a93 : d8                       cld\n                                tst_stat 0  \n0a94 : 08              >            php         ;save status\n0a95 : 68              >            pla         ;use stack to retrieve status\n0a96 : 48              >            pha\n                       >            cmp_flag 0  \n0a97 : c930            >            cmp #(0  |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0a99 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0a9b : 28              >            plp         ;restore status\n                        \n                                set_stat overfl\n                       >            load_flag overfl\n0a9c : a940            >            lda #overfl             ;allow test to change I-flag (no mask)\n                       >\n0a9e : 48              >            pha         ;use stack to load status\n0a9f : 28              >            plp\n                        \n                                tst_stat overfl\n0aa0 : 08              >            php         ;save status\n0aa1 : 68              >            pla         ;use stack to retrieve status\n0aa2 : 48              >            pha\n                       >            cmp_flag overfl\n0aa3 : c970            >            cmp #(overfl|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0aa5 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0aa7 : 28              >            plp         ;restore status\n                        \n0aa8 : b8                       clv\n                                tst_stat 0\n0aa9 : 08              >            php         ;save status\n0aaa : 68              >            pla         ;use stack to retrieve status\n0aab : 48              >            pha\n                       >            cmp_flag 0\n0aac : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0aae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ab0 : 28              >            plp         ;restore status\n                        \n                                next_test\n0ab1 : ad0002          >            lda test_case   ;previous test\n0ab4 : c90c            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0ab6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000d =                 >test_num = test_num + 1\n0ab8 : a90d            >            lda #test_num   ;*** next tests' number\n0aba : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        ; testing index register increment/decrement and transfer\n                        ; INX INY DEX DEY TAX TXA TAY TYA \n0abd : a2fe                     ldx #$fe\n                                set_stat $ff\n                       >            load_flag $ff\n0abf : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0ac1 : 48              >            pha         ;use stack to load status\n0ac2 : 28              >            plp\n                        \n0ac3 : e8                       inx             ;ff\n                                tst_x $ff,$ff-zero\n0ac4 : 08              >            php         ;save flags\n0ac5 : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0ac7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ac9 : 68              >            pla         ;load status\n0aca : 48              >            pha\n                       >            cmp_flag $ff-zero\n0acb : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0acd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0acf : 28              >            plp         ;restore status\n                        \n0ad0 : e8                       inx             ;00\n                                tst_x 0,$ff-minus\n0ad1 : 08              >            php         ;save flags\n0ad2 : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0ad4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ad6 : 68              >            pla         ;load status\n0ad7 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0ad8 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0ada : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0adc : 28              >            plp         ;restore status\n                        \n0add : e8                       inx             ;01\n                                tst_x 1,$ff-minus-zero\n0ade : 08              >            php         ;save flags\n0adf : e001            >            cpx #1     ;test result\n                       >            trap_ne\n0ae1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ae3 : 68              >            pla         ;load status\n0ae4 : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0ae5 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0ae7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ae9 : 28              >            plp         ;restore status\n                        \n0aea : ca                       dex             ;00\n                                tst_x 0,$ff-minus\n0aeb : 08              >            php         ;save flags\n0aec : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0aee : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0af0 : 68              >            pla         ;load status\n0af1 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0af2 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0af4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0af6 : 28              >            plp         ;restore status\n                        \n0af7 : ca                       dex             ;ff\n                                tst_x $ff,$ff-zero\n0af8 : 08              >            php         ;save flags\n0af9 : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0afb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0afd : 68              >            pla         ;load status\n0afe : 48              >            pha\n                       >            cmp_flag $ff-zero\n0aff : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b01 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b03 : 28              >            plp         ;restore status\n                        \n0b04 : ca                       dex             ;fe\n                                set_stat 0\n                       >            load_flag 0\n0b05 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0b07 : 48              >            pha         ;use stack to load status\n0b08 : 28              >            plp\n                        \n0b09 : e8                       inx             ;ff\n                                tst_x $ff,minus\n0b0a : 08              >            php         ;save flags\n0b0b : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0b0d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b0f : 68              >            pla         ;load status\n0b10 : 48              >            pha\n                       >            cmp_flag minus\n0b11 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b13 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b15 : 28              >            plp         ;restore status\n                        \n0b16 : e8                       inx             ;00\n                                tst_x 0,zero\n0b17 : 08              >            php         ;save flags\n0b18 : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0b1a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b1c : 68              >            pla         ;load status\n0b1d : 48              >            pha\n                       >            cmp_flag zero\n0b1e : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b20 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b22 : 28              >            plp         ;restore status\n                        \n0b23 : e8                       inx             ;01\n                                tst_x 1,0\n0b24 : 08              >            php         ;save flags\n0b25 : e001            >            cpx #1     ;test result\n                       >            trap_ne\n0b27 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b29 : 68              >            pla         ;load status\n0b2a : 48              >            pha\n                       >            cmp_flag 0\n0b2b : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b2d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b2f : 28              >            plp         ;restore status\n                        \n0b30 : ca                       dex             ;00\n                                tst_x 0,zero\n0b31 : 08              >            php         ;save flags\n0b32 : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0b34 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b36 : 68              >            pla         ;load status\n0b37 : 48              >            pha\n                       >            cmp_flag zero\n0b38 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b3a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b3c : 28              >            plp         ;restore status\n                        \n0b3d : ca                       dex             ;ff\n                                tst_x $ff,minus\n0b3e : 08              >            php         ;save flags\n0b3f : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0b41 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b43 : 68              >            pla         ;load status\n0b44 : 48              >            pha\n                       >            cmp_flag minus\n0b45 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b47 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b49 : 28              >            plp         ;restore status\n                        \n                        \n0b4a : a0fe                     ldy #$fe\n                                set_stat $ff\n                       >            load_flag $ff\n0b4c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0b4e : 48              >            pha         ;use stack to load status\n0b4f : 28              >            plp\n                        \n0b50 : c8                       iny             ;ff\n                                tst_y $ff,$ff-zero\n0b51 : 08              >            php         ;save flags\n0b52 : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0b54 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b56 : 68              >            pla         ;load status\n0b57 : 48              >            pha\n                       >            cmp_flag $ff-zero\n0b58 : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b5a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b5c : 28              >            plp         ;restore status\n                        \n0b5d : c8                       iny             ;00\n                                tst_y 0,$ff-minus\n0b5e : 08              >            php         ;save flags\n0b5f : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0b61 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b63 : 68              >            pla         ;load status\n0b64 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0b65 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b67 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b69 : 28              >            plp         ;restore status\n                        \n0b6a : c8                       iny             ;01\n                                tst_y 1,$ff-minus-zero\n0b6b : 08              >            php         ;save flags\n0b6c : c001            >            cpy #1     ;test result\n                       >            trap_ne\n0b6e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b70 : 68              >            pla         ;load status\n0b71 : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0b72 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b74 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b76 : 28              >            plp         ;restore status\n                        \n0b77 : 88                       dey             ;00\n                                tst_y 0,$ff-minus\n0b78 : 08              >            php         ;save flags\n0b79 : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0b7b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b7d : 68              >            pla         ;load status\n0b7e : 48              >            pha\n                       >            cmp_flag $ff-minus\n0b7f : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b81 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b83 : 28              >            plp         ;restore status\n                        \n0b84 : 88                       dey             ;ff\n                                tst_y $ff,$ff-zero\n0b85 : 08              >            php         ;save flags\n0b86 : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0b88 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b8a : 68              >            pla         ;load status\n0b8b : 48              >            pha\n                       >            cmp_flag $ff-zero\n0b8c : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0b8e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b90 : 28              >            plp         ;restore status\n                        \n0b91 : 88                       dey             ;fe\n                                set_stat 0\n                       >            load_flag 0\n0b92 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0b94 : 48              >            pha         ;use stack to load status\n0b95 : 28              >            plp\n                        \n0b96 : c8                       iny             ;ff\n                                tst_y $ff,0+minus\n0b97 : 08              >            php         ;save flags\n0b98 : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0b9a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0b9c : 68              >            pla         ;load status\n0b9d : 48              >            pha\n                       >            cmp_flag 0+minus\n0b9e : c9b0            >            cmp #(0+minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0ba0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ba2 : 28              >            plp         ;restore status\n                        \n0ba3 : c8                       iny             ;00\n                                tst_y 0,zero\n0ba4 : 08              >            php         ;save flags\n0ba5 : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0ba7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ba9 : 68              >            pla         ;load status\n0baa : 48              >            pha\n                       >            cmp_flag zero\n0bab : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0bad : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0baf : 28              >            plp         ;restore status\n                        \n0bb0 : c8                       iny             ;01\n                                tst_y 1,0\n0bb1 : 08              >            php         ;save flags\n0bb2 : c001            >            cpy #1     ;test result\n                       >            trap_ne\n0bb4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bb6 : 68              >            pla         ;load status\n0bb7 : 48              >            pha\n                       >            cmp_flag 0\n0bb8 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0bba : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bbc : 28              >            plp         ;restore status\n                        \n0bbd : 88                       dey             ;00\n                                tst_y 0,zero\n0bbe : 08              >            php         ;save flags\n0bbf : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0bc1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bc3 : 68              >            pla         ;load status\n0bc4 : 48              >            pha\n                       >            cmp_flag zero\n0bc5 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0bc7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bc9 : 28              >            plp         ;restore status\n                        \n0bca : 88                       dey             ;ff\n                                tst_y $ff,minus\n0bcb : 08              >            php         ;save flags\n0bcc : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0bce : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bd0 : 68              >            pla         ;load status\n0bd1 : 48              >            pha\n                       >            cmp_flag minus\n0bd2 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0bd4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bd6 : 28              >            plp         ;restore status\n                        \n                                        \n0bd7 : a2ff                     ldx #$ff\n                                set_stat $ff\n                       >            load_flag $ff\n0bd9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0bdb : 48              >            pha         ;use stack to load status\n0bdc : 28              >            plp\n                        \n0bdd : 8a                       txa\n                                tst_a $ff,$ff-zero\n0bde : 08              >            php         ;save flags\n0bdf : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n0be1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0be3 : 68              >            pla         ;load status\n0be4 : 48              >            pha\n                       >            cmp_flag $ff-zero\n0be5 : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0be7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0be9 : 28              >            plp         ;restore status\n                        \n0bea : 08                       php\n0beb : e8                       inx             ;00\n0bec : 28                       plp\n0bed : 8a                       txa\n                                tst_a 0,$ff-minus\n0bee : 08              >            php         ;save flags\n0bef : c900            >            cmp #0     ;test result\n                       >            trap_ne\n0bf1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bf3 : 68              >            pla         ;load status\n0bf4 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0bf5 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0bf7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0bf9 : 28              >            plp         ;restore status\n                        \n0bfa : 08                       php\n0bfb : e8                       inx             ;01\n0bfc : 28                       plp\n0bfd : 8a                       txa\n                                tst_a 1,$ff-minus-zero\n0bfe : 08              >            php         ;save flags\n0bff : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0c01 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c03 : 68              >            pla         ;load status\n0c04 : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0c05 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c07 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c09 : 28              >            plp         ;restore status\n                        \n                                set_stat 0\n                       >            load_flag 0\n0c0a : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0c0c : 48              >            pha         ;use stack to load status\n0c0d : 28              >            plp\n                        \n0c0e : 8a                       txa\n                                tst_a 1,0\n0c0f : 08              >            php         ;save flags\n0c10 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0c12 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c14 : 68              >            pla         ;load status\n0c15 : 48              >            pha\n                       >            cmp_flag 0\n0c16 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c18 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c1a : 28              >            plp         ;restore status\n                        \n0c1b : 08                       php\n0c1c : ca                       dex             ;00\n0c1d : 28                       plp\n0c1e : 8a                       txa\n                                tst_a 0,zero\n0c1f : 08              >            php         ;save flags\n0c20 : c900            >            cmp #0     ;test result\n                       >            trap_ne\n0c22 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c24 : 68              >            pla         ;load status\n0c25 : 48              >            pha\n                       >            cmp_flag zero\n0c26 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c28 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c2a : 28              >            plp         ;restore status\n                        \n0c2b : 08                       php\n0c2c : ca                       dex             ;ff\n0c2d : 28                       plp\n0c2e : 8a                       txa\n                                tst_a $ff,minus\n0c2f : 08              >            php         ;save flags\n0c30 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n0c32 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c34 : 68              >            pla         ;load status\n0c35 : 48              >            pha\n                       >            cmp_flag minus\n0c36 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c38 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c3a : 28              >            plp         ;restore status\n                        \n                                                \n0c3b : a0ff                     ldy #$ff\n                                set_stat $ff\n                       >            load_flag $ff\n0c3d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0c3f : 48              >            pha         ;use stack to load status\n0c40 : 28              >            plp\n                        \n0c41 : 98                       tya\n                                tst_a $ff,$ff-zero\n0c42 : 08              >            php         ;save flags\n0c43 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n0c45 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c47 : 68              >            pla         ;load status\n0c48 : 48              >            pha\n                       >            cmp_flag $ff-zero\n0c49 : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c4b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c4d : 28              >            plp         ;restore status\n                        \n0c4e : 08                       php\n0c4f : c8                       iny             ;00\n0c50 : 28                       plp\n0c51 : 98                       tya\n                                tst_a 0,$ff-minus\n0c52 : 08              >            php         ;save flags\n0c53 : c900            >            cmp #0     ;test result\n                       >            trap_ne\n0c55 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c57 : 68              >            pla         ;load status\n0c58 : 48              >            pha\n                       >            cmp_flag $ff-minus\n0c59 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c5b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c5d : 28              >            plp         ;restore status\n                        \n0c5e : 08                       php\n0c5f : c8                       iny             ;01\n0c60 : 28                       plp\n0c61 : 98                       tya\n                                tst_a 1,$ff-minus-zero\n0c62 : 08              >            php         ;save flags\n0c63 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0c65 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c67 : 68              >            pla         ;load status\n0c68 : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0c69 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c6b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c6d : 28              >            plp         ;restore status\n                        \n                                set_stat 0\n                       >            load_flag 0\n0c6e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0c70 : 48              >            pha         ;use stack to load status\n0c71 : 28              >            plp\n                        \n0c72 : 98                       tya\n                                tst_a 1,0\n0c73 : 08              >            php         ;save flags\n0c74 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n0c76 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c78 : 68              >            pla         ;load status\n0c79 : 48              >            pha\n                       >            cmp_flag 0\n0c7a : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c7c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c7e : 28              >            plp         ;restore status\n                        \n0c7f : 08                       php\n0c80 : 88                       dey             ;00\n0c81 : 28                       plp\n0c82 : 98                       tya\n                                tst_a 0,zero\n0c83 : 08              >            php         ;save flags\n0c84 : c900            >            cmp #0     ;test result\n                       >            trap_ne\n0c86 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c88 : 68              >            pla         ;load status\n0c89 : 48              >            pha\n                       >            cmp_flag zero\n0c8a : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c8c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c8e : 28              >            plp         ;restore status\n                        \n0c8f : 08                       php\n0c90 : 88                       dey             ;ff\n0c91 : 28                       plp\n0c92 : 98                       tya\n                                tst_a $ff,minus\n0c93 : 08              >            php         ;save flags\n0c94 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n0c96 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c98 : 68              >            pla         ;load status\n0c99 : 48              >            pha\n                       >            cmp_flag minus\n0c9a : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0c9c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0c9e : 28              >            plp         ;restore status\n                        \n                        \n                                load_flag $ff\n0c9f : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                        \n0ca1 : 48                       pha\n0ca2 : a2ff                     ldx #$ff        ;ff\n0ca4 : 8a                       txa\n0ca5 : 28                       plp             \n0ca6 : a8                       tay\n                                tst_y $ff,$ff-zero\n0ca7 : 08              >            php         ;save flags\n0ca8 : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0caa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cac : 68              >            pla         ;load status\n0cad : 48              >            pha\n                       >            cmp_flag $ff-zero\n0cae : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0cb0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cb2 : 28              >            plp         ;restore status\n                        \n0cb3 : 08                       php\n0cb4 : e8                       inx             ;00\n0cb5 : 8a                       txa\n0cb6 : 28                       plp\n0cb7 : a8                       tay\n                                tst_y 0,$ff-minus\n0cb8 : 08              >            php         ;save flags\n0cb9 : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0cbb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cbd : 68              >            pla         ;load status\n0cbe : 48              >            pha\n                       >            cmp_flag $ff-minus\n0cbf : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0cc1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cc3 : 28              >            plp         ;restore status\n                        \n0cc4 : 08                       php\n0cc5 : e8                       inx             ;01\n0cc6 : 8a                       txa\n0cc7 : 28                       plp\n0cc8 : a8                       tay\n                                tst_y 1,$ff-minus-zero\n0cc9 : 08              >            php         ;save flags\n0cca : c001            >            cpy #1     ;test result\n                       >            trap_ne\n0ccc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cce : 68              >            pla         ;load status\n0ccf : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0cd0 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0cd2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cd4 : 28              >            plp         ;restore status\n                        \n                                load_flag 0\n0cd5 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                        \n0cd7 : 48                       pha\n0cd8 : a900                     lda #0\n0cda : 8a                       txa\n0cdb : 28                       plp\n0cdc : a8                       tay\n                                tst_y 1,0\n0cdd : 08              >            php         ;save flags\n0cde : c001            >            cpy #1     ;test result\n                       >            trap_ne\n0ce0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ce2 : 68              >            pla         ;load status\n0ce3 : 48              >            pha\n                       >            cmp_flag 0\n0ce4 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0ce6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0ce8 : 28              >            plp         ;restore status\n                        \n0ce9 : 08                       php\n0cea : ca                       dex             ;00\n0ceb : 8a                       txa\n0cec : 28                       plp\n0ced : a8                       tay\n                                tst_y 0,zero\n0cee : 08              >            php         ;save flags\n0cef : c000            >            cpy #0     ;test result\n                       >            trap_ne\n0cf1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cf3 : 68              >            pla         ;load status\n0cf4 : 48              >            pha\n                       >            cmp_flag zero\n0cf5 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0cf7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0cf9 : 28              >            plp         ;restore status\n                        \n0cfa : 08                       php\n0cfb : ca                       dex             ;ff\n0cfc : 8a                       txa\n0cfd : 28                       plp\n0cfe : a8                       tay\n                                tst_y $ff,minus\n0cff : 08              >            php         ;save flags\n0d00 : c0ff            >            cpy #$ff     ;test result\n                       >            trap_ne\n0d02 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d04 : 68              >            pla         ;load status\n0d05 : 48              >            pha\n                       >            cmp_flag minus\n0d06 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d08 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d0a : 28              >            plp         ;restore status\n                        \n                        \n                        \n                                load_flag $ff\n0d0b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                        \n0d0d : 48                       pha\n0d0e : a0ff                     ldy #$ff        ;ff\n0d10 : 98                       tya\n0d11 : 28                       plp\n0d12 : aa                       tax\n                                tst_x $ff,$ff-zero\n0d13 : 08              >            php         ;save flags\n0d14 : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0d16 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d18 : 68              >            pla         ;load status\n0d19 : 48              >            pha\n                       >            cmp_flag $ff-zero\n0d1a : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d1c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d1e : 28              >            plp         ;restore status\n                        \n0d1f : 08                       php\n0d20 : c8                       iny             ;00\n0d21 : 98                       tya\n0d22 : 28                       plp\n0d23 : aa                       tax\n                                tst_x 0,$ff-minus\n0d24 : 08              >            php         ;save flags\n0d25 : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0d27 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d29 : 68              >            pla         ;load status\n0d2a : 48              >            pha\n                       >            cmp_flag $ff-minus\n0d2b : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d2d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d2f : 28              >            plp         ;restore status\n                        \n0d30 : 08                       php\n0d31 : c8                       iny             ;01\n0d32 : 98                       tya\n0d33 : 28                       plp\n0d34 : aa                       tax\n                                tst_x 1,$ff-minus-zero\n0d35 : 08              >            php         ;save flags\n0d36 : e001            >            cpx #1     ;test result\n                       >            trap_ne\n0d38 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d3a : 68              >            pla         ;load status\n0d3b : 48              >            pha\n                       >            cmp_flag $ff-minus-zero\n0d3c : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d3e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d40 : 28              >            plp         ;restore status\n                        \n                                load_flag 0\n0d41 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                        \n0d43 : 48                       pha\n0d44 : a900                     lda #0          ;preset status\n0d46 : 98                       tya\n0d47 : 28                       plp\n0d48 : aa                       tax\n                                tst_x 1,0\n0d49 : 08              >            php         ;save flags\n0d4a : e001            >            cpx #1     ;test result\n                       >            trap_ne\n0d4c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d4e : 68              >            pla         ;load status\n0d4f : 48              >            pha\n                       >            cmp_flag 0\n0d50 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d52 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d54 : 28              >            plp         ;restore status\n                        \n0d55 : 08                       php\n0d56 : 88                       dey             ;00\n0d57 : 98                       tya\n0d58 : 28                       plp\n0d59 : aa                       tax\n                                tst_x 0,zero\n0d5a : 08              >            php         ;save flags\n0d5b : e000            >            cpx #0     ;test result\n                       >            trap_ne\n0d5d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d5f : 68              >            pla         ;load status\n0d60 : 48              >            pha\n                       >            cmp_flag zero\n0d61 : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d63 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d65 : 28              >            plp         ;restore status\n                        \n0d66 : 08                       php\n0d67 : 88                       dey             ;ff\n0d68 : 98                       tya\n0d69 : 28                       plp\n0d6a : aa                       tax\n                                tst_x $ff,minus\n0d6b : 08              >            php         ;save flags\n0d6c : e0ff            >            cpx #$ff     ;test result\n                       >            trap_ne\n0d6e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d70 : 68              >            pla         ;load status\n0d71 : 48              >            pha\n                       >            cmp_flag minus\n0d72 : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n0d74 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0d76 : 28              >            plp         ;restore status\n                        \n                                next_test\n0d77 : ad0002          >            lda test_case   ;previous test\n0d7a : c90d            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0d7c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000e =                 >test_num = test_num + 1\n0d7e : a90e            >            lda #test_num   ;*** next tests' number\n0d80 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                             \n                        ;TSX sets NZ - TXS does not\n                        ;  This section also tests for proper stack wrap around.\n0d83 : a201                     ldx #1          ;01\n                                set_stat $ff\n                       >            load_flag $ff\n0d85 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0d87 : 48              >            pha         ;use stack to load status\n0d88 : 28              >            plp\n                        \n0d89 : 9a                       txs\n0d8a : 08                       php\n0d8b : ad0101                   lda $101\n                                cmp_flag $ff\n0d8e : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0d90 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n0d92 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0d94 : 48              >            pha         ;use stack to load status\n0d95 : 28              >            plp\n                        \n0d96 : 9a                       txs\n0d97 : 08                       php\n0d98 : ad0101                   lda $101\n                                cmp_flag 0\n0d9b : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0d9d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0d9f : ca                       dex             ;00\n                                set_stat $ff\n                       >            load_flag $ff\n0da0 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0da2 : 48              >            pha         ;use stack to load status\n0da3 : 28              >            plp\n                        \n0da4 : 9a                       txs\n0da5 : 08                       php\n0da6 : ad0001                   lda $100\n                                cmp_flag $ff\n0da9 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0dab : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n0dad : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0daf : 48              >            pha         ;use stack to load status\n0db0 : 28              >            plp\n                        \n0db1 : 9a                       txs\n0db2 : 08                       php\n0db3 : ad0001                   lda $100\n                                cmp_flag 0\n0db6 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0db8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0dba : ca                       dex             ;ff\n                                set_stat $ff\n                       >            load_flag $ff\n0dbb : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0dbd : 48              >            pha         ;use stack to load status\n0dbe : 28              >            plp\n                        \n0dbf : 9a                       txs\n0dc0 : 08                       php\n0dc1 : adff01                   lda $1ff\n                                cmp_flag $ff\n0dc4 : c9ff            >            cmp #($ff|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0dc6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n0dc8 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0dca : 48              >            pha         ;use stack to load status\n0dcb : 28              >            plp\n                        \n0dcc : 9a                       txs\n0dcd : 08                       php\n0dce : adff01                   lda $1ff\n                                cmp_flag 0\n0dd1 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                        \n                                \n0dd3 : a201                     ldx #1\n0dd5 : 9a                       txs             ;sp=01\n                                set_stat $ff\n                       >            load_flag $ff\n0dd6 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0dd8 : 48              >            pha         ;use stack to load status\n0dd9 : 28              >            plp\n                        \n0dda : ba                       tsx             ;clears Z, N\n0ddb : 08                       php             ;sp=00\n0ddc : e001                     cpx #1\n                                trap_ne\n0dde : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0de0 : ad0101                   lda $101\n                                cmp_flag $ff-minus-zero\n0de3 : c97d            >            cmp #($ff-minus-zero|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0de5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n0de7 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0de9 : 48              >            pha         ;use stack to load status\n0dea : 28              >            plp\n                        \n0deb : ba                       tsx             ;clears N, sets Z\n0dec : 08                       php             ;sp=ff\n0ded : e000                     cpx #0\n                                trap_ne\n0def : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0df1 : ad0001                   lda $100\n                                cmp_flag $ff-minus\n0df4 : c97f            >            cmp #($ff-minus|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0df6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n0df8 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0dfa : 48              >            pha         ;use stack to load status\n0dfb : 28              >            plp\n                        \n0dfc : ba                       tsx             ;clears N, sets Z\n0dfd : 08                       php             ;sp=fe\n0dfe : e0ff                     cpx #$ff\n                                trap_ne\n0e00 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e02 : adff01                   lda $1ff\n                                cmp_flag $ff-zero\n0e05 : c9fd            >            cmp #($ff-zero|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0e07 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                \n0e09 : a201                     ldx #1\n0e0b : 9a                       txs             ;sp=01\n                                set_stat 0\n                       >            load_flag 0\n0e0c : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0e0e : 48              >            pha         ;use stack to load status\n0e0f : 28              >            plp\n                        \n0e10 : ba                       tsx             ;clears Z, N\n0e11 : 08                       php             ;sp=00\n0e12 : e001                     cpx #1\n                                trap_ne\n0e14 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e16 : ad0101                   lda $101\n                                cmp_flag 0\n0e19 : c930            >            cmp #(0|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0e1b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n0e1d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0e1f : 48              >            pha         ;use stack to load status\n0e20 : 28              >            plp\n                        \n0e21 : ba                       tsx             ;clears N, sets Z\n0e22 : 08                       php             ;sp=ff\n0e23 : e000                     cpx #0\n                                trap_ne\n0e25 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e27 : ad0001                   lda $100\n                                cmp_flag zero\n0e2a : c932            >            cmp #(zero|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0e2c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n0e2e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0e30 : 48              >            pha         ;use stack to load status\n0e31 : 28              >            plp\n                        \n0e32 : ba                       tsx             ;clears N, sets Z\n0e33 : 08                       php             ;sp=fe\n0e34 : e0ff                     cpx #$ff\n                                trap_ne\n0e36 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e38 : adff01                   lda $1ff\n                                cmp_flag minus\n0e3b : c9b0            >            cmp #(minus|fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne\n0e3d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e3f : 68                       pla             ;sp=ff\n                                next_test\n0e40 : ad0002          >            lda test_case   ;previous test\n0e43 : c90e            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0e45 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n000f =                 >test_num = test_num + 1\n0e47 : a90f            >            lda #test_num   ;*** next tests' number\n0e49 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; testing index register load & store LDY LDX STY STX all addressing modes\n                        ; LDX / STX - zp,y / abs,y\n0e4c : a003                     ldy #3\n0e4e :                  tldx    \n                                set_stat 0\n                       >            load_flag 0\n0e4e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0e50 : 48              >            pha         ;use stack to load status\n0e51 : 28              >            plp\n                        \n0e52 : b613                     ldx zp1,y\n0e54 : 08                       php         ;test stores do not alter flags\n0e55 : 8a                       txa\n0e56 : 49c3                     eor #$c3\n0e58 : 28                       plp\n0e59 : 990302                   sta abst,y\n0e5c : 08                       php         ;flags after load/store sequence\n0e5d : 49c3                     eor #$c3\n0e5f : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n0e62 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e64 : 68                       pla         ;load status\n                                eor_flag 0\n0e65 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n0e67 : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n0e6a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e6c : 88                       dey\n0e6d : 10df                     bpl tldx                  \n                        \n0e6f : a003                     ldy #3\n0e71 :                  tldx1   \n                                set_stat $ff\n                       >            load_flag $ff\n0e71 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0e73 : 48              >            pha         ;use stack to load status\n0e74 : 28              >            plp\n                        \n0e75 : b613                     ldx zp1,y\n0e77 : 08                       php         ;test stores do not alter flags\n0e78 : 8a                       txa\n0e79 : 49c3                     eor #$c3\n0e7b : 28                       plp\n0e7c : 990302                   sta abst,y\n0e7f : 08                       php         ;flags after load/store sequence\n0e80 : 49c3                     eor #$c3\n0e82 : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n0e85 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e87 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n0e88 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n0e8a : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n0e8d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0e8f : 88                       dey\n0e90 : 10df                     bpl tldx1                  \n                        \n0e92 : a003                     ldy #3\n0e94 :                  tldx2   \n                                set_stat 0\n                       >            load_flag 0\n0e94 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0e96 : 48              >            pha         ;use stack to load status\n0e97 : 28              >            plp\n                        \n0e98 : be1702                   ldx abs1,y\n0e9b : 08                       php         ;test stores do not alter flags\n0e9c : 8a                       txa\n0e9d : 49c3                     eor #$c3\n0e9f : aa                       tax\n0ea0 : 28                       plp\n0ea1 : 960c                     stx zpt,y\n0ea3 : 08                       php         ;flags after load/store sequence\n0ea4 : 49c3                     eor #$c3\n0ea6 : d91300                   cmp zp1,y   ;test result\n                                trap_ne\n0ea9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0eab : 68                       pla         ;load status\n                                eor_flag 0\n0eac : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n0eae : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n0eb1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0eb3 : 88                       dey\n0eb4 : 10de                     bpl tldx2                  \n                        \n0eb6 : a003                     ldy #3\n0eb8 :                  tldx3   \n                                set_stat $ff\n                       >            load_flag $ff\n0eb8 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0eba : 48              >            pha         ;use stack to load status\n0ebb : 28              >            plp\n                        \n0ebc : be1702                   ldx abs1,y\n0ebf : 08                       php         ;test stores do not alter flags\n0ec0 : 8a                       txa\n0ec1 : 49c3                     eor #$c3\n0ec3 : aa                       tax\n0ec4 : 28                       plp\n0ec5 : 960c                     stx zpt,y\n0ec7 : 08                       php         ;flags after load/store sequence\n0ec8 : 49c3                     eor #$c3\n0eca : d91300                   cmp zp1,y   ;test result\n                                trap_ne\n0ecd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0ecf : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n0ed0 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n0ed2 : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n0ed5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0ed7 : 88                       dey\n0ed8 : 10de                     bpl tldx3\n                                \n0eda : a003                     ldy #3      ;testing store result\n0edc : a200                     ldx #0\n0ede : b90c00           tstx    lda zpt,y\n0ee1 : 49c3                     eor #$c3\n0ee3 : d91300                   cmp zp1,y\n                                trap_ne     ;store to zp data\n0ee6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0ee8 : 960c                     stx zpt,y   ;clear                \n0eea : b90302                   lda abst,y\n0eed : 49c3                     eor #$c3\n0eef : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n0ef2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0ef4 : 8a                       txa\n0ef5 : 990302                   sta abst,y  ;clear                \n0ef8 : 88                       dey\n0ef9 : 10e3                     bpl tstx\n                                next_test\n0efb : ad0002          >            lda test_case   ;previous test\n0efe : c90f            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0f00 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0010 =                 >test_num = test_num + 1\n0f02 : a910            >            lda #test_num   ;*** next tests' number\n0f04 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; indexed wraparound test (only zp should wrap)\n0f07 : a0fd                     ldy #3+$fa\n0f09 : b619             tldx4   ldx zp1-$fa&$ff,y   ;wrap on indexed zp\n0f0b : 8a                       txa\n0f0c : 990901                   sta abst-$fa,y      ;no STX abs,y!\n0f0f : 88                       dey\n0f10 : c0fa                     cpy #$fa\n0f12 : b0f5                     bcs tldx4                  \n0f14 : a0fd                     ldy #3+$fa\n0f16 : be1d01           tldx5   ldx abs1-$fa,y      ;no wrap on indexed abs\n0f19 : 9612                     stx zpt-$fa&$ff,y\n0f1b : 88                       dey\n0f1c : c0fa                     cpy #$fa\n0f1e : b0f6                     bcs tldx5                  \n0f20 : a003                     ldy #3      ;testing wraparound result\n0f22 : a200                     ldx #0\n0f24 : b90c00           tstx1   lda zpt,y\n0f27 : d91300                   cmp zp1,y\n                                trap_ne     ;store to zp data\n0f2a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f2c : 960c                     stx zpt,y   ;clear                \n0f2e : b90302                   lda abst,y\n0f31 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n0f34 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f36 : 8a                       txa\n0f37 : 990302                   sta abst,y  ;clear                \n0f3a : 88                       dey\n0f3b : 10e7                     bpl tstx1\n                                next_test\n0f3d : ad0002          >            lda test_case   ;previous test\n0f40 : c910            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0f42 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0011 =                 >test_num = test_num + 1\n0f44 : a911            >            lda #test_num   ;*** next tests' number\n0f46 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; LDY / STY - zp,x / abs,x\n0f49 : a203                     ldx #3\n0f4b :                  tldy    \n                                set_stat 0\n                       >            load_flag 0\n0f4b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0f4d : 48              >            pha         ;use stack to load status\n0f4e : 28              >            plp\n                        \n0f4f : b413                     ldy zp1,x\n0f51 : 08                       php         ;test stores do not alter flags\n0f52 : 98                       tya\n0f53 : 49c3                     eor #$c3\n0f55 : 28                       plp\n0f56 : 9d0302                   sta abst,x\n0f59 : 08                       php         ;flags after load/store sequence\n0f5a : 49c3                     eor #$c3\n0f5c : dd1702                   cmp abs1,x  ;test result\n                                trap_ne\n0f5f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f61 : 68                       pla         ;load status\n                                eor_flag 0\n0f62 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n0f64 : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n0f67 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f69 : ca                       dex\n0f6a : 10df                     bpl tldy                  \n                        \n0f6c : a203                     ldx #3\n0f6e :                  tldy1   \n                                set_stat $ff\n                       >            load_flag $ff\n0f6e : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0f70 : 48              >            pha         ;use stack to load status\n0f71 : 28              >            plp\n                        \n0f72 : b413                     ldy zp1,x\n0f74 : 08                       php         ;test stores do not alter flags\n0f75 : 98                       tya\n0f76 : 49c3                     eor #$c3\n0f78 : 28                       plp\n0f79 : 9d0302                   sta abst,x\n0f7c : 08                       php         ;flags after load/store sequence\n0f7d : 49c3                     eor #$c3\n0f7f : dd1702                   cmp abs1,x  ;test result\n                                trap_ne\n0f82 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f84 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n0f85 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n0f87 : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n0f8a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0f8c : ca                       dex\n0f8d : 10df                     bpl tldy1                  \n                        \n0f8f : a203                     ldx #3\n0f91 :                  tldy2   \n                                set_stat 0\n                       >            load_flag 0\n0f91 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n0f93 : 48              >            pha         ;use stack to load status\n0f94 : 28              >            plp\n                        \n0f95 : bc1702                   ldy abs1,x\n0f98 : 08                       php         ;test stores do not alter flags\n0f99 : 98                       tya\n0f9a : 49c3                     eor #$c3\n0f9c : a8                       tay\n0f9d : 28                       plp\n0f9e : 940c                     sty zpt,x\n0fa0 : 08                       php         ;flags after load/store sequence\n0fa1 : 49c3                     eor #$c3\n0fa3 : d513                     cmp zp1,x   ;test result\n                                trap_ne\n0fa5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0fa7 : 68                       pla         ;load status\n                                eor_flag 0\n0fa8 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n0faa : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n0fad : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0faf : ca                       dex\n0fb0 : 10df                     bpl tldy2                  \n                        \n0fb2 : a203                     ldx #3\n0fb4 :                  tldy3\n                                set_stat $ff\n                       >            load_flag $ff\n0fb4 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n0fb6 : 48              >            pha         ;use stack to load status\n0fb7 : 28              >            plp\n                        \n0fb8 : bc1702                   ldy abs1,x\n0fbb : 08                       php         ;test stores do not alter flags\n0fbc : 98                       tya\n0fbd : 49c3                     eor #$c3\n0fbf : a8                       tay\n0fc0 : 28                       plp\n0fc1 : 940c                     sty zpt,x\n0fc3 : 08                       php         ;flags after load/store sequence\n0fc4 : 49c3                     eor #$c3\n0fc6 : d513                     cmp zp1,x   ;test result\n                                trap_ne\n0fc8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0fca : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n0fcb : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n0fcd : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n0fd0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0fd2 : ca                       dex\n0fd3 : 10df                     bpl tldy3\n                        \n0fd5 : a203                     ldx #3      ;testing store result\n0fd7 : a000                     ldy #0\n0fd9 : b50c             tsty    lda zpt,x\n0fdb : 49c3                     eor #$c3\n0fdd : d513                     cmp zp1,x\n                                trap_ne     ;store to zp,x data\n0fdf : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0fe1 : 940c                     sty zpt,x   ;clear                \n0fe3 : bd0302                   lda abst,x\n0fe6 : 49c3                     eor #$c3\n0fe8 : dd1702                   cmp abs1,x\n                                trap_ne     ;store to abs,x data\n0feb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n0fed : 8a                       txa\n0fee : 9d0302                   sta abst,x  ;clear                \n0ff1 : ca                       dex\n0ff2 : 10e5                     bpl tsty\n                                next_test\n0ff4 : ad0002          >            lda test_case   ;previous test\n0ff7 : c911            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n0ff9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0012 =                 >test_num = test_num + 1\n0ffb : a912            >            lda #test_num   ;*** next tests' number\n0ffd : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; indexed wraparound test (only zp should wrap)\n1000 : a2fd                     ldx #3+$fa\n1002 : b419             tldy4   ldy zp1-$fa&$ff,x   ;wrap on indexed zp\n1004 : 98                       tya\n1005 : 9d0901                   sta abst-$fa,x      ;no STX abs,x!\n1008 : ca                       dex\n1009 : e0fa                     cpx #$fa\n100b : b0f5                     bcs tldy4                  \n100d : a2fd                     ldx #3+$fa\n100f : bc1d01           tldy5   ldy abs1-$fa,x      ;no wrap on indexed abs\n1012 : 9412                     sty zpt-$fa&$ff,x\n1014 : ca                       dex\n1015 : e0fa                     cpx #$fa\n1017 : b0f6                     bcs tldy5                  \n1019 : a203                     ldx #3      ;testing wraparound result\n101b : a000                     ldy #0\n101d : b50c             tsty1   lda zpt,x\n101f : d513                     cmp zp1,x\n                                trap_ne     ;store to zp,x data\n1021 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1023 : 940c                     sty zpt,x   ;clear                \n1025 : bd0302                   lda abst,x\n1028 : dd1702                   cmp abs1,x\n                                trap_ne     ;store to abs,x data\n102b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n102d : 8a                       txa\n102e : 9d0302                   sta abst,x  ;clear                \n1031 : ca                       dex\n1032 : 10e9                     bpl tsty1\n                                next_test\n1034 : ad0002          >            lda test_case   ;previous test\n1037 : c912            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1039 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0013 =                 >test_num = test_num + 1\n103b : a913            >            lda #test_num   ;*** next tests' number\n103d : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; LDX / STX - zp / abs / #\n                                set_stat 0  \n                       >            load_flag 0  \n1040 : a900            >            lda #0               ;allow test to change I-flag (no mask)\n                       >\n1042 : 48              >            pha         ;use stack to load status\n1043 : 28              >            plp\n                        \n1044 : a613                     ldx zp1\n1046 : 08                       php         ;test stores do not alter flags\n1047 : 8a                       txa\n1048 : 49c3                     eor #$c3\n104a : aa                       tax\n104b : 28                       plp\n104c : 8e0302                   stx abst\n104f : 08                       php         ;flags after load/store sequence\n1050 : 49c3                     eor #$c3\n1052 : aa                       tax\n1053 : e0c3                     cpx #$c3    ;test result\n                                trap_ne\n1055 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1057 : 68                       pla         ;load status\n                                eor_flag 0\n1058 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n105a : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n105d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n105f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1061 : 48              >            pha         ;use stack to load status\n1062 : 28              >            plp\n                        \n1063 : a614                     ldx zp1+1\n1065 : 08                       php         ;test stores do not alter flags\n1066 : 8a                       txa\n1067 : 49c3                     eor #$c3\n1069 : aa                       tax\n106a : 28                       plp\n106b : 8e0402                   stx abst+1\n106e : 08                       php         ;flags after load/store sequence\n106f : 49c3                     eor #$c3\n1071 : aa                       tax\n1072 : e082                     cpx #$82    ;test result\n                                trap_ne\n1074 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1076 : 68                       pla         ;load status\n                                eor_flag 0\n1077 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1079 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n107c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n107e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1080 : 48              >            pha         ;use stack to load status\n1081 : 28              >            plp\n                        \n1082 : a615                     ldx zp1+2\n1084 : 08                       php         ;test stores do not alter flags\n1085 : 8a                       txa\n1086 : 49c3                     eor #$c3\n1088 : aa                       tax\n1089 : 28                       plp\n108a : 8e0502                   stx abst+2\n108d : 08                       php         ;flags after load/store sequence\n108e : 49c3                     eor #$c3\n1090 : aa                       tax\n1091 : e041                     cpx #$41    ;test result\n                                trap_ne\n1093 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1095 : 68                       pla         ;load status\n                                eor_flag 0\n1096 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1098 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n109b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n109d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n109f : 48              >            pha         ;use stack to load status\n10a0 : 28              >            plp\n                        \n10a1 : a616                     ldx zp1+3\n10a3 : 08                       php         ;test stores do not alter flags\n10a4 : 8a                       txa\n10a5 : 49c3                     eor #$c3\n10a7 : aa                       tax\n10a8 : 28                       plp\n10a9 : 8e0602                   stx abst+3\n10ac : 08                       php         ;flags after load/store sequence\n10ad : 49c3                     eor #$c3\n10af : aa                       tax\n10b0 : e000                     cpx #0      ;test result\n                                trap_ne\n10b2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n10b4 : 68                       pla         ;load status\n                                eor_flag 0\n10b5 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n10b7 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n10ba : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n10bc : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n10be : 48              >            pha         ;use stack to load status\n10bf : 28              >            plp\n                        \n10c0 : a613                     ldx zp1  \n10c2 : 08                       php         ;test stores do not alter flags\n10c3 : 8a                       txa\n10c4 : 49c3                     eor #$c3\n10c6 : aa                       tax\n10c7 : 28                       plp\n10c8 : 8e0302                   stx abst  \n10cb : 08                       php         ;flags after load/store sequence\n10cc : 49c3                     eor #$c3\n10ce : aa                       tax\n10cf : e0c3                     cpx #$c3    ;test result\n                                trap_ne     ;\n10d1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n10d3 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n10d4 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n10d6 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n10d9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n10db : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n10dd : 48              >            pha         ;use stack to load status\n10de : 28              >            plp\n                        \n10df : a614                     ldx zp1+1\n10e1 : 08                       php         ;test stores do not alter flags\n10e2 : 8a                       txa\n10e3 : 49c3                     eor #$c3\n10e5 : aa                       tax\n10e6 : 28                       plp\n10e7 : 8e0402                   stx abst+1\n10ea : 08                       php         ;flags after load/store sequence\n10eb : 49c3                     eor #$c3\n10ed : aa                       tax\n10ee : e082                     cpx #$82    ;test result\n                                trap_ne\n10f0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n10f2 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n10f3 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n10f5 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n10f8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n10fa : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n10fc : 48              >            pha         ;use stack to load status\n10fd : 28              >            plp\n                        \n10fe : a615                     ldx zp1+2\n1100 : 08                       php         ;test stores do not alter flags\n1101 : 8a                       txa\n1102 : 49c3                     eor #$c3\n1104 : aa                       tax\n1105 : 28                       plp\n1106 : 8e0502                   stx abst+2\n1109 : 08                       php         ;flags after load/store sequence\n110a : 49c3                     eor #$c3\n110c : aa                       tax\n110d : e041                     cpx #$41    ;test result\n                                trap_ne     ;\n110f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1111 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1112 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1114 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1117 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1119 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n111b : 48              >            pha         ;use stack to load status\n111c : 28              >            plp\n                        \n111d : a616                     ldx zp1+3\n111f : 08                       php         ;test stores do not alter flags\n1120 : 8a                       txa\n1121 : 49c3                     eor #$c3\n1123 : aa                       tax\n1124 : 28                       plp\n1125 : 8e0602                   stx abst+3\n1128 : 08                       php         ;flags after load/store sequence\n1129 : 49c3                     eor #$c3\n112b : aa                       tax\n112c : e000                     cpx #0      ;test result\n                                trap_ne\n112e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1130 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1131 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1133 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1136 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat 0\n                       >            load_flag 0\n1138 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n113a : 48              >            pha         ;use stack to load status\n113b : 28              >            plp\n                        \n113c : ae1702                   ldx abs1  \n113f : 08                       php         ;test stores do not alter flags\n1140 : 8a                       txa\n1141 : 49c3                     eor #$c3\n1143 : aa                       tax\n1144 : 28                       plp\n1145 : 860c                     stx zpt  \n1147 : 08                       php         ;flags after load/store sequence\n1148 : 49c3                     eor #$c3\n114a : c513                     cmp zp1     ;test result\n                                trap_ne\n114c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n114e : 68                       pla         ;load status\n                                eor_flag 0\n114f : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1151 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1154 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1156 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1158 : 48              >            pha         ;use stack to load status\n1159 : 28              >            plp\n                        \n115a : ae1802                   ldx abs1+1\n115d : 08                       php         ;test stores do not alter flags\n115e : 8a                       txa\n115f : 49c3                     eor #$c3\n1161 : aa                       tax\n1162 : 28                       plp\n1163 : 860d                     stx zpt+1\n1165 : 08                       php         ;flags after load/store sequence\n1166 : 49c3                     eor #$c3\n1168 : c514                     cmp zp1+1   ;test result\n                                trap_ne\n116a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n116c : 68                       pla         ;load status\n                                eor_flag 0\n116d : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n116f : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1172 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1174 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1176 : 48              >            pha         ;use stack to load status\n1177 : 28              >            plp\n                        \n1178 : ae1902                   ldx abs1+2\n117b : 08                       php         ;test stores do not alter flags\n117c : 8a                       txa\n117d : 49c3                     eor #$c3\n117f : aa                       tax\n1180 : 28                       plp\n1181 : 860e                     stx zpt+2\n1183 : 08                       php         ;flags after load/store sequence\n1184 : 49c3                     eor #$c3\n1186 : c515                     cmp zp1+2   ;test result\n                                trap_ne\n1188 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n118a : 68                       pla         ;load status\n                                eor_flag 0\n118b : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n118d : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1190 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1192 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1194 : 48              >            pha         ;use stack to load status\n1195 : 28              >            plp\n                        \n1196 : ae1a02                   ldx abs1+3\n1199 : 08                       php         ;test stores do not alter flags\n119a : 8a                       txa\n119b : 49c3                     eor #$c3\n119d : aa                       tax\n119e : 28                       plp\n119f : 860f                     stx zpt+3\n11a1 : 08                       php         ;flags after load/store sequence\n11a2 : 49c3                     eor #$c3\n11a4 : c516                     cmp zp1+3   ;test result\n                                trap_ne\n11a6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n11a8 : 68                       pla         ;load status\n                                eor_flag 0\n11a9 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n11ab : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n11ae : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n11b0 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n11b2 : 48              >            pha         ;use stack to load status\n11b3 : 28              >            plp\n                        \n11b4 : ae1702                   ldx abs1  \n11b7 : 08                       php         ;test stores do not alter flags\n11b8 : 8a                       txa\n11b9 : 49c3                     eor #$c3\n11bb : aa                       tax\n11bc : 28                       plp\n11bd : 860c                     stx zpt  \n11bf : 08                       php         ;flags after load/store sequence\n11c0 : 49c3                     eor #$c3\n11c2 : aa                       tax\n11c3 : e413                     cpx zp1     ;test result\n                                trap_ne\n11c5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n11c7 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n11c8 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n11ca : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n11cd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n11cf : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n11d1 : 48              >            pha         ;use stack to load status\n11d2 : 28              >            plp\n                        \n11d3 : ae1802                   ldx abs1+1\n11d6 : 08                       php         ;test stores do not alter flags\n11d7 : 8a                       txa\n11d8 : 49c3                     eor #$c3\n11da : aa                       tax\n11db : 28                       plp\n11dc : 860d                     stx zpt+1\n11de : 08                       php         ;flags after load/store sequence\n11df : 49c3                     eor #$c3\n11e1 : aa                       tax\n11e2 : e414                     cpx zp1+1   ;test result\n                                trap_ne\n11e4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n11e6 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n11e7 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n11e9 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n11ec : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n11ee : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n11f0 : 48              >            pha         ;use stack to load status\n11f1 : 28              >            plp\n                        \n11f2 : ae1902                   ldx abs1+2\n11f5 : 08                       php         ;test stores do not alter flags\n11f6 : 8a                       txa\n11f7 : 49c3                     eor #$c3\n11f9 : aa                       tax\n11fa : 28                       plp\n11fb : 860e                     stx zpt+2\n11fd : 08                       php         ;flags after load/store sequence\n11fe : 49c3                     eor #$c3\n1200 : aa                       tax\n1201 : e415                     cpx zp1+2   ;test result\n                                trap_ne\n1203 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1205 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1206 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1208 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n120b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n120d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n120f : 48              >            pha         ;use stack to load status\n1210 : 28              >            plp\n                        \n1211 : ae1a02                   ldx abs1+3\n1214 : 08                       php         ;test stores do not alter flags\n1215 : 8a                       txa\n1216 : 49c3                     eor #$c3\n1218 : aa                       tax\n1219 : 28                       plp\n121a : 860f                     stx zpt+3\n121c : 08                       php         ;flags after load/store sequence\n121d : 49c3                     eor #$c3\n121f : aa                       tax\n1220 : e416                     cpx zp1+3   ;test result\n                                trap_ne\n1222 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1224 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1225 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1227 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n122a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat 0  \n                       >            load_flag 0  \n122c : a900            >            lda #0               ;allow test to change I-flag (no mask)\n                       >\n122e : 48              >            pha         ;use stack to load status\n122f : 28              >            plp\n                        \n1230 : a2c3                     ldx #$c3\n1232 : 08                       php\n1233 : ec1702                   cpx abs1    ;test result\n                                trap_ne\n1236 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1238 : 68                       pla         ;load status\n                                eor_flag 0\n1239 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n123b : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n123e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1240 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1242 : 48              >            pha         ;use stack to load status\n1243 : 28              >            plp\n                        \n1244 : a282                     ldx #$82\n1246 : 08                       php\n1247 : ec1802                   cpx abs1+1  ;test result\n                                trap_ne\n124a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n124c : 68                       pla         ;load status\n                                eor_flag 0\n124d : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n124f : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1252 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1254 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1256 : 48              >            pha         ;use stack to load status\n1257 : 28              >            plp\n                        \n1258 : a241                     ldx #$41\n125a : 08                       php\n125b : ec1902                   cpx abs1+2  ;test result\n                                trap_ne\n125e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1260 : 68                       pla         ;load status\n                                eor_flag 0\n1261 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1263 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1266 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1268 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n126a : 48              >            pha         ;use stack to load status\n126b : 28              >            plp\n                        \n126c : a200                     ldx #0\n126e : 08                       php\n126f : ec1a02                   cpx abs1+3  ;test result\n                                trap_ne\n1272 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1274 : 68                       pla         ;load status\n                                eor_flag 0\n1275 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1277 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n127a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n127c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n127e : 48              >            pha         ;use stack to load status\n127f : 28              >            plp\n                        \n1280 : a2c3                     ldx #$c3  \n1282 : 08                       php\n1283 : ec1702                   cpx abs1    ;test result\n                                trap_ne\n1286 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1288 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1289 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n128b : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n128e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1290 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1292 : 48              >            pha         ;use stack to load status\n1293 : 28              >            plp\n                        \n1294 : a282                     ldx #$82\n1296 : 08                       php\n1297 : ec1802                   cpx abs1+1  ;test result\n                                trap_ne\n129a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n129c : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n129d : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n129f : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n12a2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n12a4 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n12a6 : 48              >            pha         ;use stack to load status\n12a7 : 28              >            plp\n                        \n12a8 : a241                     ldx #$41\n12aa : 08                       php\n12ab : ec1902                   cpx abs1+2  ;test result\n                                trap_ne\n12ae : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12b0 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n12b1 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n12b3 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n12b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n12b8 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n12ba : 48              >            pha         ;use stack to load status\n12bb : 28              >            plp\n                        \n12bc : a200                     ldx #0\n12be : 08                       php\n12bf : ec1a02                   cpx abs1+3  ;test result\n                                trap_ne\n12c2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12c4 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n12c5 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n12c7 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n12ca : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n12cc : a200                     ldx #0\n12ce : a50c                     lda zpt  \n12d0 : 49c3                     eor #$c3\n12d2 : c513                     cmp zp1  \n                                trap_ne     ;store to zp data\n12d4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12d6 : 860c                     stx zpt     ;clear                \n12d8 : ad0302                   lda abst  \n12db : 49c3                     eor #$c3\n12dd : cd1702                   cmp abs1  \n                                trap_ne     ;store to abs data\n12e0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12e2 : 8e0302                   stx abst    ;clear                \n12e5 : a50d                     lda zpt+1\n12e7 : 49c3                     eor #$c3\n12e9 : c514                     cmp zp1+1\n                                trap_ne     ;store to zp data\n12eb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12ed : 860d                     stx zpt+1   ;clear                \n12ef : ad0402                   lda abst+1\n12f2 : 49c3                     eor #$c3\n12f4 : cd1802                   cmp abs1+1\n                                trap_ne     ;store to abs data\n12f7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n12f9 : 8e0402                   stx abst+1  ;clear                \n12fc : a50e                     lda zpt+2\n12fe : 49c3                     eor #$c3\n1300 : c515                     cmp zp1+2\n                                trap_ne     ;store to zp data\n1302 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1304 : 860e                     stx zpt+2   ;clear                \n1306 : ad0502                   lda abst+2\n1309 : 49c3                     eor #$c3\n130b : cd1902                   cmp abs1+2\n                                trap_ne     ;store to abs data\n130e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1310 : 8e0502                   stx abst+2  ;clear                \n1313 : a50f                     lda zpt+3\n1315 : 49c3                     eor #$c3\n1317 : c516                     cmp zp1+3\n                                trap_ne     ;store to zp data\n1319 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n131b : 860f                     stx zpt+3   ;clear                \n131d : ad0602                   lda abst+3\n1320 : 49c3                     eor #$c3\n1322 : cd1a02                   cmp abs1+3\n                                trap_ne     ;store to abs data\n1325 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1327 : 8e0602                   stx abst+3  ;clear                \n                                next_test\n132a : ad0002          >            lda test_case   ;previous test\n132d : c913            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n132f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0014 =                 >test_num = test_num + 1\n1331 : a914            >            lda #test_num   ;*** next tests' number\n1333 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; LDY / STY - zp / abs / #\n                                set_stat 0\n                       >            load_flag 0\n1336 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1338 : 48              >            pha         ;use stack to load status\n1339 : 28              >            plp\n                        \n133a : a413                     ldy zp1  \n133c : 08                       php         ;test stores do not alter flags\n133d : 98                       tya\n133e : 49c3                     eor #$c3\n1340 : a8                       tay\n1341 : 28                       plp\n1342 : 8c0302                   sty abst  \n1345 : 08                       php         ;flags after load/store sequence\n1346 : 49c3                     eor #$c3\n1348 : a8                       tay\n1349 : c0c3                     cpy #$c3    ;test result\n                                trap_ne\n134b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n134d : 68                       pla         ;load status\n                                eor_flag 0\n134e : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1350 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1353 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1355 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1357 : 48              >            pha         ;use stack to load status\n1358 : 28              >            plp\n                        \n1359 : a414                     ldy zp1+1\n135b : 08                       php         ;test stores do not alter flags\n135c : 98                       tya\n135d : 49c3                     eor #$c3\n135f : a8                       tay\n1360 : 28                       plp\n1361 : 8c0402                   sty abst+1\n1364 : 08                       php         ;flags after load/store sequence\n1365 : 49c3                     eor #$c3\n1367 : a8                       tay\n1368 : c082                     cpy #$82    ;test result\n                                trap_ne\n136a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n136c : 68                       pla         ;load status\n                                eor_flag 0\n136d : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n136f : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1372 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1374 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1376 : 48              >            pha         ;use stack to load status\n1377 : 28              >            plp\n                        \n1378 : a415                     ldy zp1+2\n137a : 08                       php         ;test stores do not alter flags\n137b : 98                       tya\n137c : 49c3                     eor #$c3\n137e : a8                       tay\n137f : 28                       plp\n1380 : 8c0502                   sty abst+2\n1383 : 08                       php         ;flags after load/store sequence\n1384 : 49c3                     eor #$c3\n1386 : a8                       tay\n1387 : c041                     cpy #$41    ;test result\n                                trap_ne\n1389 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n138b : 68                       pla         ;load status\n                                eor_flag 0\n138c : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n138e : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1391 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1393 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1395 : 48              >            pha         ;use stack to load status\n1396 : 28              >            plp\n                        \n1397 : a416                     ldy zp1+3\n1399 : 08                       php         ;test stores do not alter flags\n139a : 98                       tya\n139b : 49c3                     eor #$c3\n139d : a8                       tay\n139e : 28                       plp\n139f : 8c0602                   sty abst+3\n13a2 : 08                       php         ;flags after load/store sequence\n13a3 : 49c3                     eor #$c3\n13a5 : a8                       tay\n13a6 : c000                     cpy #0      ;test result\n                                trap_ne\n13a8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n13aa : 68                       pla         ;load status\n                                eor_flag 0\n13ab : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n13ad : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n13b0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n13b2 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n13b4 : 48              >            pha         ;use stack to load status\n13b5 : 28              >            plp\n                        \n13b6 : a413                     ldy zp1  \n13b8 : 08                       php         ;test stores do not alter flags\n13b9 : 98                       tya\n13ba : 49c3                     eor #$c3\n13bc : a8                       tay\n13bd : 28                       plp\n13be : 8c0302                   sty abst  \n13c1 : 08                       php         ;flags after load/store sequence\n13c2 : 49c3                     eor #$c3\n13c4 : a8                       tay\n13c5 : c0c3                     cpy #$c3    ;test result\n                                trap_ne\n13c7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n13c9 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n13ca : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n13cc : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n13cf : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n13d1 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n13d3 : 48              >            pha         ;use stack to load status\n13d4 : 28              >            plp\n                        \n13d5 : a414                     ldy zp1+1\n13d7 : 08                       php         ;test stores do not alter flags\n13d8 : 98                       tya\n13d9 : 49c3                     eor #$c3\n13db : a8                       tay\n13dc : 28                       plp\n13dd : 8c0402                   sty abst+1\n13e0 : 08                       php         ;flags after load/store sequence\n13e1 : 49c3                     eor #$c3\n13e3 : a8                       tay\n13e4 : c082                     cpy #$82   ;test result\n                                trap_ne\n13e6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n13e8 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n13e9 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n13eb : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n13ee : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n13f0 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n13f2 : 48              >            pha         ;use stack to load status\n13f3 : 28              >            plp\n                        \n13f4 : a415                     ldy zp1+2\n13f6 : 08                       php         ;test stores do not alter flags\n13f7 : 98                       tya\n13f8 : 49c3                     eor #$c3\n13fa : a8                       tay\n13fb : 28                       plp\n13fc : 8c0502                   sty abst+2\n13ff : 08                       php         ;flags after load/store sequence\n1400 : 49c3                     eor #$c3\n1402 : a8                       tay\n1403 : c041                     cpy #$41    ;test result\n                                trap_ne\n1405 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1407 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1408 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n140a : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n140d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n140f : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1411 : 48              >            pha         ;use stack to load status\n1412 : 28              >            plp\n                        \n1413 : a416                     ldy zp1+3\n1415 : 08                       php         ;test stores do not alter flags\n1416 : 98                       tya\n1417 : 49c3                     eor #$c3\n1419 : a8                       tay\n141a : 28                       plp\n141b : 8c0602                   sty abst+3\n141e : 08                       php         ;flags after load/store sequence\n141f : 49c3                     eor #$c3\n1421 : a8                       tay\n1422 : c000                     cpy #0      ;test result\n                                trap_ne\n1424 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1426 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1427 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1429 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n142c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                \n                                set_stat 0\n                       >            load_flag 0\n142e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1430 : 48              >            pha         ;use stack to load status\n1431 : 28              >            plp\n                        \n1432 : ac1702                   ldy abs1  \n1435 : 08                       php         ;test stores do not alter flags\n1436 : 98                       tya\n1437 : 49c3                     eor #$c3\n1439 : a8                       tay\n143a : 28                       plp\n143b : 840c                     sty zpt  \n143d : 08                       php         ;flags after load/store sequence\n143e : 49c3                     eor #$c3\n1440 : a8                       tay\n1441 : c413                     cpy zp1     ;test result\n                                trap_ne\n1443 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1445 : 68                       pla         ;load status\n                                eor_flag 0\n1446 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1448 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n144b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n144d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n144f : 48              >            pha         ;use stack to load status\n1450 : 28              >            plp\n                        \n1451 : ac1802                   ldy abs1+1\n1454 : 08                       php         ;test stores do not alter flags\n1455 : 98                       tya\n1456 : 49c3                     eor #$c3\n1458 : a8                       tay\n1459 : 28                       plp\n145a : 840d                     sty zpt+1\n145c : 08                       php         ;flags after load/store sequence\n145d : 49c3                     eor #$c3\n145f : a8                       tay\n1460 : c414                     cpy zp1+1   ;test result\n                                trap_ne\n1462 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1464 : 68                       pla         ;load status\n                                eor_flag 0\n1465 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1467 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n146a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n146c : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n146e : 48              >            pha         ;use stack to load status\n146f : 28              >            plp\n                        \n1470 : ac1902                   ldy abs1+2\n1473 : 08                       php         ;test stores do not alter flags\n1474 : 98                       tya\n1475 : 49c3                     eor #$c3\n1477 : a8                       tay\n1478 : 28                       plp\n1479 : 840e                     sty zpt+2\n147b : 08                       php         ;flags after load/store sequence\n147c : 49c3                     eor #$c3\n147e : a8                       tay\n147f : c415                     cpy zp1+2   ;test result\n                                trap_ne\n1481 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1483 : 68                       pla         ;load status\n                                eor_flag 0\n1484 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1486 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1489 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n148b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n148d : 48              >            pha         ;use stack to load status\n148e : 28              >            plp\n                        \n148f : ac1a02                   ldy abs1+3\n1492 : 08                       php         ;test stores do not alter flags\n1493 : 98                       tya\n1494 : 49c3                     eor #$c3\n1496 : a8                       tay\n1497 : 28                       plp\n1498 : 840f                     sty zpt+3\n149a : 08                       php         ;flags after load/store sequence\n149b : 49c3                     eor #$c3\n149d : a8                       tay\n149e : c416                     cpy zp1+3   ;test result\n                                trap_ne\n14a0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n14a2 : 68                       pla         ;load status\n                                eor_flag 0\n14a3 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n14a5 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n14a8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n14aa : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n14ac : 48              >            pha         ;use stack to load status\n14ad : 28              >            plp\n                        \n14ae : ac1702                   ldy abs1  \n14b1 : 08                       php         ;test stores do not alter flags\n14b2 : 98                       tya\n14b3 : 49c3                     eor #$c3\n14b5 : a8                       tay\n14b6 : 28                       plp\n14b7 : 840c                     sty zpt  \n14b9 : 08                       php         ;flags after load/store sequence\n14ba : 49c3                     eor #$c3\n14bc : a8                       tay\n14bd : c513                     cmp zp1     ;test result\n                                trap_ne\n14bf : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n14c1 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n14c2 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n14c4 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n14c7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n14c9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n14cb : 48              >            pha         ;use stack to load status\n14cc : 28              >            plp\n                        \n14cd : ac1802                   ldy abs1+1\n14d0 : 08                       php         ;test stores do not alter flags\n14d1 : 98                       tya\n14d2 : 49c3                     eor #$c3\n14d4 : a8                       tay\n14d5 : 28                       plp\n14d6 : 840d                     sty zpt+1\n14d8 : 08                       php         ;flags after load/store sequence\n14d9 : 49c3                     eor #$c3\n14db : a8                       tay\n14dc : c514                     cmp zp1+1   ;test result\n                                trap_ne\n14de : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n14e0 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n14e1 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n14e3 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n14e6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n14e8 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n14ea : 48              >            pha         ;use stack to load status\n14eb : 28              >            plp\n                        \n14ec : ac1902                   ldy abs1+2\n14ef : 08                       php         ;test stores do not alter flags\n14f0 : 98                       tya\n14f1 : 49c3                     eor #$c3\n14f3 : a8                       tay\n14f4 : 28                       plp\n14f5 : 840e                     sty zpt+2\n14f7 : 08                       php         ;flags after load/store sequence\n14f8 : 49c3                     eor #$c3\n14fa : a8                       tay\n14fb : c515                     cmp zp1+2   ;test result\n                                trap_ne\n14fd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n14ff : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1500 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1502 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1505 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1507 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1509 : 48              >            pha         ;use stack to load status\n150a : 28              >            plp\n                        \n150b : ac1a02                   ldy abs1+3\n150e : 08                       php         ;test stores do not alter flags\n150f : 98                       tya\n1510 : 49c3                     eor #$c3\n1512 : a8                       tay\n1513 : 28                       plp\n1514 : 840f                     sty zpt+3\n1516 : 08                       php         ;flags after load/store sequence\n1517 : 49c3                     eor #$c3\n1519 : a8                       tay\n151a : c516                     cmp zp1+3   ;test result\n                                trap_ne\n151c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n151e : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n151f : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1521 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1524 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                        \n                                set_stat 0\n                       >            load_flag 0\n1526 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1528 : 48              >            pha         ;use stack to load status\n1529 : 28              >            plp\n                        \n152a : a0c3                     ldy #$c3  \n152c : 08                       php\n152d : cc1702                   cpy abs1    ;test result\n                                trap_ne\n1530 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1532 : 68                       pla         ;load status\n                                eor_flag 0\n1533 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1535 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1538 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n153a : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n153c : 48              >            pha         ;use stack to load status\n153d : 28              >            plp\n                        \n153e : a082                     ldy #$82\n1540 : 08                       php\n1541 : cc1802                   cpy abs1+1  ;test result\n                                trap_ne\n1544 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1546 : 68                       pla         ;load status\n                                eor_flag 0\n1547 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1549 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n154c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n154e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1550 : 48              >            pha         ;use stack to load status\n1551 : 28              >            plp\n                        \n1552 : a041                     ldy #$41\n1554 : 08                       php\n1555 : cc1902                   cpy abs1+2  ;test result\n                                trap_ne\n1558 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n155a : 68                       pla         ;load status\n                                eor_flag 0\n155b : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n155d : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1560 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1562 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1564 : 48              >            pha         ;use stack to load status\n1565 : 28              >            plp\n                        \n1566 : a000                     ldy #0\n1568 : 08                       php\n1569 : cc1a02                   cpy abs1+3  ;test result\n                                trap_ne\n156c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n156e : 68                       pla         ;load status\n                                eor_flag 0\n156f : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1571 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1574 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1576 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1578 : 48              >            pha         ;use stack to load status\n1579 : 28              >            plp\n                        \n157a : a0c3                     ldy #$c3  \n157c : 08                       php\n157d : cc1702                   cpy abs1    ;test result\n                                trap_ne\n1580 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1582 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1583 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1585 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1588 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n158a : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n158c : 48              >            pha         ;use stack to load status\n158d : 28              >            plp\n                        \n158e : a082                     ldy #$82\n1590 : 08                       php\n1591 : cc1802                   cpy abs1+1  ;test result\n                                trap_ne\n1594 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1596 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1597 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1599 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n159c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n159e : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n15a0 : 48              >            pha         ;use stack to load status\n15a1 : 28              >            plp\n                        \n15a2 : a041                     ldy #$41\n15a4 : 08                       php\n15a5 : cc1902                   cpy abs1+2   ;test result\n                                trap_ne\n15a8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15aa : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n15ab : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n15ad : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n15b0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n15b2 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n15b4 : 48              >            pha         ;use stack to load status\n15b5 : 28              >            plp\n                        \n15b6 : a000                     ldy #0\n15b8 : 08                       php\n15b9 : cc1a02                   cpy abs1+3  ;test result\n                                trap_ne\n15bc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15be : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n15bf : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n15c1 : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n15c4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                \n15c6 : a000                     ldy #0\n15c8 : a50c                     lda zpt  \n15ca : 49c3                     eor #$c3\n15cc : c513                     cmp zp1  \n                                trap_ne     ;store to zp   data\n15ce : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15d0 : 840c                     sty zpt     ;clear                \n15d2 : ad0302                   lda abst  \n15d5 : 49c3                     eor #$c3\n15d7 : cd1702                   cmp abs1  \n                                trap_ne     ;store to abs   data\n15da : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15dc : 8c0302                   sty abst    ;clear                \n15df : a50d                     lda zpt+1\n15e1 : 49c3                     eor #$c3\n15e3 : c514                     cmp zp1+1\n                                trap_ne     ;store to zp+1 data\n15e5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15e7 : 840d                     sty zpt+1   ;clear                \n15e9 : ad0402                   lda abst+1\n15ec : 49c3                     eor #$c3\n15ee : cd1802                   cmp abs1+1\n                                trap_ne     ;store to abs+1 data\n15f1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15f3 : 8c0402                   sty abst+1  ;clear                \n15f6 : a50e                     lda zpt+2\n15f8 : 49c3                     eor #$c3\n15fa : c515                     cmp zp1+2\n                                trap_ne     ;store to zp+2 data\n15fc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n15fe : 840e                     sty zpt+2   ;clear                \n1600 : ad0502                   lda abst+2\n1603 : 49c3                     eor #$c3\n1605 : cd1902                   cmp abs1+2\n                                trap_ne     ;store to abs+2 data\n1608 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n160a : 8c0502                   sty abst+2  ;clear                \n160d : a50f                     lda zpt+3\n160f : 49c3                     eor #$c3\n1611 : c516                     cmp zp1+3\n                                trap_ne     ;store to zp+3 data\n1613 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1615 : 840f                     sty zpt+3   ;clear                \n1617 : ad0602                   lda abst+3\n161a : 49c3                     eor #$c3\n161c : cd1a02                   cmp abs1+3\n                                trap_ne     ;store to abs+3 data\n161f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1621 : 8c0602                   sty abst+3  ;clear                \n                                next_test\n1624 : ad0002          >            lda test_case   ;previous test\n1627 : c914            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1629 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0015 =                 >test_num = test_num + 1\n162b : a915            >            lda #test_num   ;*** next tests' number\n162d : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; testing load / store accumulator LDA / STA all addressing modes\n                        ; LDA / STA - zp,x / abs,x\n1630 : a203                     ldx #3\n1632 :                  tldax    \n                                set_stat 0\n                       >            load_flag 0\n1632 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1634 : 48              >            pha         ;use stack to load status\n1635 : 28              >            plp\n                        \n1636 : b513                     lda zp1,x\n1638 : 08                       php         ;test stores do not alter flags\n1639 : 49c3                     eor #$c3\n163b : 28                       plp\n163c : 9d0302                   sta abst,x\n163f : 08                       php         ;flags after load/store sequence\n1640 : 49c3                     eor #$c3\n1642 : dd1702                   cmp abs1,x  ;test result\n                                trap_ne\n1645 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1647 : 68                       pla         ;load status\n                                eor_flag 0\n1648 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n164a : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n164d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n164f : ca                       dex\n1650 : 10e0                     bpl tldax                  \n                        \n1652 : a203                     ldx #3\n1654 :                  tldax1   \n                                set_stat $ff\n                       >            load_flag $ff\n1654 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1656 : 48              >            pha         ;use stack to load status\n1657 : 28              >            plp\n                        \n1658 : b513                     lda zp1,x\n165a : 08                       php         ;test stores do not alter flags\n165b : 49c3                     eor #$c3\n165d : 28                       plp\n165e : 9d0302                   sta abst,x\n1661 : 08                       php         ;flags after load/store sequence\n1662 : 49c3                     eor #$c3\n1664 : dd1702                   cmp abs1,x   ;test result\n                                trap_ne\n1667 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1669 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n166a : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n166c : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n166f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1671 : ca                       dex\n1672 : 10e0                     bpl tldax1                  \n                        \n1674 : a203                     ldx #3\n1676 :                  tldax2   \n                                set_stat 0\n                       >            load_flag 0\n1676 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1678 : 48              >            pha         ;use stack to load status\n1679 : 28              >            plp\n                        \n167a : bd1702                   lda abs1,x\n167d : 08                       php         ;test stores do not alter flags\n167e : 49c3                     eor #$c3\n1680 : 28                       plp\n1681 : 950c                     sta zpt,x\n1683 : 08                       php         ;flags after load/store sequence\n1684 : 49c3                     eor #$c3\n1686 : d513                     cmp zp1,x   ;test result\n                                trap_ne\n1688 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n168a : 68                       pla         ;load status\n                                eor_flag 0\n168b : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n168d : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n1690 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1692 : ca                       dex\n1693 : 10e1                     bpl tldax2                  \n                        \n1695 : a203                     ldx #3\n1697 :                  tldax3\n                                set_stat $ff\n                       >            load_flag $ff\n1697 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1699 : 48              >            pha         ;use stack to load status\n169a : 28              >            plp\n                        \n169b : bd1702                   lda abs1,x\n169e : 08                       php         ;test stores do not alter flags\n169f : 49c3                     eor #$c3\n16a1 : 28                       plp\n16a2 : 950c                     sta zpt,x\n16a4 : 08                       php         ;flags after load/store sequence\n16a5 : 49c3                     eor #$c3\n16a7 : d513                     cmp zp1,x   ;test result\n                                trap_ne\n16a9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n16ab : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n16ac : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n16ae : dd1c02                   cmp fLDx,x  ;test flags\n                                trap_ne\n16b1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n16b3 : ca                       dex\n16b4 : 10e1                     bpl tldax3\n                        \n16b6 : a203                     ldx #3      ;testing store result\n16b8 : a000                     ldy #0\n16ba : b50c             tstax   lda zpt,x\n16bc : 49c3                     eor #$c3\n16be : d513                     cmp zp1,x\n                                trap_ne     ;store to zp,x data\n16c0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n16c2 : 940c                     sty zpt,x   ;clear                \n16c4 : bd0302                   lda abst,x\n16c7 : 49c3                     eor #$c3\n16c9 : dd1702                   cmp abs1,x\n                                trap_ne     ;store to abs,x data\n16cc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n16ce : 8a                       txa\n16cf : 9d0302                   sta abst,x  ;clear                \n16d2 : ca                       dex\n16d3 : 10e5                     bpl tstax\n                                next_test\n16d5 : ad0002          >            lda test_case   ;previous test\n16d8 : c915            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n16da : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0016 =                 >test_num = test_num + 1\n16dc : a916            >            lda #test_num   ;*** next tests' number\n16de : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; LDA / STA - (zp),y / abs,y / (zp,x)\n16e1 : a003                     ldy #3\n16e3 :                  tlday    \n                                set_stat 0\n                       >            load_flag 0\n16e3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n16e5 : 48              >            pha         ;use stack to load status\n16e6 : 28              >            plp\n                        \n16e7 : b124                     lda (ind1),y\n16e9 : 08                       php         ;test stores do not alter flags\n16ea : 49c3                     eor #$c3\n16ec : 28                       plp\n16ed : 990302                   sta abst,y\n16f0 : 08                       php         ;flags after load/store sequence\n16f1 : 49c3                     eor #$c3\n16f3 : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n16f6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n16f8 : 68                       pla         ;load status\n                                eor_flag 0\n16f9 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n16fb : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n16fe : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1700 : 88                       dey\n1701 : 10e0                     bpl tlday                  \n                        \n1703 : a003                     ldy #3\n1705 :                  tlday1   \n                                set_stat $ff\n                       >            load_flag $ff\n1705 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1707 : 48              >            pha         ;use stack to load status\n1708 : 28              >            plp\n                        \n1709 : b124                     lda (ind1),y\n170b : 08                       php         ;test stores do not alter flags\n170c : 49c3                     eor #$c3\n170e : 28                       plp\n170f : 990302                   sta abst,y\n1712 : 08                       php         ;flags after load/store sequence\n1713 : 49c3                     eor #$c3\n1715 : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n1718 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n171a : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n171b : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n171d : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n1720 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1722 : 88                       dey\n1723 : 10e0                     bpl tlday1                  \n                        \n1725 : a003                     ldy #3      ;testing store result\n1727 : a200                     ldx #0\n1729 : b90302           tstay   lda abst,y\n172c : 49c3                     eor #$c3\n172e : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n1731 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1733 : 8a                       txa\n1734 : 990302                   sta abst,y  ;clear                \n1737 : 88                       dey\n1738 : 10ef                     bpl tstay\n                        \n173a : a003                     ldy #3\n173c :                  tlday2   \n                                set_stat 0\n                       >            load_flag 0\n173c : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n173e : 48              >            pha         ;use stack to load status\n173f : 28              >            plp\n                        \n1740 : b91702                   lda abs1,y\n1743 : 08                       php         ;test stores do not alter flags\n1744 : 49c3                     eor #$c3\n1746 : 28                       plp\n1747 : 9130                     sta (indt),y\n1749 : 08                       php         ;flags after load/store sequence\n174a : 49c3                     eor #$c3\n174c : d124                     cmp (ind1),y    ;test result\n                                trap_ne\n174e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1750 : 68                       pla         ;load status\n                                eor_flag 0\n1751 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1753 : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n1756 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1758 : 88                       dey\n1759 : 10e1                     bpl tlday2                  \n                        \n175b : a003                     ldy #3\n175d :                  tlday3   \n                                set_stat $ff\n                       >            load_flag $ff\n175d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n175f : 48              >            pha         ;use stack to load status\n1760 : 28              >            plp\n                        \n1761 : b91702                   lda abs1,y\n1764 : 08                       php         ;test stores do not alter flags\n1765 : 49c3                     eor #$c3\n1767 : 28                       plp\n1768 : 9130                     sta (indt),y\n176a : 08                       php         ;flags after load/store sequence\n176b : 49c3                     eor #$c3\n176d : d124                     cmp (ind1),y   ;test result\n                                trap_ne\n176f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1771 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1772 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1774 : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n1777 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1779 : 88                       dey\n177a : 10e1                     bpl tlday3\n                                \n177c : a003                     ldy #3      ;testing store result\n177e : a200                     ldx #0\n1780 : b90302           tstay1  lda abst,y\n1783 : 49c3                     eor #$c3\n1785 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n1788 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n178a : 8a                       txa\n178b : 990302                   sta abst,y  ;clear                \n178e : 88                       dey\n178f : 10ef                     bpl tstay1\n                                \n1791 : a206                     ldx #6\n1793 : a003                     ldy #3\n1795 :                  tldax4   \n                                set_stat 0\n                       >            load_flag 0\n1795 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1797 : 48              >            pha         ;use stack to load status\n1798 : 28              >            plp\n                        \n1799 : a124                     lda (ind1,x)\n179b : 08                       php         ;test stores do not alter flags\n179c : 49c3                     eor #$c3\n179e : 28                       plp\n179f : 8130                     sta (indt,x)\n17a1 : 08                       php         ;flags after load/store sequence\n17a2 : 49c3                     eor #$c3\n17a4 : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n17a7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n17a9 : 68                       pla         ;load status\n                                eor_flag 0\n17aa : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n17ac : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n17af : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n17b1 : ca                       dex\n17b2 : ca                       dex\n17b3 : 88                       dey\n17b4 : 10df                     bpl tldax4                  \n                        \n17b6 : a206                     ldx #6\n17b8 : a003                     ldy #3\n17ba :                  tldax5\n                                set_stat $ff\n                       >            load_flag $ff\n17ba : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n17bc : 48              >            pha         ;use stack to load status\n17bd : 28              >            plp\n                        \n17be : a124                     lda (ind1,x)\n17c0 : 08                       php         ;test stores do not alter flags\n17c1 : 49c3                     eor #$c3\n17c3 : 28                       plp\n17c4 : 8130                     sta (indt,x)\n17c6 : 08                       php         ;flags after load/store sequence\n17c7 : 49c3                     eor #$c3\n17c9 : d91702                   cmp abs1,y  ;test result\n                                trap_ne\n17cc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n17ce : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n17cf : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n17d1 : d91c02                   cmp fLDx,y  ;test flags\n                                trap_ne\n17d4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n17d6 : ca                       dex\n17d7 : ca                       dex\n17d8 : 88                       dey\n17d9 : 10df                     bpl tldax5\n                        \n17db : a003                     ldy #3      ;testing store result\n17dd : a200                     ldx #0\n17df : b90302           tstay2  lda abst,y\n17e2 : 49c3                     eor #$c3\n17e4 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n17e7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n17e9 : 8a                       txa\n17ea : 990302                   sta abst,y  ;clear                \n17ed : 88                       dey\n17ee : 10ef                     bpl tstay2\n                                next_test\n17f0 : ad0002          >            lda test_case   ;previous test\n17f3 : c916            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n17f5 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0017 =                 >test_num = test_num + 1\n17f7 : a917            >            lda #test_num   ;*** next tests' number\n17f9 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; indexed wraparound test (only zp should wrap)\n17fc : a2fd                     ldx #3+$fa\n17fe : b519             tldax6  lda zp1-$fa&$ff,x   ;wrap on indexed zp\n1800 : 9d0901                   sta abst-$fa,x      ;no STX abs,x!\n1803 : ca                       dex\n1804 : e0fa                     cpx #$fa\n1806 : b0f6                     bcs tldax6                  \n1808 : a2fd                     ldx #3+$fa\n180a : bd1d01           tldax7  lda abs1-$fa,x      ;no wrap on indexed abs\n180d : 9512                     sta zpt-$fa&$ff,x\n180f : ca                       dex\n1810 : e0fa                     cpx #$fa\n1812 : b0f6                     bcs tldax7\n                                                  \n1814 : a203                     ldx #3      ;testing wraparound result\n1816 : a000                     ldy #0\n1818 : b50c             tstax1  lda zpt,x\n181a : d513                     cmp zp1,x\n                                trap_ne     ;store to zp,x data\n181c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n181e : 940c                     sty zpt,x   ;clear                \n1820 : bd0302                   lda abst,x\n1823 : dd1702                   cmp abs1,x\n                                trap_ne     ;store to abs,x data\n1826 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1828 : 8a                       txa\n1829 : 9d0302                   sta abst,x  ;clear                \n182c : ca                       dex\n182d : 10e9                     bpl tstax1\n                        \n182f : a0fb                     ldy #3+$f8\n1831 : a2fe                     ldx #6+$f8\n1833 : a12c             tlday4  lda (ind1-$f8&$ff,x) ;wrap on indexed zp indirect\n1835 : 990b01                   sta abst-$f8,y\n1838 : ca                       dex\n1839 : ca                       dex\n183a : 88                       dey\n183b : c0f8                     cpy #$f8\n183d : b0f4                     bcs tlday4\n183f : a003                     ldy #3      ;testing wraparound result\n1841 : a200                     ldx #0\n1843 : b90302           tstay4  lda abst,y\n1846 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n1849 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n184b : 8a                       txa\n184c : 990302                   sta abst,y  ;clear                \n184f : 88                       dey\n1850 : 10f1                     bpl tstay4\n                                \n1852 : a0fb                     ldy #3+$f8\n1854 : b91f01           tlday5  lda abs1-$f8,y  ;no wrap on indexed abs\n1857 : 9138                     sta (inwt),y\n1859 : 88                       dey\n185a : c0f8                     cpy #$f8\n185c : b0f6                     bcs tlday5                  \n185e : a003                     ldy #3      ;testing wraparound result\n1860 : a200                     ldx #0\n1862 : b90302           tstay5  lda abst,y\n1865 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n1868 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n186a : 8a                       txa\n186b : 990302                   sta abst,y  ;clear                \n186e : 88                       dey\n186f : 10f1                     bpl tstay5\n                        \n1871 : a0fb                     ldy #3+$f8\n1873 : a2fe                     ldx #6+$f8\n1875 : b12e             tlday6  lda (inw1),y    ;no wrap on zp indirect indexed \n1877 : 8138                     sta (indt-$f8&$ff,x)\n1879 : ca                       dex\n187a : ca                       dex\n187b : 88                       dey\n187c : c0f8                     cpy #$f8\n187e : b0f5                     bcs tlday6\n1880 : a003                     ldy #3      ;testing wraparound result\n1882 : a200                     ldx #0\n1884 : b90302           tstay6  lda abst,y\n1887 : d91702                   cmp abs1,y\n                                trap_ne     ;store to abs data\n188a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n188c : 8a                       txa\n188d : 990302                   sta abst,y  ;clear                \n1890 : 88                       dey\n1891 : 10f1                     bpl tstay6\n                                next_test\n1893 : ad0002          >            lda test_case   ;previous test\n1896 : c917            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1898 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0018 =                 >test_num = test_num + 1\n189a : a918            >            lda #test_num   ;*** next tests' number\n189c : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; LDA / STA - zp / abs / #\n                                set_stat 0  \n                       >            load_flag 0  \n189f : a900            >            lda #0               ;allow test to change I-flag (no mask)\n                       >\n18a1 : 48              >            pha         ;use stack to load status\n18a2 : 28              >            plp\n                        \n18a3 : a513                     lda zp1\n18a5 : 08                       php         ;test stores do not alter flags\n18a6 : 49c3                     eor #$c3\n18a8 : 28                       plp\n18a9 : 8d0302                   sta abst\n18ac : 08                       php         ;flags after load/store sequence\n18ad : 49c3                     eor #$c3\n18af : c9c3                     cmp #$c3    ;test result\n                                trap_ne\n18b1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n18b3 : 68                       pla         ;load status\n                                eor_flag 0\n18b4 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n18b6 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n18b9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n18bb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n18bd : 48              >            pha         ;use stack to load status\n18be : 28              >            plp\n                        \n18bf : a514                     lda zp1+1\n18c1 : 08                       php         ;test stores do not alter flags\n18c2 : 49c3                     eor #$c3\n18c4 : 28                       plp\n18c5 : 8d0402                   sta abst+1\n18c8 : 08                       php         ;flags after load/store sequence\n18c9 : 49c3                     eor #$c3\n18cb : c982                     cmp #$82    ;test result\n                                trap_ne\n18cd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n18cf : 68                       pla         ;load status\n                                eor_flag 0\n18d0 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n18d2 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n18d5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n18d7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n18d9 : 48              >            pha         ;use stack to load status\n18da : 28              >            plp\n                        \n18db : a515                     lda zp1+2\n18dd : 08                       php         ;test stores do not alter flags\n18de : 49c3                     eor #$c3\n18e0 : 28                       plp\n18e1 : 8d0502                   sta abst+2\n18e4 : 08                       php         ;flags after load/store sequence\n18e5 : 49c3                     eor #$c3\n18e7 : c941                     cmp #$41    ;test result\n                                trap_ne\n18e9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n18eb : 68                       pla         ;load status\n                                eor_flag 0\n18ec : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n18ee : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n18f1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n18f3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n18f5 : 48              >            pha         ;use stack to load status\n18f6 : 28              >            plp\n                        \n18f7 : a516                     lda zp1+3\n18f9 : 08                       php         ;test stores do not alter flags\n18fa : 49c3                     eor #$c3\n18fc : 28                       plp\n18fd : 8d0602                   sta abst+3\n1900 : 08                       php         ;flags after load/store sequence\n1901 : 49c3                     eor #$c3\n1903 : c900                     cmp #0      ;test result\n                                trap_ne\n1905 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1907 : 68                       pla         ;load status\n                                eor_flag 0\n1908 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n190a : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n190d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n190f : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1911 : 48              >            pha         ;use stack to load status\n1912 : 28              >            plp\n                        \n1913 : a513                     lda zp1  \n1915 : 08                       php         ;test stores do not alter flags\n1916 : 49c3                     eor #$c3\n1918 : 28                       plp\n1919 : 8d0302                   sta abst  \n191c : 08                       php         ;flags after load/store sequence\n191d : 49c3                     eor #$c3\n191f : c9c3                     cmp #$c3    ;test result\n                                trap_ne\n1921 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1923 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1924 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1926 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1929 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n192b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n192d : 48              >            pha         ;use stack to load status\n192e : 28              >            plp\n                        \n192f : a514                     lda zp1+1\n1931 : 08                       php         ;test stores do not alter flags\n1932 : 49c3                     eor #$c3\n1934 : 28                       plp\n1935 : 8d0402                   sta abst+1\n1938 : 08                       php         ;flags after load/store sequence\n1939 : 49c3                     eor #$c3\n193b : c982                     cmp #$82    ;test result\n                                trap_ne\n193d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n193f : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1940 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1942 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1945 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1947 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1949 : 48              >            pha         ;use stack to load status\n194a : 28              >            plp\n                        \n194b : a515                     lda zp1+2\n194d : 08                       php         ;test stores do not alter flags\n194e : 49c3                     eor #$c3\n1950 : 28                       plp\n1951 : 8d0502                   sta abst+2\n1954 : 08                       php         ;flags after load/store sequence\n1955 : 49c3                     eor #$c3\n1957 : c941                     cmp #$41    ;test result\n                                trap_ne\n1959 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n195b : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n195c : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n195e : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1961 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1963 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1965 : 48              >            pha         ;use stack to load status\n1966 : 28              >            plp\n                        \n1967 : a516                     lda zp1+3\n1969 : 08                       php         ;test stores do not alter flags\n196a : 49c3                     eor #$c3\n196c : 28                       plp\n196d : 8d0602                   sta abst+3\n1970 : 08                       php         ;flags after load/store sequence\n1971 : 49c3                     eor #$c3\n1973 : c900                     cmp #0      ;test result\n                                trap_ne\n1975 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1977 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1978 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n197a : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n197d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n197f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1981 : 48              >            pha         ;use stack to load status\n1982 : 28              >            plp\n                        \n1983 : ad1702                   lda abs1  \n1986 : 08                       php         ;test stores do not alter flags\n1987 : 49c3                     eor #$c3\n1989 : 28                       plp\n198a : 850c                     sta zpt  \n198c : 08                       php         ;flags after load/store sequence\n198d : 49c3                     eor #$c3\n198f : c513                     cmp zp1     ;test result\n                                trap_ne\n1991 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1993 : 68                       pla         ;load status\n                                eor_flag 0\n1994 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1996 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1999 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n199b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n199d : 48              >            pha         ;use stack to load status\n199e : 28              >            plp\n                        \n199f : ad1802                   lda abs1+1\n19a2 : 08                       php         ;test stores do not alter flags\n19a3 : 49c3                     eor #$c3\n19a5 : 28                       plp\n19a6 : 850d                     sta zpt+1\n19a8 : 08                       php         ;flags after load/store sequence\n19a9 : 49c3                     eor #$c3\n19ab : c514                     cmp zp1+1   ;test result\n                                trap_ne\n19ad : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n19af : 68                       pla         ;load status\n                                eor_flag 0\n19b0 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n19b2 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n19b5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n19b7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n19b9 : 48              >            pha         ;use stack to load status\n19ba : 28              >            plp\n                        \n19bb : ad1902                   lda abs1+2\n19be : 08                       php         ;test stores do not alter flags\n19bf : 49c3                     eor #$c3\n19c1 : 28                       plp\n19c2 : 850e                     sta zpt+2\n19c4 : 08                       php         ;flags after load/store sequence\n19c5 : 49c3                     eor #$c3\n19c7 : c515                     cmp zp1+2   ;test result\n                                trap_ne\n19c9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n19cb : 68                       pla         ;load status\n                                eor_flag 0\n19cc : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n19ce : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n19d1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n19d3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n19d5 : 48              >            pha         ;use stack to load status\n19d6 : 28              >            plp\n                        \n19d7 : ad1a02                   lda abs1+3\n19da : 08                       php         ;test stores do not alter flags\n19db : 49c3                     eor #$c3\n19dd : 28                       plp\n19de : 850f                     sta zpt+3\n19e0 : 08                       php         ;flags after load/store sequence\n19e1 : 49c3                     eor #$c3\n19e3 : c516                     cmp zp1+3   ;test result\n                                trap_ne\n19e5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n19e7 : 68                       pla         ;load status\n                                eor_flag 0\n19e8 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n19ea : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n19ed : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n19ef : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n19f1 : 48              >            pha         ;use stack to load status\n19f2 : 28              >            plp\n                        \n19f3 : ad1702                   lda abs1  \n19f6 : 08                       php         ;test stores do not alter flags\n19f7 : 49c3                     eor #$c3\n19f9 : 28                       plp\n19fa : 850c                     sta zpt  \n19fc : 08                       php         ;flags after load/store sequence\n19fd : 49c3                     eor #$c3\n19ff : c513                     cmp zp1     ;test result\n                                trap_ne\n1a01 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a03 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1a04 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1a06 : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1a09 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1a0b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1a0d : 48              >            pha         ;use stack to load status\n1a0e : 28              >            plp\n                        \n1a0f : ad1802                   lda abs1+1\n1a12 : 08                       php         ;test stores do not alter flags\n1a13 : 49c3                     eor #$c3\n1a15 : 28                       plp\n1a16 : 850d                     sta zpt+1\n1a18 : 08                       php         ;flags after load/store sequence\n1a19 : 49c3                     eor #$c3\n1a1b : c514                     cmp zp1+1   ;test result\n                                trap_ne\n1a1d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a1f : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1a20 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1a22 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1a25 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1a27 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1a29 : 48              >            pha         ;use stack to load status\n1a2a : 28              >            plp\n                        \n1a2b : ad1902                   lda abs1+2\n1a2e : 08                       php         ;test stores do not alter flags\n1a2f : 49c3                     eor #$c3\n1a31 : 28                       plp\n1a32 : 850e                     sta zpt+2\n1a34 : 08                       php         ;flags after load/store sequence\n1a35 : 49c3                     eor #$c3\n1a37 : c515                     cmp zp1+2   ;test result\n                                trap_ne\n1a39 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a3b : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1a3c : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1a3e : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1a41 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1a43 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1a45 : 48              >            pha         ;use stack to load status\n1a46 : 28              >            plp\n                        \n1a47 : ad1a02                   lda abs1+3\n1a4a : 08                       php         ;test stores do not alter flags\n1a4b : 49c3                     eor #$c3\n1a4d : 28                       plp\n1a4e : 850f                     sta zpt+3\n1a50 : 08                       php         ;flags after load/store sequence\n1a51 : 49c3                     eor #$c3\n1a53 : c516                     cmp zp1+3   ;test result\n                                trap_ne\n1a55 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a57 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1a58 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1a5a : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1a5d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0  \n                       >            load_flag 0  \n1a5f : a900            >            lda #0               ;allow test to change I-flag (no mask)\n                       >\n1a61 : 48              >            pha         ;use stack to load status\n1a62 : 28              >            plp\n                        \n1a63 : a9c3                     lda #$c3\n1a65 : 08                       php\n1a66 : cd1702                   cmp abs1    ;test result\n                                trap_ne\n1a69 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a6b : 68                       pla         ;load status\n                                eor_flag 0\n1a6c : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1a6e : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1a71 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1a73 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1a75 : 48              >            pha         ;use stack to load status\n1a76 : 28              >            plp\n                        \n1a77 : a982                     lda #$82\n1a79 : 08                       php\n1a7a : cd1802                   cmp abs1+1  ;test result\n                                trap_ne\n1a7d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a7f : 68                       pla         ;load status\n                                eor_flag 0\n1a80 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1a82 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1a85 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1a87 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1a89 : 48              >            pha         ;use stack to load status\n1a8a : 28              >            plp\n                        \n1a8b : a941                     lda #$41\n1a8d : 08                       php\n1a8e : cd1902                   cmp abs1+2  ;test result\n                                trap_ne\n1a91 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1a93 : 68                       pla         ;load status\n                                eor_flag 0\n1a94 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1a96 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1a99 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat 0\n                       >            load_flag 0\n1a9b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1a9d : 48              >            pha         ;use stack to load status\n1a9e : 28              >            plp\n                        \n1a9f : a900                     lda #0\n1aa1 : 08                       php\n1aa2 : cd1a02                   cmp abs1+3  ;test result\n                                trap_ne\n1aa5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1aa7 : 68                       pla         ;load status\n                                eor_flag 0\n1aa8 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                        \n1aaa : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1aad : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1aaf : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1ab1 : 48              >            pha         ;use stack to load status\n1ab2 : 28              >            plp\n                        \n1ab3 : a9c3                     lda #$c3  \n1ab5 : 08                       php\n1ab6 : cd1702                   cmp abs1    ;test result\n                                trap_ne\n1ab9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1abb : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1abc : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1abe : cd1c02                   cmp fLDx    ;test flags\n                                trap_ne\n1ac1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1ac3 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1ac5 : 48              >            pha         ;use stack to load status\n1ac6 : 28              >            plp\n                        \n1ac7 : a982                     lda #$82\n1ac9 : 08                       php\n1aca : cd1802                   cmp abs1+1  ;test result\n                                trap_ne\n1acd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1acf : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1ad0 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1ad2 : cd1d02                   cmp fLDx+1  ;test flags\n                                trap_ne\n1ad5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1ad7 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1ad9 : 48              >            pha         ;use stack to load status\n1ada : 28              >            plp\n                        \n1adb : a941                     lda #$41\n1add : 08                       php\n1ade : cd1902                   cmp abs1+2  ;test result\n                                trap_ne\n1ae1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1ae3 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1ae4 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1ae6 : cd1e02                   cmp fLDx+2  ;test flags\n                                trap_ne\n1ae9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n1aeb : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1aed : 48              >            pha         ;use stack to load status\n1aee : 28              >            plp\n                        \n1aef : a900                     lda #0\n1af1 : 08                       php\n1af2 : cd1a02                   cmp abs1+3  ;test result\n                                trap_ne\n1af5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1af7 : 68                       pla         ;load status\n                                eor_flag lo~fnz ;mask bits not altered\n1af8 : 497d            >            eor #lo~fnz |fao         ;invert expected flags + always on bits\n                        \n1afa : cd1f02                   cmp fLDx+3  ;test flags\n                                trap_ne\n1afd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                        \n1aff : a200                     ldx #0\n1b01 : a50c                     lda zpt  \n1b03 : 49c3                     eor #$c3\n1b05 : c513                     cmp zp1  \n                                trap_ne     ;store to zp data\n1b07 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b09 : 860c                     stx zpt     ;clear                \n1b0b : ad0302                   lda abst  \n1b0e : 49c3                     eor #$c3\n1b10 : cd1702                   cmp abs1  \n                                trap_ne     ;store to abs data\n1b13 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b15 : 8e0302                   stx abst    ;clear                \n1b18 : a50d                     lda zpt+1\n1b1a : 49c3                     eor #$c3\n1b1c : c514                     cmp zp1+1\n                                trap_ne     ;store to zp data\n1b1e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b20 : 860d                     stx zpt+1   ;clear                \n1b22 : ad0402                   lda abst+1\n1b25 : 49c3                     eor #$c3\n1b27 : cd1802                   cmp abs1+1\n                                trap_ne     ;store to abs data\n1b2a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b2c : 8e0402                   stx abst+1  ;clear                \n1b2f : a50e                     lda zpt+2\n1b31 : 49c3                     eor #$c3\n1b33 : c515                     cmp zp1+2\n                                trap_ne     ;store to zp data\n1b35 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b37 : 860e                     stx zpt+2   ;clear                \n1b39 : ad0502                   lda abst+2\n1b3c : 49c3                     eor #$c3\n1b3e : cd1902                   cmp abs1+2\n                                trap_ne     ;store to abs data\n1b41 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b43 : 8e0502                   stx abst+2  ;clear                \n1b46 : a50f                     lda zpt+3\n1b48 : 49c3                     eor #$c3\n1b4a : c516                     cmp zp1+3\n                                trap_ne     ;store to zp data\n1b4c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b4e : 860f                     stx zpt+3   ;clear                \n1b50 : ad0602                   lda abst+3\n1b53 : 49c3                     eor #$c3\n1b55 : cd1a02                   cmp abs1+3\n                                trap_ne     ;store to abs data\n1b58 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n1b5a : 8e0602                   stx abst+3  ;clear                \n                                next_test\n1b5d : ad0002          >            lda test_case   ;previous test\n1b60 : c918            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1b62 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0019 =                 >test_num = test_num + 1\n1b64 : a919            >            lda #test_num   ;*** next tests' number\n1b66 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; testing bit test & compares BIT CPX CPY CMP all addressing modes\n                        ; BIT - zp / abs\n                                set_a $ff,0\n                       >            load_flag 0\n1b69 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1b6b : 48              >            pha         ;use stack to load status\n1b6c : a9ff            >            lda #$ff     ;precharge accu\n1b6e : 28              >            plp\n                        \n1b6f : 2416                     bit zp1+3   ;00 - should set Z / clear  NV\n                                tst_a $ff,fz \n1b71 : 08              >            php         ;save flags\n1b72 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n1b74 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1b76 : 68              >            pla         ;load status\n1b77 : 48              >            pha\n                       >            cmp_flag fz \n1b78 : c932            >            cmp #(fz |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1b7a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1b7c : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1b7d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1b7f : 48              >            pha         ;use stack to load status\n1b80 : a901            >            lda #1     ;precharge accu\n1b82 : 28              >            plp\n                        \n1b83 : 2415                     bit zp1+2   ;41 - should set V (M6) / clear NZ\n                                tst_a 1,fv\n1b85 : 08              >            php         ;save flags\n1b86 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1b88 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1b8a : 68              >            pla         ;load status\n1b8b : 48              >            pha\n                       >            cmp_flag fv\n1b8c : c970            >            cmp #(fv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1b8e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1b90 : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1b91 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1b93 : 48              >            pha         ;use stack to load status\n1b94 : a901            >            lda #1     ;precharge accu\n1b96 : 28              >            plp\n                        \n1b97 : 2414                     bit zp1+1   ;82 - should set N (M7) & Z / clear V\n                                tst_a 1,fnz\n1b99 : 08              >            php         ;save flags\n1b9a : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1b9c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1b9e : 68              >            pla         ;load status\n1b9f : 48              >            pha\n                       >            cmp_flag fnz\n1ba0 : c9b2            >            cmp #(fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1ba2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ba4 : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1ba5 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1ba7 : 48              >            pha         ;use stack to load status\n1ba8 : a901            >            lda #1     ;precharge accu\n1baa : 28              >            plp\n                        \n1bab : 2413                     bit zp1     ;c3 - should set N (M7) & V (M6) / clear Z\n                                tst_a 1,fnv\n1bad : 08              >            php         ;save flags\n1bae : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1bb0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bb2 : 68              >            pla         ;load status\n1bb3 : 48              >            pha\n                       >            cmp_flag fnv\n1bb4 : c9f0            >            cmp #(fnv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1bb6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bb8 : 28              >            plp         ;restore status\n                        \n                                \n                                set_a $ff,$ff\n                       >            load_flag $ff\n1bb9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1bbb : 48              >            pha         ;use stack to load status\n1bbc : a9ff            >            lda #$ff     ;precharge accu\n1bbe : 28              >            plp\n                        \n1bbf : 2416                     bit zp1+3   ;00 - should set Z / clear  NV\n                                tst_a $ff,~fnv \n1bc1 : 08              >            php         ;save flags\n1bc2 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n1bc4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bc6 : 68              >            pla         ;load status\n1bc7 : 48              >            pha\n                       >            cmp_flag ~fnv \n1bc8 : c93f            >            cmp #(~fnv |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1bca : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bcc : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1bcd : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1bcf : 48              >            pha         ;use stack to load status\n1bd0 : a901            >            lda #1     ;precharge accu\n1bd2 : 28              >            plp\n                        \n1bd3 : 2415                     bit zp1+2   ;41 - should set V (M6) / clear NZ\n                                tst_a 1,~fnz\n1bd5 : 08              >            php         ;save flags\n1bd6 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1bd8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bda : 68              >            pla         ;load status\n1bdb : 48              >            pha\n                       >            cmp_flag ~fnz\n1bdc : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1bde : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1be0 : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1be1 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1be3 : 48              >            pha         ;use stack to load status\n1be4 : a901            >            lda #1     ;precharge accu\n1be6 : 28              >            plp\n                        \n1be7 : 2414                     bit zp1+1   ;82 - should set N (M7) & Z / clear V\n                                tst_a 1,~fv\n1be9 : 08              >            php         ;save flags\n1bea : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1bec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bee : 68              >            pla         ;load status\n1bef : 48              >            pha\n                       >            cmp_flag ~fv\n1bf0 : c9bf            >            cmp #(~fv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1bf2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1bf4 : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1bf5 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1bf7 : 48              >            pha         ;use stack to load status\n1bf8 : a901            >            lda #1     ;precharge accu\n1bfa : 28              >            plp\n                        \n1bfb : 2413                     bit zp1     ;c3 - should set N (M7) & V (M6) / clear Z\n                                tst_a 1,~fz\n1bfd : 08              >            php         ;save flags\n1bfe : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c00 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c02 : 68              >            pla         ;load status\n1c03 : 48              >            pha\n                       >            cmp_flag ~fz\n1c04 : c9fd            >            cmp #(~fz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c06 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c08 : 28              >            plp         ;restore status\n                        \n                                \n                                set_a $ff,0\n                       >            load_flag 0\n1c09 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1c0b : 48              >            pha         ;use stack to load status\n1c0c : a9ff            >            lda #$ff     ;precharge accu\n1c0e : 28              >            plp\n                        \n1c0f : 2c1a02                   bit abs1+3  ;00 - should set Z / clear  NV\n                                tst_a $ff,fz \n1c12 : 08              >            php         ;save flags\n1c13 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n1c15 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c17 : 68              >            pla         ;load status\n1c18 : 48              >            pha\n                       >            cmp_flag fz \n1c19 : c932            >            cmp #(fz |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c1b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c1d : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1c1e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1c20 : 48              >            pha         ;use stack to load status\n1c21 : a901            >            lda #1     ;precharge accu\n1c23 : 28              >            plp\n                        \n1c24 : 2c1902                   bit abs1+2  ;41 - should set V (M6) / clear NZ\n                                tst_a 1,fv\n1c27 : 08              >            php         ;save flags\n1c28 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c2a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c2c : 68              >            pla         ;load status\n1c2d : 48              >            pha\n                       >            cmp_flag fv\n1c2e : c970            >            cmp #(fv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c30 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c32 : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1c33 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1c35 : 48              >            pha         ;use stack to load status\n1c36 : a901            >            lda #1     ;precharge accu\n1c38 : 28              >            plp\n                        \n1c39 : 2c1802                   bit abs1+1  ;82 - should set N (M7) & Z / clear V\n                                tst_a 1,fnz\n1c3c : 08              >            php         ;save flags\n1c3d : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c3f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c41 : 68              >            pla         ;load status\n1c42 : 48              >            pha\n                       >            cmp_flag fnz\n1c43 : c9b2            >            cmp #(fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c45 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c47 : 28              >            plp         ;restore status\n                        \n                                set_a 1,0\n                       >            load_flag 0\n1c48 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1c4a : 48              >            pha         ;use stack to load status\n1c4b : a901            >            lda #1     ;precharge accu\n1c4d : 28              >            plp\n                        \n1c4e : 2c1702                   bit abs1    ;c3 - should set N (M7) & V (M6) / clear Z\n                                tst_a 1,fnv\n1c51 : 08              >            php         ;save flags\n1c52 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c54 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c56 : 68              >            pla         ;load status\n1c57 : 48              >            pha\n                       >            cmp_flag fnv\n1c58 : c9f0            >            cmp #(fnv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c5a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c5c : 28              >            plp         ;restore status\n                        \n                                \n                                set_a $ff,$ff\n                       >            load_flag $ff\n1c5d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1c5f : 48              >            pha         ;use stack to load status\n1c60 : a9ff            >            lda #$ff     ;precharge accu\n1c62 : 28              >            plp\n                        \n1c63 : 2c1a02                   bit abs1+3  ;00 - should set Z / clear  NV\n                                tst_a $ff,~fnv \n1c66 : 08              >            php         ;save flags\n1c67 : c9ff            >            cmp #$ff     ;test result\n                       >            trap_ne\n1c69 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c6b : 68              >            pla         ;load status\n1c6c : 48              >            pha\n                       >            cmp_flag ~fnv \n1c6d : c93f            >            cmp #(~fnv |fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c6f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c71 : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1c72 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1c74 : 48              >            pha         ;use stack to load status\n1c75 : a901            >            lda #1     ;precharge accu\n1c77 : 28              >            plp\n                        \n1c78 : 2c1902                   bit abs1+2  ;41 - should set V (M6) / clear NZ\n                                tst_a 1,~fnz\n1c7b : 08              >            php         ;save flags\n1c7c : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c7e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c80 : 68              >            pla         ;load status\n1c81 : 48              >            pha\n                       >            cmp_flag ~fnz\n1c82 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c84 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c86 : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1c87 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1c89 : 48              >            pha         ;use stack to load status\n1c8a : a901            >            lda #1     ;precharge accu\n1c8c : 28              >            plp\n                        \n1c8d : 2c1802                   bit abs1+1  ;82 - should set N (M7) & Z / clear V\n                                tst_a 1,~fv\n1c90 : 08              >            php         ;save flags\n1c91 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1c93 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c95 : 68              >            pla         ;load status\n1c96 : 48              >            pha\n                       >            cmp_flag ~fv\n1c97 : c9bf            >            cmp #(~fv|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1c99 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1c9b : 28              >            plp         ;restore status\n                        \n                                set_a 1,$ff\n                       >            load_flag $ff\n1c9c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1c9e : 48              >            pha         ;use stack to load status\n1c9f : a901            >            lda #1     ;precharge accu\n1ca1 : 28              >            plp\n                        \n1ca2 : 2c1702                   bit abs1    ;c3 - should set N (M7) & V (M6) / clear Z\n                                tst_a 1,~fz\n1ca5 : 08              >            php         ;save flags\n1ca6 : c901            >            cmp #1     ;test result\n                       >            trap_ne\n1ca8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1caa : 68              >            pla         ;load status\n1cab : 48              >            pha\n                       >            cmp_flag ~fz\n1cac : c9fd            >            cmp #(~fz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1cae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1cb0 : 28              >            plp         ;restore status\n                        \n                                next_test\n1cb1 : ad0002          >            lda test_case   ;previous test\n1cb4 : c919            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1cb6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001a =                 >test_num = test_num + 1\n1cb8 : a91a            >            lda #test_num   ;*** next tests' number\n1cba : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; CPX - zp / abs / #         \n                                set_x $80,0\n                       >            load_flag 0\n1cbd : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1cbf : 48              >            pha         ;use stack to load status\n1cc0 : a280            >            ldx #$80     ;precharge index x\n1cc2 : 28              >            plp\n                        \n1cc3 : e417                     cpx zp7f\n                                tst_stat fc\n1cc5 : 08              >            php         ;save status\n1cc6 : 68              >            pla         ;use stack to retrieve status\n1cc7 : 48              >            pha\n                       >            cmp_flag fc\n1cc8 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1cca : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ccc : 28              >            plp         ;restore status\n                        \n1ccd : ca                       dex\n1cce : e417                     cpx zp7f\n                                tst_stat fzc\n1cd0 : 08              >            php         ;save status\n1cd1 : 68              >            pla         ;use stack to retrieve status\n1cd2 : 48              >            pha\n                       >            cmp_flag fzc\n1cd3 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1cd5 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1cd7 : 28              >            plp         ;restore status\n                        \n1cd8 : ca                       dex\n1cd9 : e417                     cpx zp7f\n                                tst_x $7e,fn\n1cdb : 08              >            php         ;save flags\n1cdc : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1cde : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ce0 : 68              >            pla         ;load status\n1ce1 : 48              >            pha\n                       >            cmp_flag fn\n1ce2 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1ce4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ce6 : 28              >            plp         ;restore status\n                        \n                                set_x $80,$ff\n                       >            load_flag $ff\n1ce7 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1ce9 : 48              >            pha         ;use stack to load status\n1cea : a280            >            ldx #$80     ;precharge index x\n1cec : 28              >            plp\n                        \n1ced : e417                     cpx zp7f\n                                tst_stat ~fnz\n1cef : 08              >            php         ;save status\n1cf0 : 68              >            pla         ;use stack to retrieve status\n1cf1 : 48              >            pha\n                       >            cmp_flag ~fnz\n1cf2 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1cf4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1cf6 : 28              >            plp         ;restore status\n                        \n1cf7 : ca                       dex\n1cf8 : e417                     cpx zp7f\n                                tst_stat ~fn\n1cfa : 08              >            php         ;save status\n1cfb : 68              >            pla         ;use stack to retrieve status\n1cfc : 48              >            pha\n                       >            cmp_flag ~fn\n1cfd : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1cff : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d01 : 28              >            plp         ;restore status\n                        \n1d02 : ca                       dex\n1d03 : e417                     cpx zp7f\n                                tst_x $7e,~fzc\n1d05 : 08              >            php         ;save flags\n1d06 : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1d08 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d0a : 68              >            pla         ;load status\n1d0b : 48              >            pha\n                       >            cmp_flag ~fzc\n1d0c : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d0e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d10 : 28              >            plp         ;restore status\n                        \n                        \n                                set_x $80,0\n                       >            load_flag 0\n1d11 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1d13 : 48              >            pha         ;use stack to load status\n1d14 : a280            >            ldx #$80     ;precharge index x\n1d16 : 28              >            plp\n                        \n1d17 : ec1b02                   cpx abs7f\n                                tst_stat fc\n1d1a : 08              >            php         ;save status\n1d1b : 68              >            pla         ;use stack to retrieve status\n1d1c : 48              >            pha\n                       >            cmp_flag fc\n1d1d : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d1f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d21 : 28              >            plp         ;restore status\n                        \n1d22 : ca                       dex\n1d23 : ec1b02                   cpx abs7f\n                                tst_stat fzc\n1d26 : 08              >            php         ;save status\n1d27 : 68              >            pla         ;use stack to retrieve status\n1d28 : 48              >            pha\n                       >            cmp_flag fzc\n1d29 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d2b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d2d : 28              >            plp         ;restore status\n                        \n1d2e : ca                       dex\n1d2f : ec1b02                   cpx abs7f\n                                tst_x $7e,fn\n1d32 : 08              >            php         ;save flags\n1d33 : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1d35 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d37 : 68              >            pla         ;load status\n1d38 : 48              >            pha\n                       >            cmp_flag fn\n1d39 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d3b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d3d : 28              >            plp         ;restore status\n                        \n                                set_x $80,$ff\n                       >            load_flag $ff\n1d3e : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1d40 : 48              >            pha         ;use stack to load status\n1d41 : a280            >            ldx #$80     ;precharge index x\n1d43 : 28              >            plp\n                        \n1d44 : ec1b02                   cpx abs7f\n                                tst_stat ~fnz\n1d47 : 08              >            php         ;save status\n1d48 : 68              >            pla         ;use stack to retrieve status\n1d49 : 48              >            pha\n                       >            cmp_flag ~fnz\n1d4a : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d4c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d4e : 28              >            plp         ;restore status\n                        \n1d4f : ca                       dex\n1d50 : ec1b02                   cpx abs7f\n                                tst_stat ~fn\n1d53 : 08              >            php         ;save status\n1d54 : 68              >            pla         ;use stack to retrieve status\n1d55 : 48              >            pha\n                       >            cmp_flag ~fn\n1d56 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d58 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d5a : 28              >            plp         ;restore status\n                        \n1d5b : ca                       dex\n1d5c : ec1b02                   cpx abs7f\n                                tst_x $7e,~fzc\n1d5f : 08              >            php         ;save flags\n1d60 : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1d62 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d64 : 68              >            pla         ;load status\n1d65 : 48              >            pha\n                       >            cmp_flag ~fzc\n1d66 : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d68 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d6a : 28              >            plp         ;restore status\n                        \n                        \n                                set_x $80,0\n                       >            load_flag 0\n1d6b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1d6d : 48              >            pha         ;use stack to load status\n1d6e : a280            >            ldx #$80     ;precharge index x\n1d70 : 28              >            plp\n                        \n1d71 : e07f                     cpx #$7f\n                                tst_stat fc\n1d73 : 08              >            php         ;save status\n1d74 : 68              >            pla         ;use stack to retrieve status\n1d75 : 48              >            pha\n                       >            cmp_flag fc\n1d76 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d78 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d7a : 28              >            plp         ;restore status\n                        \n1d7b : ca                       dex\n1d7c : e07f                     cpx #$7f\n                                tst_stat fzc\n1d7e : 08              >            php         ;save status\n1d7f : 68              >            pla         ;use stack to retrieve status\n1d80 : 48              >            pha\n                       >            cmp_flag fzc\n1d81 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d83 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d85 : 28              >            plp         ;restore status\n                        \n1d86 : ca                       dex\n1d87 : e07f                     cpx #$7f\n                                tst_x $7e,fn\n1d89 : 08              >            php         ;save flags\n1d8a : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1d8c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d8e : 68              >            pla         ;load status\n1d8f : 48              >            pha\n                       >            cmp_flag fn\n1d90 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1d92 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1d94 : 28              >            plp         ;restore status\n                        \n                                set_x $80,$ff\n                       >            load_flag $ff\n1d95 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1d97 : 48              >            pha         ;use stack to load status\n1d98 : a280            >            ldx #$80     ;precharge index x\n1d9a : 28              >            plp\n                        \n1d9b : e07f                     cpx #$7f\n                                tst_stat ~fnz\n1d9d : 08              >            php         ;save status\n1d9e : 68              >            pla         ;use stack to retrieve status\n1d9f : 48              >            pha\n                       >            cmp_flag ~fnz\n1da0 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1da2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1da4 : 28              >            plp         ;restore status\n                        \n1da5 : ca                       dex\n1da6 : e07f                     cpx #$7f\n                                tst_stat ~fn\n1da8 : 08              >            php         ;save status\n1da9 : 68              >            pla         ;use stack to retrieve status\n1daa : 48              >            pha\n                       >            cmp_flag ~fn\n1dab : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1dad : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1daf : 28              >            plp         ;restore status\n                        \n1db0 : ca                       dex\n1db1 : e07f                     cpx #$7f\n                                tst_x $7e,~fzc\n1db3 : 08              >            php         ;save flags\n1db4 : e07e            >            cpx #$7e     ;test result\n                       >            trap_ne\n1db6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1db8 : 68              >            pla         ;load status\n1db9 : 48              >            pha\n                       >            cmp_flag ~fzc\n1dba : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1dbc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1dbe : 28              >            plp         ;restore status\n                        \n                                next_test\n1dbf : ad0002          >            lda test_case   ;previous test\n1dc2 : c91a            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1dc4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001b =                 >test_num = test_num + 1\n1dc6 : a91b            >            lda #test_num   ;*** next tests' number\n1dc8 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; CPY - zp / abs / #         \n                                set_y $80,0\n                       >            load_flag 0\n1dcb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1dcd : 48              >            pha         ;use stack to load status\n1dce : a080            >            ldy #$80     ;precharge index y\n1dd0 : 28              >            plp\n                        \n1dd1 : c417                     cpy zp7f\n                                tst_stat fc\n1dd3 : 08              >            php         ;save status\n1dd4 : 68              >            pla         ;use stack to retrieve status\n1dd5 : 48              >            pha\n                       >            cmp_flag fc\n1dd6 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1dd8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1dda : 28              >            plp         ;restore status\n                        \n1ddb : 88                       dey\n1ddc : c417                     cpy zp7f\n                                tst_stat fzc\n1dde : 08              >            php         ;save status\n1ddf : 68              >            pla         ;use stack to retrieve status\n1de0 : 48              >            pha\n                       >            cmp_flag fzc\n1de1 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1de3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1de5 : 28              >            plp         ;restore status\n                        \n1de6 : 88                       dey\n1de7 : c417                     cpy zp7f\n                                tst_y $7e,fn\n1de9 : 08              >            php         ;save flags\n1dea : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1dec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1dee : 68              >            pla         ;load status\n1def : 48              >            pha\n                       >            cmp_flag fn\n1df0 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1df2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1df4 : 28              >            plp         ;restore status\n                        \n                                set_y $80,$ff\n                       >            load_flag $ff\n1df5 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1df7 : 48              >            pha         ;use stack to load status\n1df8 : a080            >            ldy #$80     ;precharge index y\n1dfa : 28              >            plp\n                        \n1dfb : c417                     cpy zp7f\n                                tst_stat ~fnz\n1dfd : 08              >            php         ;save status\n1dfe : 68              >            pla         ;use stack to retrieve status\n1dff : 48              >            pha\n                       >            cmp_flag ~fnz\n1e00 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e02 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e04 : 28              >            plp         ;restore status\n                        \n1e05 : 88                       dey\n1e06 : c417                     cpy zp7f\n                                tst_stat ~fn\n1e08 : 08              >            php         ;save status\n1e09 : 68              >            pla         ;use stack to retrieve status\n1e0a : 48              >            pha\n                       >            cmp_flag ~fn\n1e0b : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e0d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e0f : 28              >            plp         ;restore status\n                        \n1e10 : 88                       dey\n1e11 : c417                     cpy zp7f\n                                tst_y $7e,~fzc\n1e13 : 08              >            php         ;save flags\n1e14 : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1e16 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e18 : 68              >            pla         ;load status\n1e19 : 48              >            pha\n                       >            cmp_flag ~fzc\n1e1a : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e1c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e1e : 28              >            plp         ;restore status\n                        \n                        \n                                set_y $80,0\n                       >            load_flag 0\n1e1f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1e21 : 48              >            pha         ;use stack to load status\n1e22 : a080            >            ldy #$80     ;precharge index y\n1e24 : 28              >            plp\n                        \n1e25 : cc1b02                   cpy abs7f\n                                tst_stat fc\n1e28 : 08              >            php         ;save status\n1e29 : 68              >            pla         ;use stack to retrieve status\n1e2a : 48              >            pha\n                       >            cmp_flag fc\n1e2b : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e2d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e2f : 28              >            plp         ;restore status\n                        \n1e30 : 88                       dey\n1e31 : cc1b02                   cpy abs7f\n                                tst_stat fzc\n1e34 : 08              >            php         ;save status\n1e35 : 68              >            pla         ;use stack to retrieve status\n1e36 : 48              >            pha\n                       >            cmp_flag fzc\n1e37 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e39 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e3b : 28              >            plp         ;restore status\n                        \n1e3c : 88                       dey\n1e3d : cc1b02                   cpy abs7f\n                                tst_y $7e,fn\n1e40 : 08              >            php         ;save flags\n1e41 : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1e43 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e45 : 68              >            pla         ;load status\n1e46 : 48              >            pha\n                       >            cmp_flag fn\n1e47 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e49 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e4b : 28              >            plp         ;restore status\n                        \n                                set_y $80,$ff\n                       >            load_flag $ff\n1e4c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1e4e : 48              >            pha         ;use stack to load status\n1e4f : a080            >            ldy #$80     ;precharge index y\n1e51 : 28              >            plp\n                        \n1e52 : cc1b02                   cpy abs7f\n                                tst_stat ~fnz\n1e55 : 08              >            php         ;save status\n1e56 : 68              >            pla         ;use stack to retrieve status\n1e57 : 48              >            pha\n                       >            cmp_flag ~fnz\n1e58 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e5a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e5c : 28              >            plp         ;restore status\n                        \n1e5d : 88                       dey\n1e5e : cc1b02                   cpy abs7f\n                                tst_stat ~fn\n1e61 : 08              >            php         ;save status\n1e62 : 68              >            pla         ;use stack to retrieve status\n1e63 : 48              >            pha\n                       >            cmp_flag ~fn\n1e64 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e66 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e68 : 28              >            plp         ;restore status\n                        \n1e69 : 88                       dey\n1e6a : cc1b02                   cpy abs7f\n                                tst_y $7e,~fzc\n1e6d : 08              >            php         ;save flags\n1e6e : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1e70 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e72 : 68              >            pla         ;load status\n1e73 : 48              >            pha\n                       >            cmp_flag ~fzc\n1e74 : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e76 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e78 : 28              >            plp         ;restore status\n                        \n                        \n                                set_y $80,0\n                       >            load_flag 0\n1e79 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1e7b : 48              >            pha         ;use stack to load status\n1e7c : a080            >            ldy #$80     ;precharge index y\n1e7e : 28              >            plp\n                        \n1e7f : c07f                     cpy #$7f\n                                tst_stat fc\n1e81 : 08              >            php         ;save status\n1e82 : 68              >            pla         ;use stack to retrieve status\n1e83 : 48              >            pha\n                       >            cmp_flag fc\n1e84 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e86 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e88 : 28              >            plp         ;restore status\n                        \n1e89 : 88                       dey\n1e8a : c07f                     cpy #$7f\n                                tst_stat fzc\n1e8c : 08              >            php         ;save status\n1e8d : 68              >            pla         ;use stack to retrieve status\n1e8e : 48              >            pha\n                       >            cmp_flag fzc\n1e8f : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1e91 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e93 : 28              >            plp         ;restore status\n                        \n1e94 : 88                       dey\n1e95 : c07f                     cpy #$7f\n                                tst_y $7e,fn\n1e97 : 08              >            php         ;save flags\n1e98 : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1e9a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1e9c : 68              >            pla         ;load status\n1e9d : 48              >            pha\n                       >            cmp_flag fn\n1e9e : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1ea0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ea2 : 28              >            plp         ;restore status\n                        \n                                set_y $80,$ff\n                       >            load_flag $ff\n1ea3 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1ea5 : 48              >            pha         ;use stack to load status\n1ea6 : a080            >            ldy #$80     ;precharge index y\n1ea8 : 28              >            plp\n                        \n1ea9 : c07f                     cpy #$7f\n                                tst_stat ~fnz\n1eab : 08              >            php         ;save status\n1eac : 68              >            pla         ;use stack to retrieve status\n1ead : 48              >            pha\n                       >            cmp_flag ~fnz\n1eae : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1eb0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1eb2 : 28              >            plp         ;restore status\n                        \n1eb3 : 88                       dey\n1eb4 : c07f                     cpy #$7f\n                                tst_stat ~fn\n1eb6 : 08              >            php         ;save status\n1eb7 : 68              >            pla         ;use stack to retrieve status\n1eb8 : 48              >            pha\n                       >            cmp_flag ~fn\n1eb9 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1ebb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ebd : 28              >            plp         ;restore status\n                        \n1ebe : 88                       dey\n1ebf : c07f                     cpy #$7f\n                                tst_y $7e,~fzc\n1ec1 : 08              >            php         ;save flags\n1ec2 : c07e            >            cpy #$7e     ;test result\n                       >            trap_ne\n1ec4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ec6 : 68              >            pla         ;load status\n1ec7 : 48              >            pha\n                       >            cmp_flag ~fzc\n1ec8 : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1eca : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ecc : 28              >            plp         ;restore status\n                        \n                                next_test\n1ecd : ad0002          >            lda test_case   ;previous test\n1ed0 : c91b            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n1ed2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001c =                 >test_num = test_num + 1\n1ed4 : a91c            >            lda #test_num   ;*** next tests' number\n1ed6 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; CMP - zp / abs / #         \n                                set_a $80,0\n                       >            load_flag 0\n1ed9 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1edb : 48              >            pha         ;use stack to load status\n1edc : a980            >            lda #$80     ;precharge accu\n1ede : 28              >            plp\n                        \n1edf : c517                     cmp zp7f\n                                tst_a $80,fc\n1ee1 : 08              >            php         ;save flags\n1ee2 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n1ee4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ee6 : 68              >            pla         ;load status\n1ee7 : 48              >            pha\n                       >            cmp_flag fc\n1ee8 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1eea : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1eec : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n1eed : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1eef : 48              >            pha         ;use stack to load status\n1ef0 : a97f            >            lda #$7f     ;precharge accu\n1ef2 : 28              >            plp\n                        \n1ef3 : c517                     cmp zp7f\n                                tst_a $7f,fzc\n1ef5 : 08              >            php         ;save flags\n1ef6 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n1ef8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1efa : 68              >            pla         ;load status\n1efb : 48              >            pha\n                       >            cmp_flag fzc\n1efc : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1efe : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f00 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n1f01 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1f03 : 48              >            pha         ;use stack to load status\n1f04 : a97e            >            lda #$7e     ;precharge accu\n1f06 : 28              >            plp\n                        \n1f07 : c517                     cmp zp7f\n                                tst_a $7e,fn\n1f09 : 08              >            php         ;save flags\n1f0a : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n1f0c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f0e : 68              >            pla         ;load status\n1f0f : 48              >            pha\n                       >            cmp_flag fn\n1f10 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f12 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f14 : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n1f15 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1f17 : 48              >            pha         ;use stack to load status\n1f18 : a980            >            lda #$80     ;precharge accu\n1f1a : 28              >            plp\n                        \n1f1b : c517                     cmp zp7f\n                                tst_a $80,~fnz\n1f1d : 08              >            php         ;save flags\n1f1e : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n1f20 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f22 : 68              >            pla         ;load status\n1f23 : 48              >            pha\n                       >            cmp_flag ~fnz\n1f24 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f26 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f28 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n1f29 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1f2b : 48              >            pha         ;use stack to load status\n1f2c : a97f            >            lda #$7f     ;precharge accu\n1f2e : 28              >            plp\n                        \n1f2f : c517                     cmp zp7f\n                                tst_a $7f,~fn\n1f31 : 08              >            php         ;save flags\n1f32 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n1f34 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f36 : 68              >            pla         ;load status\n1f37 : 48              >            pha\n                       >            cmp_flag ~fn\n1f38 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f3a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f3c : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n1f3d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1f3f : 48              >            pha         ;use stack to load status\n1f40 : a97e            >            lda #$7e     ;precharge accu\n1f42 : 28              >            plp\n                        \n1f43 : c517                     cmp zp7f\n                                tst_a $7e,~fzc\n1f45 : 08              >            php         ;save flags\n1f46 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n1f48 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f4a : 68              >            pla         ;load status\n1f4b : 48              >            pha\n                       >            cmp_flag ~fzc\n1f4c : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f4e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f50 : 28              >            plp         ;restore status\n                        \n                        \n                                set_a $80,0\n                       >            load_flag 0\n1f51 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1f53 : 48              >            pha         ;use stack to load status\n1f54 : a980            >            lda #$80     ;precharge accu\n1f56 : 28              >            plp\n                        \n1f57 : cd1b02                   cmp abs7f\n                                tst_a $80,fc\n1f5a : 08              >            php         ;save flags\n1f5b : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n1f5d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f5f : 68              >            pla         ;load status\n1f60 : 48              >            pha\n                       >            cmp_flag fc\n1f61 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f63 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f65 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n1f66 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1f68 : 48              >            pha         ;use stack to load status\n1f69 : a97f            >            lda #$7f     ;precharge accu\n1f6b : 28              >            plp\n                        \n1f6c : cd1b02                   cmp abs7f\n                                tst_a $7f,fzc\n1f6f : 08              >            php         ;save flags\n1f70 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n1f72 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f74 : 68              >            pla         ;load status\n1f75 : 48              >            pha\n                       >            cmp_flag fzc\n1f76 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f78 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f7a : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n1f7b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1f7d : 48              >            pha         ;use stack to load status\n1f7e : a97e            >            lda #$7e     ;precharge accu\n1f80 : 28              >            plp\n                        \n1f81 : cd1b02                   cmp abs7f\n                                tst_a $7e,fn\n1f84 : 08              >            php         ;save flags\n1f85 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n1f87 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f89 : 68              >            pla         ;load status\n1f8a : 48              >            pha\n                       >            cmp_flag fn\n1f8b : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1f8d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f8f : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n1f90 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1f92 : 48              >            pha         ;use stack to load status\n1f93 : a980            >            lda #$80     ;precharge accu\n1f95 : 28              >            plp\n                        \n1f96 : cd1b02                   cmp abs7f\n                                tst_a $80,~fnz\n1f99 : 08              >            php         ;save flags\n1f9a : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n1f9c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1f9e : 68              >            pla         ;load status\n1f9f : 48              >            pha\n                       >            cmp_flag ~fnz\n1fa0 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1fa2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fa4 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n1fa5 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1fa7 : 48              >            pha         ;use stack to load status\n1fa8 : a97f            >            lda #$7f     ;precharge accu\n1faa : 28              >            plp\n                        \n1fab : cd1b02                   cmp abs7f\n                                tst_a $7f,~fn\n1fae : 08              >            php         ;save flags\n1faf : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n1fb1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fb3 : 68              >            pla         ;load status\n1fb4 : 48              >            pha\n                       >            cmp_flag ~fn\n1fb5 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1fb7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fb9 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n1fba : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n1fbc : 48              >            pha         ;use stack to load status\n1fbd : a97e            >            lda #$7e     ;precharge accu\n1fbf : 28              >            plp\n                        \n1fc0 : cd1b02                   cmp abs7f\n                                tst_a $7e,~fzc\n1fc3 : 08              >            php         ;save flags\n1fc4 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n1fc6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fc8 : 68              >            pla         ;load status\n1fc9 : 48              >            pha\n                       >            cmp_flag ~fzc\n1fca : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1fcc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fce : 28              >            plp         ;restore status\n                        \n                        \n                                set_a $80,0\n                       >            load_flag 0\n1fcf : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1fd1 : 48              >            pha         ;use stack to load status\n1fd2 : a980            >            lda #$80     ;precharge accu\n1fd4 : 28              >            plp\n                        \n1fd5 : c97f                     cmp #$7f\n                                tst_a $80,fc\n1fd7 : 08              >            php         ;save flags\n1fd8 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n1fda : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fdc : 68              >            pla         ;load status\n1fdd : 48              >            pha\n                       >            cmp_flag fc\n1fde : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1fe0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1fe2 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n1fe3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1fe5 : 48              >            pha         ;use stack to load status\n1fe6 : a97f            >            lda #$7f     ;precharge accu\n1fe8 : 28              >            plp\n                        \n1fe9 : c97f                     cmp #$7f\n                                tst_a $7f,fzc\n1feb : 08              >            php         ;save flags\n1fec : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n1fee : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ff0 : 68              >            pla         ;load status\n1ff1 : 48              >            pha\n                       >            cmp_flag fzc\n1ff2 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n1ff4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n1ff6 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n1ff7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n1ff9 : 48              >            pha         ;use stack to load status\n1ffa : a97e            >            lda #$7e     ;precharge accu\n1ffc : 28              >            plp\n                        \n1ffd : c97f                     cmp #$7f\n                                tst_a $7e,fn\n1fff : 08              >            php         ;save flags\n2000 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n2002 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2004 : 68              >            pla         ;load status\n2005 : 48              >            pha\n                       >            cmp_flag fn\n2006 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2008 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n200a : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n200b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n200d : 48              >            pha         ;use stack to load status\n200e : a980            >            lda #$80     ;precharge accu\n2010 : 28              >            plp\n                        \n2011 : c97f                     cmp #$7f\n                                tst_a $80,~fnz\n2013 : 08              >            php         ;save flags\n2014 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2016 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2018 : 68              >            pla         ;load status\n2019 : 48              >            pha\n                       >            cmp_flag ~fnz\n201a : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n201c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n201e : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n201f : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2021 : 48              >            pha         ;use stack to load status\n2022 : a97f            >            lda #$7f     ;precharge accu\n2024 : 28              >            plp\n                        \n2025 : c97f                     cmp #$7f\n                                tst_a $7f,~fn\n2027 : 08              >            php         ;save flags\n2028 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n202a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n202c : 68              >            pla         ;load status\n202d : 48              >            pha\n                       >            cmp_flag ~fn\n202e : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2030 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2032 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n2033 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2035 : 48              >            pha         ;use stack to load status\n2036 : a97e            >            lda #$7e     ;precharge accu\n2038 : 28              >            plp\n                        \n2039 : c97f                     cmp #$7f\n                                tst_a $7e,~fzc\n203b : 08              >            php         ;save flags\n203c : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n203e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2040 : 68              >            pla         ;load status\n2041 : 48              >            pha\n                       >            cmp_flag ~fzc\n2042 : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2044 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2046 : 28              >            plp         ;restore status\n                        \n                        \n2047 : a204                     ldx #4          ;with indexing by X\n                                set_a $80,0\n                       >            load_flag 0\n2049 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n204b : 48              >            pha         ;use stack to load status\n204c : a980            >            lda #$80     ;precharge accu\n204e : 28              >            plp\n                        \n204f : d513                     cmp zp1,x\n                                tst_a $80,fc\n2051 : 08              >            php         ;save flags\n2052 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2054 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2056 : 68              >            pla         ;load status\n2057 : 48              >            pha\n                       >            cmp_flag fc\n2058 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n205a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n205c : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n205d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n205f : 48              >            pha         ;use stack to load status\n2060 : a97f            >            lda #$7f     ;precharge accu\n2062 : 28              >            plp\n                        \n2063 : d513                     cmp zp1,x\n                                tst_a $7f,fzc\n2065 : 08              >            php         ;save flags\n2066 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n2068 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n206a : 68              >            pla         ;load status\n206b : 48              >            pha\n                       >            cmp_flag fzc\n206c : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n206e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2070 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n2071 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2073 : 48              >            pha         ;use stack to load status\n2074 : a97e            >            lda #$7e     ;precharge accu\n2076 : 28              >            plp\n                        \n2077 : d513                     cmp zp1,x\n                                tst_a $7e,fn\n2079 : 08              >            php         ;save flags\n207a : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n207c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n207e : 68              >            pla         ;load status\n207f : 48              >            pha\n                       >            cmp_flag fn\n2080 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2082 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2084 : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n2085 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2087 : 48              >            pha         ;use stack to load status\n2088 : a980            >            lda #$80     ;precharge accu\n208a : 28              >            plp\n                        \n208b : d513                     cmp zp1,x\n                                tst_a $80,~fnz\n208d : 08              >            php         ;save flags\n208e : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2090 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2092 : 68              >            pla         ;load status\n2093 : 48              >            pha\n                       >            cmp_flag ~fnz\n2094 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2096 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2098 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n2099 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n209b : 48              >            pha         ;use stack to load status\n209c : a97f            >            lda #$7f     ;precharge accu\n209e : 28              >            plp\n                        \n209f : d513                     cmp zp1,x\n                                tst_a $7f,~fn\n20a1 : 08              >            php         ;save flags\n20a2 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n20a4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20a6 : 68              >            pla         ;load status\n20a7 : 48              >            pha\n                       >            cmp_flag ~fn\n20a8 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n20aa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20ac : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n20ad : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n20af : 48              >            pha         ;use stack to load status\n20b0 : a97e            >            lda #$7e     ;precharge accu\n20b2 : 28              >            plp\n                        \n20b3 : d513                     cmp zp1,x\n                                tst_a $7e,~fzc\n20b5 : 08              >            php         ;save flags\n20b6 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n20b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20ba : 68              >            pla         ;load status\n20bb : 48              >            pha\n                       >            cmp_flag ~fzc\n20bc : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n20be : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20c0 : 28              >            plp         ;restore status\n                        \n                        \n                                set_a $80,0\n                       >            load_flag 0\n20c1 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n20c3 : 48              >            pha         ;use stack to load status\n20c4 : a980            >            lda #$80     ;precharge accu\n20c6 : 28              >            plp\n                        \n20c7 : dd1702                   cmp abs1,x\n                                tst_a $80,fc\n20ca : 08              >            php         ;save flags\n20cb : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n20cd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20cf : 68              >            pla         ;load status\n20d0 : 48              >            pha\n                       >            cmp_flag fc\n20d1 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n20d3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20d5 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n20d6 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n20d8 : 48              >            pha         ;use stack to load status\n20d9 : a97f            >            lda #$7f     ;precharge accu\n20db : 28              >            plp\n                        \n20dc : dd1702                   cmp abs1,x\n                                tst_a $7f,fzc\n20df : 08              >            php         ;save flags\n20e0 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n20e2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20e4 : 68              >            pla         ;load status\n20e5 : 48              >            pha\n                       >            cmp_flag fzc\n20e6 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n20e8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20ea : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n20eb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n20ed : 48              >            pha         ;use stack to load status\n20ee : a97e            >            lda #$7e     ;precharge accu\n20f0 : 28              >            plp\n                        \n20f1 : dd1702                   cmp abs1,x\n                                tst_a $7e,fn\n20f4 : 08              >            php         ;save flags\n20f5 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n20f7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20f9 : 68              >            pla         ;load status\n20fa : 48              >            pha\n                       >            cmp_flag fn\n20fb : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n20fd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n20ff : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n2100 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2102 : 48              >            pha         ;use stack to load status\n2103 : a980            >            lda #$80     ;precharge accu\n2105 : 28              >            plp\n                        \n2106 : dd1702                   cmp abs1,x\n                                tst_a $80,~fnz\n2109 : 08              >            php         ;save flags\n210a : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n210c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n210e : 68              >            pla         ;load status\n210f : 48              >            pha\n                       >            cmp_flag ~fnz\n2110 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2112 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2114 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n2115 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2117 : 48              >            pha         ;use stack to load status\n2118 : a97f            >            lda #$7f     ;precharge accu\n211a : 28              >            plp\n                        \n211b : dd1702                   cmp abs1,x\n                                tst_a $7f,~fn\n211e : 08              >            php         ;save flags\n211f : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n2121 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2123 : 68              >            pla         ;load status\n2124 : 48              >            pha\n                       >            cmp_flag ~fn\n2125 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2127 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2129 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n212a : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n212c : 48              >            pha         ;use stack to load status\n212d : a97e            >            lda #$7e     ;precharge accu\n212f : 28              >            plp\n                        \n2130 : dd1702                   cmp abs1,x\n                                tst_a $7e,~fzc\n2133 : 08              >            php         ;save flags\n2134 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n2136 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2138 : 68              >            pla         ;load status\n2139 : 48              >            pha\n                       >            cmp_flag ~fzc\n213a : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n213c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n213e : 28              >            plp         ;restore status\n                        \n                        \n213f : a004                     ldy #4          ;with indexing by Y\n2141 : a208                     ldx #8          ;with indexed indirect\n                                set_a $80,0\n                       >            load_flag 0\n2143 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2145 : 48              >            pha         ;use stack to load status\n2146 : a980            >            lda #$80     ;precharge accu\n2148 : 28              >            plp\n                        \n2149 : d91702                   cmp abs1,y\n                                tst_a $80,fc\n214c : 08              >            php         ;save flags\n214d : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n214f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2151 : 68              >            pla         ;load status\n2152 : 48              >            pha\n                       >            cmp_flag fc\n2153 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2155 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2157 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n2158 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n215a : 48              >            pha         ;use stack to load status\n215b : a97f            >            lda #$7f     ;precharge accu\n215d : 28              >            plp\n                        \n215e : d91702                   cmp abs1,y\n                                tst_a $7f,fzc\n2161 : 08              >            php         ;save flags\n2162 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n2164 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2166 : 68              >            pla         ;load status\n2167 : 48              >            pha\n                       >            cmp_flag fzc\n2168 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n216a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n216c : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n216d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n216f : 48              >            pha         ;use stack to load status\n2170 : a97e            >            lda #$7e     ;precharge accu\n2172 : 28              >            plp\n                        \n2173 : d91702                   cmp abs1,y\n                                tst_a $7e,fn\n2176 : 08              >            php         ;save flags\n2177 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n2179 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n217b : 68              >            pla         ;load status\n217c : 48              >            pha\n                       >            cmp_flag fn\n217d : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n217f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2181 : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n2182 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2184 : 48              >            pha         ;use stack to load status\n2185 : a980            >            lda #$80     ;precharge accu\n2187 : 28              >            plp\n                        \n2188 : d91702                   cmp abs1,y\n                                tst_a $80,~fnz\n218b : 08              >            php         ;save flags\n218c : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n218e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2190 : 68              >            pla         ;load status\n2191 : 48              >            pha\n                       >            cmp_flag ~fnz\n2192 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2194 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2196 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n2197 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2199 : 48              >            pha         ;use stack to load status\n219a : a97f            >            lda #$7f     ;precharge accu\n219c : 28              >            plp\n                        \n219d : d91702                   cmp abs1,y\n                                tst_a $7f,~fn\n21a0 : 08              >            php         ;save flags\n21a1 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n21a3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21a5 : 68              >            pla         ;load status\n21a6 : 48              >            pha\n                       >            cmp_flag ~fn\n21a7 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n21a9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21ab : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n21ac : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n21ae : 48              >            pha         ;use stack to load status\n21af : a97e            >            lda #$7e     ;precharge accu\n21b1 : 28              >            plp\n                        \n21b2 : d91702                   cmp abs1,y\n                                tst_a $7e,~fzc\n21b5 : 08              >            php         ;save flags\n21b6 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n21b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21ba : 68              >            pla         ;load status\n21bb : 48              >            pha\n                       >            cmp_flag ~fzc\n21bc : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n21be : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21c0 : 28              >            plp         ;restore status\n                        \n                        \n                                set_a $80,0\n                       >            load_flag 0\n21c1 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n21c3 : 48              >            pha         ;use stack to load status\n21c4 : a980            >            lda #$80     ;precharge accu\n21c6 : 28              >            plp\n                        \n21c7 : c124                     cmp (ind1,x)\n                                tst_a $80,fc\n21c9 : 08              >            php         ;save flags\n21ca : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n21cc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21ce : 68              >            pla         ;load status\n21cf : 48              >            pha\n                       >            cmp_flag fc\n21d0 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n21d2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21d4 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n21d5 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n21d7 : 48              >            pha         ;use stack to load status\n21d8 : a97f            >            lda #$7f     ;precharge accu\n21da : 28              >            plp\n                        \n21db : c124                     cmp (ind1,x)\n                                tst_a $7f,fzc\n21dd : 08              >            php         ;save flags\n21de : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n21e0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21e2 : 68              >            pla         ;load status\n21e3 : 48              >            pha\n                       >            cmp_flag fzc\n21e4 : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n21e6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21e8 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n21e9 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n21eb : 48              >            pha         ;use stack to load status\n21ec : a97e            >            lda #$7e     ;precharge accu\n21ee : 28              >            plp\n                        \n21ef : c124                     cmp (ind1,x)\n                                tst_a $7e,fn\n21f1 : 08              >            php         ;save flags\n21f2 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n21f4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21f6 : 68              >            pla         ;load status\n21f7 : 48              >            pha\n                       >            cmp_flag fn\n21f8 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n21fa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n21fc : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n21fd : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n21ff : 48              >            pha         ;use stack to load status\n2200 : a980            >            lda #$80     ;precharge accu\n2202 : 28              >            plp\n                        \n2203 : c124                     cmp (ind1,x)\n                                tst_a $80,~fnz\n2205 : 08              >            php         ;save flags\n2206 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2208 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n220a : 68              >            pla         ;load status\n220b : 48              >            pha\n                       >            cmp_flag ~fnz\n220c : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n220e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2210 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n2211 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2213 : 48              >            pha         ;use stack to load status\n2214 : a97f            >            lda #$7f     ;precharge accu\n2216 : 28              >            plp\n                        \n2217 : c124                     cmp (ind1,x)\n                                tst_a $7f,~fn\n2219 : 08              >            php         ;save flags\n221a : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n221c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n221e : 68              >            pla         ;load status\n221f : 48              >            pha\n                       >            cmp_flag ~fn\n2220 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2222 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2224 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n2225 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2227 : 48              >            pha         ;use stack to load status\n2228 : a97e            >            lda #$7e     ;precharge accu\n222a : 28              >            plp\n                        \n222b : c124                     cmp (ind1,x)\n                                tst_a $7e,~fzc\n222d : 08              >            php         ;save flags\n222e : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n2230 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2232 : 68              >            pla         ;load status\n2233 : 48              >            pha\n                       >            cmp_flag ~fzc\n2234 : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2236 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2238 : 28              >            plp         ;restore status\n                        \n                        \n                                set_a $80,0\n                       >            load_flag 0\n2239 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n223b : 48              >            pha         ;use stack to load status\n223c : a980            >            lda #$80     ;precharge accu\n223e : 28              >            plp\n                        \n223f : d124                     cmp (ind1),y\n                                tst_a $80,fc\n2241 : 08              >            php         ;save flags\n2242 : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2244 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2246 : 68              >            pla         ;load status\n2247 : 48              >            pha\n                       >            cmp_flag fc\n2248 : c931            >            cmp #(fc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n224a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n224c : 28              >            plp         ;restore status\n                        \n                                set_a $7f,0\n                       >            load_flag 0\n224d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n224f : 48              >            pha         ;use stack to load status\n2250 : a97f            >            lda #$7f     ;precharge accu\n2252 : 28              >            plp\n                        \n2253 : d124                     cmp (ind1),y\n                                tst_a $7f,fzc\n2255 : 08              >            php         ;save flags\n2256 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n2258 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n225a : 68              >            pla         ;load status\n225b : 48              >            pha\n                       >            cmp_flag fzc\n225c : c933            >            cmp #(fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n225e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2260 : 28              >            plp         ;restore status\n                        \n                                set_a $7e,0\n                       >            load_flag 0\n2261 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2263 : 48              >            pha         ;use stack to load status\n2264 : a97e            >            lda #$7e     ;precharge accu\n2266 : 28              >            plp\n                        \n2267 : d124                     cmp (ind1),y\n                                tst_a $7e,fn\n2269 : 08              >            php         ;save flags\n226a : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n226c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n226e : 68              >            pla         ;load status\n226f : 48              >            pha\n                       >            cmp_flag fn\n2270 : c9b0            >            cmp #(fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2272 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2274 : 28              >            plp         ;restore status\n                        \n                                set_a $80,$ff\n                       >            load_flag $ff\n2275 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2277 : 48              >            pha         ;use stack to load status\n2278 : a980            >            lda #$80     ;precharge accu\n227a : 28              >            plp\n                        \n227b : d124                     cmp (ind1),y\n                                tst_a $80,~fnz\n227d : 08              >            php         ;save flags\n227e : c980            >            cmp #$80     ;test result\n                       >            trap_ne\n2280 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2282 : 68              >            pla         ;load status\n2283 : 48              >            pha\n                       >            cmp_flag ~fnz\n2284 : c97d            >            cmp #(~fnz|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n2286 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2288 : 28              >            plp         ;restore status\n                        \n                                set_a $7f,$ff\n                       >            load_flag $ff\n2289 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n228b : 48              >            pha         ;use stack to load status\n228c : a97f            >            lda #$7f     ;precharge accu\n228e : 28              >            plp\n                        \n228f : d124                     cmp (ind1),y\n                                tst_a $7f,~fn\n2291 : 08              >            php         ;save flags\n2292 : c97f            >            cmp #$7f     ;test result\n                       >            trap_ne\n2294 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2296 : 68              >            pla         ;load status\n2297 : 48              >            pha\n                       >            cmp_flag ~fn\n2298 : c97f            >            cmp #(~fn|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n229a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n229c : 28              >            plp         ;restore status\n                        \n                                set_a $7e,$ff\n                       >            load_flag $ff\n229d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n229f : 48              >            pha         ;use stack to load status\n22a0 : a97e            >            lda #$7e     ;precharge accu\n22a2 : 28              >            plp\n                        \n22a3 : d124                     cmp (ind1),y\n                                tst_a $7e,~fzc\n22a5 : 08              >            php         ;save flags\n22a6 : c97e            >            cmp #$7e     ;test result\n                       >            trap_ne\n22a8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n22aa : 68              >            pla         ;load status\n22ab : 48              >            pha\n                       >            cmp_flag ~fzc\n22ac : c9fc            >            cmp #(~fzc|fao)&m8    ;expected flags + always on bits\n                       >\n                       >            trap_ne\n22ae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n22b0 : 28              >            plp         ;restore status\n                        \n                                next_test\n22b1 : ad0002          >            lda test_case   ;previous test\n22b4 : c91c            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n22b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001d =                 >test_num = test_num + 1\n22b8 : a91d            >            lda #test_num   ;*** next tests' number\n22ba : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; testing shifts - ASL LSR ROL ROR all addressing modes\n                        ; shifts - accumulator\n22bd : a203                     ldx #3\n22bf :                  tasl\n                                set_ax zp1,0\n                       >            load_flag 0\n22bf : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n22c1 : 48              >            pha         ;use stack to load status\n22c2 : b513            >            lda zp1,x    ;precharge accu\n22c4 : 28              >            plp\n                        \n22c5 : 0a                       asl a\n                                tst_ax rASL,fASL,0\n22c6 : 08              >            php         ;save flags\n22c7 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n22ca : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n22cc : 68              >            pla         ;load status\n                       >            eor_flag 0\n22cd : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n22cf : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne     ;\n22d2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n22d4 : ca                       dex\n22d5 : 10e8                     bpl tasl\n22d7 : a203                     ldx #3\n22d9 :                  tasl1\n                                set_ax zp1,$ff\n                       >            load_flag $ff\n22d9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n22db : 48              >            pha         ;use stack to load status\n22dc : b513            >            lda zp1,x    ;precharge accu\n22de : 28              >            plp\n                        \n22df : 0a                       asl a\n                                tst_ax rASL,fASL,$ff-fnzc\n22e0 : 08              >            php         ;save flags\n22e1 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n22e4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n22e6 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n22e7 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n22e9 : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne     ;\n22ec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n22ee : ca                       dex\n22ef : 10e8                     bpl tasl1\n                        \n22f1 : a203                     ldx #3\n22f3 :                  tlsr\n                                set_ax zp1,0\n                       >            load_flag 0\n22f3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n22f5 : 48              >            pha         ;use stack to load status\n22f6 : b513            >            lda zp1,x    ;precharge accu\n22f8 : 28              >            plp\n                        \n22f9 : 4a                       lsr a\n                                tst_ax rLSR,fLSR,0\n22fa : 08              >            php         ;save flags\n22fb : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n22fe : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2300 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2301 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2303 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne     ;\n2306 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2308 : ca                       dex\n2309 : 10e8                     bpl tlsr\n230b : a203                     ldx #3\n230d :                  tlsr1\n                                set_ax zp1,$ff\n                       >            load_flag $ff\n230d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n230f : 48              >            pha         ;use stack to load status\n2310 : b513            >            lda zp1,x    ;precharge accu\n2312 : 28              >            plp\n                        \n2313 : 4a                       lsr a\n                                tst_ax rLSR,fLSR,$ff-fnzc\n2314 : 08              >            php         ;save flags\n2315 : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2318 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n231a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n231b : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n231d : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne     ;\n2320 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2322 : ca                       dex\n2323 : 10e8                     bpl tlsr1\n                        \n2325 : a203                     ldx #3\n2327 :                  trol\n                                set_ax zp1,0\n                       >            load_flag 0\n2327 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2329 : 48              >            pha         ;use stack to load status\n232a : b513            >            lda zp1,x    ;precharge accu\n232c : 28              >            plp\n                        \n232d : 2a                       rol a\n                                tst_ax rROL,fROL,0\n232e : 08              >            php         ;save flags\n232f : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n2332 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2334 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2335 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2337 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne     ;\n233a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n233c : ca                       dex\n233d : 10e8                     bpl trol\n233f : a203                     ldx #3\n2341 :                  trol1\n                                set_ax zp1,$ff-fc\n                       >            load_flag $ff-fc\n2341 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n2343 : 48              >            pha         ;use stack to load status\n2344 : b513            >            lda zp1,x    ;precharge accu\n2346 : 28              >            plp\n                        \n2347 : 2a                       rol a\n                                tst_ax rROL,fROL,$ff-fnzc\n2348 : 08              >            php         ;save flags\n2349 : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n234c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n234e : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n234f : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2351 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne     ;\n2354 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2356 : ca                       dex\n2357 : 10e8                     bpl trol1\n                        \n2359 : a203                     ldx #3\n235b :                  trolc\n                                set_ax zp1,fc\n                       >            load_flag fc\n235b : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n235d : 48              >            pha         ;use stack to load status\n235e : b513            >            lda zp1,x    ;precharge accu\n2360 : 28              >            plp\n                        \n2361 : 2a                       rol a\n                                tst_ax rROLc,fROLc,0\n2362 : 08              >            php         ;save flags\n2363 : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2366 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2368 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2369 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n236b : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne     ;\n236e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2370 : ca                       dex\n2371 : 10e8                     bpl trolc\n2373 : a203                     ldx #3\n2375 :                  trolc1\n                                set_ax zp1,$ff\n                       >            load_flag $ff\n2375 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2377 : 48              >            pha         ;use stack to load status\n2378 : b513            >            lda zp1,x    ;precharge accu\n237a : 28              >            plp\n                        \n237b : 2a                       rol a\n                                tst_ax rROLc,fROLc,$ff-fnzc\n237c : 08              >            php         ;save flags\n237d : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2380 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2382 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2383 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2385 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne     ;\n2388 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n238a : ca                       dex\n238b : 10e8                     bpl trolc1\n                        \n238d : a203                     ldx #3\n238f :                  tror\n                                set_ax zp1,0\n                       >            load_flag 0\n238f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2391 : 48              >            pha         ;use stack to load status\n2392 : b513            >            lda zp1,x    ;precharge accu\n2394 : 28              >            plp\n                        \n2395 : 6a                       ror a\n                                tst_ax rROR,fROR,0\n2396 : 08              >            php         ;save flags\n2397 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n239a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n239c : 68              >            pla         ;load status\n                       >            eor_flag 0\n239d : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n239f : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne     ;\n23a2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n23a4 : ca                       dex\n23a5 : 10e8                     bpl tror\n23a7 : a203                     ldx #3\n23a9 :                  tror1\n                                set_ax zp1,$ff-fc\n                       >            load_flag $ff-fc\n23a9 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n23ab : 48              >            pha         ;use stack to load status\n23ac : b513            >            lda zp1,x    ;precharge accu\n23ae : 28              >            plp\n                        \n23af : 6a                       ror a\n                                tst_ax rROR,fROR,$ff-fnzc\n23b0 : 08              >            php         ;save flags\n23b1 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n23b4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n23b6 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n23b7 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n23b9 : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne     ;\n23bc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n23be : ca                       dex\n23bf : 10e8                     bpl tror1\n                        \n23c1 : a203                     ldx #3\n23c3 :                  trorc\n                                set_ax zp1,fc\n                       >            load_flag fc\n23c3 : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n23c5 : 48              >            pha         ;use stack to load status\n23c6 : b513            >            lda zp1,x    ;precharge accu\n23c8 : 28              >            plp\n                        \n23c9 : 6a                       ror a\n                                tst_ax rRORc,fRORc,0\n23ca : 08              >            php         ;save flags\n23cb : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n23ce : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n23d0 : 68              >            pla         ;load status\n                       >            eor_flag 0\n23d1 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n23d3 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne     ;\n23d6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n23d8 : ca                       dex\n23d9 : 10e8                     bpl trorc\n23db : a203                     ldx #3\n23dd :                  trorc1\n                                set_ax zp1,$ff\n                       >            load_flag $ff\n23dd : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n23df : 48              >            pha         ;use stack to load status\n23e0 : b513            >            lda zp1,x    ;precharge accu\n23e2 : 28              >            plp\n                        \n23e3 : 6a                       ror a\n                                tst_ax rRORc,fRORc,$ff-fnzc\n23e4 : 08              >            php         ;save flags\n23e5 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n23e8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n23ea : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n23eb : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n23ed : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne     ;\n23f0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n23f2 : ca                       dex\n23f3 : 10e8                     bpl trorc1\n                                next_test\n23f5 : ad0002          >            lda test_case   ;previous test\n23f8 : c91d            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n23fa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001e =                 >test_num = test_num + 1\n23fc : a91e            >            lda #test_num   ;*** next tests' number\n23fe : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; shifts - zeropage\n2401 : a203                     ldx #3\n2403 :                  tasl2\n                                set_z zp1,0\n                       >            load_flag 0\n2403 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2405 : 48              >            pha         ;use stack to load status\n2406 : b513            >            lda zp1,x    ;load to zeropage\n2408 : 850c            >            sta zpt\n240a : 28              >            plp\n                        \n240b : 060c                     asl zpt\n                                tst_z rASL,fASL,0\n240d : 08              >            php         ;save flags\n240e : a50c            >            lda zpt\n2410 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n2413 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2415 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2416 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2418 : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n241b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n241d : ca                       dex\n241e : 10e3                     bpl tasl2\n2420 : a203                     ldx #3\n2422 :                  tasl3\n                                set_z zp1,$ff\n                       >            load_flag $ff\n2422 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2424 : 48              >            pha         ;use stack to load status\n2425 : b513            >            lda zp1,x    ;load to zeropage\n2427 : 850c            >            sta zpt\n2429 : 28              >            plp\n                        \n242a : 060c                     asl zpt\n                                tst_z rASL,fASL,$ff-fnzc\n242c : 08              >            php         ;save flags\n242d : a50c            >            lda zpt\n242f : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n2432 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2434 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2435 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2437 : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n243a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n243c : ca                       dex\n243d : 10e3                     bpl tasl3\n                        \n243f : a203                     ldx #3\n2441 :                  tlsr2\n                                set_z zp1,0\n                       >            load_flag 0\n2441 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2443 : 48              >            pha         ;use stack to load status\n2444 : b513            >            lda zp1,x    ;load to zeropage\n2446 : 850c            >            sta zpt\n2448 : 28              >            plp\n                        \n2449 : 460c                     lsr zpt\n                                tst_z rLSR,fLSR,0\n244b : 08              >            php         ;save flags\n244c : a50c            >            lda zpt\n244e : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2451 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2453 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2454 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2456 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n2459 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n245b : ca                       dex\n245c : 10e3                     bpl tlsr2\n245e : a203                     ldx #3\n2460 :                  tlsr3\n                                set_z zp1,$ff\n                       >            load_flag $ff\n2460 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2462 : 48              >            pha         ;use stack to load status\n2463 : b513            >            lda zp1,x    ;load to zeropage\n2465 : 850c            >            sta zpt\n2467 : 28              >            plp\n                        \n2468 : 460c                     lsr zpt\n                                tst_z rLSR,fLSR,$ff-fnzc\n246a : 08              >            php         ;save flags\n246b : a50c            >            lda zpt\n246d : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2470 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2472 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2473 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2475 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n2478 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n247a : ca                       dex\n247b : 10e3                     bpl tlsr3\n                        \n247d : a203                     ldx #3\n247f :                  trol2\n                                set_z zp1,0\n                       >            load_flag 0\n247f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2481 : 48              >            pha         ;use stack to load status\n2482 : b513            >            lda zp1,x    ;load to zeropage\n2484 : 850c            >            sta zpt\n2486 : 28              >            plp\n                        \n2487 : 260c                     rol zpt\n                                tst_z rROL,fROL,0\n2489 : 08              >            php         ;save flags\n248a : a50c            >            lda zpt\n248c : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n248f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2491 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2492 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2494 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n2497 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2499 : ca                       dex\n249a : 10e3                     bpl trol2\n249c : a203                     ldx #3\n249e :                  trol3\n                                set_z zp1,$ff-fc\n                       >            load_flag $ff-fc\n249e : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n24a0 : 48              >            pha         ;use stack to load status\n24a1 : b513            >            lda zp1,x    ;load to zeropage\n24a3 : 850c            >            sta zpt\n24a5 : 28              >            plp\n                        \n24a6 : 260c                     rol zpt\n                                tst_z rROL,fROL,$ff-fnzc\n24a8 : 08              >            php         ;save flags\n24a9 : a50c            >            lda zpt\n24ab : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n24ae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n24b0 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n24b1 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n24b3 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n24b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n24b8 : ca                       dex\n24b9 : 10e3                     bpl trol3\n                        \n24bb : a203                     ldx #3\n24bd :                  trolc2\n                                set_z zp1,fc\n                       >            load_flag fc\n24bd : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n24bf : 48              >            pha         ;use stack to load status\n24c0 : b513            >            lda zp1,x    ;load to zeropage\n24c2 : 850c            >            sta zpt\n24c4 : 28              >            plp\n                        \n24c5 : 260c                     rol zpt\n                                tst_z rROLc,fROLc,0\n24c7 : 08              >            php         ;save flags\n24c8 : a50c            >            lda zpt\n24ca : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n24cd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n24cf : 68              >            pla         ;load status\n                       >            eor_flag 0\n24d0 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n24d2 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n24d5 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n24d7 : ca                       dex\n24d8 : 10e3                     bpl trolc2\n24da : a203                     ldx #3\n24dc :                  trolc3\n                                set_z zp1,$ff\n                       >            load_flag $ff\n24dc : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n24de : 48              >            pha         ;use stack to load status\n24df : b513            >            lda zp1,x    ;load to zeropage\n24e1 : 850c            >            sta zpt\n24e3 : 28              >            plp\n                        \n24e4 : 260c                     rol zpt\n                                tst_z rROLc,fROLc,$ff-fnzc\n24e6 : 08              >            php         ;save flags\n24e7 : a50c            >            lda zpt\n24e9 : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n24ec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n24ee : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n24ef : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n24f1 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n24f4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n24f6 : ca                       dex\n24f7 : 10e3                     bpl trolc3\n                        \n24f9 : a203                     ldx #3\n24fb :                  tror2\n                                set_z zp1,0\n                       >            load_flag 0\n24fb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n24fd : 48              >            pha         ;use stack to load status\n24fe : b513            >            lda zp1,x    ;load to zeropage\n2500 : 850c            >            sta zpt\n2502 : 28              >            plp\n                        \n2503 : 660c                     ror zpt\n                                tst_z rROR,fROR,0\n2505 : 08              >            php         ;save flags\n2506 : a50c            >            lda zpt\n2508 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n250b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n250d : 68              >            pla         ;load status\n                       >            eor_flag 0\n250e : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2510 : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n2513 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2515 : ca                       dex\n2516 : 10e3                     bpl tror2\n2518 : a203                     ldx #3\n251a :                  tror3\n                                set_z zp1,$ff-fc\n                       >            load_flag $ff-fc\n251a : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n251c : 48              >            pha         ;use stack to load status\n251d : b513            >            lda zp1,x    ;load to zeropage\n251f : 850c            >            sta zpt\n2521 : 28              >            plp\n                        \n2522 : 660c                     ror zpt\n                                tst_z rROR,fROR,$ff-fnzc\n2524 : 08              >            php         ;save flags\n2525 : a50c            >            lda zpt\n2527 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n252a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n252c : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n252d : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n252f : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n2532 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2534 : ca                       dex\n2535 : 10e3                     bpl tror3\n                        \n2537 : a203                     ldx #3\n2539 :                  trorc2\n                                set_z zp1,fc\n                       >            load_flag fc\n2539 : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n253b : 48              >            pha         ;use stack to load status\n253c : b513            >            lda zp1,x    ;load to zeropage\n253e : 850c            >            sta zpt\n2540 : 28              >            plp\n                        \n2541 : 660c                     ror zpt\n                                tst_z rRORc,fRORc,0\n2543 : 08              >            php         ;save flags\n2544 : a50c            >            lda zpt\n2546 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n2549 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n254b : 68              >            pla         ;load status\n                       >            eor_flag 0\n254c : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n254e : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2551 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2553 : ca                       dex\n2554 : 10e3                     bpl trorc2\n2556 : a203                     ldx #3\n2558 :                  trorc3\n                                set_z zp1,$ff\n                       >            load_flag $ff\n2558 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n255a : 48              >            pha         ;use stack to load status\n255b : b513            >            lda zp1,x    ;load to zeropage\n255d : 850c            >            sta zpt\n255f : 28              >            plp\n                        \n2560 : 660c                     ror zpt\n                                tst_z rRORc,fRORc,$ff-fnzc\n2562 : 08              >            php         ;save flags\n2563 : a50c            >            lda zpt\n2565 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n2568 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n256a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n256b : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n256d : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2570 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2572 : ca                       dex\n2573 : 10e3                     bpl trorc3\n                                next_test\n2575 : ad0002          >            lda test_case   ;previous test\n2578 : c91e            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n257a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n001f =                 >test_num = test_num + 1\n257c : a91f            >            lda #test_num   ;*** next tests' number\n257e : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; shifts - absolute\n2581 : a203                     ldx #3\n2583 :                  tasl4\n                                set_abs zp1,0\n                       >            load_flag 0\n2583 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2585 : 48              >            pha         ;use stack to load status\n2586 : b513            >            lda zp1,x    ;load to memory\n2588 : 8d0302          >            sta abst\n258b : 28              >            plp\n                        \n258c : 0e0302                   asl abst\n                                tst_abs rASL,fASL,0\n258f : 08              >            php         ;save flags\n2590 : ad0302          >            lda abst\n2593 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n2596 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2598 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2599 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n259b : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n259e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n25a0 : ca                       dex\n25a1 : 10e0                     bpl tasl4\n25a3 : a203                     ldx #3\n25a5 :                  tasl5\n                                set_abs zp1,$ff\n                       >            load_flag $ff\n25a5 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n25a7 : 48              >            pha         ;use stack to load status\n25a8 : b513            >            lda zp1,x    ;load to memory\n25aa : 8d0302          >            sta abst\n25ad : 28              >            plp\n                        \n25ae : 0e0302                   asl abst\n                                tst_abs rASL,fASL,$ff-fnzc\n25b1 : 08              >            php         ;save flags\n25b2 : ad0302          >            lda abst\n25b5 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n25b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n25ba : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n25bb : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n25bd : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n25c0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n25c2 : ca                       dex\n25c3 : 10e0                     bpl tasl5\n                        \n25c5 : a203                     ldx #3\n25c7 :                  tlsr4\n                                set_abs zp1,0\n                       >            load_flag 0\n25c7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n25c9 : 48              >            pha         ;use stack to load status\n25ca : b513            >            lda zp1,x    ;load to memory\n25cc : 8d0302          >            sta abst\n25cf : 28              >            plp\n                        \n25d0 : 4e0302                   lsr abst\n                                tst_abs rLSR,fLSR,0\n25d3 : 08              >            php         ;save flags\n25d4 : ad0302          >            lda abst\n25d7 : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n25da : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n25dc : 68              >            pla         ;load status\n                       >            eor_flag 0\n25dd : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n25df : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n25e2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n25e4 : ca                       dex\n25e5 : 10e0                     bpl tlsr4\n25e7 : a203                     ldx #3\n25e9 :                  tlsr5\n                                set_abs zp1,$ff\n                       >            load_flag $ff\n25e9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n25eb : 48              >            pha         ;use stack to load status\n25ec : b513            >            lda zp1,x    ;load to memory\n25ee : 8d0302          >            sta abst\n25f1 : 28              >            plp\n                        \n25f2 : 4e0302                   lsr abst\n                                tst_abs rLSR,fLSR,$ff-fnzc\n25f5 : 08              >            php         ;save flags\n25f6 : ad0302          >            lda abst\n25f9 : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n25fc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n25fe : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n25ff : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2601 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n2604 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2606 : ca                       dex\n2607 : 10e0                     bpl tlsr5\n                        \n2609 : a203                     ldx #3\n260b :                  trol4\n                                set_abs zp1,0\n                       >            load_flag 0\n260b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n260d : 48              >            pha         ;use stack to load status\n260e : b513            >            lda zp1,x    ;load to memory\n2610 : 8d0302          >            sta abst\n2613 : 28              >            plp\n                        \n2614 : 2e0302                   rol abst\n                                tst_abs rROL,fROL,0\n2617 : 08              >            php         ;save flags\n2618 : ad0302          >            lda abst\n261b : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n261e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2620 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2621 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2623 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n2626 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2628 : ca                       dex\n2629 : 10e0                     bpl trol4\n262b : a203                     ldx #3\n262d :                  trol5\n                                set_abs zp1,$ff-fc\n                       >            load_flag $ff-fc\n262d : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n262f : 48              >            pha         ;use stack to load status\n2630 : b513            >            lda zp1,x    ;load to memory\n2632 : 8d0302          >            sta abst\n2635 : 28              >            plp\n                        \n2636 : 2e0302                   rol abst\n                                tst_abs rROL,fROL,$ff-fnzc\n2639 : 08              >            php         ;save flags\n263a : ad0302          >            lda abst\n263d : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n2640 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2642 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2643 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2645 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n2648 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n264a : ca                       dex\n264b : 10e0                     bpl trol5\n                        \n264d : a203                     ldx #3\n264f :                  trolc4\n                                set_abs zp1,fc\n                       >            load_flag fc\n264f : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n2651 : 48              >            pha         ;use stack to load status\n2652 : b513            >            lda zp1,x    ;load to memory\n2654 : 8d0302          >            sta abst\n2657 : 28              >            plp\n                        \n2658 : 2e0302                   rol abst\n                                tst_abs rROLc,fROLc,0\n265b : 08              >            php         ;save flags\n265c : ad0302          >            lda abst\n265f : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2662 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2664 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2665 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2667 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n266a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n266c : ca                       dex\n266d : 10e0                     bpl trolc4\n266f : a203                     ldx #3\n2671 :                  trolc5\n                                set_abs zp1,$ff\n                       >            load_flag $ff\n2671 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2673 : 48              >            pha         ;use stack to load status\n2674 : b513            >            lda zp1,x    ;load to memory\n2676 : 8d0302          >            sta abst\n2679 : 28              >            plp\n                        \n267a : 2e0302                   rol abst\n                                tst_abs rROLc,fROLc,$ff-fnzc\n267d : 08              >            php         ;save flags\n267e : ad0302          >            lda abst\n2681 : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2684 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2686 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2687 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2689 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n268c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n268e : ca                       dex\n268f : 10e0                     bpl trolc5\n                        \n2691 : a203                     ldx #3\n2693 :                  tror4\n                                set_abs zp1,0\n                       >            load_flag 0\n2693 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2695 : 48              >            pha         ;use stack to load status\n2696 : b513            >            lda zp1,x    ;load to memory\n2698 : 8d0302          >            sta abst\n269b : 28              >            plp\n                        \n269c : 6e0302                   ror abst\n                                tst_abs rROR,fROR,0\n269f : 08              >            php         ;save flags\n26a0 : ad0302          >            lda abst\n26a3 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n26a6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n26a8 : 68              >            pla         ;load status\n                       >            eor_flag 0\n26a9 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n26ab : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n26ae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n26b0 : ca                       dex\n26b1 : 10e0                     bpl tror4\n26b3 : a203                     ldx #3\n26b5 :                  tror5\n                                set_abs zp1,$ff-fc\n                       >            load_flag $ff-fc\n26b5 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n26b7 : 48              >            pha         ;use stack to load status\n26b8 : b513            >            lda zp1,x    ;load to memory\n26ba : 8d0302          >            sta abst\n26bd : 28              >            plp\n                        \n26be : 6e0302                   ror abst\n                                tst_abs rROR,fROR,$ff-fnzc\n26c1 : 08              >            php         ;save flags\n26c2 : ad0302          >            lda abst\n26c5 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n26c8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n26ca : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n26cb : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n26cd : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n26d0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n26d2 : ca                       dex\n26d3 : 10e0                     bpl tror5\n                        \n26d5 : a203                     ldx #3\n26d7 :                  trorc4\n                                set_abs zp1,fc\n                       >            load_flag fc\n26d7 : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n26d9 : 48              >            pha         ;use stack to load status\n26da : b513            >            lda zp1,x    ;load to memory\n26dc : 8d0302          >            sta abst\n26df : 28              >            plp\n                        \n26e0 : 6e0302                   ror abst\n                                tst_abs rRORc,fRORc,0\n26e3 : 08              >            php         ;save flags\n26e4 : ad0302          >            lda abst\n26e7 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n26ea : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n26ec : 68              >            pla         ;load status\n                       >            eor_flag 0\n26ed : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n26ef : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n26f2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n26f4 : ca                       dex\n26f5 : 10e0                     bpl trorc4\n26f7 : a203                     ldx #3\n26f9 :                  trorc5\n                                set_abs zp1,$ff\n                       >            load_flag $ff\n26f9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n26fb : 48              >            pha         ;use stack to load status\n26fc : b513            >            lda zp1,x    ;load to memory\n26fe : 8d0302          >            sta abst\n2701 : 28              >            plp\n                        \n2702 : 6e0302                   ror abst\n                                tst_abs rRORc,fRORc,$ff-fnzc\n2705 : 08              >            php         ;save flags\n2706 : ad0302          >            lda abst\n2709 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n270c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n270e : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n270f : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2711 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2714 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2716 : ca                       dex\n2717 : 10e0                     bpl trorc5\n                                next_test\n2719 : ad0002          >            lda test_case   ;previous test\n271c : c91f            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n271e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0020 =                 >test_num = test_num + 1\n2720 : a920            >            lda #test_num   ;*** next tests' number\n2722 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; shifts - zp indexed\n2725 : a203                     ldx #3\n2727 :                  tasl6\n                                set_zx zp1,0\n                       >            load_flag 0\n2727 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2729 : 48              >            pha         ;use stack to load status\n272a : b513            >            lda zp1,x    ;load to indexed zeropage\n272c : 950c            >            sta zpt,x\n272e : 28              >            plp\n                        \n272f : 160c                     asl zpt,x\n                                tst_zx rASL,fASL,0\n2731 : 08              >            php         ;save flags\n2732 : b50c            >            lda zpt,x\n2734 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n2737 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2739 : 68              >            pla         ;load status\n                       >            eor_flag 0\n273a : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n273c : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n273f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2741 : ca                       dex\n2742 : 10e3                     bpl tasl6\n2744 : a203                     ldx #3\n2746 :                  tasl7\n                                set_zx zp1,$ff\n                       >            load_flag $ff\n2746 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2748 : 48              >            pha         ;use stack to load status\n2749 : b513            >            lda zp1,x    ;load to indexed zeropage\n274b : 950c            >            sta zpt,x\n274d : 28              >            plp\n                        \n274e : 160c                     asl zpt,x\n                                tst_zx rASL,fASL,$ff-fnzc\n2750 : 08              >            php         ;save flags\n2751 : b50c            >            lda zpt,x\n2753 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n2756 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2758 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2759 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n275b : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n275e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2760 : ca                       dex\n2761 : 10e3                     bpl tasl7\n                        \n2763 : a203                     ldx #3\n2765 :                  tlsr6\n                                set_zx zp1,0\n                       >            load_flag 0\n2765 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2767 : 48              >            pha         ;use stack to load status\n2768 : b513            >            lda zp1,x    ;load to indexed zeropage\n276a : 950c            >            sta zpt,x\n276c : 28              >            plp\n                        \n276d : 560c                     lsr zpt,x\n                                tst_zx rLSR,fLSR,0\n276f : 08              >            php         ;save flags\n2770 : b50c            >            lda zpt,x\n2772 : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2775 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2777 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2778 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n277a : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n277d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n277f : ca                       dex\n2780 : 10e3                     bpl tlsr6\n2782 : a203                     ldx #3\n2784 :                  tlsr7\n                                set_zx zp1,$ff\n                       >            load_flag $ff\n2784 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2786 : 48              >            pha         ;use stack to load status\n2787 : b513            >            lda zp1,x    ;load to indexed zeropage\n2789 : 950c            >            sta zpt,x\n278b : 28              >            plp\n                        \n278c : 560c                     lsr zpt,x\n                                tst_zx rLSR,fLSR,$ff-fnzc\n278e : 08              >            php         ;save flags\n278f : b50c            >            lda zpt,x\n2791 : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2794 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2796 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2797 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2799 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n279c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n279e : ca                       dex\n279f : 10e3                     bpl tlsr7\n                        \n27a1 : a203                     ldx #3\n27a3 :                  trol6\n                                set_zx zp1,0\n                       >            load_flag 0\n27a3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n27a5 : 48              >            pha         ;use stack to load status\n27a6 : b513            >            lda zp1,x    ;load to indexed zeropage\n27a8 : 950c            >            sta zpt,x\n27aa : 28              >            plp\n                        \n27ab : 360c                     rol zpt,x\n                                tst_zx rROL,fROL,0\n27ad : 08              >            php         ;save flags\n27ae : b50c            >            lda zpt,x\n27b0 : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n27b3 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n27b5 : 68              >            pla         ;load status\n                       >            eor_flag 0\n27b6 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n27b8 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n27bb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n27bd : ca                       dex\n27be : 10e3                     bpl trol6\n27c0 : a203                     ldx #3\n27c2 :                  trol7\n                                set_zx zp1,$ff-fc\n                       >            load_flag $ff-fc\n27c2 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n27c4 : 48              >            pha         ;use stack to load status\n27c5 : b513            >            lda zp1,x    ;load to indexed zeropage\n27c7 : 950c            >            sta zpt,x\n27c9 : 28              >            plp\n                        \n27ca : 360c                     rol zpt,x\n                                tst_zx rROL,fROL,$ff-fnzc\n27cc : 08              >            php         ;save flags\n27cd : b50c            >            lda zpt,x\n27cf : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n27d2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n27d4 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n27d5 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n27d7 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n27da : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n27dc : ca                       dex\n27dd : 10e3                     bpl trol7\n                        \n27df : a203                     ldx #3\n27e1 :                  trolc6\n                                set_zx zp1,fc\n                       >            load_flag fc\n27e1 : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n27e3 : 48              >            pha         ;use stack to load status\n27e4 : b513            >            lda zp1,x    ;load to indexed zeropage\n27e6 : 950c            >            sta zpt,x\n27e8 : 28              >            plp\n                        \n27e9 : 360c                     rol zpt,x\n                                tst_zx rROLc,fROLc,0\n27eb : 08              >            php         ;save flags\n27ec : b50c            >            lda zpt,x\n27ee : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n27f1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n27f3 : 68              >            pla         ;load status\n                       >            eor_flag 0\n27f4 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n27f6 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n27f9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n27fb : ca                       dex\n27fc : 10e3                     bpl trolc6\n27fe : a203                     ldx #3\n2800 :                  trolc7\n                                set_zx zp1,$ff\n                       >            load_flag $ff\n2800 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2802 : 48              >            pha         ;use stack to load status\n2803 : b513            >            lda zp1,x    ;load to indexed zeropage\n2805 : 950c            >            sta zpt,x\n2807 : 28              >            plp\n                        \n2808 : 360c                     rol zpt,x\n                                tst_zx rROLc,fROLc,$ff-fnzc\n280a : 08              >            php         ;save flags\n280b : b50c            >            lda zpt,x\n280d : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2810 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2812 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2813 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2815 : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n2818 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n281a : ca                       dex\n281b : 10e3                     bpl trolc7\n                        \n281d : a203                     ldx #3\n281f :                  tror6\n                                set_zx zp1,0\n                       >            load_flag 0\n281f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2821 : 48              >            pha         ;use stack to load status\n2822 : b513            >            lda zp1,x    ;load to indexed zeropage\n2824 : 950c            >            sta zpt,x\n2826 : 28              >            plp\n                        \n2827 : 760c                     ror zpt,x\n                                tst_zx rROR,fROR,0\n2829 : 08              >            php         ;save flags\n282a : b50c            >            lda zpt,x\n282c : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n282f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2831 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2832 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2834 : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n2837 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2839 : ca                       dex\n283a : 10e3                     bpl tror6\n283c : a203                     ldx #3\n283e :                  tror7\n                                set_zx zp1,$ff-fc\n                       >            load_flag $ff-fc\n283e : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n2840 : 48              >            pha         ;use stack to load status\n2841 : b513            >            lda zp1,x    ;load to indexed zeropage\n2843 : 950c            >            sta zpt,x\n2845 : 28              >            plp\n                        \n2846 : 760c                     ror zpt,x\n                                tst_zx rROR,fROR,$ff-fnzc\n2848 : 08              >            php         ;save flags\n2849 : b50c            >            lda zpt,x\n284b : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n284e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2850 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2851 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2853 : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n2856 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2858 : ca                       dex\n2859 : 10e3                     bpl tror7\n                        \n285b : a203                     ldx #3\n285d :                  trorc6\n                                set_zx zp1,fc\n                       >            load_flag fc\n285d : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n285f : 48              >            pha         ;use stack to load status\n2860 : b513            >            lda zp1,x    ;load to indexed zeropage\n2862 : 950c            >            sta zpt,x\n2864 : 28              >            plp\n                        \n2865 : 760c                     ror zpt,x\n                                tst_zx rRORc,fRORc,0\n2867 : 08              >            php         ;save flags\n2868 : b50c            >            lda zpt,x\n286a : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n286d : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n286f : 68              >            pla         ;load status\n                       >            eor_flag 0\n2870 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2872 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2875 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2877 : ca                       dex\n2878 : 10e3                     bpl trorc6\n287a : a203                     ldx #3\n287c :                  trorc7\n                                set_zx zp1,$ff\n                       >            load_flag $ff\n287c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n287e : 48              >            pha         ;use stack to load status\n287f : b513            >            lda zp1,x    ;load to indexed zeropage\n2881 : 950c            >            sta zpt,x\n2883 : 28              >            plp\n                        \n2884 : 760c                     ror zpt,x\n                                tst_zx rRORc,fRORc,$ff-fnzc\n2886 : 08              >            php         ;save flags\n2887 : b50c            >            lda zpt,x\n2889 : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n288c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n288e : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n288f : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2891 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2894 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2896 : ca                       dex\n2897 : 10e3                     bpl trorc7\n                                next_test\n2899 : ad0002          >            lda test_case   ;previous test\n289c : c920            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n289e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0021 =                 >test_num = test_num + 1\n28a0 : a921            >            lda #test_num   ;*** next tests' number\n28a2 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                                \n                        ; shifts - abs indexed\n28a5 : a203                     ldx #3\n28a7 :                  tasl8\n                                set_absx zp1,0\n                       >            load_flag 0\n28a7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n28a9 : 48              >            pha         ;use stack to load status\n28aa : b513            >            lda zp1,x    ;load to indexed memory\n28ac : 9d0302          >            sta abst,x\n28af : 28              >            plp\n                        \n28b0 : 1e0302                   asl abst,x\n                                tst_absx rASL,fASL,0\n28b3 : 08              >            php         ;save flags\n28b4 : bd0302          >            lda abst,x\n28b7 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n28ba : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n28bc : 68              >            pla         ;load status\n                       >            eor_flag 0\n28bd : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n28bf : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n28c2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n28c4 : ca                       dex\n28c5 : 10e0                     bpl tasl8\n28c7 : a203                     ldx #3\n28c9 :                  tasl9\n                                set_absx zp1,$ff\n                       >            load_flag $ff\n28c9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n28cb : 48              >            pha         ;use stack to load status\n28cc : b513            >            lda zp1,x    ;load to indexed memory\n28ce : 9d0302          >            sta abst,x\n28d1 : 28              >            plp\n                        \n28d2 : 1e0302                   asl abst,x\n                                tst_absx rASL,fASL,$ff-fnzc\n28d5 : 08              >            php         ;save flags\n28d6 : bd0302          >            lda abst,x\n28d9 : dd2002          >            cmp rASL,x    ;test result\n                       >            trap_ne\n28dc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n28de : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n28df : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n28e1 : dd3002          >            cmp fASL,x    ;test flags\n                       >            trap_ne\n28e4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n28e6 : ca                       dex\n28e7 : 10e0                     bpl tasl9\n                        \n28e9 : a203                     ldx #3\n28eb :                  tlsr8\n                                set_absx zp1,0\n                       >            load_flag 0\n28eb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n28ed : 48              >            pha         ;use stack to load status\n28ee : b513            >            lda zp1,x    ;load to indexed memory\n28f0 : 9d0302          >            sta abst,x\n28f3 : 28              >            plp\n                        \n28f4 : 5e0302                   lsr abst,x\n                                tst_absx rLSR,fLSR,0\n28f7 : 08              >            php         ;save flags\n28f8 : bd0302          >            lda abst,x\n28fb : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n28fe : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2900 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2901 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2903 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n2906 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2908 : ca                       dex\n2909 : 10e0                     bpl tlsr8\n290b : a203                     ldx #3\n290d :                  tlsr9\n                                set_absx zp1,$ff\n                       >            load_flag $ff\n290d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n290f : 48              >            pha         ;use stack to load status\n2910 : b513            >            lda zp1,x    ;load to indexed memory\n2912 : 9d0302          >            sta abst,x\n2915 : 28              >            plp\n                        \n2916 : 5e0302                   lsr abst,x\n                                tst_absx rLSR,fLSR,$ff-fnzc\n2919 : 08              >            php         ;save flags\n291a : bd0302          >            lda abst,x\n291d : dd2802          >            cmp rLSR,x    ;test result\n                       >            trap_ne\n2920 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2922 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2923 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2925 : dd3802          >            cmp fLSR,x    ;test flags\n                       >            trap_ne\n2928 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n292a : ca                       dex\n292b : 10e0                     bpl tlsr9\n                        \n292d : a203                     ldx #3\n292f :                  trol8\n                                set_absx zp1,0\n                       >            load_flag 0\n292f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2931 : 48              >            pha         ;use stack to load status\n2932 : b513            >            lda zp1,x    ;load to indexed memory\n2934 : 9d0302          >            sta abst,x\n2937 : 28              >            plp\n                        \n2938 : 3e0302                   rol abst,x\n                                tst_absx rROL,fROL,0\n293b : 08              >            php         ;save flags\n293c : bd0302          >            lda abst,x\n293f : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n2942 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2944 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2945 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2947 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n294a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n294c : ca                       dex\n294d : 10e0                     bpl trol8\n294f : a203                     ldx #3\n2951 :                  trol9\n                                set_absx zp1,$ff-fc\n                       >            load_flag $ff-fc\n2951 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n2953 : 48              >            pha         ;use stack to load status\n2954 : b513            >            lda zp1,x    ;load to indexed memory\n2956 : 9d0302          >            sta abst,x\n2959 : 28              >            plp\n                        \n295a : 3e0302                   rol abst,x\n                                tst_absx rROL,fROL,$ff-fnzc\n295d : 08              >            php         ;save flags\n295e : bd0302          >            lda abst,x\n2961 : dd2002          >            cmp rROL,x    ;test result\n                       >            trap_ne\n2964 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2966 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2967 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2969 : dd3002          >            cmp fROL,x    ;test flags\n                       >            trap_ne\n296c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n296e : ca                       dex\n296f : 10e0                     bpl trol9\n                        \n2971 : a203                     ldx #3\n2973 :                  trolc8\n                                set_absx zp1,fc\n                       >            load_flag fc\n2973 : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n2975 : 48              >            pha         ;use stack to load status\n2976 : b513            >            lda zp1,x    ;load to indexed memory\n2978 : 9d0302          >            sta abst,x\n297b : 28              >            plp\n                        \n297c : 3e0302                   rol abst,x\n                                tst_absx rROLc,fROLc,0\n297f : 08              >            php         ;save flags\n2980 : bd0302          >            lda abst,x\n2983 : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n2986 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2988 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2989 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n298b : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n298e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2990 : ca                       dex\n2991 : 10e0                     bpl trolc8\n2993 : a203                     ldx #3\n2995 :                  trolc9\n                                set_absx zp1,$ff\n                       >            load_flag $ff\n2995 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2997 : 48              >            pha         ;use stack to load status\n2998 : b513            >            lda zp1,x    ;load to indexed memory\n299a : 9d0302          >            sta abst,x\n299d : 28              >            plp\n                        \n299e : 3e0302                   rol abst,x\n                                tst_absx rROLc,fROLc,$ff-fnzc\n29a1 : 08              >            php         ;save flags\n29a2 : bd0302          >            lda abst,x\n29a5 : dd2402          >            cmp rROLc,x    ;test result\n                       >            trap_ne\n29a8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n29aa : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n29ab : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n29ad : dd3402          >            cmp fROLc,x    ;test flags\n                       >            trap_ne\n29b0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n29b2 : ca                       dex\n29b3 : 10e0                     bpl trolc9\n                        \n29b5 : a203                     ldx #3\n29b7 :                  tror8\n                                set_absx zp1,0\n                       >            load_flag 0\n29b7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n29b9 : 48              >            pha         ;use stack to load status\n29ba : b513            >            lda zp1,x    ;load to indexed memory\n29bc : 9d0302          >            sta abst,x\n29bf : 28              >            plp\n                        \n29c0 : 7e0302                   ror abst,x\n                                tst_absx rROR,fROR,0\n29c3 : 08              >            php         ;save flags\n29c4 : bd0302          >            lda abst,x\n29c7 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n29ca : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n29cc : 68              >            pla         ;load status\n                       >            eor_flag 0\n29cd : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n29cf : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n29d2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n29d4 : ca                       dex\n29d5 : 10e0                     bpl tror8\n29d7 : a203                     ldx #3\n29d9 :                  tror9\n                                set_absx zp1,$ff-fc\n                       >            load_flag $ff-fc\n29d9 : a9fe            >            lda #$ff-fc             ;allow test to change I-flag (no mask)\n                       >\n29db : 48              >            pha         ;use stack to load status\n29dc : b513            >            lda zp1,x    ;load to indexed memory\n29de : 9d0302          >            sta abst,x\n29e1 : 28              >            plp\n                        \n29e2 : 7e0302                   ror abst,x\n                                tst_absx rROR,fROR,$ff-fnzc\n29e5 : 08              >            php         ;save flags\n29e6 : bd0302          >            lda abst,x\n29e9 : dd2802          >            cmp rROR,x    ;test result\n                       >            trap_ne\n29ec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n29ee : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n29ef : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n29f1 : dd3802          >            cmp fROR,x    ;test flags\n                       >            trap_ne\n29f4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n29f6 : ca                       dex\n29f7 : 10e0                     bpl tror9\n                        \n29f9 : a203                     ldx #3\n29fb :                  trorc8\n                                set_absx zp1,fc\n                       >            load_flag fc\n29fb : a901            >            lda #fc             ;allow test to change I-flag (no mask)\n                       >\n29fd : 48              >            pha         ;use stack to load status\n29fe : b513            >            lda zp1,x    ;load to indexed memory\n2a00 : 9d0302          >            sta abst,x\n2a03 : 28              >            plp\n                        \n2a04 : 7e0302                   ror abst,x\n                                tst_absx rRORc,fRORc,0\n2a07 : 08              >            php         ;save flags\n2a08 : bd0302          >            lda abst,x\n2a0b : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n2a0e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2a10 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2a11 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2a13 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2a16 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2a18 : ca                       dex\n2a19 : 10e0                     bpl trorc8\n2a1b : a203                     ldx #3\n2a1d :                  trorc9\n                                set_absx zp1,$ff\n                       >            load_flag $ff\n2a1d : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2a1f : 48              >            pha         ;use stack to load status\n2a20 : b513            >            lda zp1,x    ;load to indexed memory\n2a22 : 9d0302          >            sta abst,x\n2a25 : 28              >            plp\n                        \n2a26 : 7e0302                   ror abst,x\n                                tst_absx rRORc,fRORc,$ff-fnzc\n2a29 : 08              >            php         ;save flags\n2a2a : bd0302          >            lda abst,x\n2a2d : dd2c02          >            cmp rRORc,x    ;test result\n                       >            trap_ne\n2a30 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2a32 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnzc\n2a33 : 497c            >            eor #$ff-fnzc|fao         ;invert expected flags + always on bits\n                       >\n2a35 : dd3c02          >            cmp fRORc,x    ;test flags\n                       >            trap_ne\n2a38 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2a3a : ca                       dex\n2a3b : 10e0                     bpl trorc9\n                                next_test\n2a3d : ad0002          >            lda test_case   ;previous test\n2a40 : c921            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2a42 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0022 =                 >test_num = test_num + 1\n2a44 : a922            >            lda #test_num   ;*** next tests' number\n2a46 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; testing memory increment/decrement - INC DEC all addressing modes\n                        ; zeropage\n2a49 : a200                     ldx #0\n2a4b : a97e                     lda #$7e\n2a4d : 850c                     sta zpt\n2a4f :                  tinc    \n                                set_stat 0\n                       >            load_flag 0\n2a4f : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2a51 : 48              >            pha         ;use stack to load status\n2a52 : 28              >            plp\n                        \n2a53 : e60c                     inc zpt\n                                tst_z rINC,fINC,0\n2a55 : 08              >            php         ;save flags\n2a56 : a50c            >            lda zpt\n2a58 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2a5b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2a5d : 68              >            pla         ;load status\n                       >            eor_flag 0\n2a5e : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2a60 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2a63 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2a65 : e8                       inx\n2a66 : e002                     cpx #2\n2a68 : d004                     bne tinc1\n2a6a : a9fe                     lda #$fe\n2a6c : 850c                     sta zpt\n2a6e : e005             tinc1   cpx #5\n2a70 : d0dd                     bne tinc\n2a72 : ca                       dex\n2a73 : e60c                     inc zpt\n2a75 :                  tdec    \n                                set_stat 0\n                       >            load_flag 0\n2a75 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2a77 : 48              >            pha         ;use stack to load status\n2a78 : 28              >            plp\n                        \n2a79 : c60c                     dec zpt\n                                tst_z rINC,fINC,0\n2a7b : 08              >            php         ;save flags\n2a7c : a50c            >            lda zpt\n2a7e : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2a81 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2a83 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2a84 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2a86 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2a89 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2a8b : ca                       dex\n2a8c : 300a                     bmi tdec1\n2a8e : e001                     cpx #1\n2a90 : d0e3                     bne tdec\n2a92 : a981                     lda #$81\n2a94 : 850c                     sta zpt\n2a96 : d0dd                     bne tdec\n2a98 :                  tdec1\n2a98 : a200                     ldx #0\n2a9a : a97e                     lda #$7e\n2a9c : 850c                     sta zpt\n2a9e :                  tinc10    \n                                set_stat $ff\n                       >            load_flag $ff\n2a9e : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2aa0 : 48              >            pha         ;use stack to load status\n2aa1 : 28              >            plp\n                        \n2aa2 : e60c                     inc zpt\n                                tst_z rINC,fINC,$ff-fnz\n2aa4 : 08              >            php         ;save flags\n2aa5 : a50c            >            lda zpt\n2aa7 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2aaa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2aac : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2aad : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2aaf : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2ab2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ab4 : e8                       inx\n2ab5 : e002                     cpx #2\n2ab7 : d004                     bne tinc11\n2ab9 : a9fe                     lda #$fe\n2abb : 850c                     sta zpt\n2abd : e005             tinc11  cpx #5\n2abf : d0dd                     bne tinc10\n2ac1 : ca                       dex\n2ac2 : e60c                     inc zpt\n2ac4 :                  tdec10    \n                                set_stat $ff\n                       >            load_flag $ff\n2ac4 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2ac6 : 48              >            pha         ;use stack to load status\n2ac7 : 28              >            plp\n                        \n2ac8 : c60c                     dec zpt\n                                tst_z rINC,fINC,$ff-fnz\n2aca : 08              >            php         ;save flags\n2acb : a50c            >            lda zpt\n2acd : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2ad0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2ad2 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2ad3 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2ad5 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2ad8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ada : ca                       dex\n2adb : 300a                     bmi tdec11\n2add : e001                     cpx #1\n2adf : d0e3                     bne tdec10\n2ae1 : a981                     lda #$81\n2ae3 : 850c                     sta zpt\n2ae5 : d0dd                     bne tdec10\n2ae7 :                  tdec11\n                                next_test\n2ae7 : ad0002          >            lda test_case   ;previous test\n2aea : c922            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2aec : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0023 =                 >test_num = test_num + 1\n2aee : a923            >            lda #test_num   ;*** next tests' number\n2af0 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; absolute memory\n2af3 : a200                     ldx #0\n2af5 : a97e                     lda #$7e\n2af7 : 8d0302                   sta abst\n2afa :                  tinc2    \n                                set_stat 0\n                       >            load_flag 0\n2afa : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2afc : 48              >            pha         ;use stack to load status\n2afd : 28              >            plp\n                        \n2afe : ee0302                   inc abst\n                                tst_abs rINC,fINC,0\n2b01 : 08              >            php         ;save flags\n2b02 : ad0302          >            lda abst\n2b05 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2b08 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2b0a : 68              >            pla         ;load status\n                       >            eor_flag 0\n2b0b : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2b0d : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2b10 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2b12 : e8                       inx\n2b13 : e002                     cpx #2\n2b15 : d005                     bne tinc3\n2b17 : a9fe                     lda #$fe\n2b19 : 8d0302                   sta abst\n2b1c : e005             tinc3   cpx #5\n2b1e : d0da                     bne tinc2\n2b20 : ca                       dex\n2b21 : ee0302                   inc abst\n2b24 :                  tdec2    \n                                set_stat 0\n                       >            load_flag 0\n2b24 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2b26 : 48              >            pha         ;use stack to load status\n2b27 : 28              >            plp\n                        \n2b28 : ce0302                   dec abst\n                                tst_abs rINC,fINC,0\n2b2b : 08              >            php         ;save flags\n2b2c : ad0302          >            lda abst\n2b2f : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2b32 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2b34 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2b35 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2b37 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2b3a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2b3c : ca                       dex\n2b3d : 300b                     bmi tdec3\n2b3f : e001                     cpx #1\n2b41 : d0e1                     bne tdec2\n2b43 : a981                     lda #$81\n2b45 : 8d0302                   sta abst\n2b48 : d0da                     bne tdec2\n2b4a :                  tdec3\n2b4a : a200                     ldx #0\n2b4c : a97e                     lda #$7e\n2b4e : 8d0302                   sta abst\n2b51 :                  tinc12    \n                                set_stat $ff\n                       >            load_flag $ff\n2b51 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2b53 : 48              >            pha         ;use stack to load status\n2b54 : 28              >            plp\n                        \n2b55 : ee0302                   inc abst\n                                tst_abs rINC,fINC,$ff-fnz\n2b58 : 08              >            php         ;save flags\n2b59 : ad0302          >            lda abst\n2b5c : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2b5f : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2b61 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2b62 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2b64 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2b67 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2b69 : e8                       inx\n2b6a : e002                     cpx #2\n2b6c : d005                     bne tinc13\n2b6e : a9fe                     lda #$fe\n2b70 : 8d0302                   sta abst\n2b73 : e005             tinc13   cpx #5\n2b75 : d0da                     bne tinc12\n2b77 : ca                       dex\n2b78 : ee0302                   inc abst\n2b7b :                  tdec12    \n                                set_stat $ff\n                       >            load_flag $ff\n2b7b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2b7d : 48              >            pha         ;use stack to load status\n2b7e : 28              >            plp\n                        \n2b7f : ce0302                   dec abst\n                                tst_abs rINC,fINC,$ff-fnz\n2b82 : 08              >            php         ;save flags\n2b83 : ad0302          >            lda abst\n2b86 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2b89 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2b8b : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2b8c : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2b8e : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2b91 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2b93 : ca                       dex\n2b94 : 300b                     bmi tdec13\n2b96 : e001                     cpx #1\n2b98 : d0e1                     bne tdec12\n2b9a : a981                     lda #$81\n2b9c : 8d0302                   sta abst\n2b9f : d0da                     bne tdec12\n2ba1 :                  tdec13\n                                next_test\n2ba1 : ad0002          >            lda test_case   ;previous test\n2ba4 : c923            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2ba6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0024 =                 >test_num = test_num + 1\n2ba8 : a924            >            lda #test_num   ;*** next tests' number\n2baa : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; zeropage indexed\n2bad : a200                     ldx #0\n2baf : a97e                     lda #$7e\n2bb1 : 950c             tinc4   sta zpt,x\n                                set_stat 0\n                       >            load_flag 0\n2bb3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2bb5 : 48              >            pha         ;use stack to load status\n2bb6 : 28              >            plp\n                        \n2bb7 : f60c                     inc zpt,x\n                                tst_zx rINC,fINC,0\n2bb9 : 08              >            php         ;save flags\n2bba : b50c            >            lda zpt,x\n2bbc : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2bbf : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2bc1 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2bc2 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2bc4 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2bc7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2bc9 : b50c                     lda zpt,x\n2bcb : e8                       inx\n2bcc : e002                     cpx #2\n2bce : d002                     bne tinc5\n2bd0 : a9fe                     lda #$fe\n2bd2 : e005             tinc5   cpx #5\n2bd4 : d0db                     bne tinc4\n2bd6 : ca                       dex\n2bd7 : a902                     lda #2\n2bd9 : 950c             tdec4   sta zpt,x \n                                set_stat 0\n                       >            load_flag 0\n2bdb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2bdd : 48              >            pha         ;use stack to load status\n2bde : 28              >            plp\n                        \n2bdf : d60c                     dec zpt,x\n                                tst_zx rINC,fINC,0\n2be1 : 08              >            php         ;save flags\n2be2 : b50c            >            lda zpt,x\n2be4 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2be7 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2be9 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2bea : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2bec : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2bef : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2bf1 : b50c                     lda zpt,x\n2bf3 : ca                       dex\n2bf4 : 3008                     bmi tdec5\n2bf6 : e001                     cpx #1\n2bf8 : d0df                     bne tdec4\n2bfa : a981                     lda #$81\n2bfc : d0db                     bne tdec4\n2bfe :                  tdec5\n2bfe : a200                     ldx #0\n2c00 : a97e                     lda #$7e\n2c02 : 950c             tinc14  sta zpt,x\n                                set_stat $ff\n                       >            load_flag $ff\n2c04 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2c06 : 48              >            pha         ;use stack to load status\n2c07 : 28              >            plp\n                        \n2c08 : f60c                     inc zpt,x\n                                tst_zx rINC,fINC,$ff-fnz\n2c0a : 08              >            php         ;save flags\n2c0b : b50c            >            lda zpt,x\n2c0d : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2c10 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2c12 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2c13 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2c15 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2c18 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2c1a : b50c                     lda zpt,x\n2c1c : e8                       inx\n2c1d : e002                     cpx #2\n2c1f : d002                     bne tinc15\n2c21 : a9fe                     lda #$fe\n2c23 : e005             tinc15  cpx #5\n2c25 : d0db                     bne tinc14\n2c27 : ca                       dex\n2c28 : a902                     lda #2\n2c2a : 950c             tdec14  sta zpt,x \n                                set_stat $ff\n                       >            load_flag $ff\n2c2c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2c2e : 48              >            pha         ;use stack to load status\n2c2f : 28              >            plp\n                        \n2c30 : d60c                     dec zpt,x\n                                tst_zx rINC,fINC,$ff-fnz\n2c32 : 08              >            php         ;save flags\n2c33 : b50c            >            lda zpt,x\n2c35 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2c38 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2c3a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2c3b : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2c3d : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2c40 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2c42 : b50c                     lda zpt,x\n2c44 : ca                       dex\n2c45 : 3008                     bmi tdec15\n2c47 : e001                     cpx #1\n2c49 : d0df                     bne tdec14\n2c4b : a981                     lda #$81\n2c4d : d0db                     bne tdec14\n2c4f :                  tdec15\n                                next_test\n2c4f : ad0002          >            lda test_case   ;previous test\n2c52 : c924            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2c54 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0025 =                 >test_num = test_num + 1\n2c56 : a925            >            lda #test_num   ;*** next tests' number\n2c58 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; memory indexed\n2c5b : a200                     ldx #0\n2c5d : a97e                     lda #$7e\n2c5f : 9d0302           tinc6   sta abst,x\n                                set_stat 0\n                       >            load_flag 0\n2c62 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2c64 : 48              >            pha         ;use stack to load status\n2c65 : 28              >            plp\n                        \n2c66 : fe0302                   inc abst,x\n                                tst_absx rINC,fINC,0\n2c69 : 08              >            php         ;save flags\n2c6a : bd0302          >            lda abst,x\n2c6d : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2c70 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2c72 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2c73 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2c75 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2c78 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2c7a : bd0302                   lda abst,x\n2c7d : e8                       inx\n2c7e : e002                     cpx #2\n2c80 : d002                     bne tinc7\n2c82 : a9fe                     lda #$fe\n2c84 : e005             tinc7   cpx #5\n2c86 : d0d7                     bne tinc6\n2c88 : ca                       dex\n2c89 : a902                     lda #2\n2c8b : 9d0302           tdec6   sta abst,x \n                                set_stat 0\n                       >            load_flag 0\n2c8e : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2c90 : 48              >            pha         ;use stack to load status\n2c91 : 28              >            plp\n                        \n2c92 : de0302                   dec abst,x\n                                tst_absx rINC,fINC,0\n2c95 : 08              >            php         ;save flags\n2c96 : bd0302          >            lda abst,x\n2c99 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2c9c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2c9e : 68              >            pla         ;load status\n                       >            eor_flag 0\n2c9f : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2ca1 : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2ca4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ca6 : bd0302                   lda abst,x\n2ca9 : ca                       dex\n2caa : 3008                     bmi tdec7\n2cac : e001                     cpx #1\n2cae : d0db                     bne tdec6\n2cb0 : a981                     lda #$81\n2cb2 : d0d7                     bne tdec6\n2cb4 :                  tdec7\n2cb4 : a200                     ldx #0\n2cb6 : a97e                     lda #$7e\n2cb8 : 9d0302           tinc16  sta abst,x\n                                set_stat $ff\n                       >            load_flag $ff\n2cbb : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2cbd : 48              >            pha         ;use stack to load status\n2cbe : 28              >            plp\n                        \n2cbf : fe0302                   inc abst,x\n                                tst_absx rINC,fINC,$ff-fnz\n2cc2 : 08              >            php         ;save flags\n2cc3 : bd0302          >            lda abst,x\n2cc6 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2cc9 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2ccb : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2ccc : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2cce : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2cd1 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2cd3 : bd0302                   lda abst,x\n2cd6 : e8                       inx\n2cd7 : e002                     cpx #2\n2cd9 : d002                     bne tinc17\n2cdb : a9fe                     lda #$fe\n2cdd : e005             tinc17  cpx #5\n2cdf : d0d7                     bne tinc16\n2ce1 : ca                       dex\n2ce2 : a902                     lda #2\n2ce4 : 9d0302           tdec16  sta abst,x \n                                set_stat $ff\n                       >            load_flag $ff\n2ce7 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2ce9 : 48              >            pha         ;use stack to load status\n2cea : 28              >            plp\n                        \n2ceb : de0302                   dec abst,x\n                                tst_absx rINC,fINC,$ff-fnz\n2cee : 08              >            php         ;save flags\n2cef : bd0302          >            lda abst,x\n2cf2 : dd4002          >            cmp rINC,x    ;test result\n                       >            trap_ne\n2cf5 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2cf7 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2cf8 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2cfa : dd4502          >            cmp fINC,x    ;test flags\n                       >            trap_ne\n2cfd : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2cff : bd0302                   lda abst,x\n2d02 : ca                       dex\n2d03 : 3008                     bmi tdec17\n2d05 : e001                     cpx #1\n2d07 : d0db                     bne tdec16\n2d09 : a981                     lda #$81\n2d0b : d0d7                     bne tdec16\n2d0d :                  tdec17\n                                next_test\n2d0d : ad0002          >            lda test_case   ;previous test\n2d10 : c925            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2d12 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0026 =                 >test_num = test_num + 1\n2d14 : a926            >            lda #test_num   ;*** next tests' number\n2d16 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; testing logical instructions - AND EOR ORA all addressing modes\n                        ; AND\n2d19 : a203                     ldx #3          ;immediate\n2d1b : b51c             tand    lda zpAN,x\n2d1d : 8d0902                   sta ex_andi+1   ;set AND # operand\n                                set_ax  absANa,0\n                       >            load_flag 0\n2d20 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2d22 : 48              >            pha         ;use stack to load status\n2d23 : bd5a02          >            lda absANa,x    ;precharge accu\n2d26 : 28              >            plp\n                        \n2d27 : 200802                   jsr ex_andi     ;execute AND # in RAM\n                                tst_ax  absrlo,absflo,0\n2d2a : 08              >            php         ;save flags\n2d2b : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2d2e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2d30 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2d31 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2d33 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2d36 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2d38 : ca                       dex\n2d39 : 10e0                     bpl tand\n2d3b : a203                     ldx #3\n2d3d : b51c             tand1   lda zpAN,x\n2d3f : 8d0902                   sta ex_andi+1   ;set AND # operand\n                                set_ax  absANa,$ff\n                       >            load_flag $ff\n2d42 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2d44 : 48              >            pha         ;use stack to load status\n2d45 : bd5a02          >            lda absANa,x    ;precharge accu\n2d48 : 28              >            plp\n                        \n2d49 : 200802                   jsr ex_andi     ;execute AND # in RAM\n                                tst_ax  absrlo,absflo,$ff-fnz\n2d4c : 08              >            php         ;save flags\n2d4d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2d50 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2d52 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2d53 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2d55 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2d58 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2d5a : ca                       dex\n2d5b : 10e0                     bpl tand1\n                            \n2d5d : a203                     ldx #3      ;zp\n2d5f : b51c             tand2   lda zpAN,x\n2d61 : 850c                     sta zpt\n                                set_ax  absANa,0\n                       >            load_flag 0\n2d63 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2d65 : 48              >            pha         ;use stack to load status\n2d66 : bd5a02          >            lda absANa,x    ;precharge accu\n2d69 : 28              >            plp\n                        \n2d6a : 250c                     and zpt\n                                tst_ax  absrlo,absflo,0\n2d6c : 08              >            php         ;save flags\n2d6d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2d70 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2d72 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2d73 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2d75 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2d78 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2d7a : ca                       dex\n2d7b : 10e2                     bpl tand2\n2d7d : a203                     ldx #3\n2d7f : b51c             tand3   lda zpAN,x\n2d81 : 850c                     sta zpt\n                                set_ax  absANa,$ff\n                       >            load_flag $ff\n2d83 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2d85 : 48              >            pha         ;use stack to load status\n2d86 : bd5a02          >            lda absANa,x    ;precharge accu\n2d89 : 28              >            plp\n                        \n2d8a : 250c                     and zpt\n                                tst_ax  absrlo,absflo,$ff-fnz\n2d8c : 08              >            php         ;save flags\n2d8d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2d90 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2d92 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2d93 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2d95 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2d98 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2d9a : ca                       dex\n2d9b : 10e2                     bpl tand3\n                        \n2d9d : a203                     ldx #3      ;abs\n2d9f : b51c             tand4   lda zpAN,x\n2da1 : 8d0302                   sta abst\n                                set_ax  absANa,0\n                       >            load_flag 0\n2da4 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2da6 : 48              >            pha         ;use stack to load status\n2da7 : bd5a02          >            lda absANa,x    ;precharge accu\n2daa : 28              >            plp\n                        \n2dab : 2d0302                   and abst\n                                tst_ax  absrlo,absflo,0\n2dae : 08              >            php         ;save flags\n2daf : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2db2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2db4 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2db5 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2db7 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2dba : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2dbc : ca                       dex\n2dbd : 10e0                     bpl tand4\n2dbf : a203                     ldx #3\n2dc1 : b51c             tand5   lda zpAN,x\n2dc3 : 8d0302                   sta abst\n                                set_ax  absANa,$ff\n                       >            load_flag $ff\n2dc6 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2dc8 : 48              >            pha         ;use stack to load status\n2dc9 : bd5a02          >            lda absANa,x    ;precharge accu\n2dcc : 28              >            plp\n                        \n2dcd : 2d0302                   and abst\n                                tst_ax  absrlo,absflo,$ff-fnz\n2dd0 : 08              >            php         ;save flags\n2dd1 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2dd4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2dd6 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2dd7 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2dd9 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2ddc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2dde : ca                       dex\n2ddf : 1002                     bpl tand6\n                        \n2de1 : a203                     ldx #3      ;zp,x\n2de3 :                  tand6\n                                set_ax  absANa,0\n                       >            load_flag 0\n2de3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2de5 : 48              >            pha         ;use stack to load status\n2de6 : bd5a02          >            lda absANa,x    ;precharge accu\n2de9 : 28              >            plp\n                        \n2dea : 351c                     and zpAN,x\n                                tst_ax  absrlo,absflo,0\n2dec : 08              >            php         ;save flags\n2ded : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2df0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2df2 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2df3 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2df5 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2df8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2dfa : ca                       dex\n2dfb : 10e6                     bpl tand6\n2dfd : a203                     ldx #3\n2dff :                  tand7\n                                set_ax  absANa,$ff\n                       >            load_flag $ff\n2dff : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2e01 : 48              >            pha         ;use stack to load status\n2e02 : bd5a02          >            lda absANa,x    ;precharge accu\n2e05 : 28              >            plp\n                        \n2e06 : 351c                     and zpAN,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n2e08 : 08              >            php         ;save flags\n2e09 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2e0c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2e0e : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2e0f : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2e11 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2e14 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2e16 : ca                       dex\n2e17 : 10e6                     bpl tand7\n                        \n2e19 : a203                     ldx #3      ;abs,x\n2e1b :                  tand8\n                                set_ax  absANa,0\n                       >            load_flag 0\n2e1b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2e1d : 48              >            pha         ;use stack to load status\n2e1e : bd5a02          >            lda absANa,x    ;precharge accu\n2e21 : 28              >            plp\n                        \n2e22 : 3d4e02                   and absAN,x\n                                tst_ax  absrlo,absflo,0\n2e25 : 08              >            php         ;save flags\n2e26 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2e29 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2e2b : 68              >            pla         ;load status\n                       >            eor_flag 0\n2e2c : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2e2e : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2e31 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2e33 : ca                       dex\n2e34 : 10e5                     bpl tand8\n2e36 : a203                     ldx #3\n2e38 :                  tand9\n                                set_ax  absANa,$ff\n                       >            load_flag $ff\n2e38 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2e3a : 48              >            pha         ;use stack to load status\n2e3b : bd5a02          >            lda absANa,x    ;precharge accu\n2e3e : 28              >            plp\n                        \n2e3f : 3d4e02                   and absAN,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n2e42 : 08              >            php         ;save flags\n2e43 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2e46 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2e48 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2e49 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2e4b : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2e4e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2e50 : ca                       dex\n2e51 : 10e5                     bpl tand9\n                        \n2e53 : a003                     ldy #3      ;abs,y\n2e55 :                  tand10\n                                set_ay  absANa,0\n                       >            load_flag 0\n2e55 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2e57 : 48              >            pha         ;use stack to load status\n2e58 : b95a02          >            lda absANa,y    ;precharge accu\n2e5b : 28              >            plp\n                        \n2e5c : 394e02                   and absAN,y\n                                tst_ay  absrlo,absflo,0\n2e5f : 08              >            php         ;save flags\n2e60 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2e63 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2e65 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2e66 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2e68 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2e6b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2e6d : 88                       dey\n2e6e : 10e5                     bpl tand10\n2e70 : a003                     ldy #3\n2e72 :                  tand11\n                                set_ay  absANa,$ff\n                       >            load_flag $ff\n2e72 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2e74 : 48              >            pha         ;use stack to load status\n2e75 : b95a02          >            lda absANa,y    ;precharge accu\n2e78 : 28              >            plp\n                        \n2e79 : 394e02                   and absAN,y\n                                tst_ay  absrlo,absflo,$ff-fnz\n2e7c : 08              >            php         ;save flags\n2e7d : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2e80 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2e82 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2e83 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2e85 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2e88 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2e8a : 88                       dey\n2e8b : 10e5                     bpl tand11\n                        \n2e8d : a206                     ldx #6      ;(zp,x)\n2e8f : a003                     ldy #3\n2e91 :                  tand12\n                                set_ay  absANa,0\n                       >            load_flag 0\n2e91 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2e93 : 48              >            pha         ;use stack to load status\n2e94 : b95a02          >            lda absANa,y    ;precharge accu\n2e97 : 28              >            plp\n                        \n2e98 : 213a                     and (indAN,x)\n                                tst_ay  absrlo,absflo,0\n2e9a : 08              >            php         ;save flags\n2e9b : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2e9e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2ea0 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2ea1 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2ea3 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2ea6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ea8 : ca                       dex\n2ea9 : ca                       dex\n2eaa : 88                       dey\n2eab : 10e4                     bpl tand12\n2ead : a206                     ldx #6\n2eaf : a003                     ldy #3\n2eb1 :                  tand13\n                                set_ay  absANa,$ff\n                       >            load_flag $ff\n2eb1 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2eb3 : 48              >            pha         ;use stack to load status\n2eb4 : b95a02          >            lda absANa,y    ;precharge accu\n2eb7 : 28              >            plp\n                        \n2eb8 : 213a                     and (indAN,x)\n                                tst_ay  absrlo,absflo,$ff-fnz\n2eba : 08              >            php         ;save flags\n2ebb : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2ebe : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2ec0 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2ec1 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2ec3 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2ec6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ec8 : ca                       dex\n2ec9 : ca                       dex\n2eca : 88                       dey\n2ecb : 10e4                     bpl tand13\n                        \n2ecd : a003                     ldy #3      ;(zp),y\n2ecf :                  tand14\n                                set_ay  absANa,0\n                       >            load_flag 0\n2ecf : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2ed1 : 48              >            pha         ;use stack to load status\n2ed2 : b95a02          >            lda absANa,y    ;precharge accu\n2ed5 : 28              >            plp\n                        \n2ed6 : 313a                     and (indAN),y\n                                tst_ay  absrlo,absflo,0\n2ed8 : 08              >            php         ;save flags\n2ed9 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2edc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2ede : 68              >            pla         ;load status\n                       >            eor_flag 0\n2edf : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2ee1 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2ee4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ee6 : 88                       dey\n2ee7 : 10e6                     bpl tand14\n2ee9 : a003                     ldy #3\n2eeb :                  tand15\n                                set_ay  absANa,$ff\n                       >            load_flag $ff\n2eeb : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2eed : 48              >            pha         ;use stack to load status\n2eee : b95a02          >            lda absANa,y    ;precharge accu\n2ef1 : 28              >            plp\n                        \n2ef2 : 313a                     and (indAN),y\n                                tst_ay  absrlo,absflo,$ff-fnz\n2ef4 : 08              >            php         ;save flags\n2ef5 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n2ef8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2efa : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2efb : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2efd : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n2f00 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2f02 : 88                       dey\n2f03 : 10e6                     bpl tand15\n                                next_test\n2f05 : ad0002          >            lda test_case   ;previous test\n2f08 : c926            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n2f0a : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0027 =                 >test_num = test_num + 1\n2f0c : a927            >            lda #test_num   ;*** next tests' number\n2f0e : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; EOR\n2f11 : a203                     ldx #3          ;immediate - self modifying code\n2f13 : b520             teor    lda zpEO,x\n2f15 : 8d0c02                   sta ex_eori+1   ;set EOR # operand\n                                set_ax  absEOa,0\n                       >            load_flag 0\n2f18 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2f1a : 48              >            pha         ;use stack to load status\n2f1b : bd5e02          >            lda absEOa,x    ;precharge accu\n2f1e : 28              >            plp\n                        \n2f1f : 200b02                   jsr ex_eori     ;execute EOR # in RAM\n                                tst_ax  absrlo,absflo,0\n2f22 : 08              >            php         ;save flags\n2f23 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2f26 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2f28 : 68              >            pla         ;load status\n                       >            eor_flag 0\n2f29 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2f2b : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2f2e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2f30 : ca                       dex\n2f31 : 10e0                     bpl teor\n2f33 : a203                     ldx #3\n2f35 : b520             teor1   lda zpEO,x\n2f37 : 8d0c02                   sta ex_eori+1   ;set EOR # operand\n                                set_ax  absEOa,$ff\n                       >            load_flag $ff\n2f3a : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2f3c : 48              >            pha         ;use stack to load status\n2f3d : bd5e02          >            lda absEOa,x    ;precharge accu\n2f40 : 28              >            plp\n                        \n2f41 : 200b02                   jsr ex_eori     ;execute EOR # in RAM\n                                tst_ax  absrlo,absflo,$ff-fnz\n2f44 : 08              >            php         ;save flags\n2f45 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2f48 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2f4a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2f4b : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2f4d : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2f50 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2f52 : ca                       dex\n2f53 : 10e0                     bpl teor1\n                            \n2f55 : a203                     ldx #3      ;zp\n2f57 : b520             teor2    lda zpEO,x\n2f59 : 850c                     sta zpt\n                                set_ax  absEOa,0\n                       >            load_flag 0\n2f5b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2f5d : 48              >            pha         ;use stack to load status\n2f5e : bd5e02          >            lda absEOa,x    ;precharge accu\n2f61 : 28              >            plp\n                        \n2f62 : 450c                     eor zpt\n                                tst_ax  absrlo,absflo,0\n2f64 : 08              >            php         ;save flags\n2f65 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2f68 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2f6a : 68              >            pla         ;load status\n                       >            eor_flag 0\n2f6b : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2f6d : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2f70 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2f72 : ca                       dex\n2f73 : 10e2                     bpl teor2\n2f75 : a203                     ldx #3\n2f77 : b520             teor3   lda zpEO,x\n2f79 : 850c                     sta zpt\n                                set_ax  absEOa,$ff\n                       >            load_flag $ff\n2f7b : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2f7d : 48              >            pha         ;use stack to load status\n2f7e : bd5e02          >            lda absEOa,x    ;precharge accu\n2f81 : 28              >            plp\n                        \n2f82 : 450c                     eor zpt\n                                tst_ax  absrlo,absflo,$ff-fnz\n2f84 : 08              >            php         ;save flags\n2f85 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2f88 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2f8a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2f8b : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2f8d : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2f90 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2f92 : ca                       dex\n2f93 : 10e2                     bpl teor3\n                        \n2f95 : a203                     ldx #3      ;abs\n2f97 : b520             teor4   lda zpEO,x\n2f99 : 8d0302                   sta abst\n                                set_ax  absEOa,0\n                       >            load_flag 0\n2f9c : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2f9e : 48              >            pha         ;use stack to load status\n2f9f : bd5e02          >            lda absEOa,x    ;precharge accu\n2fa2 : 28              >            plp\n                        \n2fa3 : 4d0302                   eor abst\n                                tst_ax  absrlo,absflo,0\n2fa6 : 08              >            php         ;save flags\n2fa7 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2faa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2fac : 68              >            pla         ;load status\n                       >            eor_flag 0\n2fad : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2faf : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2fb2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2fb4 : ca                       dex\n2fb5 : 10e0                     bpl teor4\n2fb7 : a203                     ldx #3\n2fb9 : b520             teor5   lda zpEO,x\n2fbb : 8d0302                   sta abst\n                                set_ax  absEOa,$ff\n                       >            load_flag $ff\n2fbe : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2fc0 : 48              >            pha         ;use stack to load status\n2fc1 : bd5e02          >            lda absEOa,x    ;precharge accu\n2fc4 : 28              >            plp\n                        \n2fc5 : 4d0302                   eor abst\n                                tst_ax  absrlo,absflo,$ff-fnz\n2fc8 : 08              >            php         ;save flags\n2fc9 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2fcc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2fce : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n2fcf : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n2fd1 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2fd4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2fd6 : ca                       dex\n2fd7 : 1002                     bpl teor6\n                        \n2fd9 : a203                     ldx #3      ;zp,x\n2fdb :                  teor6\n                                set_ax  absEOa,0\n                       >            load_flag 0\n2fdb : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n2fdd : 48              >            pha         ;use stack to load status\n2fde : bd5e02          >            lda absEOa,x    ;precharge accu\n2fe1 : 28              >            plp\n                        \n2fe2 : 5520                     eor zpEO,x\n                                tst_ax  absrlo,absflo,0\n2fe4 : 08              >            php         ;save flags\n2fe5 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n2fe8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n2fea : 68              >            pla         ;load status\n                       >            eor_flag 0\n2feb : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n2fed : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n2ff0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n2ff2 : ca                       dex\n2ff3 : 10e6                     bpl teor6\n2ff5 : a203                     ldx #3\n2ff7 :                  teor7\n                                set_ax  absEOa,$ff\n                       >            load_flag $ff\n2ff7 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n2ff9 : 48              >            pha         ;use stack to load status\n2ffa : bd5e02          >            lda absEOa,x    ;precharge accu\n2ffd : 28              >            plp\n                        \n2ffe : 5520                     eor zpEO,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n3000 : 08              >            php         ;save flags\n3001 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3004 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3006 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3007 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3009 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n300c : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n300e : ca                       dex\n300f : 10e6                     bpl teor7\n                        \n3011 : a203                     ldx #3      ;abs,x\n3013 :                  teor8\n                                set_ax  absEOa,0\n                       >            load_flag 0\n3013 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3015 : 48              >            pha         ;use stack to load status\n3016 : bd5e02          >            lda absEOa,x    ;precharge accu\n3019 : 28              >            plp\n                        \n301a : 5d5202                   eor absEO,x\n                                tst_ax  absrlo,absflo,0\n301d : 08              >            php         ;save flags\n301e : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3021 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3023 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3024 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3026 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3029 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n302b : ca                       dex\n302c : 10e5                     bpl teor8\n302e : a203                     ldx #3\n3030 :                  teor9\n                                set_ax  absEOa,$ff\n                       >            load_flag $ff\n3030 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3032 : 48              >            pha         ;use stack to load status\n3033 : bd5e02          >            lda absEOa,x    ;precharge accu\n3036 : 28              >            plp\n                        \n3037 : 5d5202                   eor absEO,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n303a : 08              >            php         ;save flags\n303b : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n303e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3040 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3041 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3043 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3046 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3048 : ca                       dex\n3049 : 10e5                     bpl teor9\n                        \n304b : a003                     ldy #3      ;abs,y\n304d :                  teor10\n                                set_ay  absEOa,0\n                       >            load_flag 0\n304d : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n304f : 48              >            pha         ;use stack to load status\n3050 : b95e02          >            lda absEOa,y    ;precharge accu\n3053 : 28              >            plp\n                        \n3054 : 595202                   eor absEO,y\n                                tst_ay  absrlo,absflo,0\n3057 : 08              >            php         ;save flags\n3058 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n305b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n305d : 68              >            pla         ;load status\n                       >            eor_flag 0\n305e : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3060 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n3063 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3065 : 88                       dey\n3066 : 10e5                     bpl teor10\n3068 : a003                     ldy #3\n306a :                  teor11\n                                set_ay  absEOa,$ff\n                       >            load_flag $ff\n306a : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n306c : 48              >            pha         ;use stack to load status\n306d : b95e02          >            lda absEOa,y    ;precharge accu\n3070 : 28              >            plp\n                        \n3071 : 595202                   eor absEO,y\n                                tst_ay  absrlo,absflo,$ff-fnz\n3074 : 08              >            php         ;save flags\n3075 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n3078 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n307a : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n307b : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n307d : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n3080 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3082 : 88                       dey\n3083 : 10e5                     bpl teor11\n                        \n3085 : a206                     ldx #6      ;(zp,x)\n3087 : a003                     ldy #3\n3089 :                  teor12\n                                set_ay  absEOa,0\n                       >            load_flag 0\n3089 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n308b : 48              >            pha         ;use stack to load status\n308c : b95e02          >            lda absEOa,y    ;precharge accu\n308f : 28              >            plp\n                        \n3090 : 4142                     eor (indEO,x)\n                                tst_ay  absrlo,absflo,0\n3092 : 08              >            php         ;save flags\n3093 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n3096 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3098 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3099 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n309b : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n309e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n30a0 : ca                       dex\n30a1 : ca                       dex\n30a2 : 88                       dey\n30a3 : 10e4                     bpl teor12\n30a5 : a206                     ldx #6\n30a7 : a003                     ldy #3\n30a9 :                  teor13\n                                set_ay  absEOa,$ff\n                       >            load_flag $ff\n30a9 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n30ab : 48              >            pha         ;use stack to load status\n30ac : b95e02          >            lda absEOa,y    ;precharge accu\n30af : 28              >            plp\n                        \n30b0 : 4142                     eor (indEO,x)\n                                tst_ay  absrlo,absflo,$ff-fnz\n30b2 : 08              >            php         ;save flags\n30b3 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n30b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n30b8 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n30b9 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n30bb : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n30be : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n30c0 : ca                       dex\n30c1 : ca                       dex\n30c2 : 88                       dey\n30c3 : 10e4                     bpl teor13\n                        \n30c5 : a003                     ldy #3      ;(zp),y\n30c7 :                  teor14\n                                set_ay  absEOa,0\n                       >            load_flag 0\n30c7 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n30c9 : 48              >            pha         ;use stack to load status\n30ca : b95e02          >            lda absEOa,y    ;precharge accu\n30cd : 28              >            plp\n                        \n30ce : 5142                     eor (indEO),y\n                                tst_ay  absrlo,absflo,0\n30d0 : 08              >            php         ;save flags\n30d1 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n30d4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n30d6 : 68              >            pla         ;load status\n                       >            eor_flag 0\n30d7 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n30d9 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n30dc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n30de : 88                       dey\n30df : 10e6                     bpl teor14\n30e1 : a003                     ldy #3\n30e3 :                  teor15\n                                set_ay  absEOa,$ff\n                       >            load_flag $ff\n30e3 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n30e5 : 48              >            pha         ;use stack to load status\n30e6 : b95e02          >            lda absEOa,y    ;precharge accu\n30e9 : 28              >            plp\n                        \n30ea : 5142                     eor (indEO),y\n                                tst_ay  absrlo,absflo,$ff-fnz\n30ec : 08              >            php         ;save flags\n30ed : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n30f0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n30f2 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n30f3 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n30f5 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n30f8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n30fa : 88                       dey\n30fb : 10e6                     bpl teor15\n                                next_test\n30fd : ad0002          >            lda test_case   ;previous test\n3100 : c927            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n3102 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0028 =                 >test_num = test_num + 1\n3104 : a928            >            lda #test_num   ;*** next tests' number\n3106 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; OR\n3109 : a203                     ldx #3          ;immediate - self modifying code\n310b : b518             tora    lda zpOR,x\n310d : 8d0f02                   sta ex_orai+1   ;set ORA # operand\n                                set_ax  absORa,0\n                       >            load_flag 0\n3110 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3112 : 48              >            pha         ;use stack to load status\n3113 : bd5602          >            lda absORa,x    ;precharge accu\n3116 : 28              >            plp\n                        \n3117 : 200e02                   jsr ex_orai     ;execute ORA # in RAM\n                                tst_ax  absrlo,absflo,0\n311a : 08              >            php         ;save flags\n311b : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n311e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3120 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3121 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3123 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3126 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3128 : ca                       dex\n3129 : 10e0                     bpl tora\n312b : a203                     ldx #3\n312d : b518             tora1   lda zpOR,x\n312f : 8d0f02                   sta ex_orai+1   ;set ORA # operand\n                                set_ax  absORa,$ff\n                       >            load_flag $ff\n3132 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3134 : 48              >            pha         ;use stack to load status\n3135 : bd5602          >            lda absORa,x    ;precharge accu\n3138 : 28              >            plp\n                        \n3139 : 200e02                   jsr ex_orai     ;execute ORA # in RAM\n                                tst_ax  absrlo,absflo,$ff-fnz\n313c : 08              >            php         ;save flags\n313d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3140 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3142 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3143 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3145 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3148 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n314a : ca                       dex\n314b : 10e0                     bpl tora1\n                            \n314d : a203                     ldx #3      ;zp\n314f : b518             tora2   lda zpOR,x\n3151 : 850c                     sta zpt\n                                set_ax  absORa,0\n                       >            load_flag 0\n3153 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3155 : 48              >            pha         ;use stack to load status\n3156 : bd5602          >            lda absORa,x    ;precharge accu\n3159 : 28              >            plp\n                        \n315a : 050c                     ora zpt\n                                tst_ax  absrlo,absflo,0\n315c : 08              >            php         ;save flags\n315d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3160 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3162 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3163 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3165 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3168 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n316a : ca                       dex\n316b : 10e2                     bpl tora2\n316d : a203                     ldx #3\n316f : b518             tora3   lda zpOR,x\n3171 : 850c                     sta zpt\n                                set_ax  absORa,$ff\n                       >            load_flag $ff\n3173 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3175 : 48              >            pha         ;use stack to load status\n3176 : bd5602          >            lda absORa,x    ;precharge accu\n3179 : 28              >            plp\n                        \n317a : 050c                     ora zpt\n                                tst_ax  absrlo,absflo,$ff-fnz\n317c : 08              >            php         ;save flags\n317d : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3180 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3182 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3183 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3185 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3188 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n318a : ca                       dex\n318b : 10e2                     bpl tora3\n                        \n318d : a203                     ldx #3      ;abs\n318f : b518             tora4   lda zpOR,x\n3191 : 8d0302                   sta abst\n                                set_ax  absORa,0\n                       >            load_flag 0\n3194 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3196 : 48              >            pha         ;use stack to load status\n3197 : bd5602          >            lda absORa,x    ;precharge accu\n319a : 28              >            plp\n                        \n319b : 0d0302                   ora abst\n                                tst_ax  absrlo,absflo,0\n319e : 08              >            php         ;save flags\n319f : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n31a2 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n31a4 : 68              >            pla         ;load status\n                       >            eor_flag 0\n31a5 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n31a7 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n31aa : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n31ac : ca                       dex\n31ad : 10e0                     bpl tora4\n31af : a203                     ldx #3\n31b1 : b518             tora5   lda zpOR,x\n31b3 : 8d0302                   sta abst\n                                set_ax  absORa,$ff\n                       >            load_flag $ff\n31b6 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n31b8 : 48              >            pha         ;use stack to load status\n31b9 : bd5602          >            lda absORa,x    ;precharge accu\n31bc : 28              >            plp\n                        \n31bd : 0d0302                   ora abst\n                                tst_ax  absrlo,absflo,$ff-fnz\n31c0 : 08              >            php         ;save flags\n31c1 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n31c4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n31c6 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n31c7 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n31c9 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n31cc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n31ce : ca                       dex\n31cf : 1002                     bpl tora6\n                        \n31d1 : a203                     ldx #3      ;zp,x\n31d3 :                  tora6\n                                set_ax  absORa,0\n                       >            load_flag 0\n31d3 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n31d5 : 48              >            pha         ;use stack to load status\n31d6 : bd5602          >            lda absORa,x    ;precharge accu\n31d9 : 28              >            plp\n                        \n31da : 1518                     ora zpOR,x\n                                tst_ax  absrlo,absflo,0\n31dc : 08              >            php         ;save flags\n31dd : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n31e0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n31e2 : 68              >            pla         ;load status\n                       >            eor_flag 0\n31e3 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n31e5 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n31e8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n31ea : ca                       dex\n31eb : 10e6                     bpl tora6\n31ed : a203                     ldx #3\n31ef :                  tora7\n                                set_ax  absORa,$ff\n                       >            load_flag $ff\n31ef : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n31f1 : 48              >            pha         ;use stack to load status\n31f2 : bd5602          >            lda absORa,x    ;precharge accu\n31f5 : 28              >            plp\n                        \n31f6 : 1518                     ora zpOR,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n31f8 : 08              >            php         ;save flags\n31f9 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n31fc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n31fe : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n31ff : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3201 : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3204 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3206 : ca                       dex\n3207 : 10e6                     bpl tora7\n                        \n3209 : a203                     ldx #3      ;abs,x\n320b :                  tora8\n                                set_ax  absORa,0\n                       >            load_flag 0\n320b : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n320d : 48              >            pha         ;use stack to load status\n320e : bd5602          >            lda absORa,x    ;precharge accu\n3211 : 28              >            plp\n                        \n3212 : 1d4a02                   ora absOR,x\n                                tst_ax  absrlo,absflo,0\n3215 : 08              >            php         ;save flags\n3216 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3219 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n321b : 68              >            pla         ;load status\n                       >            eor_flag 0\n321c : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n321e : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n3221 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3223 : ca                       dex\n3224 : 10e5                     bpl tora8\n3226 : a203                     ldx #3\n3228 :                  tora9\n                                set_ax  absORa,$ff\n                       >            load_flag $ff\n3228 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n322a : 48              >            pha         ;use stack to load status\n322b : bd5602          >            lda absORa,x    ;precharge accu\n322e : 28              >            plp\n                        \n322f : 1d4a02                   ora absOR,x\n                                tst_ax  absrlo,absflo,$ff-fnz\n3232 : 08              >            php         ;save flags\n3233 : dd6202          >            cmp absrlo,x    ;test result\n                       >            trap_ne\n3236 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3238 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3239 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n323b : dd6602          >            cmp absflo,x    ;test flags\n                       >            trap_ne     ;\n323e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3240 : ca                       dex\n3241 : 10e5                     bpl tora9\n                        \n3243 : a003                     ldy #3      ;abs,y\n3245 :                  tora10\n                                set_ay  absORa,0\n                       >            load_flag 0\n3245 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3247 : 48              >            pha         ;use stack to load status\n3248 : b95602          >            lda absORa,y    ;precharge accu\n324b : 28              >            plp\n                        \n324c : 194a02                   ora absOR,y\n                                tst_ay  absrlo,absflo,0\n324f : 08              >            php         ;save flags\n3250 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n3253 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3255 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3256 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3258 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n325b : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n325d : 88                       dey\n325e : 10e5                     bpl tora10\n3260 : a003                     ldy #3\n3262 :                  tora11\n                                set_ay  absORa,$ff\n                       >            load_flag $ff\n3262 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3264 : 48              >            pha         ;use stack to load status\n3265 : b95602          >            lda absORa,y    ;precharge accu\n3268 : 28              >            plp\n                        \n3269 : 194a02                   ora absOR,y\n                                tst_ay  absrlo,absflo,$ff-fnz\n326c : 08              >            php         ;save flags\n326d : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n3270 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3272 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n3273 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n3275 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n3278 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n327a : 88                       dey\n327b : 10e5                     bpl tora11\n                        \n327d : a206                     ldx #6      ;(zp,x)\n327f : a003                     ldy #3\n3281 :                  tora12\n                                set_ay  absORa,0\n                       >            load_flag 0\n3281 : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n3283 : 48              >            pha         ;use stack to load status\n3284 : b95602          >            lda absORa,y    ;precharge accu\n3287 : 28              >            plp\n                        \n3288 : 014a                     ora (indOR,x)\n                                tst_ay  absrlo,absflo,0\n328a : 08              >            php         ;save flags\n328b : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n328e : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n3290 : 68              >            pla         ;load status\n                       >            eor_flag 0\n3291 : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n3293 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n3296 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n3298 : ca                       dex\n3299 : ca                       dex\n329a : 88                       dey\n329b : 10e4                     bpl tora12\n329d : a206                     ldx #6\n329f : a003                     ldy #3\n32a1 :                  tora13\n                                set_ay  absORa,$ff\n                       >            load_flag $ff\n32a1 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n32a3 : 48              >            pha         ;use stack to load status\n32a4 : b95602          >            lda absORa,y    ;precharge accu\n32a7 : 28              >            plp\n                        \n32a8 : 014a                     ora (indOR,x)\n                                tst_ay  absrlo,absflo,$ff-fnz\n32aa : 08              >            php         ;save flags\n32ab : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n32ae : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n32b0 : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n32b1 : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n32b3 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n32b6 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n32b8 : ca                       dex\n32b9 : ca                       dex\n32ba : 88                       dey\n32bb : 10e4                     bpl tora13\n                        \n32bd : a003                     ldy #3      ;(zp),y\n32bf :                  tora14\n                                set_ay  absORa,0\n                       >            load_flag 0\n32bf : a900            >            lda #0             ;allow test to change I-flag (no mask)\n                       >\n32c1 : 48              >            pha         ;use stack to load status\n32c2 : b95602          >            lda absORa,y    ;precharge accu\n32c5 : 28              >            plp\n                        \n32c6 : 114a                     ora (indOR),y\n                                tst_ay  absrlo,absflo,0\n32c8 : 08              >            php         ;save flags\n32c9 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n32cc : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n32ce : 68              >            pla         ;load status\n                       >            eor_flag 0\n32cf : 4930            >            eor #0|fao         ;invert expected flags + always on bits\n                       >\n32d1 : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n32d4 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n32d6 : 88                       dey\n32d7 : 10e6                     bpl tora14\n32d9 : a003                     ldy #3\n32db :                  tora15\n                                set_ay  absORa,$ff\n                       >            load_flag $ff\n32db : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n32dd : 48              >            pha         ;use stack to load status\n32de : b95602          >            lda absORa,y    ;precharge accu\n32e1 : 28              >            plp\n                        \n32e2 : 114a                     ora (indOR),y\n                                tst_ay  absrlo,absflo,$ff-fnz\n32e4 : 08              >            php         ;save flags\n32e5 : d96202          >            cmp absrlo,y    ;test result\n                       >            trap_ne     ;\n32e8 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n32ea : 68              >            pla         ;load status\n                       >            eor_flag $ff-fnz\n32eb : 497d            >            eor #$ff-fnz|fao         ;invert expected flags + always on bits\n                       >\n32ed : d96602          >            cmp absflo,y    ;test flags\n                       >            trap_ne\n32f0 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n                        \n32f2 : 88                       dey\n32f3 : 10e6                     bpl tora15\n                            if I_flag = 3\n32f5 : 58                       cli\n                            endif                \n                                next_test\n32f6 : ad0002          >            lda test_case   ;previous test\n32f9 : c928            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n32fb : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n0029 =                 >test_num = test_num + 1\n32fd : a929            >            lda #test_num   ;*** next tests' number\n32ff : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; full binary add/subtract test\n                        ; iterates through all combinations of operands and carry input\n                        ; uses increments/decrements to predict result & result flags\n3302 : d8                       cld\n3303 : a20e                     ldx #ad2        ;for indexed test\n3305 : a0ff                     ldy #$ff        ;max range\n3307 : a900                     lda #0          ;start with adding zeroes & no carry\n3309 : 850c                     sta adfc        ;carry in - for diag\n330b : 850d                     sta ad1         ;operand 1 - accumulator\n330d : 850e                     sta ad2         ;operand 2 - memory or immediate\n330f : 8d0302                   sta ada2        ;non zp\n3312 : 850f                     sta adrl        ;expected result bits 0-7\n3314 : 8510                     sta adrh        ;expected result bit 8 (carry out)\n3316 : a9ff                     lda #$ff        ;complemented operand 2 for subtract\n3318 : 8512                     sta sb2\n331a : 8d0402                   sta sba2        ;non zp\n331d : a902                     lda #2          ;expected Z-flag\n331f : 8511                     sta adrf\n3321 : 18               tadd    clc             ;test with carry clear\n3322 : 209c35                   jsr chkadd\n3325 : e60c                     inc adfc        ;now with carry\n3327 : e60f                     inc adrl        ;result +1\n3329 : 08                       php             ;save N & Z from low result\n332a : 08                       php\n332b : 68                       pla             ;accu holds expected flags\n332c : 2982                     and #$82        ;mask N & Z\n332e : 28                       plp\n332f : d002                     bne tadd1\n3331 : e610                     inc adrh        ;result bit 8 - carry\n3333 : 0510             tadd1   ora adrh        ;merge C to expected flags\n3335 : 8511                     sta adrf        ;save expected flags except overflow\n3337 : 38                       sec             ;test with carry set\n3338 : 209c35                   jsr chkadd\n333b : c60c                     dec adfc        ;same for operand +1 but no carry\n333d : e60d                     inc ad1\n333f : d0e0                     bne tadd        ;iterate op1\n3341 : a900                     lda #0          ;preset result to op2 when op1 = 0\n3343 : 8510                     sta adrh\n3345 : ee0302                   inc ada2\n3348 : e60e                     inc ad2\n334a : 08                       php             ;save NZ as operand 2 becomes the new result\n334b : 68                       pla\n334c : 2982                     and #$82        ;mask N00000Z0\n334e : 8511                     sta adrf        ;no need to check carry as we are adding to 0\n3350 : c612                     dec sb2         ;complement subtract operand 2\n3352 : ce0402                   dec sba2\n3355 : a50e                     lda ad2         \n3357 : 850f                     sta adrl\n3359 : d0c6                     bne tadd        ;iterate op2\n                            if disable_decimal < 1\n                                next_test\n335b : ad0002          >            lda test_case   ;previous test\n335e : c929            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n3360 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n002a =                 >test_num = test_num + 1\n3362 : a92a            >            lda #test_num   ;*** next tests' number\n3364 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; decimal add/subtract test\n                        ; *** WARNING - tests documented behavior only! ***\n                        ;   only valid BCD operands are tested, N V Z flags are ignored\n                        ; iterates through all valid combinations of operands and carry input\n                        ; uses increments/decrements to predict result & carry flag\n3367 : f8                       sed \n3368 : a20e                     ldx #ad2        ;for indexed test\n336a : a0ff                     ldy #$ff        ;max range\n336c : a999                     lda #$99        ;start with adding 99 to 99 with carry\n336e : 850d                     sta ad1         ;operand 1 - accumulator\n3370 : 850e                     sta ad2         ;operand 2 - memory or immediate\n3372 : 8d0302                   sta ada2        ;non zp\n3375 : 850f                     sta adrl        ;expected result bits 0-7\n3377 : a901                     lda #1          ;set carry in & out\n3379 : 850c                     sta adfc        ;carry in - for diag\n337b : 8510                     sta adrh        ;expected result bit 8 (carry out)\n337d : a900                     lda #0          ;complemented operand 2 for subtract\n337f : 8512                     sta sb2\n3381 : 8d0402                   sta sba2        ;non zp\n3384 : 38               tdad    sec             ;test with carry set\n3385 : 206934                   jsr chkdad\n3388 : c60c                     dec adfc        ;now with carry clear\n338a : a50f                     lda adrl        ;decimal adjust result\n338c : d008                     bne tdad1       ;skip clear carry & preset result 99 (9A-1)\n338e : c610                     dec adrh\n3390 : a999                     lda #$99\n3392 : 850f                     sta adrl\n3394 : d012                     bne tdad3\n3396 : 290f             tdad1   and #$f         ;lower nibble mask\n3398 : d00c                     bne tdad2       ;no decimal adjust needed\n339a : c60f                     dec adrl        ;decimal adjust (?0-6)\n339c : c60f                     dec adrl\n339e : c60f                     dec adrl\n33a0 : c60f                     dec adrl\n33a2 : c60f                     dec adrl\n33a4 : c60f                     dec adrl\n33a6 : c60f             tdad2   dec adrl        ;result -1\n33a8 : 18               tdad3   clc             ;test with carry clear\n33a9 : 206934                   jsr chkdad\n33ac : e60c                     inc adfc        ;same for operand -1 but with carry\n33ae : a50d                     lda ad1         ;decimal adjust operand 1\n33b0 : f015                     beq tdad5       ;iterate operand 2\n33b2 : 290f                     and #$f         ;lower nibble mask\n33b4 : d00c                     bne tdad4       ;skip decimal adjust\n33b6 : c60d                     dec ad1         ;decimal adjust (?0-6)\n33b8 : c60d                     dec ad1\n33ba : c60d                     dec ad1\n33bc : c60d                     dec ad1\n33be : c60d                     dec ad1\n33c0 : c60d                     dec ad1\n33c2 : c60d             tdad4   dec ad1         ;operand 1 -1\n33c4 : 4c8433                   jmp tdad        ;iterate op1\n                        \n33c7 : a999             tdad5   lda #$99        ;precharge op1 max\n33c9 : 850d                     sta ad1\n33cb : a50e                     lda ad2         ;decimal adjust operand 2\n33cd : f030                     beq tdad7       ;end of iteration\n33cf : 290f                     and #$f         ;lower nibble mask\n33d1 : d018                     bne tdad6       ;skip decimal adjust\n33d3 : c60e                     dec ad2         ;decimal adjust (?0-6)\n33d5 : c60e                     dec ad2\n33d7 : c60e                     dec ad2\n33d9 : c60e                     dec ad2\n33db : c60e                     dec ad2\n33dd : c60e                     dec ad2\n33df : e612                     inc sb2         ;complemented decimal adjust for subtract (?9+6)\n33e1 : e612                     inc sb2\n33e3 : e612                     inc sb2\n33e5 : e612                     inc sb2\n33e7 : e612                     inc sb2\n33e9 : e612                     inc sb2\n33eb : c60e             tdad6   dec ad2         ;operand 2 -1\n33ed : e612                     inc sb2         ;complemented operand for subtract\n33ef : a512                     lda sb2\n33f1 : 8d0402                   sta sba2        ;copy as non zp operand\n33f4 : a50e                     lda ad2\n33f6 : 8d0302                   sta ada2        ;copy as non zp operand\n33f9 : 850f                     sta adrl        ;new result since op1+carry=00+carry +op2=op2\n33fb : e610                     inc adrh        ;result carry\n33fd : d085                     bne tdad        ;iterate op2\n33ff :                  tdad7\n                                next_test\n33ff : ad0002          >            lda test_case   ;previous test\n3402 : c92a            >            cmp #test_num\n                       >            trap_ne         ;test is out of sequence\n3404 : d0fe            >        bne *           ;failed not equal (non zero)\n                       >\n002b =                 >test_num = test_num + 1\n3406 : a92b            >            lda #test_num   ;*** next tests' number\n3408 : 8d0002          >            sta test_case\n                       >            ;check_ram       ;uncomment to find altered RAM after each test\n                        \n                        \n                        ; decimal/binary switch test\n                        ; tests CLD, SED, PLP, RTI to properly switch between decimal & binary opcode\n                        ;   tables\n340b : 18                       clc\n340c : d8                       cld\n340d : 08                       php\n340e : a955                     lda #$55\n3410 : 6955                     adc #$55\n3412 : c9aa                     cmp #$aa\n                                trap_ne         ;expected binary result after cld\n3414 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3416 : 18                       clc\n3417 : f8                       sed\n3418 : 08                       php\n3419 : a955                     lda #$55\n341b : 6955                     adc #$55\n341d : c910                     cmp #$10\n                                trap_ne         ;expected decimal result after sed\n341f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3421 : d8                       cld\n3422 : 28                       plp\n3423 : a955                     lda #$55\n3425 : 6955                     adc #$55\n3427 : c910                     cmp #$10\n                                trap_ne         ;expected decimal result after plp D=1\n3429 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n342b : 28                       plp\n342c : a955                     lda #$55\n342e : 6955                     adc #$55\n3430 : c9aa                     cmp #$aa\n                                trap_ne         ;expected binary result after plp D=0\n3432 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3434 : 18                       clc\n3435 : a934                     lda #hi bin_rti_ret ;emulated interrupt for rti\n3437 : 48                       pha\n3438 : a94f                     lda #lo bin_rti_ret\n343a : 48                       pha\n343b : 08                       php\n343c : f8                       sed\n343d : a934                     lda #hi dec_rti_ret ;emulated interrupt for rti\n343f : 48                       pha\n3440 : a946                     lda #lo dec_rti_ret\n3442 : 48                       pha\n3443 : 08                       php\n3444 : d8                       cld\n3445 : 40                       rti\n3446 :                  dec_rti_ret\n3446 : a955                     lda #$55\n3448 : 6955                     adc #$55\n344a : c910                     cmp #$10\n                                trap_ne         ;expected decimal result after rti D=1\n344c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n344e : 40                       rti\n344f :                  bin_rti_ret        \n344f : a955                     lda #$55\n3451 : 6955                     adc #$55\n3453 : c9aa                     cmp #$aa\n                                trap_ne         ;expected binary result after rti D=0\n3455 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                            endif\n                            \n3457 : ad0002                   lda test_case\n345a : c92b                     cmp #test_num\n                                trap_ne         ;previous test is out of sequence\n345c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n345e : a9f0                     lda #$f0        ;mark opcode testing complete\n3460 : 8d0002                   sta test_case\n                                \n                        ; final RAM integrity test\n                        ;   verifies that none of the previous tests has altered RAM outside of the\n                        ;   designated write areas.\n                                check_ram\n                       >            ;RAM check disabled - RAM size not set\n                        \n                        ; *** DEBUG INFO ***\n                        ; to debug checksum errors uncomment check_ram in the next_test macro to\n                        ; narrow down the responsible opcode.\n                        ; may give false errors when monitor, OS or other background activity is\n                        ; allowed during previous tests.\n                        \n                        \n                        ; S U C C E S S ************************************************\n                        ; -------------       \n                                success         ;if you get here everything went well\n3463 : 4c6334          >        jmp *           ;test passed, no errors\n                        \n                        ; -------------       \n                        ; S U C C E S S ************************************************\n3466 : 4c0004                   jmp start       ;run again      \n                        \n                            if disable_decimal < 1\n                        ; core subroutine of the decimal add/subtract test\n                        ; *** WARNING - tests documented behavior only! ***\n                        ;   only valid BCD operands are tested, N V Z flags are ignored\n                        ; iterates through all valid combinations of operands and carry input\n                        ; uses increments/decrements to predict result & carry flag\n3469 :                  chkdad\n                        ; decimal ADC / SBC zp\n3469 : 08                       php             ;save carry for subtract\n346a : a50d                     lda ad1\n346c : 650e                     adc ad2         ;perform add\n346e : 08                       php          \n346f : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3471 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3473 : 68                       pla             ;check flags\n3474 : 2901                     and #1          ;mask carry\n3476 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3478 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n347a : 28                       plp\n347b : 08                       php             ;save carry for next add\n347c : a50d                     lda ad1\n347e : e512                     sbc sb2         ;perform subtract\n3480 : 08                       php          \n3481 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3483 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3485 : 68                       pla             ;check flags\n3486 : 2901                     and #1          ;mask carry\n3488 : c510                     cmp adrh\n                                trap_ne         ;bad flags\n348a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n348c : 28                       plp\n                        ; decimal ADC / SBC abs\n348d : 08                       php             ;save carry for subtract\n348e : a50d                     lda ad1\n3490 : 6d0302                   adc ada2        ;perform add\n3493 : 08                       php          \n3494 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3496 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3498 : 68                       pla             ;check flags\n3499 : 2901                     and #1          ;mask carry\n349b : c510                     cmp adrh\n                                trap_ne         ;bad carry\n349d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n349f : 28                       plp\n34a0 : 08                       php             ;save carry for next add\n34a1 : a50d                     lda ad1\n34a3 : ed0402                   sbc sba2        ;perform subtract\n34a6 : 08                       php          \n34a7 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n34a9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34ab : 68                       pla             ;check flags\n34ac : 2901                     and #1          ;mask carry\n34ae : c510                     cmp adrh\n                                trap_ne         ;bad carry\n34b0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34b2 : 28                       plp\n                        ; decimal ADC / SBC #\n34b3 : 08                       php             ;save carry for subtract\n34b4 : a50e                     lda ad2\n34b6 : 8d1202                   sta ex_adci+1   ;set ADC # operand\n34b9 : a50d                     lda ad1\n34bb : 201102                   jsr ex_adci     ;execute ADC # in RAM\n34be : 08                       php          \n34bf : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n34c1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34c3 : 68                       pla             ;check flags\n34c4 : 2901                     and #1          ;mask carry\n34c6 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n34c8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34ca : 28                       plp\n34cb : 08                       php             ;save carry for next add\n34cc : a512                     lda sb2\n34ce : 8d1502                   sta ex_sbci+1   ;set SBC # operand\n34d1 : a50d                     lda ad1\n34d3 : 201402                   jsr ex_sbci     ;execute SBC # in RAM\n34d6 : 08                       php          \n34d7 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n34d9 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34db : 68                       pla             ;check flags\n34dc : 2901                     and #1          ;mask carry\n34de : c510                     cmp adrh\n                                trap_ne         ;bad carry\n34e0 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34e2 : 28                       plp\n                        ; decimal ADC / SBC zp,x\n34e3 : 08                       php             ;save carry for subtract\n34e4 : a50d                     lda ad1\n34e6 : 7500                     adc 0,x         ;perform add\n34e8 : 08                       php          \n34e9 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n34eb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34ed : 68                       pla             ;check flags\n34ee : 2901                     and #1          ;mask carry\n34f0 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n34f2 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34f4 : 28                       plp\n34f5 : 08                       php             ;save carry for next add\n34f6 : a50d                     lda ad1\n34f8 : f504                     sbc sb2-ad2,x   ;perform subtract\n34fa : 08                       php          \n34fb : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n34fd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n34ff : 68                       pla             ;check flags\n3500 : 2901                     and #1          ;mask carry\n3502 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3504 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3506 : 28                       plp\n                        ; decimal ADC / SBC abs,x\n3507 : 08                       php             ;save carry for subtract\n3508 : a50d                     lda ad1\n350a : 7df501                   adc ada2-ad2,x  ;perform add\n350d : 08                       php          \n350e : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3510 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3512 : 68                       pla             ;check flags\n3513 : 2901                     and #1          ;mask carry\n3515 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3517 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3519 : 28                       plp\n351a : 08                       php             ;save carry for next add\n351b : a50d                     lda ad1\n351d : fdf601                   sbc sba2-ad2,x  ;perform subtract\n3520 : 08                       php          \n3521 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3523 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3525 : 68                       pla             ;check flags\n3526 : 2901                     and #1          ;mask carry\n3528 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n352a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n352c : 28                       plp\n                        ; decimal ADC / SBC abs,y\n352d : 08                       php             ;save carry for subtract\n352e : a50d                     lda ad1\n3530 : 790401                   adc ada2-$ff,y  ;perform add\n3533 : 08                       php          \n3534 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3536 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3538 : 68                       pla             ;check flags\n3539 : 2901                     and #1          ;mask carry\n353b : c510                     cmp adrh\n                                trap_ne         ;bad carry\n353d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n353f : 28                       plp\n3540 : 08                       php             ;save carry for next add\n3541 : a50d                     lda ad1\n3543 : f90501                   sbc sba2-$ff,y  ;perform subtract\n3546 : 08                       php          \n3547 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3549 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n354b : 68                       pla             ;check flags\n354c : 2901                     and #1          ;mask carry\n354e : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3550 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3552 : 28                       plp\n                        ; decimal ADC / SBC (zp,x)\n3553 : 08                       php             ;save carry for subtract\n3554 : a50d                     lda ad1\n3556 : 6144                     adc (lo adi2-ad2,x) ;perform add\n3558 : 08                       php          \n3559 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n355b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n355d : 68                       pla             ;check flags\n355e : 2901                     and #1          ;mask carry\n3560 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3562 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3564 : 28                       plp\n3565 : 08                       php             ;save carry for next add\n3566 : a50d                     lda ad1\n3568 : e146                     sbc (lo sbi2-ad2,x) ;perform subtract\n356a : 08                       php          \n356b : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n356d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n356f : 68                       pla             ;check flags\n3570 : 2901                     and #1          ;mask carry\n3572 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3574 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3576 : 28                       plp\n                        ; decimal ADC / SBC (abs),y\n3577 : 08                       php             ;save carry for subtract\n3578 : a50d                     lda ad1\n357a : 7156                     adc (adiy2),y   ;perform add\n357c : 08                       php          \n357d : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n357f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3581 : 68                       pla             ;check flags\n3582 : 2901                     and #1          ;mask carry\n3584 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3586 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3588 : 28                       plp\n3589 : 08                       php             ;save carry for next add\n358a : a50d                     lda ad1\n358c : f158                     sbc (sbiy2),y   ;perform subtract\n358e : 08                       php          \n358f : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3591 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3593 : 68                       pla             ;check flags\n3594 : 2901                     and #1          ;mask carry\n3596 : c510                     cmp adrh\n                                trap_ne         ;bad carry\n3598 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n359a : 28                       plp\n359b : 60                       rts\n                            endif\n                        \n                        ; core subroutine of the full binary add/subtract test\n                        ; iterates through all combinations of operands and carry input\n                        ; uses increments/decrements to predict result & result flags\n359c : a511             chkadd  lda adrf        ;add V-flag if overflow\n359e : 2983                     and #$83        ;keep N-----ZC / clear V\n35a0 : 48                       pha\n35a1 : a50d                     lda ad1         ;test sign unequal between operands\n35a3 : 450e                     eor ad2\n35a5 : 300a                     bmi ckad1       ;no overflow possible - operands have different sign\n35a7 : a50d                     lda ad1         ;test sign equal between operands and result\n35a9 : 450f                     eor adrl\n35ab : 1004                     bpl ckad1       ;no overflow occured - operand and result have same sign\n35ad : 68                       pla\n35ae : 0940                     ora #$40        ;set V\n35b0 : 48                       pha\n35b1 : 68               ckad1   pla\n35b2 : 8511                     sta adrf        ;save expected flags\n                        ; binary ADC / SBC zp\n35b4 : 08                       php             ;save carry for subtract\n35b5 : a50d                     lda ad1\n35b7 : 650e                     adc ad2         ;perform add\n35b9 : 08                       php          \n35ba : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n35bc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35be : 68                       pla             ;check flags\n35bf : 29c3                     and #$c3        ;mask NV----ZC\n35c1 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n35c3 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35c5 : 28                       plp\n35c6 : 08                       php             ;save carry for next add\n35c7 : a50d                     lda ad1\n35c9 : e512                     sbc sb2         ;perform subtract\n35cb : 08                       php          \n35cc : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n35ce : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35d0 : 68                       pla             ;check flags\n35d1 : 29c3                     and #$c3        ;mask NV----ZC\n35d3 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n35d5 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35d7 : 28                       plp\n                        ; binary ADC / SBC abs\n35d8 : 08                       php             ;save carry for subtract\n35d9 : a50d                     lda ad1\n35db : 6d0302                   adc ada2        ;perform add\n35de : 08                       php          \n35df : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n35e1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35e3 : 68                       pla             ;check flags\n35e4 : 29c3                     and #$c3        ;mask NV----ZC\n35e6 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n35e8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35ea : 28                       plp\n35eb : 08                       php             ;save carry for next add\n35ec : a50d                     lda ad1\n35ee : ed0402                   sbc sba2        ;perform subtract\n35f1 : 08                       php          \n35f2 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n35f4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35f6 : 68                       pla             ;check flags\n35f7 : 29c3                     and #$c3        ;mask NV----ZC\n35f9 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n35fb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n35fd : 28                       plp\n                        ; binary ADC / SBC #\n35fe : 08                       php             ;save carry for subtract\n35ff : a50e                     lda ad2\n3601 : 8d1202                   sta ex_adci+1   ;set ADC # operand\n3604 : a50d                     lda ad1\n3606 : 201102                   jsr ex_adci     ;execute ADC # in RAM\n3609 : 08                       php          \n360a : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n360c : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n360e : 68                       pla             ;check flags\n360f : 29c3                     and #$c3        ;mask NV----ZC\n3611 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n3613 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3615 : 28                       plp\n3616 : 08                       php             ;save carry for next add\n3617 : a512                     lda sb2\n3619 : 8d1502                   sta ex_sbci+1   ;set SBC # operand\n361c : a50d                     lda ad1\n361e : 201402                   jsr ex_sbci     ;execute SBC # in RAM\n3621 : 08                       php          \n3622 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3624 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3626 : 68                       pla             ;check flags\n3627 : 29c3                     and #$c3        ;mask NV----ZC\n3629 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n362b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n362d : 28                       plp\n                        ; binary ADC / SBC zp,x\n362e : 08                       php             ;save carry for subtract\n362f : a50d                     lda ad1\n3631 : 7500                     adc 0,x         ;perform add\n3633 : 08                       php          \n3634 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3636 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3638 : 68                       pla             ;check flags\n3639 : 29c3                     and #$c3        ;mask NV----ZC\n363b : c511                     cmp adrf\n                                trap_ne         ;bad flags\n363d : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n363f : 28                       plp\n3640 : 08                       php             ;save carry for next add\n3641 : a50d                     lda ad1\n3643 : f504                     sbc sb2-ad2,x   ;perform subtract\n3645 : 08                       php          \n3646 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3648 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n364a : 68                       pla             ;check flags\n364b : 29c3                     and #$c3        ;mask NV----ZC\n364d : c511                     cmp adrf\n                                trap_ne         ;bad flags\n364f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3651 : 28                       plp\n                        ; binary ADC / SBC abs,x\n3652 : 08                       php             ;save carry for subtract\n3653 : a50d                     lda ad1\n3655 : 7df501                   adc ada2-ad2,x  ;perform add\n3658 : 08                       php          \n3659 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n365b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n365d : 68                       pla             ;check flags\n365e : 29c3                     and #$c3        ;mask NV----ZC\n3660 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n3662 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3664 : 28                       plp\n3665 : 08                       php             ;save carry for next add\n3666 : a50d                     lda ad1\n3668 : fdf601                   sbc sba2-ad2,x  ;perform subtract\n366b : 08                       php          \n366c : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n366e : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3670 : 68                       pla             ;check flags\n3671 : 29c3                     and #$c3        ;mask NV----ZC\n3673 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n3675 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3677 : 28                       plp\n                        ; binary ADC / SBC abs,y\n3678 : 08                       php             ;save carry for subtract\n3679 : a50d                     lda ad1\n367b : 790401                   adc ada2-$ff,y  ;perform add\n367e : 08                       php          \n367f : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3681 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3683 : 68                       pla             ;check flags\n3684 : 29c3                     and #$c3        ;mask NV----ZC\n3686 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n3688 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n368a : 28                       plp\n368b : 08                       php             ;save carry for next add\n368c : a50d                     lda ad1\n368e : f90501                   sbc sba2-$ff,y  ;perform subtract\n3691 : 08                       php          \n3692 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n3694 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3696 : 68                       pla             ;check flags\n3697 : 29c3                     and #$c3        ;mask NV----ZC\n3699 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n369b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n369d : 28                       plp\n                        ; binary ADC / SBC (zp,x)\n369e : 08                       php             ;save carry for subtract\n369f : a50d                     lda ad1\n36a1 : 6144                     adc (lo adi2-ad2,x) ;perform add\n36a3 : 08                       php          \n36a4 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n36a6 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36a8 : 68                       pla             ;check flags\n36a9 : 29c3                     and #$c3        ;mask NV----ZC\n36ab : c511                     cmp adrf\n                                trap_ne         ;bad flags\n36ad : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36af : 28                       plp\n36b0 : 08                       php             ;save carry for next add\n36b1 : a50d                     lda ad1\n36b3 : e146                     sbc (lo sbi2-ad2,x) ;perform subtract\n36b5 : 08                       php          \n36b6 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n36b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36ba : 68                       pla             ;check flags\n36bb : 29c3                     and #$c3        ;mask NV----ZC\n36bd : c511                     cmp adrf\n                                trap_ne         ;bad flags\n36bf : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36c1 : 28                       plp\n                        ; binary ADC / SBC (abs),y\n36c2 : 08                       php             ;save carry for subtract\n36c3 : a50d                     lda ad1\n36c5 : 7156                     adc (adiy2),y   ;perform add\n36c7 : 08                       php          \n36c8 : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n36ca : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36cc : 68                       pla             ;check flags\n36cd : 29c3                     and #$c3        ;mask NV----ZC\n36cf : c511                     cmp adrf\n                                trap_ne         ;bad flags\n36d1 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36d3 : 28                       plp\n36d4 : 08                       php             ;save carry for next add\n36d5 : a50d                     lda ad1\n36d7 : f158                     sbc (sbiy2),y   ;perform subtract\n36d9 : 08                       php          \n36da : c50f                     cmp adrl        ;check result\n                                trap_ne         ;bad result\n36dc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36de : 68                       pla             ;check flags\n36df : 29c3                     and #$c3        ;mask NV----ZC\n36e1 : c511                     cmp adrf\n                                trap_ne         ;bad flags\n36e3 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36e5 : 28                       plp\n36e6 : 60                       rts\n                        \n                        ; target for the jump absolute test\n36e7 : 88                       dey\n36e8 : 88                       dey\n36e9 :                  test_far\n36e9 : 08                       php             ;either SP or Y count will fail, if we do not hit\n36ea : 88                       dey\n36eb : 88                       dey\n36ec : 88                       dey\n36ed : 28                       plp\n                                trap_cs         ;flags loaded?\n36ee : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_vs\n36f0 : 70fe            >        bvs *           ;failed overflow set\n                        \n                                trap_mi\n36f2 : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n                                trap_eq \n36f4 : f0fe            >        beq *           ;failed equal (zero)\n                        \n36f6 : c946                     cmp #'F'        ;registers loaded?\n                                trap_ne\n36f8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36fa : e041                     cpx #'A'\n                                trap_ne        \n36fc : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n36fe : c04f                     cpy #('R'-3)\n                                trap_ne\n3700 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3702 : 48                       pha             ;save a,x\n3703 : 8a                       txa\n3704 : 48                       pha\n3705 : ba                       tsx\n3706 : e0fd                     cpx #$fd        ;check SP\n                                trap_ne\n3708 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n370a : 68                       pla             ;restore x\n370b : aa                       tax\n                                set_stat $ff\n                       >            load_flag $ff\n370c : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n370e : 48              >            pha         ;use stack to load status\n370f : 28              >            plp\n                        \n3710 : 68                       pla             ;restore a\n3711 : e8                       inx             ;return registers with modifications\n3712 : 49aa                     eor #$aa        ;N=1, V=1, Z=0, C=1\n3714 : 4c2f09                   jmp far_ret\n                                \n                        ; target for the jump indirect test\n3717 : 00                       align\n3718 : 2137             ptr_tst_ind dw test_ind\n371a : 8409             ptr_ind_ret dw ind_ret\n                                trap            ;runover protection\n371c : 4c1c37          >        jmp *           ;failed anyway\n                        \n371f : 88                       dey\n3720 : 88                       dey\n3721 :                  test_ind\n3721 : 08                       php             ;either SP or Y count will fail, if we do not hit\n3722 : 88                       dey\n3723 : 88                       dey\n3724 : 88                       dey\n3725 : 28                       plp\n                                trap_cs         ;flags loaded?\n3726 : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_vs\n3728 : 70fe            >        bvs *           ;failed overflow set\n                        \n                                trap_mi\n372a : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n                                trap_eq \n372c : f0fe            >        beq *           ;failed equal (zero)\n                        \n372e : c949                     cmp #'I'        ;registers loaded?\n                                trap_ne\n3730 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3732 : e04e                     cpx #'N'\n                                trap_ne        \n3734 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3736 : c041                     cpy #('D'-3)\n                                trap_ne\n3738 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n373a : 48                       pha             ;save a,x\n373b : 8a                       txa\n373c : 48                       pha\n373d : ba                       tsx\n373e : e0fd                     cpx #$fd        ;check SP\n                                trap_ne\n3740 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3742 : 68                       pla             ;restore x\n3743 : aa                       tax\n                                set_stat $ff\n                       >            load_flag $ff\n3744 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3746 : 48              >            pha         ;use stack to load status\n3747 : 28              >            plp\n                        \n3748 : 68                       pla             ;restore a\n3749 : e8                       inx             ;return registers with modifications\n374a : 49aa                     eor #$aa        ;N=1, V=1, Z=0, C=1\n374c : 6c1a37                   jmp (ptr_ind_ret)\n                                trap            ;runover protection\n374f : 4c4f37          >        jmp *           ;failed anyway\n                        \n                        \n                        ; target for the jump subroutine test\n3752 : 88                       dey\n3753 : 88                       dey\n3754 :                  test_jsr\n3754 : 08                       php             ;either SP or Y count will fail, if we do not hit\n3755 : 88                       dey\n3756 : 88                       dey\n3757 : 88                       dey\n3758 : 28                       plp\n                                trap_cs         ;flags loaded?\n3759 : b0fe            >        bcs *           ;failed carry set\n                        \n                                trap_vs\n375b : 70fe            >        bvs *           ;failed overflow set\n                        \n                                trap_mi\n375d : 30fe            >        bmi *           ;failed minus (bit 7 set)\n                        \n                                trap_eq \n375f : f0fe            >        beq *           ;failed equal (zero)\n                        \n3761 : c94a                     cmp #'J'        ;registers loaded?\n                                trap_ne\n3763 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3765 : e053                     cpx #'S'\n                                trap_ne        \n3767 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3769 : c04f                     cpy #('R'-3)\n                                trap_ne\n376b : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n376d : 48                       pha             ;save a,x\n376e : 8a                       txa\n376f : 48                       pha       \n3770 : ba                       tsx             ;sp -4? (return addr,a,x)\n3771 : e0fb                     cpx #$fb\n                                trap_ne\n3773 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n3775 : adff01                   lda $1ff        ;propper return on stack\n3778 : c909                     cmp #hi(jsr_ret)\n                                trap_ne\n377a : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n377c : adfe01                   lda $1fe\n377f : c9ba                     cmp #lo(jsr_ret)\n                                trap_ne\n3781 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n3783 : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n3785 : 48              >            pha         ;use stack to load status\n3786 : 28              >            plp\n                        \n3787 : 68                       pla             ;pull x,a\n3788 : aa                       tax\n3789 : 68                       pla\n378a : e8                       inx             ;return registers with modifications\n378b : 49aa                     eor #$aa        ;N=1, V=1, Z=0, C=1\n378d : 60                       rts\n                                trap            ;runover protection\n378e : 4c8e37          >        jmp *           ;failed anyway\n                        \n                                \n                        ;trap in case of unexpected IRQ, NMI, BRK, RESET - BRK test target\n3791 :                  nmi_trap\n                                trap            ;check stack for conditions at NMI\n3791 : 4c9137          >        jmp *           ;failed anyway\n                        \n3794 :                  res_trap\n                                trap            ;unexpected RESET\n3794 : 4c9437          >        jmp *           ;failed anyway\n                        \n                                \n3797 : 88                       dey\n3798 : 88                       dey\n3799 :                  irq_trap                ;BRK test or unextpected BRK or IRQ\n3799 : 08                       php             ;either SP or Y count will fail, if we do not hit\n379a : 88                       dey\n379b : 88                       dey\n379c : 88                       dey\n                                ;next 4 traps could be caused by unexpected BRK or IRQ\n                                ;check stack for BREAK and originating location\n                                ;possible jump/branch into weeds (uninitialized space)\n379d : c942                     cmp #'B'        ;registers loaded?\n                                trap_ne\n379f : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37a1 : e052                     cpx #'R'\n                                trap_ne        \n37a3 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37a5 : c048                     cpy #('K'-3)\n                                trap_ne\n37a7 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37a9 : 850a                     sta irq_a       ;save registers during break test\n37ab : 860b                     stx irq_x\n37ad : ba                       tsx             ;test break on stack\n37ae : bd0201                   lda $102,x\n                                cmp_flag 0      ;break test should have B=1\n37b1 : c930            >            cmp #(0      |fao)&m8    ;expected flags + always on bits\n                        \n                                trap_ne         ; - no break flag on stack\n37b3 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37b5 : 68                       pla\n37b6 : c934                     cmp #fai        ;should have added interrupt disable\n                                trap_ne\n37b8 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37ba : ba                       tsx\n37bb : e0fc                     cpx #$fc        ;sp -3? (return addr, flags)\n                                trap_ne\n37bd : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37bf : adff01                   lda $1ff        ;propper return on stack\n37c2 : c909                     cmp #hi(brk_ret)\n                                trap_ne\n37c4 : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n37c6 : adfe01                   lda $1fe\n37c9 : c9f1                     cmp #lo(brk_ret)\n                                trap_ne\n37cb : d0fe            >        bne *           ;failed not equal (non zero)\n                        \n                                set_stat $ff\n                       >            load_flag $ff\n37cd : a9ff            >            lda #$ff             ;allow test to change I-flag (no mask)\n                       >\n37cf : 48              >            pha         ;use stack to load status\n37d0 : 28              >            plp\n                        \n37d1 : a60b                     ldx irq_x\n37d3 : e8                       inx             ;return registers with modifications\n37d4 : a50a                     lda irq_a\n37d6 : 49aa                     eor #$aa        ;N=1, V=1, Z=0, C=1 but original flags should be restored\n37d8 : 40                       rti\n                                trap            ;runover protection\n37d9 : 4cd937          >        jmp *           ;failed anyway\n                        \n                                \n                            if report = 1\n                                include \"report.i65\"\n                            endif\n                                \n                        ;copy of data to initialize BSS segment\n                            if load_data_direct != 1\n37dc :                  zp_init\n37dc : c3824100         zp1_    db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\n37e0 : 7f               zp7f_   db  $7f             ;test pattern for compare\n                        ;logical zeropage operands\n37e1 : 001f7180         zpOR_   db  0,$1f,$71,$80   ;test pattern for OR\n37e5 : 0fff7f80         zpAN_   db  $0f,$ff,$7f,$80 ;test pattern for AND\n37e9 : ff0f8f8f         zpEO_   db  $ff,$0f,$8f,$8f ;test pattern for EOR\n                        ;indirect addressing pointers\n37ed : 1702             ind1_   dw  abs1            ;indirect pointer to pattern in absolute memory\n37ef : 1802                     dw  abs1+1\n37f1 : 1902                     dw  abs1+2\n37f3 : 1a02                     dw  abs1+3\n37f5 : 1b02                     dw  abs7f\n37f7 : 1f01             inw1_   dw  abs1-$f8        ;indirect pointer for wrap-test pattern\n37f9 : 0302             indt_   dw  abst            ;indirect pointer to store area in absolute memory\n37fb : 0402                     dw  abst+1\n37fd : 0502                     dw  abst+2\n37ff : 0602                     dw  abst+3\n3801 : 0b01             inwt_   dw  abst-$f8        ;indirect pointer for wrap-test store\n3803 : 4e02             indAN_  dw  absAN           ;indirect pointer to AND pattern in absolute memory\n3805 : 4f02                     dw  absAN+1\n3807 : 5002                     dw  absAN+2\n3809 : 5102                     dw  absAN+3\n380b : 5202             indEO_  dw  absEO           ;indirect pointer to EOR pattern in absolute memory\n380d : 5302                     dw  absEO+1\n380f : 5402                     dw  absEO+2\n3811 : 5502                     dw  absEO+3\n3813 : 4a02             indOR_  dw  absOR           ;indirect pointer to OR pattern in absolute memory\n3815 : 4b02                     dw  absOR+1\n3817 : 4c02                     dw  absOR+2\n3819 : 4d02                     dw  absOR+3\n                        ;add/subtract indirect pointers\n381b : 0302             adi2_   dw  ada2            ;indirect pointer to operand 2 in absolute memory\n381d : 0402             sbi2_   dw  sba2            ;indirect pointer to complemented operand 2 (SBC)\n381f : 0401             adiy2_  dw  ada2-$ff        ;with offset for indirect indexed\n3821 : 0501             sbiy2_  dw  sba2-$ff\n3823 :                  zp_end\n                            if (zp_end - zp_init) != (zp_bss_end - zp_bss)   \n                                ;force assembler error if size is different   \n                                ERROR ERROR ERROR   ;mismatch between bss and zeropage data\n                            endif \n3823 :                  data_init\n3823 : 2900             ex_and_ and #0              ;execute immediate opcodes\n3825 : 60                       rts\n3826 : 4900             ex_eor_ eor #0              ;execute immediate opcodes\n3828 : 60                       rts\n3829 : 0900             ex_ora_ ora #0              ;execute immediate opcodes\n382b : 60                       rts\n382c : 6900             ex_adc_ adc #0              ;execute immediate opcodes\n382e : 60                       rts\n382f : e900             ex_sbc_ sbc #0              ;execute immediate opcodes\n3831 : 60                       rts\n3832 : c3824100         abs1_   db  $c3,$82,$41,0   ;test patterns for LDx BIT ROL ROR ASL LSR\n3836 : 7f               abs7f_  db  $7f             ;test pattern for compare\n                        ;loads\n3837 : 80800002         fLDx_   db  fn,fn,0,fz      ;expected flags for load\n                        ;shifts\n383b :                  rASL_                       ;expected result ASL & ROL -carry\n383b : 86048200         rROL_   db  $86,$04,$82,0   ; \"\n383f : 87058301         rROLc_  db  $87,$05,$83,1   ;expected result ROL +carry\n3843 :                  rLSR_                       ;expected result LSR & ROR -carry\n3843 : 61412000         rROR_   db  $61,$41,$20,0   ; \"\n3847 : e1c1a080         rRORc_  db  $e1,$c1,$a0,$80 ;expected result ROR +carry\n384b :                  fASL_                       ;expected flags for shifts\n384b : 81018002         fROL_   db  fnc,fc,fn,fz    ;no carry in\n384f : 81018000         fROLc_  db  fnc,fc,fn,0     ;carry in\n3853 :                  fLSR_\n3853 : 01000102         fROR_   db  fc,0,fc,fz      ;no carry in\n3857 : 81808180         fRORc_  db  fnc,fn,fnc,fn   ;carry in\n                        ;increments (decrements)\n385b : 7f80ff0001       rINC_   db  $7f,$80,$ff,0,1 ;expected result for INC/DEC\n3860 : 0080800200       fINC_   db  0,fn,fn,fz,0    ;expected flags for INC/DEC\n                        ;logical memory operand\n3865 : 001f7180         absOR_  db  0,$1f,$71,$80   ;test pattern for OR\n3869 : 0fff7f80         absAN_  db  $0f,$ff,$7f,$80 ;test pattern for AND\n386d : ff0f8f8f         absEO_  db  $ff,$0f,$8f,$8f ;test pattern for EOR\n                        ;logical accu operand\n3871 : 00f11f00         absORa_ db  0,$f1,$1f,0     ;test pattern for OR\n3875 : f0ffffff         absANa_ db  $f0,$ff,$ff,$ff ;test pattern for AND\n3879 : fff0f00f         absEOa_ db  $ff,$f0,$f0,$0f ;test pattern for EOR\n                        ;logical results\n387d : 00ff7f80         absrlo_ db  0,$ff,$7f,$80\n3881 : 02800080         absflo_ db  fz,fn,0,fn\n3885 :                  data_end\n                            if (data_end - data_init) != (data_bss_end - data_bss)\n                                ;force assembler error if size is different   \n                                ERROR ERROR ERROR   ;mismatch between bss and data\n                            endif \n                        \n3885 :                  vec_init\n3885 : 9137                     dw  nmi_trap\n3887 : 9437                     dw  res_trap\n3889 : 9937                     dw  irq_trap\nfffa =                  vec_bss equ $fffa\n                            endif                   ;end of RAM init data\n                            \n                            if (load_data_direct = 1) & (ROM_vectors = 1)  \n                                org $fffa       ;vectors\n                                dw  nmi_trap\n                                dw  res_trap\n                                dw  irq_trap\n                            endif\n                        \nfffa =                          end start\n                                    \n                        \nNo errors in pass 2.\nWrote binary from address $0400 through $388a.\nTotal size 13451 bytes.\nProgram start address is at $0400 (1024).\n\f"
  },
  {
    "path": "assets/tests/README.md",
    "content": "These are Klaus Dormann 6502 functional tests, also available at:\n\nhttps://github.com/Klaus2m5/6502_65C02_functional_tests\n\n# 6502_functional_test.a65\n\n  Source code\n\n# 6502_functional_test.bin\n\n  Assembled binary to be loaded at 0x400\n\n# 6502_functional_test.lst\n\n  Listing file, comes in useful to identify bugs, since these tests have no \n  actual output.\n"
  },
  {
    "path": "cmake/FindSDL2.cmake",
    "content": "\n# This module defines\n# SDL2_LIBRARY, the name of the library to link against\n# SDL2_FOUND, if false, do not try to link to SDL2\n# SDL2_INCLUDE_DIR, where to find SDL.h\n#\n# This module responds to the the flag:\n# SDL2_BUILDING_LIBRARY\n# If this is defined, then no SDL2main will be linked in because\n# only applications need main().\n# Otherwise, it is assumed you are building an application and this\n# module will attempt to locate and set the the proper link flags\n# as part of the returned SDL2_LIBRARY variable.\n#\n# Don't forget to include SDLmain.h and SDLmain.m your project for the\n# OS X framework based version. (Other versions link to -lSDL2main which\n# this module will try to find on your behalf.) Also for OS X, this\n# module will automatically add the -framework Cocoa on your behalf.\n#\n#\n# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration\n# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library\n# (SDL2.dll, libsdl2.so, SDL2.framework, etc).\n# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.\n# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value\n# as appropriate. These values are used to generate the final SDL2_LIBRARY\n# variable, but when these values are unset, SDL2_LIBRARY does not get created.\n#\n#\n# $SDL2DIR is an environment variable that would\n# correspond to the ./configure --prefix=$SDL2DIR\n# used in building SDL2.\n# l.e.galup  9-20-02\n#\n# Modified by Eric Wing.\n# Added code to assist with automated building by using environmental variables\n# and providing a more controlled/consistent search behavior.\n# Added new modifications to recognize OS X frameworks and\n# additional Unix paths (FreeBSD, etc).\n# Also corrected the header search path to follow \"proper\" SDL guidelines.\n# Added a search for SDL2main which is needed by some platforms.\n# Added a search for threads which is needed by some platforms.\n# Added needed compile switches for MinGW.\n#\n# On OSX, this will prefer the Framework version (if found) over others.\n# People will have to manually change the cache values of\n# SDL2_LIBRARY to override this selection or set the CMake environment\n# CMAKE_INCLUDE_PATH to modify the search paths.\n#\n# Note that the header path has changed from SDL2/SDL.h to just SDL.h\n# This needed to change because \"proper\" SDL convention\n# is #include \"SDL.h\", not <SDL2/SDL.h>. This is done for portability\n# reasons because not all systems place things in SDL2/ (see FreeBSD).\n\n#=============================================================================\n# Copyright 2003-2009 Kitware, Inc.\n#\n# Distributed under the OSI-approved BSD License (the \"License\");\n# see accompanying file Copyright.txt for details.\n#\n# This software is distributed WITHOUT ANY WARRANTY; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the License for more information.\n#=============================================================================\n# (To distribute this file outside of CMake, substitute the full\n#  License text for the above reference.)\n\nmessage(\"<FindSDL2.cmake>\")\n\nSET(SDL2_SEARCH_PATHS\n\t~/Library/Frameworks\n\t/Library/Frameworks\n\t/usr/local\n\t/usr\n\t/sw # Fink\n\t/opt/local # DarwinPorts\n\t/opt/csw # Blastwave\n\t/opt\n\t${SDL2_PATH}\n)\n\nFIND_PATH(SDL2_INCLUDE_DIR SDL.h\n\tHINTS\n\t$ENV{SDL2DIR}\n\tPATH_SUFFIXES include/SDL2 include\n\tPATHS ${SDL2_SEARCH_PATHS}\n)\n\nFIND_LIBRARY(SDL2_LIBRARY_TEMP\n\tNAMES SDL2\n\tHINTS\n\t$ENV{SDL2DIR}\n\tPATH_SUFFIXES lib64 lib\n\tPATHS ${SDL2_SEARCH_PATHS}\n)\n\nIF(NOT SDL2_BUILDING_LIBRARY)\n\tIF(NOT ${SDL2_INCLUDE_DIR} MATCHES \".framework\")\n\t\t# Non-OS X framework versions expect you to also dynamically link to\n\t\t# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms\n\t\t# seem to provide SDL2main for compatibility even though they don't\n\t\t# necessarily need it.\n\t\tFIND_LIBRARY(SDL2MAIN_LIBRARY\n\t\t\tNAMES SDL2main\n\t\t\tHINTS\n\t\t\t$ENV{SDL2DIR}\n\t\t\tPATH_SUFFIXES lib64 lib\n\t\t\tPATHS ${SDL2_SEARCH_PATHS}\n\t\t)\n\tENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES \".framework\")\nENDIF(NOT SDL2_BUILDING_LIBRARY)\n\n# SDL2 may require threads on your system.\n# The Apple build may not need an explicit flag because one of the\n# frameworks may already provide it.\n# But for non-OSX systems, I will use the CMake Threads package.\nIF(NOT APPLE)\n\tFIND_PACKAGE(Threads)\nENDIF(NOT APPLE)\n\n# MinGW needs an additional library, mwindows\n# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows\n# (Actually on second look, I think it only needs one of the m* libraries.)\nIF(MINGW)\n\tSET(MINGW32_LIBRARY mingw32 CACHE STRING \"mwindows for MinGW\")\nENDIF(MINGW)\n\nIF(SDL2_LIBRARY_TEMP)\n\t# For SDL2main\n\tIF(NOT SDL2_BUILDING_LIBRARY)\n\t\tIF(SDL2MAIN_LIBRARY)\n\t\t\tSET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})\n\t\tENDIF(SDL2MAIN_LIBRARY)\n\tENDIF(NOT SDL2_BUILDING_LIBRARY)\n\n\t# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.\n\t# CMake doesn't display the -framework Cocoa string in the UI even\n\t# though it actually is there if I modify a pre-used variable.\n\t# I think it has something to do with the CACHE STRING.\n\t# So I use a temporary variable until the end so I can set the\n\t# \"real\" variable in one-shot.\n\tIF(APPLE)\n\t\tSET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} \"-framework Cocoa\")\n\tENDIF(APPLE)\n\n\t# For threads, as mentioned Apple doesn't need this.\n\t# In fact, there seems to be a problem if I used the Threads package\n\t# and try using this line, so I'm just skipping it entirely for OS X.\n\tIF(NOT APPLE)\n\t\tSET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})\n\tENDIF(NOT APPLE)\n\n\t# For MinGW library\n\tIF(MINGW)\n\t\tSET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})\n\tENDIF(MINGW)\n\n\t# Set the final string here so the GUI reflects the final state.\n\tSET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING \"Where the SDL2 Library can be found\")\n\t# Set the temp variable to INTERNAL so it is not seen in the CMake GUI\n\tSET(SDL2_LIBRARY_TEMP \"${SDL2_LIBRARY_TEMP}\" CACHE INTERNAL \"\")\nENDIF(SDL2_LIBRARY_TEMP)\n\nmessage(\"</FindSDL2.cmake>\")\n\nINCLUDE(FindPackageHandleStandardArgs)\n\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)\n\n"
  },
  {
    "path": "cmake/FindSDL2_image.cmake",
    "content": "# Locate SDL_image library\n#\n# This module defines:\n#\n# ::\n#\n#   SDL_IMAGE_LIBRARIES, the name of the library to link against\n#   SDL_IMAGE_INCLUDE_DIRS, where to find the headers\n#   SDL_IMAGE_FOUND, if false, do not try to link against\n#   SDL_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image\n#\n#\n#\n# For backward compatiblity the following variables are also set:\n#\n# ::\n#\n#   SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES)\n#   SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS)\n#   SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND)\n#\n#\n#\n# $SDLDIR is an environment variable that would correspond to the\n# ./configure --prefix=$SDLDIR used in building SDL.\n#\n# Created by Eric Wing.  This was influenced by the FindSDL.cmake\n# module, but with modifications to recognize OS X frameworks and\n# additional Unix paths (FreeBSD, etc).\n\n#=============================================================================\n# Copyright 2005-2009 Kitware, Inc.\n# Copyright 2012 Benjamin Eikel\n#\n# Distributed under the OSI-approved BSD License (the \"License\");\n# see accompanying file Copyright.txt for details.\n#\n# This software is distributed WITHOUT ANY WARRANTY; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the License for more information.\n#=============================================================================\n# (To distribute this file outside of CMake, substitute the full\n#  License text for the above reference.)\n\nfind_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h\n  HINTS\n    ENV SDL2IMAGEDIR\n    ENV SDL2DIR\n  PATH_SUFFIXES SDL2\n                # path suffixes to search inside ENV{SDLDIR}\n                include/SDL2 include\n)\n\nif(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  set(VC_LIB_PATH_SUFFIX lib/x64)\nelse()\n  set(VC_LIB_PATH_SUFFIX lib/x86)\nendif()\n\nfind_library(SDL2_IMAGE_LIBRARY\n  NAMES SDL2_image\n  HINTS\n    ENV SDL2IMAGEDIR\n    ENV SDL2DIR\n  PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}\n)\n\nif(SDL2_IMAGE_INCLUDE_DIR AND EXISTS \"${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h\")\n  file(STRINGS \"${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h\" SDL_IMAGE_VERSION_MAJOR_LINE REGEX \"^#define[ \\t]+SDL_IMAGE_MAJOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h\" SDL2_IMAGE_VERSION_MINOR_LINE REGEX \"^#define[ \\t]+SDL2_IMAGE_MINOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h\" SDL2_IMAGE_VERSION_PATCH_LINE REGEX \"^#define[ \\t]+SDL2_IMAGE_PATCHLEVEL[ \\t]+[0-9]+$\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_IMAGE_MAJOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_IMAGE_VERSION_MAJOR \"${SDL2_IMAGE_VERSION_MAJOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_IMAGE_MINOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_IMAGE_VERSION_MINOR \"${SDL2_IMAGE_VERSION_MINOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_IMAGE_PATCHLEVEL[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_IMAGE_VERSION_PATCH \"${SDL2_IMAGE_VERSION_PATCH_LINE}\")\n  set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH})\n  unset(SDL2_IMAGE_VERSION_MAJOR_LINE)\n  unset(SDL2_IMAGE_VERSION_MINOR_LINE)\n  unset(SDL2_IMAGE_VERSION_PATCH_LINE)\n  unset(SDL2_IMAGE_VERSION_MAJOR)\n  unset(SDL2_IMAGE_VERSION_MINOR)\n  unset(SDL2_IMAGE_VERSION_PATCH)\nendif()\n\nset(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})\nset(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})\n\ninclude(FindPackageHandleStandardArgs)\n\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image\n                                  REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS\n                                  VERSION_VAR SDL2_IMAGE_VERSION_STRING)\n\n# for backward compatiblity\n#set(SDLIMAGE_LIBRARY ${SDL_IMAGE_LIBRARIES})\n#set(SDLIMAGE_INCLUDE_DIR ${SDL_IMAGE_INCLUDE_DIRS})\n#set(SDLIMAGE_FOUND ${SDL_IMAGE_FOUND})\n\nmark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)\n"
  },
  {
    "path": "cmake/FindSDL2_net.cmake",
    "content": "# - Find SDL2_net library and headers\n# \n# Find module for SDL_net 2.0 (http://www.libsdl.org/projects/SDL_net/).\n# It defines the following variables:\n#  SDL2_NET_INCLUDE_DIRS - The location of the headers, e.g., SDL_net.h.\n#  SDL2_NET_LIBRARIES - The libraries to link against to use SDL2_net.\n#  SDL2_NET_FOUND - If false, do not try to use SDL2_net.\n#  SDL2_NET_VERSION_STRING\n#    Human-readable string containing the version of SDL2_net.\n#\n# Also defined, but not for general use are:\n#   SDL2_NET_INCLUDE_DIR - The directory that contains SDL_net.h.\n#   SDL2_NET_LIBRARY - The location of the SDL2_net library.\n#\n\n#=============================================================================\n# Copyright 2013 Benjamin Eikel\n#\n# Distributed under the OSI-approved BSD License (the \"License\");\n# see accompanying file Copyright.txt for details.\n#\n# This software is distributed WITHOUT ANY WARRANTY; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the License for more information.\n#=============================================================================\n# (To distribute this file outside of CMake, substitute the full\n#  License text for the above reference.)\n\nfind_package(PkgConfig QUIET)\npkg_check_modules(PC_SDL2_NET QUIET SDL2_net)\n\nfind_path(SDL2_NET_INCLUDE_DIR\n  NAMES SDL_net.h\n  HINTS\n    ${PC_SDL2_NET_INCLUDEDIR}\n    ${PC_SDL2_NET_INCLUDE_DIRS}\n  PATH_SUFFIXES SDL2\n)\n\nfind_library(SDL2_NET_LIBRARY\n  NAMES SDL2_net\n  HINTS\n    ${PC_SDL2_NET_LIBDIR}\n    ${PC_SDL2_NET_LIBRARY_DIRS}\n  PATH_SUFFIXES x64 x86\n)\n\nif(SDL2_NET_INCLUDE_DIR AND EXISTS \"${SDL2_NET_INCLUDE_DIR}/SDL_net.h\")\n  file(STRINGS \"${SDL2_NET_INCLUDE_DIR}/SDL_net.h\" SDL2_NET_VERSION_MAJOR_LINE REGEX \"^#define[ \\t]+SDL_NET_MAJOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_NET_INCLUDE_DIR}/SDL_net.h\" SDL2_NET_VERSION_MINOR_LINE REGEX \"^#define[ \\t]+SDL_NET_MINOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_NET_INCLUDE_DIR}/SDL_net.h\" SDL2_NET_VERSION_PATCH_LINE REGEX \"^#define[ \\t]+SDL_NET_PATCHLEVEL[ \\t]+[0-9]+$\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL_NET_MAJOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_NET_VERSION_MAJOR \"${SDL2_NET_VERSION_MAJOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL_NET_MINOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_NET_VERSION_MINOR \"${SDL2_NET_VERSION_MINOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL_NET_PATCHLEVEL[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_NET_VERSION_PATCH \"${SDL2_NET_VERSION_PATCH_LINE}\")\n  set(SDL2_NET_VERSION_STRING ${SDL2_NET_VERSION_MAJOR}.${SDL2_NET_VERSION_MINOR}.${SDL2_NET_VERSION_PATCH})\n  unset(SDL2_NET_VERSION_MAJOR_LINE)\n  unset(SDL2_NET_VERSION_MINOR_LINE)\n  unset(SDL2_NET_VERSION_PATCH_LINE)\n  unset(SDL2_NET_VERSION_MAJOR)\n  unset(SDL2_NET_VERSION_MINOR)\n  unset(SDL2_NET_VERSION_PATCH)\nendif()\n\nset(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})\nset(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})\n\ninclude(FindPackageHandleStandardArgs)\n\nfind_package_handle_standard_args(SDL2_net\n                                  REQUIRED_VARS SDL2_NET_INCLUDE_DIRS SDL2_NET_LIBRARIES\n                                  VERSION_VAR SDL2_NET_VERSION_STRING)\n\nmark_as_advanced(SDL2_NET_INCLUDE_DIR SDL2_NET_LIBRARY)\n"
  },
  {
    "path": "cmake/FindSDL2_ttf.cmake",
    "content": "# Locate SDL_image library\n#\n# This module defines:\n#\n# ::\n#\n#   SDL_TTF_LIBRARIES, the name of the library to link against\n#   SDL_TTF_INCLUDE_DIRS, where to find the headers\n#   SDL_TTF_FOUND, if false, do not try to link against\n#   SDL_F_VERSION_STRING - human-readable string containing the version of SDL_ttf\n#\n#\n#\n# For backward compatiblity the following variables are also set:\n#\n# ::\n#\n#   SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES)\n#   SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS)\n#   SDLTTF_FOUND (same value as SDL_TTF_FOUND)\n#\n#\n#\n# $SDLDIR is an environment variable that would correspond to the\n# ./configure --prefix=$SDLDIR used in building SDL.\n#\n# Created by Eric Wing.  This was influenced by the FindSDL.cmake\n# module, but with modifications to recognize OS X frameworks and\n# additional Unix paths (FreeBSD, etc).\n\n#=============================================================================\n# Copyright 2005-2009 Kitware, Inc.\n# Copyright 2012 Benjamin Eikel\n#\n# Distributed under the OSI-approved BSD License (the \"License\");\n# see accompanying file Copyright.txt for details.\n#\n# This software is distributed WITHOUT ANY WARRANTY; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n# See the License for more information.\n#=============================================================================\n# (To distribute this file outside of CMake, substitute the full\n#  License text for the above reference.)\n\nfind_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h\n  HINTS\n    ENV SDL2TTFDIR\n    ENV SDL2DIR\n  PATH_SUFFIXES SDL2\n                # path suffixes to search inside ENV{SDLDIR}\n                include/SDL2 include\n)\n\nif(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  set(VC_LIB_PATH_SUFFIX lib/x64)\nelse()\n  set(VC_LIB_PATH_SUFFIX lib/x86)\nendif()\n\nfind_library(SDL2_TTF_LIBRARY\n  NAMES SDL2_ttf\n  HINTS\n    ENV SDL2TTFDIR\n    ENV SDL2DIR\n  PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}\n)\n\nif(SDL2_TTF_INCLUDE_DIR AND EXISTS \"${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h\")\n  file(STRINGS \"${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h\" SDL_TTF_VERSION_MAJOR_LINE REGEX \"^#define[ \\t]+SDL_TTF_MAJOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h\" SDL2_TTF_VERSION_MINOR_LINE REGEX \"^#define[ \\t]+SDL2_TTF_MINOR_VERSION[ \\t]+[0-9]+$\")\n  file(STRINGS \"${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h\" SDL2_TTF_VERSION_PATCH_LINE REGEX \"^#define[ \\t]+SDL2_TTF_PATCHLEVEL[ \\t]+[0-9]+$\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_TTF_MAJOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_TTF_VERSION_MAJOR \"${SDL2_TTF_VERSION_MAJOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_TTF_MINOR_VERSION[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_TTF_VERSION_MINOR \"${SDL2_TTF_VERSION_MINOR_LINE}\")\n  string(REGEX REPLACE \"^#define[ \\t]+SDL2_TTF_PATCHLEVEL[ \\t]+([0-9]+)$\" \"\\\\1\" SDL2_TTF_VERSION_PATCH \"${SDL2_TTF_VERSION_PATCH_LINE}\")\n  set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH})\n  unset(SDL2_TTF_VERSION_MAJOR_LINE)\n  unset(SDL2_TTF_VERSION_MINOR_LINE)\n  unset(SDL2_TTF_VERSION_PATCH_LINE)\n  unset(SDL2_TTF_VERSION_MAJOR)\n  unset(SDL2_TTF_VERSION_MINOR)\n  unset(SDL2_TTF_VERSION_PATCH)\nendif()\n\nset(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})\nset(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})\n\ninclude(FindPackageHandleStandardArgs)\n\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf\n                                  REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS\n                                  VERSION_VAR SDL2_TTF_VERSION_STRING)\n\n# for backward compatiblity\n#set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})\n#set(SDLTTF_INCLUDE_DIR ${SDL_TTF_INCLUDE_DIRS})\n#set(SDLTTF_FOUND ${SDL_TTF_FOUND})\n\nmark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)\n"
  },
  {
    "path": "cmake/README.md",
    "content": "These have been downloaded from:\n\nhttps://github.com/tcbrindle/sdl2-cmake-scripts\n"
  },
  {
    "path": "doc/.gitignore",
    "content": "html/\n"
  },
  {
    "path": "doc/doxygen.conf",
    "content": "\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\nDOXYFILE_ENCODING      = UTF-8\nPROJECT_NAME           = \"Emudore\"\nPROJECT_NUMBER         = \nPROJECT_BRIEF          = \"Commodore 64 emulator\"\nPROJECT_LOGO           = \nOUTPUT_DIRECTORY       = .\nCREATE_SUBDIRS         = NO\nOUTPUT_LANGUAGE        = English\nBRIEF_MEMBER_DESC      = YES\nREPEAT_BRIEF           = YES\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\nALWAYS_DETAILED_SEC    = NO\nINLINE_INHERITED_MEMB  = NO\nFULL_PATH_NAMES        = NO\nSTRIP_FROM_PATH        = \nSTRIP_FROM_INC_PATH    = \nSHORT_NAMES            = NO\nJAVADOC_AUTOBRIEF      = NO\nQT_AUTOBRIEF           = NO\nMULTILINE_CPP_IS_BRIEF = NO\nINHERIT_DOCS           = YES\nSEPARATE_MEMBER_PAGES  = NO\nTAB_SIZE               = 8\nALIASES                = \nTCL_SUBST              = \nOPTIMIZE_OUTPUT_FOR_C  = NO\nOPTIMIZE_OUTPUT_JAVA   = NO\nOPTIMIZE_FOR_FORTRAN   = NO\nOPTIMIZE_OUTPUT_VHDL   = NO\nEXTENSION_MAPPING      = \nMARKDOWN_SUPPORT       = YES\nBUILTIN_STL_SUPPORT    = NO\nCPP_CLI_SUPPORT        = NO\nSIP_SUPPORT            = NO\nIDL_PROPERTY_SUPPORT   = YES\nDISTRIBUTE_GROUP_DOC   = NO\nSUBGROUPING            = YES\nINLINE_GROUPED_CLASSES = NO\nINLINE_SIMPLE_STRUCTS  = NO\nTYPEDEF_HIDES_STRUCT   = NO\nSYMBOL_CACHE_SIZE      = 0\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\nEXTRACT_ALL            = YES\nEXTRACT_PRIVATE        = YES\nEXTRACT_PACKAGE        = NO\nEXTRACT_STATIC         = NO\nEXTRACT_LOCAL_CLASSES  = YES\nEXTRACT_LOCAL_METHODS  = NO\nEXTRACT_ANON_NSPACES   = NO\nHIDE_UNDOC_MEMBERS     = NO\nHIDE_UNDOC_CLASSES     = NO\nHIDE_FRIEND_COMPOUNDS  = NO\nHIDE_IN_BODY_DOCS      = NO\nINTERNAL_DOCS          = NO\nCASE_SENSE_NAMES       = NO\nHIDE_SCOPE_NAMES       = NO\nSHOW_INCLUDE_FILES     = YES\nFORCE_LOCAL_INCLUDES   = NO\nINLINE_INFO            = YES\nSORT_MEMBER_DOCS       = YES\nSORT_BRIEF_DOCS        = NO\nSORT_MEMBERS_CTORS_1ST = NO\nSORT_GROUP_NAMES       = NO\nSORT_BY_SCOPE_NAME     = NO\nSTRICT_PROTO_MATCHING  = NO\nGENERATE_TODOLIST      = YES\nGENERATE_TESTLIST      = YES\nGENERATE_BUGLIST       = YES\nGENERATE_DEPRECATEDLIST= YES\nENABLED_SECTIONS       = \nMAX_INITIALIZER_LINES  = 30\nSHOW_USED_FILES        = NO\nSHOW_FILES             = YES\nSHOW_NAMESPACES        = YES\nFILE_VERSION_FILTER    = \nLAYOUT_FILE            = \nCITE_BIB_FILES         = \n\n#---------------------------------------------------------------------------\n# configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\nQUIET                  = NO\nWARNINGS               = YES\nWARN_IF_UNDOCUMENTED   = YES\nWARN_IF_DOC_ERROR      = YES\nWARN_NO_PARAMDOC       = NO\nWARN_FORMAT            = \"$file:$line: $text\"\nWARN_LOGFILE           = \n\n#---------------------------------------------------------------------------\n# configuration options related to the input files\n#---------------------------------------------------------------------------\nINPUT                  = ../src/\nINPUT_ENCODING         = UTF-8\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cpp \\\n                         *.c++ \\\n                         *.d \\\n                         *.java \\\n                         *.ii \\\n                         *.ixx \\\n                         *.ipp \\\n                         *.i++ \\\n                         *.inl \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.h++ \\\n                         *.idl \\\n                         *.odl \\\n                         *.cs \\\n                         *.php \\\n                         *.php3 \\\n                         *.inc \\\n                         *.m \\\n                         *.markdown \\\n                         *.md \\\n                         *.mm \\\n                         *.dox \\\n                         *.py \\\n                         *.f90 \\\n                         *.f \\\n                         *.for \\\n                         *.vhd \\\n                         *.vhdl\nRECURSIVE              = YES\nEXCLUDE                = \nEXCLUDE_SYMLINKS       = NO\nEXCLUDE_PATTERNS       = \nEXCLUDE_SYMBOLS        = \nEXAMPLE_PATH           = \nEXAMPLE_PATTERNS       = *\nEXAMPLE_RECURSIVE      = NO\nIMAGE_PATH             = \nINPUT_FILTER           = \nFILTER_PATTERNS        = \nFILTER_SOURCE_FILES    = NO\nFILTER_SOURCE_PATTERNS = \n\n#---------------------------------------------------------------------------\n# configuration options related to source browsing\n#---------------------------------------------------------------------------\nSOURCE_BROWSER         = NO\nINLINE_SOURCES         = NO\nSTRIP_CODE_COMMENTS    = YES\nREFERENCED_BY_RELATION = NO\nREFERENCES_RELATION    = NO\nREFERENCES_LINK_SOURCE = YES\nUSE_HTAGS              = NO\nVERBATIM_HEADERS       = YES\n\n#---------------------------------------------------------------------------\n# configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\nALPHABETICAL_INDEX     = YES\nCOLS_IN_ALPHA_INDEX    = 5\nIGNORE_PREFIX          = \n\n#---------------------------------------------------------------------------\n# configuration options related to the HTML output\n#---------------------------------------------------------------------------\nGENERATE_HTML          = YES\nHTML_OUTPUT            = html\nHTML_FILE_EXTENSION    = .html\nHTML_HEADER            = \nHTML_FOOTER            = \nHTML_STYLESHEET        = \nHTML_EXTRA_FILES       = \nHTML_COLORSTYLE_HUE    = 220\nHTML_COLORSTYLE_SAT    = 100\nHTML_COLORSTYLE_GAMMA  = 80\nHTML_TIMESTAMP         = YES\nHTML_DYNAMIC_SECTIONS  = NO\nHTML_INDEX_NUM_ENTRIES = 100\nGENERATE_DOCSET        = NO\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\nDOCSET_BUNDLE_ID       = org.doxygen.Project\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\nDOCSET_PUBLISHER_NAME  = Publisher\nGENERATE_HTMLHELP      = NO\nCHM_FILE               = \nHHC_LOCATION           = \nGENERATE_CHI           = NO\nCHM_INDEX_ENCODING     = \nBINARY_TOC             = NO\nTOC_EXPAND             = NO\nGENERATE_QHP           = NO\nQCH_FILE               = \nQHP_NAMESPACE          = org.doxygen.Project\nQHP_VIRTUAL_FOLDER     = doc\nQHP_CUST_FILTER_NAME   = \nQHP_CUST_FILTER_ATTRS  = \nQHP_SECT_FILTER_ATTRS  = \nQHG_LOCATION           = \nGENERATE_ECLIPSEHELP   = NO\nECLIPSE_DOC_ID         = org.doxygen.Project\nDISABLE_INDEX          = NO\nGENERATE_TREEVIEW      = YES\nENUM_VALUES_PER_LINE   = 4\nTREEVIEW_WIDTH         = 250\nEXT_LINKS_IN_WINDOW    = NO\nFORMULA_FONTSIZE       = 10\nFORMULA_TRANSPARENT    = YES\nUSE_MATHJAX            = NO\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\nMATHJAX_EXTENSIONS     = \nSEARCHENGINE           = YES\nSERVER_BASED_SEARCH    = NO\n\n#---------------------------------------------------------------------------\n# configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\nGENERATE_LATEX         = NO\nLATEX_OUTPUT           = latex\nLATEX_CMD_NAME         = latex\nMAKEINDEX_CMD_NAME     = makeindex\nCOMPACT_LATEX          = NO\nPAPER_TYPE             = a4\nEXTRA_PACKAGES         = \nLATEX_HEADER           = \nLATEX_FOOTER           = \nPDF_HYPERLINKS         = YES\nUSE_PDFLATEX           = YES\nLATEX_BATCHMODE        = NO\nLATEX_HIDE_INDICES     = NO\nLATEX_SOURCE_CODE      = NO\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# configuration options related to the RTF output\n#---------------------------------------------------------------------------\nGENERATE_RTF           = NO\nRTF_OUTPUT             = rtf\nCOMPACT_RTF            = NO\nRTF_HYPERLINKS         = NO\nRTF_STYLESHEET_FILE    = \nRTF_EXTENSIONS_FILE    = \n\n#---------------------------------------------------------------------------\n# configuration options related to the man page output\n#---------------------------------------------------------------------------\nGENERATE_MAN           = NO\nMAN_OUTPUT             = man\nMAN_EXTENSION          = .3\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# configuration options related to the XML output\n#---------------------------------------------------------------------------\nGENERATE_XML           = NO\nXML_OUTPUT             = xml\nXML_SCHEMA             = \nXML_DTD                = \nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# configuration options related to the Perl module output\n#---------------------------------------------------------------------------\nGENERATE_PERLMOD       = NO\nPERLMOD_LATEX          = NO\nPERLMOD_PRETTY         = YES\nPERLMOD_MAKEVAR_PREFIX = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\nENABLE_PREPROCESSING   = YES\nMACRO_EXPANSION        = NO\nEXPAND_ONLY_PREDEF     = NO\nSEARCH_INCLUDES        = YES\nINCLUDE_PATH           = \nINCLUDE_FILE_PATTERNS  = \nPREDEFINED             = \nEXPAND_AS_DEFINED      = \nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration::additions related to external references\n#---------------------------------------------------------------------------\nTAGFILES               = \nGENERATE_TAGFILE       = \nALLEXTERNALS           = NO\nEXTERNAL_GROUPS        = YES\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\nCLASS_DIAGRAMS         = YES\nMSCGEN_PATH            = \nHIDE_UNDOC_RELATIONS   = YES\nHAVE_DOT               = NO\nDOT_NUM_THREADS        = 0\nDOT_FONTNAME           = Helvetica\nDOT_FONTSIZE           = 10\nDOT_FONTPATH           = \nCLASS_GRAPH            = YES\nCOLLABORATION_GRAPH    = YES\nGROUP_GRAPHS           = YES\nUML_LOOK               = NO\nUML_LIMIT_NUM_FIELDS   = 10\nTEMPLATE_RELATIONS     = NO\nINCLUDE_GRAPH          = YES\nINCLUDED_BY_GRAPH      = YES\nCALL_GRAPH             = NO\nCALLER_GRAPH           = NO\nGRAPHICAL_HIERARCHY    = YES\nDIRECTORY_GRAPH        = YES\nDOT_IMAGE_FORMAT       = png\nINTERACTIVE_SVG        = NO\nDOT_PATH               = \nDOTFILE_DIRS           = \nMSCFILE_DIRS           = \nDOT_GRAPH_MAX_NODES    = 50\nMAX_DOT_GRAPH_DEPTH    = 0\nDOT_TRANSPARENT        = NO\nDOT_MULTI_TARGETS      = NO\nGENERATE_LEGEND        = YES\nDOT_CLEANUP            = YES\n\n"
  },
  {
    "path": "res/emudore.rc",
    "content": "IDI_ICON1               ICON    DISCARDABLE     \"emudore.ico\"\n"
  },
  {
    "path": "src/c64.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#include \"c64.h\"\n#include \"util.h\"\n\nC64::C64()\n{\n  /* create chips */\n  cpu_  = new Cpu();\n  mem_  = new Memory();\n  cia1_ = new Cia1();\n  cia2_ = new Cia2();\n  vic_  = new Vic();\n  sid_  = new Sid();\n  io_   = new IO();\n  /* init cpu */\n  cpu_->memory(mem_);\n  cpu_->reset();\n  /* init vic-ii */\n  vic_->memory(mem_);\n  vic_->cpu(cpu_);\n  vic_->io(io_);\n  /* init cia1 */\n  cia1_->cpu(cpu_);\n  cia1_->io(io_);\n  /* init cia2 */\n  cia2_->cpu(cpu_);\n  /* init io */\n  io_->cpu(cpu_);\n  /* DMA */\n  mem_->vic(vic_);\n  mem_->cia1(cia1_);\n  mem_->cia2(cia2_);\n /* r2 support */\n#ifdef DEBUGGER_SUPPORT\n  debugger_ = new Debugger();\n  debugger_->memory(mem_);\n  debugger_->cpu(cpu_);\n#endif   \n}\n\nC64::~C64()\n{\n  delete cpu_;\n  delete mem_;\n  delete cia1_;\n  delete cia2_;\n  delete vic_;\n  delete sid_;\n  delete io_;\n#ifdef DEBUGGER_SUPPORT\n  delete debugger_;\n#endif   \n}\n\nvoid C64::start()\n{\n  /* main emulator loop */\n  while(true)\n  {\n#ifdef DEBUGGER_SUPPORT\n    if(!debugger_->emulate())\n      break;\n#endif\n    /* CIA1 */\n    if(!cia1_->emulate())\n      break;\n    /* CIA2 */\n    if(!cia2_->emulate())\n      break;\n    /* CPU */\n    if(!cpu_->emulate())\n      break;\n    /* VIC-II */\n    if(!vic_->emulate())\n      break;\n    /* IO */\n    if(!io_->emulate())\n      break;\n    /* callback */\n    if(callback_ && !callback_())\n      break;\n  }\n}\n\n/**\n * @brief emscripten's main loop\n */\nvoid C64::emscripten_loop()\n{\n  unsigned int frame = vic_->frames();\n  while(frame == vic_->frames())\n  {\n    /* CIA1 */\n    cia1_->emulate();\n    /* CIA2 */\n    cia2_->emulate();\n    /* CPU */\n    cpu_->emulate();\n    /* VIC-II */\n    vic_->emulate();\n    /* IO */\n    io_->emulate();\n    /* callback */\n    if(callback_) callback_();\n  }\n}\n \n/**\n * @brief runs Klaus Dormann's 6502 test suite \n *\n * https://github.com/Klaus2m5/6502_65C02_functional_tests\n */\nvoid C64::test_cpu()\n{\n  uint16_t pc=0;\n  /* unmap C64 ROMs */\n  mem_->write_byte(Memory::kAddrMemoryLayout, 0);\n  /* load tests into RAM */\n  mem_->load_ram(\"tests/6502_functional_test.bin\",0x400);\n  cpu_->pc(0x400);\n  while(true)\n  {\n    if(pc == cpu_->pc())\n    {\n      D(\"infinite loop at %x\\n\",pc);\n      break;\n    }\n    else if(cpu_->pc() == 0x3463)\n    {\n      D(\"test passed!\\n\");\n      break;\n    }\n    pc = cpu_->pc();\n    if(!cpu_->emulate())\n      break;\n  }\n}\n"
  },
  {
    "path": "src/c64.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef EMUDORE_C64_H\n#define EMUDORE_C64_H\n\n#include <functional>\n\n#include \"cpu.h\"\n#include \"memory.h\"\n#include \"cia1.h\"\n#include \"cia2.h\"\n#include \"vic.h\"\n#include \"sid.h\"\n#include \"io.h\"\n\n#ifdef DEBUGGER_SUPPORT\n#include \"debugger.h\"\n#endif\n \n/**\n * @brief Commodore 64\n * \n * This class glues together all the different\n * components in a Commodore 64 computer\n */\nclass C64\n{\n  private:\n    Cpu *cpu_;\n    Memory *mem_;\n    Cia1 *cia1_;\n    Cia2 *cia2_;\n    Vic *vic_;\n    Sid *sid_;\n    IO *io_;\n    std::function<bool()> callback_;\n#ifdef DEBUGGER_SUPPORT\n    Debugger *debugger_;\n#endif\n  public:\n    C64();\n    ~C64();\n    void start();\n    void emscripten_loop();\n    void callback(std::function<bool()> cb){callback_ = cb;};\n    Cpu * cpu(){return cpu_;};\n    Memory * memory(){return mem_;};\n    IO * io(){return io_;};\n    /* test cpu */\n    void test_cpu();\n};\n\n#endif\n"
  },
  {
    "path": "src/cia1.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"cia1.h\"\n\n// ctor  /////////////////////////////////////////////////////////////////////\n\nCia1::Cia1()\n{\n  timer_a_latch_ = timer_b_latch_ = timer_a_counter_ = timer_b_counter_ = 0;\n  timer_a_enabled_ = timer_b_enabled_ = timer_a_irq_enabled_ = timer_b_irq_enabled_ = false;\n  timer_a_irq_triggered_ = timer_b_irq_triggered_ = false;\n  timer_a_input_mode_ = timer_b_input_mode_ = kModeProcessor;\n  timer_a_run_mode_ = timer_b_run_mode_ = kModeRestart;\n  pra_ = prb_ = 0xff;\n  prev_cpu_cycles_ = 0;\n}\n\n// DMA register access  //////////////////////////////////////////////////////\n\nvoid Cia1::write_register(uint8_t r, uint8_t v)\n{\n  switch(r)\n  {\n  /* data port a (PRA), keyboard matrix cols and joystick #2 */\n  case 0x0:\n    pra_ = v;\n    break;\n  /* data port b (PRB), keyboard matrix rows and joystick #1 */\n  case 0x1:\n    break;\n  /* data direction port a (DDRA) */\n  case 0x2:\n    break;\n  /* data direction port b (DDRB) */\n  case 0x3:\n    break;\n  /* timer a low byte */\n  case 0x4:\n    timer_a_latch_ &= 0xff00;\n    timer_a_latch_ |= v;\n    break;\n  /* timer a high byte */\n  case 0x5:\n    timer_a_latch_ &= 0x00ff;\n    timer_a_latch_ |= v << 8;\n    break;\n  /* timer b low byte */\n  case 0x6:\n    timer_b_latch_ &= 0xff00;\n    timer_b_latch_ |= v;\n    break;\n  /* timer b high byte */\n  case 0x7: \n    timer_b_latch_ &= 0x00ff;\n    timer_b_latch_ |= v << 8;\n    break;\n  /* RTC 1/10s  */\n  case 0x8:\n    break;\n  /* RTC seconds */\n  case 0x9:\n    break;\n  /* RTC minutes */\n  case 0xa:\n    break;\n  /* RTC hours */\n  case 0xb:\n    break;\n  /* shift serial */\n  case 0xc:\n    break;\n  /* interrupt control and status */\n  case 0xd:\n    /**\n     * if bit 7 is set, enable selected mask of \n     * interrupts, else disable them\n     */\n    if(ISSET_BIT(v,0)) timer_a_irq_enabled_ = ISSET_BIT(v,7);\n    if(ISSET_BIT(v,1)) timer_b_irq_enabled_ = ISSET_BIT(v,7);\n    break;\n  /* control timer a */\n  case 0xe:\n    timer_a_enabled_ = ((v&(1<<0))!=0);\n    timer_a_input_mode_ = (v&(1<<5)) >> 5;\n    /* load latch requested */\n    if((v&(1<<4))!=0)\n      timer_a_counter_ = timer_a_latch_;\n    break;\n  /* control timer b */\n  case 0xf:\n    timer_b_enabled_ = ((v&0x1)!=0);\n    timer_b_input_mode_ = (v&(1<<5)) | (v&(1<<6)) >> 5;\n    /* load latch requested */\n    if((v&(1<<4))!=0)\n      timer_b_counter_ = timer_b_latch_;\n    break;\n  }\n}\n\nuint8_t Cia1::read_register(uint8_t r)\n{\n  uint8_t retval = 0;\n\n  switch(r)\n  {\n  /* data port a (PRA), keyboard matrix cols and joystick #2 */\n  case 0x0:\n    break;\n  /* data port b (PRB), keyboard matrix rows and joystick #1 */\n  case 0x1:\n    if (pra_ == 0xff) retval = 0xff;\n    else if(pra_)\n    {\n      int col = 0;\n      uint8_t v = ~pra_;\n      while (v >>= 1)col++;\n      retval = io_->keyboard_matrix_row(col);\n    }\n    break;\n  /* data direction port a (DDRA) */\n  case 0x2:\n    break;\n  /* data direction port b (DDRB) */\n  case 0x3:\n    break;\n  /* timer a low byte */\n  case 0x4:\n    retval = (uint8_t)(timer_a_counter_ & 0x00ff);\n    break;\n  /* timer a high byte */\n  case 0x5:\n    retval = (uint8_t)((timer_a_counter_ & 0xff00) >> 8);\n    break;\n  /* timer b low byte */\n  case 0x6:\n    retval = (uint8_t)(timer_b_counter_ & 0x00ff);\n    break;\n  /* timer b high byte */\n  case 0x7: \n    retval = (uint8_t)((timer_b_counter_ & 0xff00) >> 8);\n    break;\n  /* RTC 1/10s  */\n  case 0x8:\n    break;\n  /* RTC seconds */\n  case 0x9:\n    break;\n  /* RTC minutes */\n  case 0xa:\n    break;\n  /* RTC hours */\n  case 0xb:\n    break;\n  /* shift serial */\n  case 0xc:\n    break;\n  /* interrupt control and status */\n  case 0xd:\n    if(timer_a_irq_triggered_ ||\n       timer_b_irq_triggered_)\n    {\n      retval |= (1 << 7); // IRQ occured\n      if(timer_a_irq_triggered_) retval |= (1 << 0);\n      if(timer_b_irq_triggered_) retval |= (1 << 1);\n    }\n    break;\n  /* control timer a */\n  case 0xe:\n    break;\n  /* control timer b */\n  case 0xf:\n    break;\n  }\n  return retval;\n}\n\n// timer reset ///////////////////////////////////////////////////////////////\n\nvoid Cia1::reset_timer_a()\n{\n  switch(timer_a_run_mode_)\n  {\n  case kModeRestart:\n    timer_a_counter_ = timer_a_latch_;\n    break;\n  case kModeOneTime:\n    timer_a_enabled_ = false;\n    break;\n  }\n}\n\nvoid Cia1::reset_timer_b()\n{\n  switch(timer_b_run_mode_)\n  {\n  case kModeRestart:\n    timer_b_counter_ = timer_b_latch_;\n    break;\n  case kModeOneTime:\n    timer_b_enabled_ = false;\n    break;\n  }      \n}\n\n// emulation  ////////////////////////////////////////////////////////////////\n\nbool Cia1::emulate()\n{\n  /* timer a */\n  if(timer_a_enabled_)\n  {\n    switch(timer_a_input_mode_)\n    {\n    case kModeProcessor:\n      timer_a_counter_ -= cpu_->cycles() - prev_cpu_cycles_;\n      if (timer_a_counter_ <= 0)\n      {\n        if(timer_a_irq_enabled_) \n        {\n          timer_a_irq_triggered_ = true;\n          cpu_->irq();\n        }\n        reset_timer_a();\n      }\n      break;\n    case kModeCNT:\n      break;\n    }\n  }\n  /* timer b */\n  if(timer_b_enabled_)\n  {\n    switch(timer_b_input_mode_)\n    {\n    case kModeProcessor:\n      timer_b_counter_ -= cpu_->cycles() - prev_cpu_cycles_;\n      if (timer_b_counter_ <= 0)\n      {\n        if(timer_b_irq_enabled_)\n        {\n          timer_b_irq_triggered_ = true;\n          cpu_->irq();\n        }\n        reset_timer_b();\n      }   \n      break;\n    case kModeCNT:\n      break;\n    case kModeTimerA:\n      break;\n    case kModeTimerACNT:\n      break;\n    }\n  }\n  prev_cpu_cycles_ = cpu_->cycles();\n  return true;\n}\n"
  },
  {
    "path": "src/cia1.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#ifndef EMUDORE_CIA1_H\n#define EMUDORE_CIA1_H\n\n#include \"io.h\"\n#include \"cpu.h\"\n\n/**\n * @brief MOS 6526 Complex Interface Adapter #1\n *\n * - Memory area : $DC00-$DCFF\n * - Tasks       : Keyboard, Joystick, Paddles, Datasette, IRQ control\n */\nclass Cia1\n{\n  private:\n    Cpu *cpu_;\n    IO *io_;\n    int16_t timer_a_latch_;\n    int16_t timer_b_latch_;\n    int16_t timer_a_counter_;\n    int16_t timer_b_counter_;\n    bool timer_a_enabled_;\n    bool timer_b_enabled_;\n    bool timer_a_irq_enabled_;\n    bool timer_b_irq_enabled_;\n    bool timer_a_irq_triggered_;\n    bool timer_b_irq_triggered_;\n    uint8_t timer_a_run_mode_;\n    uint8_t timer_b_run_mode_;\n    uint8_t timer_a_input_mode_;\n    uint8_t timer_b_input_mode_;\n    unsigned int prev_cpu_cycles_;\n    uint8_t pra_, prb_;\n  public:\n    Cia1();\n    void cpu(Cpu *v){ cpu_ = v;};\n    void io(IO *v){ io_ = v;};\n    void write_register(uint8_t r, uint8_t v);\n    uint8_t read_register(uint8_t r);\n    void reset_timer_a();\n    void reset_timer_b();\n    bool emulate();\n    /* constants */\n    enum kInputMode\n    {\n      kModeProcessor,\n      kModeCNT,\n      kModeTimerA,\n      kModeTimerACNT\n    };\n    enum kRunMode\n    {\n      kModeRestart,\n      kModeOneTime\n    };\n};\n\n#endif\n"
  },
  {
    "path": "src/cia2.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"cia2.h\"\n\n// ctor  /////////////////////////////////////////////////////////////////////\n\nCia2::Cia2()\n{\n  timer_a_latch_ = timer_b_latch_ = timer_a_counter_ = timer_b_counter_ = 0;\n  timer_a_enabled_ = timer_b_enabled_ = timer_a_irq_enabled_ = timer_b_irq_enabled_ = false;\n  timer_a_irq_triggered_ = timer_b_irq_triggered_ = false;\n  timer_a_input_mode_ = timer_b_input_mode_ = kModeProcessor;\n  timer_a_run_mode_ = timer_b_run_mode_ = kModeRestart;\n  pra_ = prb_ = 0xff;\n  prev_cpu_cycles_ = 0;\n}\n\n// DMA register access  //////////////////////////////////////////////////////\n\nvoid Cia2::write_register(uint8_t r, uint8_t v)\n{\n  switch(r)\n  {\n  /* data port a (PRA) */\n  case 0x0:\n    pra_ = v;\n    break;\n  /* data port b (PRB) */\n  case 0x1:\n    prb_ = v;\n    break;\n  /* data direction port a (DDRA) */\n  case 0x2:\n    break;\n  /* data direction port b (DDRB) */\n  case 0x3:\n    break;\n  /* timer a low byte */\n  case 0x4:\n    timer_a_latch_ &= 0xff00;\n    timer_a_latch_ |= v;\n    break;\n  /* timer a high byte */\n  case 0x5:\n    timer_a_latch_ &= 0x00ff;\n    timer_a_latch_ |= v << 8;\n    break;\n  /* timer b low byte */\n  case 0x6:\n    timer_b_latch_ &= 0xff00;\n    timer_b_latch_ |= v;\n    break;\n  /* timer b high byte */\n  case 0x7: \n    timer_b_latch_ &= 0x00ff;\n    timer_b_latch_ |= v << 8;\n    break;\n  /* RTC 1/10s  */\n  case 0x8:\n    break;\n  /* RTC seconds */\n  case 0x9:\n    break;\n  /* RTC minutes */\n  case 0xa:\n    break;\n  /* RTC hours */\n  case 0xb:\n    break;\n  /* shift serial */\n  case 0xc:\n    break;\n  /* interrupt control and status */\n  case 0xd:\n    /**\n     * if bit 7 is set, enable selected mask of \n     * interrupts, else disable them\n     */\n    if(ISSET_BIT(v,0)) timer_a_irq_enabled_ = ISSET_BIT(v,7);\n    if(ISSET_BIT(v,1)) timer_b_irq_enabled_ = ISSET_BIT(v,7);\n    break;\n  /* control timer a */\n  case 0xe:\n    timer_a_enabled_ = ((v&(1<<0))!=0);\n    timer_a_input_mode_ = (v&(1<<5)) >> 5;\n    /* load latch requested */\n    if((v&(1<<4))!=0)\n      timer_a_counter_ = timer_a_latch_;\n    break;\n  /* control timer b */\n  case 0xf:\n    timer_b_enabled_ = ((v&0x1)!=0);\n    timer_b_input_mode_ = (v&(1<<5)) | (v&(1<<6)) >> 5;\n    /* load latch requested */\n    if((v&(1<<4))!=0)\n      timer_b_counter_ = timer_b_latch_;\n    break;\n  }\n}\n\nuint8_t Cia2::read_register(uint8_t r)\n{\n  uint8_t retval = 0;\n\n  switch(r)\n  {\n  /* data port a (PRA) */\n  case 0x0:\n    retval = pra_;\n    break;\n  /* data port b (PRB) */\n  case 0x1:\n    retval = prb_;\n    break;\n  /* data direction port a (DDRA) */\n  case 0x2:\n    break;\n  /* data direction port b (DDRB) */\n  case 0x3:\n    break;\n  /* timer a low byte */\n  case 0x4:\n    retval = (uint8_t)(timer_a_counter_ & 0x00ff);\n    break;\n  /* timer a high byte */\n  case 0x5:\n    retval = (uint8_t)((timer_a_counter_ & 0xff00) >> 8);\n    break;\n  /* timer b low byte */\n  case 0x6:\n    retval = (uint8_t)(timer_b_counter_ & 0x00ff);\n    break;\n  /* timer b high byte */\n  case 0x7: \n    retval = (uint8_t)((timer_b_counter_ & 0xff00) >> 8);\n    break;\n  /* RTC 1/10s  */\n  case 0x8:\n    break;\n  /* RTC seconds */\n  case 0x9:\n    break;\n  /* RTC minutes */\n  case 0xa:\n    break;\n  /* RTC hours */\n  case 0xb:\n    break;\n  /* shift serial */\n  case 0xc:\n    break;\n  /* interrupt control and status */\n  case 0xd:\n    if(timer_a_irq_triggered_ ||\n       timer_b_irq_triggered_)\n    {\n      retval |= (1 << 7); // IRQ occured\n      if(timer_a_irq_triggered_) retval |= (1 << 0);\n      if(timer_b_irq_triggered_) retval |= (1 << 1);\n    }\n    break;\n  /* control timer a */\n  case 0xe:\n    break;\n  /* control timer b */\n  case 0xf:\n    break;\n  }\n  return retval;\n}\n\n// timer reset ///////////////////////////////////////////////////////////////\n\nvoid Cia2::reset_timer_a()\n{\n  switch(timer_a_run_mode_)\n  {\n  case kModeRestart:\n    timer_a_counter_ = timer_a_latch_;\n    break;\n  case kModeOneTime:\n    timer_a_enabled_ = false;\n    break;\n  }\n}\n\nvoid Cia2::reset_timer_b()\n{\n  switch(timer_b_run_mode_)\n  {\n  case kModeRestart:\n    timer_b_counter_ = timer_b_latch_;\n    break;\n  case kModeOneTime:\n    timer_b_enabled_ = false;\n    break;\n  }      \n}\n\n// VIC banking ///////////////////////////////////////////////////////////////\n\n/**\n * @brief retrieves vic base address\n *\n * PRA bits (0..1)\n *\n *  %00, 0: Bank 3: $C000-$FFFF, 49152-65535\n *  %01, 1: Bank 2: $8000-$BFFF, 32768-49151\n *  %10, 2: Bank 1: $4000-$7FFF, 16384-32767\n *  %11, 3: Bank 0: $0000-$3FFF, 0-16383 (standard)\n */\nuint16_t Cia2::vic_base_address()\n{\n  return ((~pra_&0x3) << 14);\n}\n\n// emulation  ////////////////////////////////////////////////////////////////\n\nbool Cia2::emulate()\n{\n  /* timer a */\n  if(timer_a_enabled_)\n  {\n    switch(timer_a_input_mode_)\n    {\n    case kModeProcessor:\n      timer_a_counter_ -= cpu_->cycles() - prev_cpu_cycles_;\n      if (timer_a_counter_ <= 0)\n      {\n        if(timer_a_irq_enabled_) \n        {\n          timer_a_irq_triggered_ = true;\n          cpu_->nmi();\n        }\n        reset_timer_a();\n      }\n      break;\n    case kModeCNT:\n      break;\n    }\n  }\n  /* timer b */\n  if(timer_b_enabled_)\n  {\n    switch(timer_b_input_mode_)\n    {\n    case kModeProcessor:\n      timer_b_counter_ -= cpu_->cycles() - prev_cpu_cycles_;\n      if (timer_b_counter_ <= 0)\n      {\n        if(timer_b_irq_enabled_)\n        {\n          timer_b_irq_triggered_ = true;\n          cpu_->nmi();\n        }\n        reset_timer_b();\n      }   \n      break;\n    case kModeCNT:\n      break;\n    case kModeTimerA:\n      break;\n    case kModeTimerACNT:\n      break;\n    }\n  }\n  prev_cpu_cycles_ = cpu_->cycles();\n  return true;\n}\n"
  },
  {
    "path": "src/cia2.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#ifndef EMUDORE_CIA2_H\n#define EMUDORE_CIA2_H\n\n#include \"io.h\"\n#include \"cpu.h\"\n\n/**\n * @brief MOS 6526 Complex Interface Adapter #2\n *\n * - Memory area : $DD00-$DDFF\n * - Tasks       : Serial bus, RS-232, VIC banking, NMI control\n */\nclass Cia2\n{\n  private:\n    Cpu *cpu_;\n    int16_t timer_a_latch_;\n    int16_t timer_b_latch_;\n    int16_t timer_a_counter_;\n    int16_t timer_b_counter_;\n    bool timer_a_enabled_;\n    bool timer_b_enabled_;\n    bool timer_a_irq_enabled_;\n    bool timer_b_irq_enabled_;\n    bool timer_a_irq_triggered_;\n    bool timer_b_irq_triggered_;\n    uint8_t timer_a_run_mode_;\n    uint8_t timer_b_run_mode_;\n    uint8_t timer_a_input_mode_;\n    uint8_t timer_b_input_mode_;\n    unsigned int prev_cpu_cycles_;\n    uint8_t pra_, prb_;        \n  public:\n    Cia2();\n    void cpu(Cpu *v){ cpu_ = v;};\n    void write_register(uint8_t r, uint8_t v);\n    uint8_t read_register(uint8_t r);\n    void reset_timer_a();\n    void reset_timer_b();\n    uint16_t vic_base_address();\n    bool emulate();\n    /* constants */\n    enum kInputMode\n    {\n      kModeProcessor,\n      kModeCNT,\n      kModeTimerA,\n      kModeTimerACNT\n    };\n    enum kRunMode\n    {\n      kModeRestart,\n      kModeOneTime\n    };                        \n};\n\n#endif\n"
  },
  {
    "path": "src/cpu.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"cpu.h\"\n#include \"util.h\"\n#include <sstream>\n\n/**\n * @brief Cold reset\n *\n * https://www.c64-wiki.com/index.php/Reset_(Process)\n */\nvoid Cpu::reset()\n{\n  a_ = x_ = y_ = sp_ = 0;\n  cf_ = zf_ = idf_ = dmf_ = bcf_ = of_ = nf_ = false;\n  pc(mem_->read_word(Memory::kAddrResetVector));\n  cycles_ = 6;\n}\n\n/** \n * @brief emulate instruction \n * @return returns false if something goes wrong (e.g. illegal instruction)\n *\n * Current limitations:\n * \n * - Illegal instructions are not implemented\n * - Excess cycles due to page boundary crossing are not calculated\n * - Some known architectural bugs are not emulated\n */\nbool Cpu::emulate()\n{\n  /* fetch instruction */\n  uint8_t insn = fetch_op();\n  bool retval = true;\n  /* emulate instruction */\n  switch(insn)\n  {\n  /* BRK */\n  case 0x0: brk(); break;\n  /* ORA (nn,X) */\n  case 0x1: ora(load_byte(addr_indx()),6); break;\n  /* ORA nn */\n  case 0x5: ora(load_byte(addr_zero()),3); break;\n  /* ASL nn */\n  case 0x6: asl_mem(addr_zero(),5); break;\n  /* PHP */\n  case 0x8: php(); break;\n  /* ORA #nn */\n  case 0x9: ora(fetch_op(),2); break;\n  /* ASL A */\n  case 0xA: asl_a(); break;\n  /* ORA nnnn */\n  case 0xD: ora(load_byte(addr_abs()),4); break;\n  /* ASL nnnn */\n  case 0xE: asl_mem(addr_abs(),6); break; \n  /* BPL nn */\n  case 0x10: bpl(); break;\n  /* ORA (nn,Y) */\n  case 0x11: ora(load_byte(addr_indy()),5); break;\n  /* ORA nn,X */\n  case 0x15: ora(load_byte(addr_zerox()),4); break;\n  /* ASL nn,X */\n  case 0x16: asl_mem(addr_zerox(),6); break;\n  /* CLC */\n  case 0x18: clc(); break;\n  /* ORA nnnn,Y */\n  case 0x19: ora(load_byte(addr_absy()),4); break;\n  /* ORA nnnn,X */\n  case 0x1D: ora(load_byte(addr_absx()),4); break;\n  /* ASL nnnn,X */\n  case 0x1E: asl_mem(addr_absx(),7); break;\n  /* JSR */\n  case 0x20: jsr(); break;\n  /* AND (nn,X) */\n  case 0x21: _and(load_byte(addr_indx()),6); break;\n  /* BIT nn */\n  case 0x24: bit(addr_zero(),3); break;\n  /* AND nn */\n  case 0x25: _and(load_byte(addr_zero()),3); break;\n  /* ROL nn */\n  case 0x26: rol_mem(addr_zero(),5); break;\n  /* PLP */\n  case 0x28: plp(); break;\n  /* AND #nn */\n  case 0x29: _and(fetch_op(),2); break;\n  /* ROL A */\n  case 0x2A: rol_a(); break;\n  /* BIT nnnn */\n  case 0x2C: bit(addr_abs(),4); break;\n  /* AND nnnn */\n  case 0x2D: _and(load_byte(addr_abs()),4); break;\n  /* ROL nnnn */\n  case 0x2E: rol_mem(addr_abs(),6); break;\n  /* BMI nn */\n  case 0x30: bmi(); break;\n  /* AND (nn,Y) */\n  case 0x31: _and(load_byte(addr_indy()),5); break;               \n  /* AND nn,X */\n  case 0x35: _and(load_byte(addr_zerox()),4); break;\n  /* ROL nn,X */\n  case 0x36: rol_mem(addr_zerox(),6); break;\n  /* SEC */\n  case 0x38: sec(); break;\n  /* AND nnnn,Y */\n  case 0x39: _and(load_byte(addr_absy()),4); break;\n  /* AND nnnn,X */\n  case 0x3D: _and(load_byte(addr_absx()),4); break;\n  /* ROL nnnn,X */\n  case 0x3E: rol_mem(addr_absx(),7); break;\n  /* RTI */\n  case 0x40: rti(); break;\n  /* EOR (nn,X) */\n  case 0x41: eor(load_byte(addr_indx()),6); break;\n  /* EOR nn */\n  case 0x45: eor(load_byte(addr_zero()),3); break;\n  /* LSR nn */\n  case 0x46: lsr_mem(addr_zero(),5); break;\n  /* PHA */\n  case 0x48: pha(); break;\n  /* EOR #nn */\n  case 0x49: eor(fetch_op(),2); break;\n  /* BVC */\n  case 0x50: bvc(); break;\n  /* JMP nnnn */\n  case 0x4C: jmp(); break;\n  /* EOR nnnn */\n  case 0x4D: eor(load_byte(addr_abs()),4); break;\n  /* LSR A */\n  case 0x4A: lsr_a(); break;\n  /* LSR nnnn */\n  case 0x4E: lsr_mem(addr_abs(),6); break;\n  /* EOR (nn,Y) */\n  case 0x51: eor(load_byte(addr_indy()),5); break;\n  /* EOR nn,X */\n  case 0x55: eor(load_byte(addr_zerox()),4); break;\n  /* LSR nn,X */\n  case 0x56: lsr_mem(addr_zerox(),6); break;\n  /* CLI */\n  case 0x58: cli(); break;\n  /* EOR nnnn,Y */\n  case 0x59: eor(load_byte(addr_absy()),4); break;\n  /* EOR nnnn,X */\n  case 0x5D: eor(load_byte(addr_absx()),4); break;\n  /* LSR nnnn,X */\n  case 0x5E: lsr_mem(addr_absx(),7); break;\n  /* RTS */\n  case 0x60: rts(); break;\n  /* ADC (nn,X) */\n  case 0x61: adc(load_byte(addr_indx()),6); break;\n  /* ADC nn */\n  case 0x65: adc(load_byte(addr_zero()),3); break;\n  /* ROR nn */\n  case 0x66: ror_mem(addr_zero(),5); break;\n  /* PLA */\n  case 0x68: pla(); break;\n  /* ADC #nn */\n  case 0x69: adc(fetch_op(),2); break;\n  /* ROR A */\n  case 0x6A: ror_a(); break;\n  /* JMP (nnnn) */\n  case 0x6C: jmp_ind(); break;\n  /* ADC nnnn */\n  case 0x6D: adc(load_byte(addr_abs()),4); break;\n  /* ROR nnnn */\n  case 0x6E: ror_mem(addr_abs(),6); break;\n  /* BVS */\n  case 0x70: bvs(); break;\n  /* ADC (nn,Y) */\n  case 0x71: adc(load_byte(addr_indy()),5); break;\n  /* ADC nn,X */\n  case 0x75: adc(load_byte(addr_zerox()),4); break;\n  /* ROR nn,X */\n  case 0x76: ror_mem(addr_zerox(),6); break;\n  /* SEI */\n  case 0x78: sei(); break;\n  /* ADC nnnn,Y */\n  case 0x79: adc(load_byte(addr_absy()),4); break;\n  /* ADC nnnn,X */\n  case 0x7D: adc(load_byte(addr_absx()),4); break;\n  /* ROR nnnn,X */\n  case 0x7E: ror_mem(addr_absx(),7); break;\n  /* STA (nn,X) */\n  case 0x81: sta(addr_indx(),6); break;\n  /* STY nn */\n  case 0x84: sty(addr_zero(),3); break;\n  /* STA nn */\n  case 0x85: sta(addr_zero(),3); break;\n  /* STX nn */\n  case 0x86: stx(addr_zero(),3); break;\n  /* DEY */\n  case 0x88: dey(); break;\n  /* TXA */\n  case 0x8A: txa(); break;\n  /* STY nnnn */\n  case 0x8C: sty(addr_abs(),4); break;\n  /* STA nnnn */\n  case 0x8D: sta(addr_abs(),4); break;\n  /* STX nnnn */\n  case 0x8E: stx(addr_abs(),4); break;\n  /* BCC nn */\n  case 0x90: bcc(); break;\n  /* STA (nn,Y) */\n  case 0x91: sta(addr_indy(),6); break;\n  /* STY nn,X */\n  case 0x94: sty(addr_zerox(),4); break;\n  /* STA nn,X */\n  case 0x95: sta(addr_zerox(),4); break;\n  /* STX nn,Y */\n  case 0x96: stx(addr_zeroy(),4); break;\n  /* TYA */\n  case 0x98: tya(); break;\n  /* STA nnnn,Y */\n  case 0x99: sta(addr_absy(),5); break;\n  /* TXS */\n  case 0x9A: txs(); break;\n  /* STA nnnn,X */\n  case 0x9D: sta(addr_absx(),5); break;\n  /* LDY #nn */\n  case 0xA0: ldy(fetch_op(),2); break; \n  /* LDA (nn,X) */\n  case 0xA1: lda(load_byte(addr_indx()),6); break;\n  /* LDX #nn */\n  case 0xA2: ldx(fetch_op(),2); break;\n  /* LDY nn */\n  case 0xA4: ldy(load_byte(addr_zero()),3); break;\n  /* LDA nn */\n  case 0xA5: lda(load_byte(addr_zero()),3); break;\n  /* LDX nn */\n  case 0xA6: ldx(load_byte(addr_zero()),3); break;\n  /* TAY */\n  case 0xA8: tay(); break;\n  /* LDA #nn */\n  case 0xA9: lda(fetch_op(),2); break;\n  /* TAX */\n  case 0xAA: tax(); break;\n  /* LDY nnnn */\n  case 0xAC: ldy(load_byte(addr_abs()),4); break;\n  /* LDA nnnn */\n  case 0xAD: lda(load_byte(addr_abs()),4); break;\n  /* LDX nnnn */\n  case 0xAE: ldx(load_byte(addr_abs()),4); break;\n  /* BCS nn */\n  case 0xB0: bcs(); break;\n  /* LDA (nn,Y) */\n  case 0xB1: lda(load_byte(addr_indy()),5); break;\n  /* LDY nn,X */\n  case 0xB4: ldy(load_byte(addr_zerox()),3); break;\n  /* LDA nn,X */\n  case 0xB5: lda(load_byte(addr_zerox()),3); break;\n  /* LDX nn,Y */\n  case 0xB6: ldx(load_byte(addr_zeroy()),3); break;\n  /* CLV */\n  case 0xB8: clv(); break;\n  /* LDA nnnn,Y */\n  case 0xB9: lda(load_byte(addr_absy()),4); break;\n  /* TSX */\n  case 0xBA: tsx(); break;\n  /* LDY nnnn,X */\n  case 0xBC: ldy(load_byte(addr_absx()),4); break;\n  /* LDA nnnn,X */\n  case 0xBD: lda(load_byte(addr_absx()),4); break;\n  /* LDX nnnn,Y */\n  case 0xBE: ldx(load_byte(addr_absy()),4); break;\n  /* CPY #nn */\n  case 0xC0: cpy(fetch_op(),2); break;\n  /* CMP (nn,X) */\n  case 0xC1: cmp(load_byte(addr_indx()),6); break;\n  /* CPY nn */\n  case 0xC4: cpy(load_byte(addr_zero()),3); break;\n  /* CMP nn */\n  case 0xC5: cmp(load_byte(addr_zero()),3); break;\n  /* DEC nn */\n  case 0xC6: dec(addr_zero(),5); break;\n  /* INY */\n  case 0xC8: iny(); break;\n  /* CMP #nn */\n  case 0xC9: cmp(fetch_op(),2); break;\n  /* DEX */\n  case 0xCA: dex(); break;\n  /* CPY nnnn */\n  case 0xCC: cpy(load_byte(addr_abs()),4); break;\n  /* CMP nnnn */\n  case 0xCD: cmp(load_byte(addr_abs()),4); break;\n  /* DEC nnnn */\n  case 0xCE: dec(addr_abs(),6); break;\n  /* BNE nn */\n  case 0xD0: bne(); break;\n  /* CMP (nn,Y) */\n  case 0xD1: cmp(load_byte(addr_indy()),5); break;\n  /* CMP nn,X */\n  case 0xD5: cmp(load_byte(addr_zerox()),4); break;\n  /* DEC nn,X */\n  case 0xD6: dec(addr_zerox(),6); break;\n  /* CLD */\n  case 0xD8: cld(); break;\n  /* CMP nnnn,Y */\n  case 0xD9: cmp(load_byte(addr_absy()),4); break;\n  /* CMP nnnn,X */\n  case 0xDD: cmp(load_byte(addr_absx()),4); break;\n  /* DEC nnnn,X */\n  case 0xDE: dec(addr_absx(),7); break;\n  /* CPX #nn */\n  case 0xE0: cpx(fetch_op(),2); break;\n  /* SBC (nn,X) */\n  case 0xE1: sbc(load_byte(addr_indx()),6); break;\n  /* CPX nn */\n  case 0xE4: cpx(load_byte(addr_zero()),3); break;\n  /* SBC nn */\n  case 0xE5: sbc(load_byte(addr_zero()),3); break;\n  /* INC nn */\n  case 0xE6: inc(addr_zero(),5); break;\n  /* INX */\n  case 0xE8: inx(); break;\n  /* SBC #nn */\n  case 0xE9: sbc(fetch_op(),2); break;\n  /* NOP */\n  case 0xEA: nop(); break;\n  /* CPX nnnn */\n  case 0xEC: cpx(load_byte(addr_abs()),4); break;\n  /* SBC nnnn */\n  case 0xED: sbc(load_byte(addr_abs()),4); break;\n  /* INC nnnn */\n  case 0xEE: inc(addr_abs(),6); break;\n  /* BEQ nn */\n  case 0xF0: beq(); break;\n  /* SBC (nn,Y) */\n  case 0xF1: sbc(load_byte(addr_indy()),5); break;\n  /* SBC nn,X */\n  case 0xF5: sbc(load_byte(addr_zerox()),4); break;\n  /* INC nn,X */\n  case 0xF6: inc(addr_zerox(),6); break;\n  /* SED */\n  case 0xF8: sed(); break;\n  /* SBC nnnn,Y */\n  case 0xF9: sbc(load_byte(addr_absy()),4); break;\n  /* SBC nnnn,X */\n  case 0xFD: sbc(load_byte(addr_absx()),4); break;\n  /* INC nnnn,X */\n  case 0xFE: inc(addr_absx(),7); break;\n  /* Unknown or illegal instruction */\n  default:\n    D(\"Unknown instruction: %X at %04x\\n\", insn,pc());\n    retval = false;\n  }\n  return retval;\n}\n\n// helpers ///////////////////////////////////////////////////////////////////\n\nuint8_t Cpu::load_byte(uint16_t addr)\n{\n  return mem_->read_byte(addr);\n}\n\nvoid Cpu::push(uint8_t v)\n{\n  uint16_t addr = Memory::kBaseAddrStack+sp_;\n  mem_->write_byte(addr,v);\n  sp_--;\n}\n\nuint8_t Cpu::pop()\n{\n  uint16_t addr = ++sp_+Memory::kBaseAddrStack;\n  return load_byte(addr);\n}\n \nuint8_t Cpu::fetch_op()\n{\n  return load_byte(pc_++);\n}\n\nuint16_t Cpu::fetch_opw()\n{\n  uint16_t retval = mem_->read_word(pc_);\n  pc_+=2;\n  return retval;\n}\n\nuint16_t Cpu::addr_zero()\n{\n  uint16_t addr = fetch_op();\n  return addr;\n}\n\nuint16_t Cpu::addr_zerox()\n{\n  /* wraps around the zeropage */\n  uint16_t addr = (fetch_op() + x()) & 0xff ;\n  return addr;\n}\n \nuint16_t Cpu::addr_zeroy()\n{\n  /* wraps around the zeropage */\n  uint16_t addr = (fetch_op() + y()) & 0xff;\n  return addr;\n}\n\nuint16_t Cpu::addr_abs()\n{\n  uint16_t addr = fetch_opw();\n  return addr;\n}\n\nuint16_t Cpu::addr_absy()\n{\n  uint16_t addr = fetch_opw() + y();\n  return addr;\n}\n\nuint16_t Cpu::addr_absx()\n{\n  uint16_t addr = fetch_opw() + x();\n  return addr;  \n}\n\nuint16_t Cpu::addr_indx()\n{\n  /* wraps around the zeropage */\n  uint16_t addr = mem_->read_word((addr_zero() + x()) & 0xff);\n  return addr;\n}\n\nuint16_t Cpu::addr_indy()\n{\n  uint16_t addr = mem_->read_word(addr_zero()) + y();\n  return addr;\n}\n\n// Instructions: data handling and memory operations  ////////////////////////\n\n/**\n * @brief STore Accumulator\n */\nvoid Cpu::sta(uint16_t addr, uint8_t cycles)\n{\n  mem_->write_byte(addr,a());\n  tick(cycles);\n}\n\n/**\n * @brief STore X\n */\nvoid Cpu::stx(uint16_t addr, uint8_t cycles)\n{\n  mem_->write_byte(addr,x());\n  tick(cycles);\n}\n\n/**\n * @brief STore Y\n */\nvoid Cpu::sty(uint16_t addr, uint8_t cycles)\n{\n  mem_->write_byte(addr,y());\n  tick(cycles);\n}\n\n/**\n * @brief Transfer X to Stack pointer\n */\nvoid Cpu::txs()\n{\n  sp(x());\n  tick(2);\n}\n\n/**\n * @brief Transfer Stack pointer to X\n */\nvoid Cpu::tsx()\n{\n  x(sp());\n  SET_ZF(x());\n  SET_NF(x());\n  tick(2);\n}\n\n/**\n * @brief LoaD Accumulator\n */\nvoid Cpu::lda(uint8_t v, uint8_t cycles)\n{\n  a(v);\n  SET_ZF(a());\n  SET_NF(a());\n  tick(cycles);\n}\n\n/**\n * @brief LoaD X\n */\nvoid Cpu::ldx(uint8_t v, uint8_t cycles)\n{\n  x(v);\n  SET_ZF(x());\n  SET_NF(x());\n  tick(cycles);\n}\n\n/**\n * @brief LoaD Y\n */\nvoid Cpu::ldy(uint8_t v, uint8_t cycles)\n{\n  y(v);\n  SET_ZF(y());\n  SET_NF(y());\n  tick(cycles);\n}\n\n/**\n * @brief Transfer X to Accumulator \n */\nvoid Cpu::txa()\n{\n  a(x());\n  SET_ZF(a());\n  SET_NF(a());\n  tick(2);\n}\n\n/**\n * @brief Transfer Accumulator to X \n */\nvoid Cpu::tax()\n{\n  x(a());\n  SET_ZF(x());\n  SET_NF(x());\n  tick(2);\n}\n\n/**\n * @brief Transfer Accumulator to Y \n */\nvoid Cpu::tay()\n{\n  y(a());\n  SET_ZF(y());\n  SET_NF(y());\n  tick(2);\n}\n\n/**\n * @brief Transfer Y to Accumulator \n */\nvoid Cpu::tya()\n{\n  a(y());\n  SET_ZF(a());\n  SET_NF(a());\n  tick(2);\n}\n\n/**\n * @brief PusH Accumulator \n */\nvoid Cpu::pha()\n{\n  push(a());\n  tick(3);\n}\n\n/**\n * @brief PuLl Accumulator \n */\nvoid Cpu::pla()\n{\n  a(pop());\n  SET_ZF(a());\n  SET_NF(a());\n  tick(4);\n}\n \n// Instructions: logic operations  ///////////////////////////////////////////\n\n/**\n * @brief Logical OR on Accumulator\n */\nvoid Cpu::ora(uint8_t v, uint8_t cycles)\n{\n  a(a()|v);\n  SET_ZF(a());\n  SET_NF(a());\n  tick(cycles);\n}\n\n/**\n * @brief Logical AND\n */\nvoid Cpu::_and(uint8_t v, uint8_t cycles)\n{\n  a(a()&v);\n  SET_ZF(a());\n  SET_NF(a());\n  tick(cycles);\n}\n\n/**\n * @brief BIT test\n */\nvoid Cpu::bit(uint16_t addr, uint8_t cycles)\n{\n  uint8_t t = load_byte(addr);\n  of((t&0x40)!=0);\n  SET_NF(t);\n  SET_ZF(t&a());\n  tick(cycles);\n}\n \n/**\n * @brief ROtate Left\n */\nuint8_t Cpu::rol(uint8_t v)\n{\n  uint16_t t = (v << 1) | (uint8_t)cf();\n  cf((t&0x100)!=0);\n  SET_ZF(t);\n  SET_NF(t);\n  return (uint8_t)t;\n}\n\n/** \n * @brief ROL A register\n */\nvoid Cpu::rol_a()\n{\n  a(rol(a()));\n  tick(2);\n}\n\n/**\n * @brief ROL mem \n */\nvoid Cpu::rol_mem(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  /* see ASL doc */\n  mem_->write_byte(addr,v);\n  mem_->write_byte(addr,rol(v));\n  tick(cycles);\n}\n\n/**\n * @brief ROtate Right\n */\nuint8_t Cpu::ror(uint8_t v)\n{\n  uint16_t t = (v >> 1) | (uint8_t)(cf() << 7);\n  cf((v&0x1)!=0);\n  SET_ZF(t);\n  SET_NF(t);\n  return (uint8_t)t;\n}\n\n/** \n * @brief ROR A register\n */\nvoid Cpu::ror_a()\n{\n  a(ror(a()));\n  tick(2);\n}\n\n/**\n * @brief ROR mem \n */\nvoid Cpu::ror_mem(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  /* see ASL doc */\n  mem_->write_byte(addr,v);\n  mem_->write_byte(addr,ror(v));\n  tick(cycles);\n}       \n\n/**\n * @brief Logic Shift Right\n */\nuint8_t Cpu::lsr(uint8_t v)\n{\n  uint8_t t = v >> 1;\n  cf((v&0x1)!=0);\n  SET_ZF(t);\n  SET_NF(t);\n  return t;\n}\n\n/** \n * @brief LSR A\n */\nvoid Cpu::lsr_a()\n{\n  a(lsr(a()));\n  tick(2);\n}\n\n/**\n * @brief LSR mem\n */\nvoid Cpu::lsr_mem(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  /* see ASL doc */\n  mem_->write_byte(addr,v);\n  mem_->write_byte(addr,lsr(v));\n  tick(cycles);\n}\n\n/**\n * @brief Arithmetic Shift Left\n */\nuint8_t Cpu::asl(uint8_t v)\n{\n  uint8_t t = (v << 1) & 0xff;\n  cf((v&0x80)!=0);\n  SET_ZF(t);\n  SET_NF(t);\n  return t;\n}\n\n/** \n * @brief ASL A\n */\nvoid Cpu::asl_a()\n{\n  a(asl(a()));\n  tick(2);\n}\n\n/**\n * @brief ASL mem \n *\n * ASL and the other read-modify-write instructions contain a bug (wikipedia):\n *\n * --\n * The 6502's read-modify-write instructions perform one read and two write \n * cycles. First the unmodified data that was read is written back, and then \n * the modified data is written. This characteristic may cause issues by \n * twice accessing hardware that acts on a write. This anomaly continued \n * through the entire NMOS line, but was fixed in the CMOS derivatives, in \n * which the processor will do two reads and one write cycle. \n * --\n *\n * I have come across code that uses this side-effect as a feature, for\n * instance, the following instruction will acknowledge VIC interrupts \n * on the first write cycle:\n *\n * ASL $d019\n *\n * So.. we need to mimic the behaviour.\n */\nvoid Cpu::asl_mem(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  mem_->write_byte(addr,v); \n  mem_->write_byte(addr,asl(v));\n  tick(cycles);\n} \n\n/**\n * @brief Exclusive OR \n */\nvoid Cpu::eor(uint8_t v, uint8_t cycles)\n{\n  a(a()^v);\n  SET_ZF(a());\n  SET_NF(a());\n  tick(cycles);\n}\n \n// Instructions: arithmetic operations  //////////////////////////////////////\n\n/**\n * @brief INCrement\n */\nvoid Cpu::inc(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  /* see ASL doc */\n  mem_->write_byte(addr,v);\n  v++;\n  mem_->write_byte(addr,v);\n  SET_ZF(v);\n  SET_NF(v);\n}\n\n/**\n * @brief DECrement\n */\nvoid Cpu::dec(uint16_t addr, uint8_t cycles)\n{\n  uint8_t v = load_byte(addr);\n  /* see ASL doc */\n  mem_->write_byte(addr,v);\n  v--;\n  mem_->write_byte(addr,v);\n  SET_ZF(v);\n  SET_NF(v);\n}\n\n/**\n * @brief INcrement X\n */\nvoid Cpu::inx()\n{\n  x_+=1;\n  SET_ZF(x());\n  SET_NF(x());\n  tick(2);\n}\n\n/**\n * @brief INcrement Y\n */\nvoid Cpu::iny()\n{\n  y_+=1;\n  SET_ZF(y());\n  SET_NF(y());\n  tick(2);\n}\n\n/**\n * @brief DEcrement X\n */\nvoid Cpu::dex()\n{\n  x_-=1;\n  SET_ZF(x());\n  SET_NF(x());\n  tick(2);\n}\n\n/**\n * @brief DEcrement Y\n */\nvoid Cpu::dey()\n{\n  y_-=1;\n  SET_ZF(y());\n  SET_NF(y());\n  tick(2);\n}\n\n/**\n * @brief ADd with Carry\n */\nvoid Cpu::adc(uint8_t v, uint8_t cycles)\n{\n  uint16_t t;\n  if(dmf())\n  {\n    t = (a()&0xf) + (v&0xf) + (cf() ? 1 : 0);\n    if (t > 0x09) \n      t += 0x6;\n    t += (a()&0xf0) + (v&0xf0);\n    if((t & 0x1f0) > 0x90) \n      t += 0x60;\n  }\n  else\n  {\n    t = a() + v + (cf() ? 1 : 0);\n  }\n  cf(t>0xff);\n  t=t&0xff;\n  of(!((a()^v)&0x80) && ((a()^t) & 0x80));\n  SET_ZF(t);\n  SET_NF(t);\n  a((uint8_t)t);\n}\n\n/**\n * @brief SuBstract with Carry\n */\nvoid Cpu::sbc(uint8_t v, uint8_t cycles)\n{\n  uint16_t t;\n  if(dmf())\n  {\n    t = (a()&0xf) - (v&0xf) - (cf() ? 0 : 1);\n    if((t & 0x10) != 0)\n      t = ((t-0x6)&0xf) | ((a()&0xf0) - (v&0xf0) - 0x10);\n    else\n      t = (t&0xf) | ((a()&0xf0) - (v&0xf0));\n    if((t&0x100)!=0)\n      t -= 0x60;\n  }\n  else\n  {\n    t = a() - v - (cf() ? 0 : 1);\n  }\n  cf(t<0x100);\n  t=t&0xff;\n  of(((a()^t)&0x80) && ((a()^v) & 0x80));\n  SET_ZF(t);\n  SET_NF(t);\n  a((uint8_t)t);\n}\n \n// Instructions: flag access ///////////////////////////////////////////////// \n\n/** \n * @brief SEt Interrupt flag\n */\nvoid Cpu::sei()\n{\n  idf(true);\n  tick(2);\n}\n\n/**\n * @brief CLear Interrupt flag\n */\nvoid Cpu::cli()\n{\n  idf(false);\n  tick(2);\n}\n\n/**\n * @brief SEt Carry flag \n */\nvoid Cpu::sec()\n{\n  cf(true);\n  tick(2);\n}\n \n/**\n * @brief CLear Carry flag \n */\nvoid Cpu::clc()\n{\n  cf(false);\n  tick(2);\n}\n\n/**\n * @brief SEt Decimal flag \n */\nvoid Cpu::sed()\n{\n  dmf(true);\n  tick(2);\n}\n \n/**\n * @brief CLear Decimal flag \n */\nvoid Cpu::cld()\n{\n  dmf(false);\n  tick(2);\n}\n\n/**\n * @brief CLear oVerflow flag \n */\nvoid Cpu::clv()\n{\n  of(false);\n  tick(2);\n}\n\nuint8_t Cpu::flags()\n{\n  uint8_t v=0;\n  v |= cf()  << 0;\n  v |= zf()  << 1;\n  v |= idf() << 2;\n  v |= dmf() << 3;\n  /* brk & php instructions push the bcf flag active */\n  v |= 1 << 4;\n  /* unused, always set */\n  v |= 1     << 5;\n  v |= of()  << 6;\n  v |= nf()  << 7;\n  return v;\n}\n\nvoid Cpu::flags(uint8_t v)\n{\n  cf(ISSET_BIT(v,0));\n  zf(ISSET_BIT(v,1));\n  idf(ISSET_BIT(v,2));\n  dmf(ISSET_BIT(v,3));\n  of(ISSET_BIT(v,6));\n  nf(ISSET_BIT(v,7));     \n}\n\n/**\n * @brief PusH Processor flags\n */\nvoid Cpu::php()\n{\n  push(flags());\n  tick(3);\n}\n\n/**\n * @brief PuLl Processor flags\n */\nvoid Cpu::plp()\n{\n  flags(pop());\n  tick(4);\n}\n\n/**\n * @brief Jump to SubRoutine\n * \n * Note that JSR does not push the address of the next instruction\n * to the stack but the address to the last byte of its own \n * instruction.\n */\nvoid Cpu::jsr()\n{\n  uint16_t addr = addr_abs();\n  push(((pc()-1) >> 8) & 0xff);\n  push(((pc()-1) & 0xff));\n  pc(addr);\n  tick(6);\n}\n\n/**\n * @brief JuMP\n */\nvoid Cpu::jmp()\n{\n  uint16_t addr = addr_abs();\n  pc(addr);\n  tick(3);\n}\n\n/**\n * @brief JuMP (indirect)\n */\nvoid Cpu::jmp_ind()\n{\n  uint16_t addr = mem_->read_word(addr_abs());\n  pc(addr);\n  tick(3);    \n}\n \n/**\n * @brief ReTurn from SubRoutine\n */\nvoid Cpu::rts()\n{\n  uint16_t addr = (pop() + (pop() << 8)) + 1;\n  pc(addr);\n  tick(6);\n}\n\n/** \n * @brief Branch if Not Equal\n */\nvoid Cpu::bne()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(!zf()) pc(addr);\n  tick(2);\n}\n\n/** \n * @brief CoMPare\n */\nvoid Cpu::cmp(uint8_t v, uint8_t cycles)\n{\n  uint16_t t;\n  t = a() - v;\n  cf(t<0x100);\n  t = t&0xff;\n  SET_ZF(t);\n  SET_NF(t);\n  tick(cycles);\n}\n\n/** \n * @brief CoMPare X\n */\nvoid Cpu::cpx(uint8_t v, uint8_t cycles)\n{\n  uint16_t t;\n  t = x() - v;\n  cf(t<0x100);\n  t = t&0xff;\n  SET_ZF(t);\n  SET_NF(t);\n  tick(cycles);\n}\n\n/** \n * @brief CoMPare Y\n */\nvoid Cpu::cpy(uint8_t v, uint8_t cycles)\n{\n  uint16_t t;\n  t = y() - v;\n  cf(t<0x100);\n  t = t&0xff;\n  SET_ZF(t);\n  SET_NF(t);\n  tick(cycles);\n}\n \n/** \n * @brief Branch if Equal\n */\nvoid Cpu::beq()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(zf()) pc(addr);\n  tick(2);\n}\n\n/** \n * @brief Branch if Carry is Set\n */\nvoid Cpu::bcs()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(cf()) pc(addr);\n  tick(2);\n}\n\n/** \n * @brief Branch if Carry is Clear\n */\nvoid Cpu::bcc()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(!cf()) pc(addr);\n  tick(2);\n}\n \n/**\n * @brief, Branch if PLus\n */\nvoid Cpu::bpl()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(!nf()) pc(addr);\n  tick(2);\n}\n\n/**\n * @brief Branch if MInus\n */\nvoid Cpu::bmi()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(nf()) pc(addr);\n  tick(2);    \n}\n\n/**\n * @brief Branch if oVerflow Clear\n */\nvoid Cpu::bvc()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(!of()) pc(addr);\n  tick(2);    \n}\n\n/**\n * @brief Branch if oVerflow Set\n */\nvoid Cpu::bvs()\n{\n  uint16_t addr = (int8_t) fetch_op() + pc();\n  if(of()) pc(addr);\n  tick(2);    \n}\n\n// misc //////////////////////////////////////////////////////////////////////\n\n/**\n * @brief No OPeration\n */\nvoid Cpu::nop()\n{\n  tick(2);\n}\n\n/**\n * @brief BReaKpoint\n */\nvoid Cpu::brk()\n{\n  push(((pc()+1) >> 8) & 0xff);\n  push(((pc()+1) & 0xff));\n  push(flags());\n  pc(mem_->read_word(Memory::kAddrIRQVector));\n  idf(true);\n  bcf(true);\n  tick(7);\n}\n\n/**\n * @brief ReTurn from Interrupt \n */\nvoid Cpu::rti()\n{\n  flags(pop());\n  pc(pop() + (pop() << 8));\n  tick(7);\n}\n\n// interrupts  ///////////////////////////////////////////////////////////////\n\n/**\n * @brief Interrupt ReQuest\n */\nvoid Cpu::irq()\n{\n  if(!idf())\n  {\n    push(((pc()) >> 8) & 0xff);\n    push(((pc()) & 0xff));\n    /* push flags with bcf cleared */\n    push((flags()&0xef));\n    pc(mem_->read_word(Memory::kAddrIRQVector));\n    idf(true);\n    tick(7);\n  }\n}\n\n/**\n * @brief Non Maskable Interrupt\n */\nvoid Cpu::nmi()\n{\n  push(((pc()) >> 8) & 0xff);\n  push(((pc()) & 0xff));\n  /* push flags with bcf cleared */\n  push((flags() & 0xef));\n  pc(mem_->read_word(Memory::kAddrNMIVector));\n  tick(7);\n}\n\n// debugging /////////////////////////////////////////////////////////////////\n\nvoid Cpu::dump_regs()\n{\n  std::stringstream sflags;\n  if(cf())  sflags << \"CF \";\n  if(zf())  sflags << \"ZF \";\n  if(idf()) sflags << \"IDF \";\n  if(dmf()) sflags << \"DMF \";\n  if(bcf()) sflags << \"BCF \";\n  if(of())  sflags << \"OF \";\n  if(nf())  sflags << \"NF \";\n  D(\"pc=%04x, a=%02x x=%02x y=%02x sp=%02x flags= %s\\n\",\n    pc(),a(),x(),y(),sp(),sflags.str().c_str());\n}\n\nvoid Cpu::dump_regs_json()\n{\n  D(\"{\");\n  D(\"\\\"pc\\\":%d,\",pc());\n  D(\"\\\"a\\\":%d,\",a());\n  D(\"\\\"x\\\":%d,\",x());\n  D(\"\\\"y\\\":%d,\",y());\n  D(\"\\\"sp\\\":%d\",sp());\n  D(\"}\\n\");\n}\n"
  },
  {
    "path": "src/cpu.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef EMUDORE_CPU_H\n#define EMUDORE_CPU_H\n\n#include <cstdint>\n#include \"memory.h\"\n\n/**\n * @brief MOS 6510 microprocessor\n */\nclass Cpu\n{\n  private:\n    /* registers */\n    uint16_t pc_;\n    uint8_t sp_, a_, x_, y_;\n    /* flags (p/status reg) */\n    bool cf_,zf_,idf_,dmf_,bcf_,of_,nf_;\n    /* memory and clock */\n    Memory *mem_;\n    unsigned int cycles_;\n    /* helpers */\n    inline uint8_t load_byte(uint16_t addr);\n    inline void push(uint8_t);\n    inline uint8_t pop();\n    inline uint8_t fetch_op();\n    inline uint16_t fetch_opw();\n    inline uint16_t addr_zero();\n    inline uint16_t addr_zerox();\n    inline uint16_t addr_zeroy();\n    inline uint16_t addr_abs();\n    inline uint16_t addr_absy();\n    inline uint16_t addr_absx();\n    inline uint16_t addr_indx();\n    inline uint16_t addr_indy();\n    inline uint8_t rol(uint8_t v);\n    inline uint8_t ror(uint8_t v);\n    inline uint8_t lsr(uint8_t v);\n    inline uint8_t asl(uint8_t v);\n    inline void tick(uint8_t v){cycles_+=v;};\n    inline uint8_t flags();\n    inline void flags(uint8_t v);\n    /* instructions : data handling and memory operations */\n    inline void sta(uint16_t addr, uint8_t cycles);\n    inline void stx(uint16_t addr, uint8_t cycles);\n    inline void sty(uint16_t addr, uint8_t cycles);\n    inline void lda(uint8_t v, uint8_t cycles);\n    inline void ldx(uint8_t v, uint8_t cycles);\n    inline void ldy(uint8_t v, uint8_t cycles);\n    inline void txs();\n    inline void tsx();\n    inline void tax();\n    inline void txa();\n    inline void tay();\n    inline void tya();\n    inline void pha();\n    inline void pla();\n    /* instructions: logic operations */\n    inline void ora(uint8_t v, uint8_t cycles);\n    inline void _and(uint8_t v, uint8_t cycles);\n    inline void bit(uint16_t addr, uint8_t cycles);\n    inline void rol_a();\n    inline void rol_mem(uint16_t addr, uint8_t cycles);\n    inline void ror_a();\n    inline void ror_mem(uint16_t addr, uint8_t cycles);\n    inline void asl_a();\n    inline void asl_mem(uint16_t addr, uint8_t cycles);\n    inline void lsr_a();\n    inline void lsr_mem(uint16_t addr, uint8_t cycles);\n    inline void eor(uint8_t v, uint8_t cycles);\n    /* instructions: arithmetic operations */\n    inline void inc(uint16_t addr, uint8_t cycles);\n    inline void dec(uint16_t addr, uint8_t cycles);\n    inline void inx();\n    inline void iny();\n    inline void dex();\n    inline void dey();\n    inline void adc(uint8_t v, uint8_t cycles);\n    inline void sbc(uint8_t v, uint8_t cycles);\n    /* instructions: flag access */\n    inline void sei();\n    inline void cli();\n    inline void sec();\n    inline void clc();\n    inline void sed();\n    inline void cld();\n    inline void clv();\n    inline void php();\n    inline void plp();\n    /* instructions: control flow */\n    inline void cmp(uint8_t v, uint8_t cycles);\n    inline void cpx(uint8_t v, uint8_t cycles);\n    inline void cpy(uint8_t v, uint8_t cycles);\n    inline void rts();\n    inline void jsr();\n    inline void bne();\n    inline void beq();\n    inline void bcs();\n    inline void bcc();\n    inline void bpl();\n    inline void bmi();\n    inline void bvc();\n    inline void bvs();\n    inline void jmp();\n    inline void jmp_ind();\n    /* instructions: misc */\n    inline void nop();\n    inline void brk();\n    inline void rti();\n  public:\n    /* cpu state */\n    void reset();\n    bool emulate();\n    /* memory */\n    void memory(Memory *v){mem_ = v;};\n    Memory* memory(){return mem_;};\n    /* register access */\n    inline uint16_t pc() {return pc_;};\n    inline void pc(uint16_t v) {pc_=v;};\n    inline uint8_t sp() {return sp_;};\n    inline void sp(uint8_t v) {sp_=v;};\n    inline uint8_t a() {return a_;};\n    inline void a(uint8_t v) {a_=v;};\n    inline uint8_t x() {return x_;};\n    inline void x(uint8_t v) {x_=v;};\n    inline uint8_t y() {return y_;};\n    inline void y(uint8_t v) {y_=v;};\n    /* flags */\n    inline bool cf() {return cf_;};\n    inline void cf(bool v) { cf_=v;};\n    inline bool zf() {return zf_;};\n    inline void zf(bool v) {zf_=v;};\n    inline bool idf() {return idf_;};\n    inline void idf(bool v) { idf_=v;};\n    inline bool dmf() {return dmf_;};\n    inline void dmf(bool v) { dmf_=v;};\n    inline bool bcf() {return bcf_;};\n    inline void bcf(bool v) { bcf_=v;};\n    inline bool of() {return of_;};\n    inline void of(bool v) { of_=v;};\n    inline bool nf() {return nf_;};\n    inline void nf(bool v) {nf_=v;};\n    /* clock */\n    inline unsigned int cycles(){return cycles_;};\n    inline void cycles(unsigned int v){cycles_=v;};\n    /* interrupts */\n    void nmi();\n    void irq();\n    /* debug */\n    void dump_regs();\n    void dump_regs_json();\n};\n\n/* macro helpers */\n\n#define SET_ZF(val)     (zf(!(uint8_t)(val)))\n#define SET_NF(val)     (nf(((uint8_t)(val)&0x80)!=0))\n\n#endif\n"
  },
  {
    "path": "src/debugger.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <fcntl.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n\n#include <string>\n#include <sstream>\n#include <iomanip>\n#include <iostream>\n#include <stdexcept>\n\n#include \"util.h\"\n#include \"debugger.h\"\n\nDebugger::Debugger()\n{\n  int e = 1;\n  offset_ = 0;\n  struct sockaddr_in serv_addr;\n  /* SOCK_NONBLOCK requires a Linux kernel >= 2.6.27 */\n#ifdef SOCK_NONBLOCK\n  ss_ = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);\n#else\n  ss_ = socket(AF_INET, SOCK_STREAM,0);\n  fcntl(ss_, F_SETFL, fcntl(ss_, F_GETFL, 0) | O_NONBLOCK);\n#endif\n  if(ss_ < 0)\n  {\n    D(\"Debuggger: Error opening socket\\n\");\n    exit(1);\n  }\n  setsockopt(ss_, SOL_SOCKET, SO_REUSEADDR, &e, sizeof(int)); \n  bzero((char *) &serv_addr, sizeof(serv_addr));\n  /* init socket struct */\n  serv_addr.sin_family      = AF_INET;\n  serv_addr.sin_addr.s_addr = INADDR_ANY;\n  serv_addr.sin_port        = htons(kDbgPort);\n  /* bind */\n  if (bind(ss_, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)\n  {\n    D(\"Debugger: ERROR binding\\n\");\n    exit(1);\n  }\n  /* listen */\n  listen(ss_ , 3);\n}\n\nDebugger::~Debugger()\n{\n  close(ss_);\n}\n\nstd::vector<std::string> Debugger::split_cmd(const std::string &s)\n{\n  const char c = ' '; \n  std::string buff{\"\"};\n  std::vector<std::string> v;\n  for(auto n:s)\n  {\n    if(n != c) buff+=n; else\n    if(n == c && buff != \"\") { v.push_back(buff); buff = \"\"; }\n  }\n  if(buff != \"\") v.push_back(buff);\n  return v;\n}\n\nuint16_t Debugger::emu_seek(uint16_t offset, int whence)\n{\n  switch(whence)\n  {\n  case SEEK_SET:\n    offset_ = offset; \n    break;\n  case SEEK_CUR:\n    offset_ = offset + offset_;\n    break;\n  case SEEK_END:\n    offset_ = 0xffff + offset;\n    break;\n  }\n  return offset_;\n}\n\nuint8_t * Debugger::emu_read_mem(size_t sz)\n{\n  uint8_t *mem = (uint8_t *) malloc(sz);\n  for(size_t i = 0 ; i < sz ; i++)\n    mem[i] = mem_->read_byte(offset_ + i);\n  return mem;\n}\n\nvoid Debugger::emu_write_mem(uint8_t *mem, size_t sz)\n{\n  for(size_t i = 0 ; i < sz ; i++)\n  {\n    mem_->write_byte(offset_++,mem[i]);\n  }\n}\n\nstd::string Debugger::regs_cmd()\n{\n  std::stringstream v;\n  v << std::hex << std::setfill('0');\n  v << \"a = 0x\" << std::setw(2) << (unsigned int) cpu_->a() << \"\\n\";\n  v << \"x = 0x\" << std::setw(2) << (unsigned int) cpu_->x() << \"\\n\";\n  v << \"y = 0x\" << std::setw(2) << (unsigned int) cpu_->y() << \"\\n\";\n  v << \"sp = 0x\" << std::setw(2) << (unsigned int) cpu_->sp() << \"\\n\";\n  v << \"pc = 0x\" << std::setw(4) << (unsigned int) cpu_->pc() << \"\\n\";\n  v << \"flags = \";\n  if(cpu_->cf())  v << \"cf \";\n  if(cpu_->zf())  v << \"zf \";\n  if(cpu_->idf()) v << \"idf \";\n  if(cpu_->dmf()) v << \"dmf \";\n  if(cpu_->bcf()) v << \"bcf \";\n  if(cpu_->of())  v << \"of \";\n  if(cpu_->nf())  v << \"nf \";\n  v << \"\\n\";\n  return v.str();\n}\n\nstd::string Debugger::emu_handle_cmd(const std::string &s)\n{\n  std::vector<std::string> args = split_cmd(s);\n  std::string r(\"\");\n  try\n  {\n    if(args.at(0) == \"dr\")\n      r = regs_cmd();\n  }\n  catch(const std::out_of_range){}\n  return r;\n}\n\nbool Debugger::emulate()\n{ \n  int sockfd;\n  struct sockaddr_in sa;\n  socklen_t sl = sizeof(sa);\n  /* non blocking */\n  sockfd = accept(ss_, (struct sockaddr *)&sa, &sl);\n  if(sockfd > 0)\n  {\n    /* unset fd's O_NONBLOCK flag\n     * on Linux reading from the fd seems to block while\n     * on OSX it seems to inherit the socket's non-blocking flag\n     */\n    fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) &~ O_NONBLOCK);\n    D(\"Debugger: client connected\\n\");\n    /* emulation paused while debugger is connected */\n    while(1)\n    {    \n      int whence;\n      uint8_t *mem;\n      uint32_t sz;\n      uint64_t offset;\n      uint8_t buff[kMaxCmdLen];\n      std::string r;\n      /* continue emulation if debugger disconnected */\n      if(!recv(sockfd,buff,1,0))\n      {\n        D(\"Debugger: client disconnected\\n\");\n        break;\n      }\n      switch(buff[0])\n      {\n      case RAP_RMT_OPEN:\n        recv(sockfd,&buff[1],2,0);\n        recv(sockfd,&buff[3],(int)buff[2],0);\n        buff[0] = RAP_RMT_OPEN | RAP_RMT_REPLY;\n        send(sockfd,buff,5,0);\n        break;\n      case RAP_RMT_SEEK:\n        recv(sockfd,&buff[1],9,0);\n        whence = buff[1];\n        offset = ntohll(*(uint64_t*)&buff[2]);\n        offset = htonll(emu_seek((uint16_t)offset,whence));\n        buff[0] = RAP_RMT_SEEK | RAP_RMT_REPLY;\n        send(sockfd,buff,1,0);\n        send(sockfd,&offset,8,0);\n        break;\n      case RAP_RMT_READ:\n        recv(sockfd,&buff[1],4,0);\n        sz = ntohl(*(uint32_t*)&buff[1]);\n        buff[0] = RAP_RMT_READ | RAP_RMT_REPLY;\n        mem = emu_read_mem(sz);\n        send(sockfd,buff,5,0);\n        send(sockfd,mem,sz,0);\n        free(mem);\n        break;\n      case RAP_RMT_WRITE:\n        recv(sockfd,&buff[1],4,0);\n        sz = ntohl(*(uint32_t*)&buff[1]);\n        recv(sockfd,&buff[5],sz,0);\n        emu_write_mem(&buff[5],sz);\n        buff[0] = RAP_RMT_WRITE | RAP_RMT_REPLY;\n        send(sockfd,buff,5,0);\n        break;\n      case RAP_RMT_CMD:\n        recv(sockfd,&buff[1],4,0);\n        sz = ntohl(*(uint32_t*)&buff[1]);\n        recv(sockfd,&buff[5],sz,0);\n        r = emu_handle_cmd(std::string((char*)&buff[5],(size_t)(sz-1)));\n        *(uint32_t*)(&buff[1]) = htonl(r.length());\n        buff[0] = RAP_RMT_CMD | RAP_RMT_REPLY;\n        send(sockfd,buff,5,0);\n        send(sockfd,r.c_str(),r.length(),0);\n        break;\n      default:\n        D(\"Debugger: Unknown command %x\\n\",buff[0]);\n        break;\n      }\n    }\n  }\n  return true;\n}\n"
  },
  {
    "path": "src/debugger.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#ifndef EMUDORE_DEBUGGER_H\n#define EMUDORE_DEBUGGER_H\n\n/**\n * @brief Debugger\n *\n * Sponsored by radare2\n * \n * https://github.com/radare/radare2\n */\n\n#include \"cpu.h\"\n#include \"memory.h\"\n\n#include <vector>\n#include <string>\n\nclass Debugger\n{\n  private:\n    int ss_;\n    uint16_t offset_;\n    Cpu *cpu_;\n    Memory *mem_;\n    uint16_t emu_seek(uint16_t offset, int whence);\n    uint8_t * emu_read_mem(size_t sz);\n    std::string emu_handle_cmd(const std::string &s);\n    void emu_write_mem(uint8_t *mem, size_t sz);\n    std::vector<std::string> split_cmd(const std::string &s);\n    std::string regs_cmd();\n  public:\n    Debugger();\n    ~Debugger();\n    void cpu(Cpu *v){cpu_=v;};\n    void memory(Memory *v){mem_=v;};\n    bool emulate();\n    static const int kDbgPort = 9999;\n    static const int kMaxCmdLen = 256;\n    enum kDbgCommands{\n      RAP_RMT_OPEN = 0x01,\n      RAP_RMT_READ,\n      RAP_RMT_WRITE,\n      RAP_RMT_SEEK,\n      RAP_RMT_CLOSE,\n      RAP_RMT_CMD,\n      RAP_RMT_REPLY = 0x80,\n      RAP_RMT_MAX = 4096\n    };\n};\n\n#endif\n"
  },
  {
    "path": "src/io.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <stdexcept>\n#include \"io.h\"\n#include \"vic.h\"\n\n// clas ctor and dtor //////////////////////////////////////////////////////////\n\nIO::IO()\n{\n  SDL_Init(SDL_INIT_VIDEO);\n  /**\n   * We create the window double the original pixel size, \n   * the renderer takes care of upscaling \n   */\n  window_ = SDL_CreateWindow(\n        \"emudore\",\n        SDL_WINDOWPOS_UNDEFINED,\n        SDL_WINDOWPOS_UNDEFINED,\n        Vic::kVisibleScreenWidth * 2,\n        Vic::kVisibleScreenHeight * 2,\n        SDL_WINDOW_OPENGL\n  );\n  cols_ = Vic::kVisibleScreenWidth;\n  rows_ = Vic::kVisibleScreenHeight;\n  /* use a single texture and hardware acceleration */\n  renderer_ = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED);\n  texture_  = SDL_CreateTexture(renderer_,\n                                SDL_PIXELFORMAT_ARGB8888,\n                                SDL_TEXTUREACCESS_STREAMING,\n                                cols_,\n                                rows_);\n  format_ = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888);\n  /**\n   * unfortunately, we need to keep a copy of the rendered frame \n   * in our own memory, there does not seem to be a way around \n   * that would allow manipulating pixels straight on the GPU \n   * memory due to how the image is internally stored, etc..\n   *\n   * The rendered frame gets uploaded to the GPU on every \n   * screen refresh.\n   */\n  frame_  = new uint32_t[cols_ * rows_]();\n  init_color_palette();\n  init_keyboard();\n  next_key_event_at_ = 0;\n  prev_frame_was_at_ = std::chrono::high_resolution_clock::now();\n}\n\nIO::~IO()\n{\n  delete [] frame_;\n  SDL_DestroyRenderer(renderer_);\n  SDL_DestroyTexture(texture_);\n  SDL_FreeFormat(format_);\n  SDL_Quit();\n}\n\n// init io devices  ////////////////////////////////////////////////////////////\n\n/**\n * @brief init keyboard state and keymap\n */\nvoid IO::init_keyboard()\n{\n  /* init keyboard matrix state */\n  for(size_t i=0 ; i < sizeof(keyboard_matrix_) ; i++)\n  {\n    keyboard_matrix_[i] = 0xff;\n  }\n  /* character to sdl key map */\n  charmap_['A']  = {SDL_SCANCODE_A};\n  charmap_['B']  = {SDL_SCANCODE_B};\n  charmap_['C']  = {SDL_SCANCODE_C};\n  charmap_['D']  = {SDL_SCANCODE_D};\n  charmap_['E']  = {SDL_SCANCODE_E};\n  charmap_['F']  = {SDL_SCANCODE_F};\n  charmap_['G']  = {SDL_SCANCODE_G};\n  charmap_['H']  = {SDL_SCANCODE_H};\n  charmap_['I']  = {SDL_SCANCODE_I};\n  charmap_['J']  = {SDL_SCANCODE_J};\n  charmap_['K']  = {SDL_SCANCODE_K};\n  charmap_['L']  = {SDL_SCANCODE_L};\n  charmap_['M']  = {SDL_SCANCODE_M};\n  charmap_['N']  = {SDL_SCANCODE_N};\n  charmap_['O']  = {SDL_SCANCODE_O};\n  charmap_['P']  = {SDL_SCANCODE_P};\n  charmap_['Q']  = {SDL_SCANCODE_Q};\n  charmap_['R']  = {SDL_SCANCODE_R};\n  charmap_['S']  = {SDL_SCANCODE_S};\n  charmap_['T']  = {SDL_SCANCODE_T};\n  charmap_['U']  = {SDL_SCANCODE_U};\n  charmap_['V']  = {SDL_SCANCODE_V};\n  charmap_['W']  = {SDL_SCANCODE_W};\n  charmap_['X']  = {SDL_SCANCODE_X};\n  charmap_['Y']  = {SDL_SCANCODE_Y};\n  charmap_['Z']  = {SDL_SCANCODE_Z};\n  charmap_['1']  = {SDL_SCANCODE_1};\n  charmap_['2']  = {SDL_SCANCODE_2};\n  charmap_['3']  = {SDL_SCANCODE_3};\n  charmap_['4']  = {SDL_SCANCODE_4};\n  charmap_['5']  = {SDL_SCANCODE_5};\n  charmap_['6']  = {SDL_SCANCODE_6};\n  charmap_['7']  = {SDL_SCANCODE_7};\n  charmap_['8']  = {SDL_SCANCODE_8};\n  charmap_['9']  = {SDL_SCANCODE_9};\n  charmap_['0']  = {SDL_SCANCODE_0};\n  charmap_['\\n'] = {SDL_SCANCODE_RETURN};\n  charmap_[' ']  = {SDL_SCANCODE_SPACE};\n  charmap_[',']  = {SDL_SCANCODE_COMMA};\n  charmap_['.']  = {SDL_SCANCODE_PERIOD};\n  charmap_['/']  = {SDL_SCANCODE_SLASH};\n  charmap_[';']  = {SDL_SCANCODE_SEMICOLON};\n  charmap_['=']  = {SDL_SCANCODE_EQUALS};\n  charmap_['-']  = {SDL_SCANCODE_MINUS};\n  charmap_[':']  = {SDL_SCANCODE_BACKSLASH};\n  charmap_['+']  = {SDL_SCANCODE_LEFTBRACKET};\n  charmap_['*']  = {SDL_SCANCODE_RIGHTBRACKET};\n  charmap_['@']  = {SDL_SCANCODE_APOSTROPHE};\n  charmap_['(']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_8};\n  charmap_[')']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_9};\n  charmap_['<']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_COMMA};\n  charmap_['>']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_PERIOD};\n  charmap_['\"']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_2};\n  charmap_['$']  = {SDL_SCANCODE_LSHIFT,SDL_SCANCODE_4};\n  /* keymap letters */\n  keymap_[SDL_SCANCODE_A] = std::make_pair(1,2);\n  keymap_[SDL_SCANCODE_B] = std::make_pair(3,4);\n  keymap_[SDL_SCANCODE_C] = std::make_pair(2,4);\n  keymap_[SDL_SCANCODE_D] = std::make_pair(2,2);\n  keymap_[SDL_SCANCODE_E] = std::make_pair(1,6);\n  keymap_[SDL_SCANCODE_F] = std::make_pair(2,5);\n  keymap_[SDL_SCANCODE_G] = std::make_pair(3,2);\n  keymap_[SDL_SCANCODE_H] = std::make_pair(3,5);\n  keymap_[SDL_SCANCODE_I] = std::make_pair(4,1);\n  keymap_[SDL_SCANCODE_J] = std::make_pair(4,2);\n  keymap_[SDL_SCANCODE_K] = std::make_pair(4,5);\n  keymap_[SDL_SCANCODE_L] = std::make_pair(5,2);\n  keymap_[SDL_SCANCODE_M] = std::make_pair(4,4);\n  keymap_[SDL_SCANCODE_N] = std::make_pair(4,7);\n  keymap_[SDL_SCANCODE_O] = std::make_pair(4,6);\n  keymap_[SDL_SCANCODE_P] = std::make_pair(5,1);\n  keymap_[SDL_SCANCODE_Q] = std::make_pair(7,6);\n  keymap_[SDL_SCANCODE_R] = std::make_pair(2,1);\n  keymap_[SDL_SCANCODE_S] = std::make_pair(1,5);\n  keymap_[SDL_SCANCODE_T] = std::make_pair(2,6);\n  keymap_[SDL_SCANCODE_U] = std::make_pair(3,6);\n  keymap_[SDL_SCANCODE_V] = std::make_pair(3,7);\n  keymap_[SDL_SCANCODE_W] = std::make_pair(1,1);\n  keymap_[SDL_SCANCODE_X] = std::make_pair(2,7);\n  keymap_[SDL_SCANCODE_Y] = std::make_pair(3,1);\n  keymap_[SDL_SCANCODE_Z] = std::make_pair(1,4);\n  /* keymap numbers */\n  keymap_[SDL_SCANCODE_1] = std::make_pair(7,0);\n  keymap_[SDL_SCANCODE_2] = std::make_pair(7,3);\n  keymap_[SDL_SCANCODE_3] = std::make_pair(1,0);\n  keymap_[SDL_SCANCODE_4] = std::make_pair(1,3);\n  keymap_[SDL_SCANCODE_5] = std::make_pair(2,0);\n  keymap_[SDL_SCANCODE_6] = std::make_pair(2,3);\n  keymap_[SDL_SCANCODE_7] = std::make_pair(3,0);\n  keymap_[SDL_SCANCODE_8] = std::make_pair(3,3);\n  keymap_[SDL_SCANCODE_9] = std::make_pair(4,0);\n  keymap_[SDL_SCANCODE_0] = std::make_pair(4,3);\n  /* keymap function keys */\n  keymap_[SDL_SCANCODE_F1] = std::make_pair(0,4);\n  keymap_[SDL_SCANCODE_F3] = std::make_pair(0,4);\n  keymap_[SDL_SCANCODE_F5] = std::make_pair(0,4);\n  keymap_[SDL_SCANCODE_F7] = std::make_pair(0,4);\n  /* keymap: other */\n  keymap_[SDL_SCANCODE_RETURN]    = std::make_pair(0,1);\n  keymap_[SDL_SCANCODE_SPACE]     = std::make_pair(7,4);\n  keymap_[SDL_SCANCODE_LSHIFT]    = std::make_pair(1,7);\n  keymap_[SDL_SCANCODE_RSHIFT]    = std::make_pair(6,4);\n  keymap_[SDL_SCANCODE_COMMA]     = std::make_pair(5,7);\n  keymap_[SDL_SCANCODE_PERIOD]    = std::make_pair(5,4);\n  keymap_[SDL_SCANCODE_SLASH]     = std::make_pair(6,7);\n  keymap_[SDL_SCANCODE_SEMICOLON] = std::make_pair(6,2);\n  keymap_[SDL_SCANCODE_EQUALS]    = std::make_pair(6,5);\n  keymap_[SDL_SCANCODE_BACKSPACE] = std::make_pair(0,0);\n  keymap_[SDL_SCANCODE_MINUS]     = std::make_pair(5,3);\n  /* keymap: these are mapped to other keys */\n  keymap_[SDL_SCANCODE_BACKSLASH]    = std::make_pair(5,5); // : \n  keymap_[SDL_SCANCODE_LEFTBRACKET]  = std::make_pair(5,0); // +\n  keymap_[SDL_SCANCODE_RIGHTBRACKET] = std::make_pair(6,1); // *\n  keymap_[SDL_SCANCODE_APOSTROPHE]   = std::make_pair(5,6); // @\n  keymap_[SDL_SCANCODE_LGUI]         = std::make_pair(7,5); // commodore key\n}\n\n/** \n * @brief init c64 color palette \n */\nvoid IO::init_color_palette()\n{\n\n  color_palette[0]   = SDL_MapRGB(format_, 0x00, 0x00, 0x00);\n  color_palette[1]   = SDL_MapRGB(format_, 0xff, 0xff, 0xff);\n  color_palette[2]   = SDL_MapRGB(format_, 0xab, 0x31, 0x26);\n  color_palette[3]   = SDL_MapRGB(format_, 0x66, 0xda, 0xff);\n  color_palette[4]   = SDL_MapRGB(format_, 0xbb, 0x3f, 0xb8);\n  color_palette[5]   = SDL_MapRGB(format_, 0x55, 0xce, 0x58);\n  color_palette[6]   = SDL_MapRGB(format_, 0x1d, 0x0e, 0x97);\n  color_palette[7]   = SDL_MapRGB(format_, 0xea, 0xf5, 0x7c);\n  color_palette[8]   = SDL_MapRGB(format_, 0xb9, 0x74, 0x18);\n  color_palette[9]   = SDL_MapRGB(format_, 0x78, 0x53, 0x00);\n  color_palette[10]  = SDL_MapRGB(format_, 0xdd, 0x93, 0x87);\n  color_palette[11]  = SDL_MapRGB(format_, 0x5b, 0x5b, 0x5b);\n  color_palette[12]  = SDL_MapRGB(format_, 0x8b, 0x8b, 0x8b);\n  color_palette[13]  = SDL_MapRGB(format_, 0xb0, 0xf4, 0xac);\n  color_palette[14]  = SDL_MapRGB(format_, 0xaa, 0x9d, 0xef);\n  color_palette[15]  = SDL_MapRGB(format_, 0xb8, 0xb8, 0xb8);\n}\n\n// emulation /////////////////////////////////////////////////////////////////// \n\nbool IO::emulate()\n{\n  return retval_;\n}\n\nvoid IO::process_events()\n{\n  SDL_Event event;\n  while(SDL_PollEvent(&event))\n  {\n    switch(event.type)\n    {\n    case SDL_KEYDOWN:\n      handle_keydown(event.key.keysym.scancode);\n      break;\n    case SDL_KEYUP:\n      handle_keyup(event.key.keysym.scancode);\n      break;\n    case SDL_QUIT:\n      retval_ = false;\n      break;\n    }\n  }\n  /* process fake keystrokes if any */\n  if(!key_event_queue_.empty() && \n     cpu_->cycles() > next_key_event_at_)\n  {\n    std::pair<kKeyEvent,SDL_Keycode> &ev = key_event_queue_.front();\n    key_event_queue_.pop();\n    switch(ev.first)\n    {\n    case kPress:\n      handle_keydown(ev.second);\n      break;\n    case kRelease:\n      handle_keyup(ev.second);\n      break;\n    }\n    next_key_event_at_ = cpu_->cycles() + kWait;\n  }\n}\n\n// keyboard handling /////////////////////////////////////////////////////////// \n\n/**\n * @brief emulate keydown\n */\nvoid IO::handle_keydown(SDL_Keycode k)\n{\n  try\n  {\n    uint8_t mask = ~(1 << keymap_.at(k).second);\n    keyboard_matrix_[keymap_.at(k).first] &= mask;\n  }\n  catch(const std::out_of_range){}\n}\n\n/**\n * @brief emulate keyup\n */\nvoid IO::handle_keyup(SDL_Keycode k)\n{\n  try\n  {\n    uint8_t mask = (1 << keymap_.at(k).second);\n    keyboard_matrix_[keymap_.at(k).first] |= mask;\n  }\n  catch(const std::out_of_range){}  \n}\n\n/**\n * @brief fake press a key, monkeys love it\n *\n * Characters are added to a queue and processed within \n * the emulation loop.\n */\nvoid IO::type_character(char c)\n{\n  try\n  {\n    for(SDL_Keycode &k: charmap_.at(toupper(c)))\n      key_event_queue_.push(std::make_pair(kPress,k));\n    for(SDL_Keycode &k: charmap_.at(toupper(c)))\n      key_event_queue_.push(std::make_pair(kRelease,k));\n  }\n  catch(const std::out_of_range){}   \n}\n\n// screen handling /////////////////////////////////////////////////////////////\n\nvoid IO::screen_draw_rect(int x, int y, int n, int color)\n{\n  for(int i=0; i < n ; i++)\n  {\n    screen_update_pixel(x+i,y,color);\n  }\n}\n \nvoid IO::screen_draw_border(int y, int color)\n{\n  screen_draw_rect(0,y,cols_,color);\n}\n \n/**\n * @brief refresh screen \n *\n * Upload the texture to the GPU \n */\nvoid IO::screen_refresh()\n{\n  SDL_UpdateTexture(texture_, NULL, frame_, cols_ * sizeof(uint32_t));\n  SDL_RenderClear(renderer_);\n  SDL_RenderCopy(renderer_,texture_, NULL, NULL);\n  SDL_RenderPresent(renderer_);\n  /* process SDL events once every frame */\n  process_events();\n  /* perform vertical refresh sync */\n  vsync();\n}\n\n/**\n * @brief vsync\n *\n * vsync() is called at the end of every frame, if we are ahead \n * of time compared to a real C64 (very likely) we sleep for a bit, \n * this way we avoid running at full speed allowing the host CPU to \n * take a little nap before getting back to work.\n *\n * This should also help with performance runing on slow computers, \n * uploading data to the GPU is a relatively slow operation, doing \n * more fps obviously has a performance impact.\n *\n * Also, and more importantly, by doing this we emulate the actual \n * speed of the C64 so visual effects do not look accelerated and \n * games become playable :)\n */\nvoid IO::vsync()\n{\n  using namespace std::chrono;\n  auto t = high_resolution_clock::now() - prev_frame_was_at_;\n  duration<double> rr(Vic::kRefreshRate);\n  /**\n   * Microsoft's chrono is buggy and does not properly handle \n   * doubles, we need to recast to milliseconds.\n   */\n  auto ttw = duration_cast<milliseconds>(rr - t);\n  std::this_thread::sleep_for(ttw);\n  prev_frame_was_at_ = std::chrono::high_resolution_clock::now();\n}\n"
  },
  {
    "path": "src/io.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef EMUDORE_IO_H\n#define EMUDORE_IO_H\n\n#include <SDL.h>\n#include <queue>\n#include <chrono>\n#include <thread>\n#include <vector>\n#include <utility>\n#include <unordered_map>\n\n#include \"cpu.h\"\n#include \"util.h\"\n\n/**\n * @brief IO devices\n *\n * This class implements Input/Output devices connected to the \n * Commodore 64 such as the screen and keyboard.\n *\n * Current backend is SDL2.\n */\nclass IO\n{\n  private:\n    Cpu *cpu_;\n    SDL_Window *window_;\n    SDL_Renderer *renderer_;\n    SDL_Texture *texture_;\n    SDL_PixelFormat *format_;\n    uint32_t *frame_;\n    size_t cols_;\n    size_t rows_;\n    unsigned int color_palette[16];\n    uint8_t keyboard_matrix_[8];\n    bool retval_ = true;\n    /* keyboard mappings */\n    std::unordered_map<SDL_Keycode,std::pair<int,int>> keymap_;\n    std::unordered_map<char,std::vector<SDL_Keycode>> charmap_;\n    enum kKeyEvent\n    {\n      kPress,\n      kRelease,\n    };\n    /* key events */\n    std::queue<std::pair<kKeyEvent,SDL_Keycode>> key_event_queue_;\n    unsigned int next_key_event_at_;\n    static const int kWait = 18000;\n    /* vertical refresh sync */\n    std::chrono::high_resolution_clock::time_point prev_frame_was_at_;\n    void vsync();\n  public:\n    IO();\n    ~IO();\n    bool emulate();\n    void process_events();\n    void cpu(Cpu *v){cpu_=v;};\n    void init_color_palette();\n    void init_keyboard();\n    void handle_keydown(SDL_Keycode k);\n    void handle_keyup(SDL_Keycode k);\n    void type_character(char c);\n    inline uint8_t keyboard_matrix_row(int col){return keyboard_matrix_[col];};\n    void screen_update_pixel(int x, int y, int color);\n    void screen_draw_rect(int x, int y, int n, int color);\n    void screen_draw_border(int y, int color);\n    void screen_refresh();\n};\n\n// inline member functions accesible from other classes /////////////////////\n\ninline void IO::screen_update_pixel(int x, int y, int color)\n{\n  frame_[y * cols_  + x] = color_palette[color & 0xf];\n};\n\n#endif\n"
  },
  {
    "path": "src/loader.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"loader.h\"\n\nLoader::Loader(C64 *c64)\n{\n  c64_ = c64;\n  io_  = c64_->io();\n  cpu_ = c64_->cpu();\n  mem_ = c64_->memory();\n  booted_up_ = false;\n  format_ = kNone;\n}\n// common ///////////////////////////////////////////////////////////////////\n\nuint16_t Loader::read_short_le()\n{\n  char b;\n  uint16_t v = 0;\n  is_.get(b);\n  v |= (b);\n  is_.get(b);\n  v |= b << 8;\n  return v;\n}\n\n// BASIC listings ///////////////////////////////////////////////////////////\n\nvoid Loader::bas(const std::string &f)\n{\n  format_ = kBasic; \n  is_.open(f,std::ios::in);\n}\n\nvoid Loader::load_basic()\n{\n  char c;\n  if(is_.is_open())\n  {\n    while(is_.good())\n    {\n      is_.get(c);\n      io_->IO::type_character(c);\n    }\n  }\n}\n\n// PRG //////////////////////////////////////////////////////////////////////\n\nvoid Loader::prg(const std::string &f)\n{\n  format_ = kPRG;\n  is_.open(f,std::ios::in|std::ios::binary);\n}\n\nvoid Loader::load_prg()\n{\n  char b;\n  uint16_t pbuf, addr;\n  pbuf = addr = read_short_le();\n  if(is_.is_open())\n  {\n    while(is_.good())\n    {\n      is_.get(b);\n      mem_->write_byte_no_io(pbuf++,b);\n    }\n    /* basic-tokenized prg */\n    if(addr == kBasicPrgStart)\n    {\n      /* make BASIC happy */\n      mem_->write_word_no_io(kBasicTxtTab,kBasicPrgStart);\n      mem_->write_word_no_io(kBasicVarTab,pbuf);\n      mem_->write_word_no_io(kBasicAryTab,pbuf);\n      mem_->write_word_no_io(kBasicStrEnd,pbuf);\n      /* exec RUN */ \n      for(char &c: std::string(\"RUN\\n\"))\n        io_->IO::type_character(c);\n    }\n    /* ML */\n    else cpu_->pc(addr);\n  }\n}\n \n// emulate //////////////////////////////////////////////////////////////////\n\nbool Loader::emulate()\n{\n  if(booted_up_)\n  {\n    switch(format_)\n    {\n    case kBasic: \n      load_basic();\n      break;\n    case kPRG:\n      load_prg();\n      break;\n    default: \n      break;\n    }\n    return false;\n  }\n  else\n  {\n    /* at this point BASIC is ready */\n    if(cpu_->pc() == 0xa65c)\n      booted_up_ = true;\n  }\n  return true;\n}\n"
  },
  {
    "path": "src/loader.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef EMUDORE_LOADER_H\n#define EMUDORE_LOADER_H\n\n#include <fstream>\n#include \"c64.h\"\n\n/**\n * @brief Program loader\n */\nclass Loader\n{\n  private:\n    bool booted_up_;\n    C64 *c64_;\n    IO *io_;\n    Cpu *cpu_;\n    Memory *mem_;\n    std::ifstream is_;\n    enum kFormat\n    {\n      kNone,\n      kBasic,\n      kPRG\n    };\n    kFormat format_;\n    void load_basic();\n    void load_prg();\n    uint16_t read_short_le();\n  public:\n    Loader(C64 *c64);\n    void bas(const std::string &f);\n    void prg(const std::string &f);\n    bool emulate();\n    /* constants */\n    static const uint16_t kBasicPrgStart = 0x0801;\n    static const uint16_t kBasicTxtTab   = 0x002b;\n    static const uint16_t kBasicVarTab   = 0x002d; \n    static const uint16_t kBasicAryTab   = 0x002f;\n    static const uint16_t kBasicStrEnd   = 0x0031;\n};\n\n#endif\n"
  },
  {
    "path": "src/main.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n#include <iostream>\n#include <string>\n#include <algorithm>\n\n#include \"c64.h\"\n#include \"loader.h\"\n#ifdef EMSCRIPTEN\n#include <emscripten.h>\n#endif\n\nC64 *c64;\nLoader *loader;\nbool wget_download_finished = false;\n\nbool loader_cb()\n{\n  if(!loader->emulate())\n    c64->callback(nullptr);\n  return true;\n}\n\nbool emscripten_loader_cb()\n{\n  if (!loader->emulate() && wget_download_finished)\n    c64->callback(nullptr);\n  return true;\n}\n\nvoid load_file(const char *file)\n{\n  std::string f(file);\n  size_t ext_i = f.find_last_of(\".\");\n  if(ext_i != std::string::npos)\n  {\n    std::string ext(f.substr(ext_i+1));\n    std::transform(ext.begin(),ext.end(),ext.begin(),::tolower);\n    if(ext == \"bas\"){\n      loader->bas(f);\n    }\n    else if(ext == \"prg\"){\n      loader->prg(f);\n    }\n  }\n}\n\nvoid wget_cb(const char *f)\n{\n  wget_download_finished = true;\n  load_file(f);\n}\n\nvoid emscripten_loop()\n{\n  c64->emscripten_loop();\n}\n\nint main(int argc, char **argv)\n{\n  c64 = new C64();\n  /* check if asked load a program */\n  if(argc != 1)\n  {\n    loader = new Loader(c64);\n#ifdef EMSCRIPTEN\n    std::string f(argv[1]);\n    size_t sp = f.find_last_of(\"/\");\n    if(sp != std::string::npos)\n    {\n      std::string fname(f.substr(sp+1));\n      c64->callback(emscripten_loader_cb);\n      emscripten_async_wget(argv[1],fname.c_str(),wget_cb,nullptr);\n    }\n#else\n    c64->callback(loader_cb);\n    load_file(argv[1]);\n#endif \n  }\n#ifdef EMSCRIPTEN\n  emscripten_set_main_loop(emscripten_loop,0,0);\n#else\n  c64->start();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "src/memory.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <fstream>\n#include \"memory.h\"\n#include \"util.h\"\n#include \"vic.h\"\n#include \"cia1.h\"\n#include \"cia2.h\"\n\nMemory::Memory()\n{\n  /**\n   * 64 kB memory buffers, zeroed.\n   *\n   * We use two buffers to handle special circumstances, for instance,\n   * any write to a ROM-mapped location will in turn store data on the \n   * hidden RAM, this trickery is used in certain graphic modes.\n   */\n  mem_ram_ = new uint8_t[kMemSize]();\n  mem_rom_ = new uint8_t[kMemSize]();\n  /* configure memory layout */\n  setup_memory_banks(kLORAM|kHIRAM|kCHAREN);\n  /* configure data directional bits */\n  write_byte_no_io(kAddrDataDirection,0x2f);\n}\n\nMemory::~Memory()\n{\n  delete [] mem_ram_;\n  delete [] mem_rom_;\n}\n\n/**\n * @brief configure memory banks\n *\n * There are five latch bits that control the configuration allowing\n * for a total of 32 different memory layouts, for now we only take\n * in count three bits : HIRAM/LORAM/CHAREN\n */\nvoid Memory::setup_memory_banks(uint8_t v)\n{\n  /* get config bits */\n  bool hiram  = ((v&kHIRAM) != 0);\n  bool loram  = ((v&kLORAM) != 0);\n  bool charen = ((v&kCHAREN)!= 0);\n  /* init everything to ram */\n  for(size_t i=0 ; i < sizeof(banks_) ; i++)\n    banks_[i] = kRAM;\n  /* load ROMs */\n  load_rom(\"basic.901226-01.bin\",kBaseAddrBasic);\n  load_rom(\"characters.901225-01.bin\",kBaseAddrChars);\n  load_rom(\"kernal.901227-03.bin\",kBaseAddrKernal);\n  /* kernal */\n  if (hiram) \n    banks_[kBankKernal] = kROM;\n  /* basic */\n  if (loram && hiram) \n    banks_[kBankBasic] = kROM;\n  /* charen */\n  if (charen && (loram || hiram))\n    banks_[kBankCharen] = kIO;\n  else if (charen && !loram && !hiram)\n    banks_[kBankCharen] = kRAM;\n  else \n    banks_[kBankCharen] = kROM;\n  /* write the config to the zero page */\n  write_byte_no_io(kAddrMemoryLayout, v);\n}\n\n/**\n * @brief writes a byte to RAM without performing I/O\n */\nvoid Memory::write_byte_no_io(uint16_t addr, uint8_t v)\n{\n  mem_ram_[addr] = v;\n}\n\n/**\n * @brief writes a byte to RAM handling I/O\n */\nvoid Memory::write_byte(uint16_t addr, uint8_t v)\n{\n  uint16_t page = addr&0xff00;\n  /* ZP */\n  if (page == kAddrZeroPage)\n  {\n    /* bank switching */\n    if (addr == kAddrMemoryLayout)\n      setup_memory_banks(v);\n    else\n      mem_ram_[addr] = v;\n  }\n  /* VIC-II DMA or Character ROM */\n  else if (page >= kAddrVicFirstPage && page <= kAddrVicLastPage)\n  {\n    if(banks_[kBankCharen] == kIO)\n      vic_->write_register(addr&0x7f,v);\n    else\n      mem_ram_[addr] = v;\n  }\n  /* CIA1 */\n  else if (page == kAddrCIA1Page)\n  {\n    if(banks_[kBankCharen] == kIO)\n      cia1_->write_register(addr&0x0f,v);\n    else\n      mem_ram_[addr] = v;\n  }\n  else if (page == kAddrCIA2Page)\n  {\n    if(banks_[kBankCharen] == kIO)\n      cia2_->write_register(addr&0x0f,v);\n    else\n      mem_ram_[addr] = v;\n  }\n  /* default */\n  else\n  {\n    mem_ram_[addr] = v;\n  }\n}\n\n/**\n * @brief reads a byte from RAM or ROM (depending on bank config)\n */\nuint8_t Memory::read_byte(uint16_t addr)\n{\n  uint8_t  retval = 0;\n  uint16_t page   = addr&0xff00;\n  /* VIC-II DMA or Character ROM */\n  if (page >= kAddrVicFirstPage && page <= kAddrVicLastPage)\n  {\n    if(banks_[kBankCharen] == kIO)\n      retval = vic_->read_register(addr&0x7f);\n    else if(banks_[kBankCharen] == kROM)\n      retval = mem_rom_[addr];\n    else\n      retval = mem_ram_[addr];\n  }\n  /* CIA1 */\n  else if (page == kAddrCIA1Page)\n  {\n    if(banks_[kBankCharen] == kIO)\n      retval = cia1_->read_register(addr&0x0f);\n    else\n      retval = mem_ram_[addr];\n  }\n  /* CIA2 */\n  else if (page == kAddrCIA2Page)\n  {\n    if(banks_[kBankCharen] == kIO)\n      retval = cia2_->read_register(addr&0x0f);\n    else\n      retval = mem_ram_[addr];\n  }       \n  /* BASIC or RAM */\n  else if (page >= kAddrBasicFirstPage && page <= kAddrBasicLastPage)\n  {\n    if (banks_[kBankBasic] == kROM)\n      retval = mem_rom_[addr];\n    else\n      retval = mem_ram_[addr];\n  }\n  /* KERNAL */\n  else if (page >= kAddrKernalFirstPage && page <= kAddrKernalLastPage)\n  {\n    if (banks_[kBankKernal] == kROM)\n      retval = mem_rom_[addr];\n    else \n      retval = mem_ram_[addr];\n  }\n  /* default */\n  else\n  {\n    retval = mem_ram_[addr];\n  }\n  return retval;\n}\n\n/**\n * @brief writes a byte without performing I/O (always to RAM)\n */\n\nuint8_t Memory::read_byte_no_io(uint16_t addr)\n{\n  return mem_ram_[addr];\n}\n\n/**\n * @brief reads a word performing I/O\n */\nuint16_t Memory::read_word(uint16_t addr)\n{\n  return read_byte(addr) | (read_byte(addr+1) << 8);\n}\n\n/**\n * @brief reads a word withouth performing I/O\n */\nuint16_t Memory::read_word_no_io(uint16_t addr)\n{\n  return read_byte_no_io(addr) | (read_byte_no_io(addr+1) << 8);\n}\n\n/** \n * @brief writes a word performing I/O\n */\nvoid Memory::write_word(uint16_t addr, uint16_t v)\n{\n  write_byte(addr, (uint8_t)(v));\n  write_byte(addr+1, (uint8_t)(v>>8));\n}\n\n/** \n * @brief writes a word without performing I/O\n */\nvoid Memory::write_word_no_io(uint16_t addr, uint16_t v)\n{\n  write_byte_no_io(addr, (uint8_t)(v));\n  write_byte_no_io(addr+1, (uint8_t)(v>>8));\n}\n\n/**\n * @brief read byte (from VIC's perspective)\n *\n * The VIC has only 14 address lines so it can only access \n * 16kB of memory at once, the two missing address bits are \n * provided by CIA2.\n *\n * The VIC always reads from RAM ignoring the memory configuration,\n * there's one exception: the character generator ROM. Unless the \n * Ultimax mode is selected, VIC sees the character generator ROM \n * in the memory areas:\n *\n *  1000-1FFF\n *  9000-9FFF\n */\nuint8_t Memory::vic_read_byte(uint16_t addr)\n{\n  uint8_t v;\n  uint16_t vic_addr = cia2_->vic_base_address() + (addr & 0x3fff);\n  if((vic_addr >= 0x1000 && vic_addr <  0x2000) ||\n     (vic_addr >= 0x9000 && vic_addr <  0xa000))\n    v = mem_rom_[kBaseAddrChars + (vic_addr & 0xfff)];\n  else\n    v = read_byte_no_io(vic_addr);\n  return v;\n}\n\n/**\n * @brief loads a external binary into ROM\n */\nvoid Memory::load_rom(const std::string &f, uint16_t baseaddr)\n{\n  std::string path = \"./assets/roms/\" + f;\n  std::ifstream is(path, std::ios::in | std::ios::binary);\n  if(is)\n  {\n    is.seekg (0, is.end);\n    std::streamoff length = is.tellg();\n    is.seekg (0, is.beg);\n    is.read ((char *) &mem_rom_[baseaddr],length);\n  }\n}\n\n/**\n * @brief loads a external binary into RAM\n */\nvoid Memory::load_ram(const std::string &f, uint16_t baseaddr)\n{\n  std::string path = \"./assets/\" + f;\n  std::ifstream is(path, std::ios::in | std::ios::binary);\n  if(is)\n  {\n    is.seekg (0, is.end);\n    std::streamoff length = is.tellg();\n    is.seekg (0, is.beg);\n    is.read ((char *) &mem_ram_[baseaddr],length);\n  }\n}\n\n// debug ////////////////////////////////////////////////////////////////////\n\n/**\n * @brief dumps memory as seen by the CPU to stdout\n */\nvoid Memory::dump()\n{\n  for(unsigned int p=0 ; p < kMemSize ; p++)\n  {\n    std::cout << read_byte(p);\n  }\n}\n"
  },
  {
    "path": "src/memory.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n#ifndef EMUDORE_MEMORY_H\n#define EMUDORE_MEMORY_H \n\n#include <iostream>\n#include <cstdint>\n\n/* forward declarations */\n\nclass Vic;\nclass Cia1;\nclass Cia2;\nclass Sid;\n\n/**\n * @brief DRAM\n *\n * - @c $0000-$00FF  Page 0        Zeropage addressing\n * - @c $0100-$01FF  Page 1        Enhanced Zeropage contains the stack\n * - @c $0200-$02FF  Page 2        Operating System and BASIC pointers\n * - @c $0300-$03FF  Page 3        Operating System and BASIC pointers\n * - @c $0400-$07FF  Page 4-7      Screen Memory\n * - @c $0800-$9FFF  Page 8-159    Free BASIC program storage area (38911 bytes)\n * - @c $A000-$BFFF  Page 160-191  Free machine language program storage area (when switched-out with ROM)\n * - @c $C000-$CFFF  Page 192-207  Free machine language program storage area\n * - @c $D000-$D3FF  Page 208-211  \n * - @c $D400-$D4FF  Page 212-215  \n * - @c $D800-$DBFF  Page 216-219  \n * - @c $DC00-$DCFF  Page 220  \n * - @c $DD00-$DDFF  Page 221  \n * - @c $DE00-$DFFF  Page 222-223  Reserved for interface extensions\n * - @c $E000-$FFFF  Page 224-255  Free machine language program storage area (when switched-out with ROM)\n */\nclass Memory\n{\n  private:\n    uint8_t *mem_ram_;\n    uint8_t *mem_rom_;\n    uint8_t banks_[7];\n    Vic *vic_;\n    Cia1 *cia1_;\n    Cia2 *cia2_;\n    Sid *sid_;\n  public:\n    Memory();\n    ~Memory();\n    void vic(Vic *v){vic_ = v;};\n    void cia1(Cia1 *v){cia1_ = v;};\n    void cia2(Cia2 *v){cia2_ = v;};\n    /* bank switching */\n    enum kBankCfg\n    {\n      kROM,\n      kRAM,\n      kIO\n    };\n    enum Banks\n    {\n      kBankBasic =  3,\n      kBankCharen = 5,\n      kBankKernal =  6,\n    };\n    void setup_memory_banks(uint8_t v);\n    /* read/write memory */\n    uint8_t read_byte(uint16_t addr);\n    uint8_t read_byte_no_io(uint16_t addr);\n    void write_byte(uint16_t addr, uint8_t v);\n    void write_byte_no_io(uint16_t addr, uint8_t v);\n    uint16_t read_word(uint16_t addr);\n    uint16_t read_word_no_io(uint16_t);\n    void write_word(uint16_t addr, uint16_t v);\n    void write_word_no_io(uint16_t addr, uint16_t v);\n    /* vic memory access */\n    uint8_t vic_read_byte(uint16_t addr);\n    uint8_t read_byte_rom(uint16_t addr);\n    /* load external binaries */\n    void load_rom(const std::string &f, uint16_t baseaddr);\n    void load_ram(const std::string &f, uint16_t baseaddr);\n    /* debug */\n    void dump();\n    void print_screen_text();\n    /* constants */\n    static const size_t kMemSize = 0x10000;\n    /* memory addresses  */\n    static const uint16_t kBaseAddrBasic  = 0xa000;\n    static const uint16_t kBaseAddrKernal = 0xe000;\n    static const uint16_t kBaseAddrStack  = 0x0100;\n    static const uint16_t kBaseAddrScreen = 0x0400;\n    static const uint16_t kBaseAddrChars  = 0xd000;\n    static const uint16_t kBaseAddrBitmap = 0x0000;\n    static const uint16_t kBaseAddrColorRAM = 0xd800;\n    static const uint16_t kAddrResetVector = 0xfffc;\n    static const uint16_t kAddrIRQVector = 0xfffe;\n    static const uint16_t kAddrNMIVector = 0xfffa;\n    static const uint16_t kAddrDataDirection = 0x0000;\n    static const uint16_t kAddrMemoryLayout  = 0x0001;\n    static const uint16_t kAddrColorRAM = 0xd800;\n    /* memory layout */\n    static const uint16_t kAddrZeroPage     = 0x0000;\n    static const uint16_t kAddrVicFirstPage = 0xd000;\n    static const uint16_t kAddrVicLastPage  = 0xd300;\n    static const uint16_t kAddrCIA1Page = 0xdc00;\n    static const uint16_t kAddrCIA2Page = 0xdd00;\n    static const uint16_t kAddrBasicFirstPage = 0xa000; \n    static const uint16_t kAddrBasicLastPage  = 0xbf00;\n    static const uint16_t kAddrKernalFirstPage = 0xe000;\n    static const uint16_t kAddrKernalLastPage = 0xff00;\n    /* bank switching */\n    static const uint8_t kLORAM  = 1 << 0;\n    static const uint8_t kHIRAM  = 1 << 1;\n    static const uint8_t kCHAREN = 1 << 2;\n};\n\n#endif\n"
  },
  {
    "path": "src/sid.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#ifndef EMUDORE_SID_H\n#define EMUDORE_SID_H\n\n/**\n * @brief MOS 6581 SID (Sound Interface Device)\n *\n * - Memory area : $D400-$D7FF\n * - Tasks       : Sound\n */\nclass Sid\n{\n  private:\n  public:\n};\n\n#endif\n"
  },
  {
    "path": "src/util.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n#ifndef EMUDORE_UTIL_H\n#define EMUDORE_UTIL_H\n\n#include <stdio.h>\n\n#ifndef NDEBUG\n#define D(...) fprintf (stderr,__VA_ARGS__)\n#else\n#define D(...) do {} while (0)\n#endif\n\n#define ISSET_BIT(v,b)  ((v&(1<<b))!=0)\n\n#if defined(__APPLE__)\n# include <machine/endian.h>\n# include <libkern/OSByteOrder.h>\n#elif defined(_MSC_VER)\n# include <stdlib.h>\n#else\n# include <byteswap.h>\n#endif\n\n#if !defined(htonll) && !defined(ntohll)\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n# if defined(__APPLE__)\n#  define htonll(x) OSSwapInt64(x)\n#  define ntohll(x) OSSwapInt64(x)\n# elif defined(_MSC_VER)\n#  define htonll(x) _byteswap_uint64(x)\n#  define ntohll(x) _byteswap_uint64(x)\n# else\n#  define htonll(x) bswap_64(x)\n#  define ntohll(x) bswap_64(x)\n# endif\n#else\n# define htonll(x) (x)\n# define ntohll(x) (x)\n#endif\n#endif \n\n#endif\n"
  },
  {
    "path": "src/vic.cpp",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"vic.h\"\n#include \"util.h\"\n\n// ctor and emulate()  ///////////////////////////////////////////////////////\n\nVic::Vic()\n{\n  /* raster */\n  raster_irq_ = raster_c_ = 0; \n  irq_enabled_ = irq_status_ = 0;\n  next_raster_at_ = kLineCycles;\n  /* sprites */\n  for(int i = 0 ; i<8 ; i++)\n  {\n    mx_[i] = my_[i] = sprite_colors_[i] = 0;\n  }\n  msbx_ = sprite_double_height_ = sprite_double_width_ = 0;\n  sprite_enabled_ = sprite_priority_ = sprite_multicolor_ = 0;       \n  sprite_shared_colors_[0] = sprite_shared_colors_[1] = 0;\n  /* colors */\n  border_color_ = 0;\n  bgcolor_[0] = bgcolor_[1] = bgcolor_[2] = bgcolor_[3] = 0;\n  /* control regs */\n  cr1_ = cr2_ = 0;\n  /* frame counter */\n  frame_c_ = 0;\n  /* default memory pointers */\n  screen_mem_ = Memory::kBaseAddrScreen;\n  char_mem_   = Memory::kBaseAddrChars;\n  bitmap_mem_ = Memory::kBaseAddrBitmap;\n  /* bit 0 is unused */\n  mem_pointers_ = (1 << 0);\n  /* current graphic mode */\n  graphic_mode_ = kCharMode;\n}\n\nbool Vic::emulate()\n{\n  /** \n   * if there are unacknowledged interrupts \n   * raise an interrupt again\n   **/\n  if((read_register(0x19) & 0x80) != 0)\n  {\n    cpu_->irq();\n  }\n  /* are we at the next raster line? */\n  if (cpu_->cycles() >= next_raster_at_)\n  {\n    int rstr = raster_counter();\n    /* check raster IRQs */\n    if (raster_irq_enabled() &&\n        rstr == raster_irq_)\n    {\n      /* set interrupt origin (raster) */\n      irq_status_ |= (1<<0);\n      /* raise interrupt */\n      cpu_->irq();\n    }\n    if (rstr >= kFirstVisibleLine &&\n        rstr < kLastVisibleLine)\n    {\n      /* draw border */\n      int screen_y = rstr - kFirstVisibleLine;\n      io_->screen_draw_border(screen_y,border_color_);\n      /* draw raster on current graphic mode */\n      switch(graphic_mode_)\n      {\n      case kCharMode:\n      case kMCCharMode:\n        draw_raster_char_mode();\n        break;\n      case kBitmapMode:\n      case kMCBitmapMode:\n        draw_raster_bitmap_mode();\n        break;\n      default:\n        D(\"unsupported graphic mode: %d\\n\",graphic_mode_);\n        return false;\n      }\n      /* draw sprites */\n      draw_raster_sprites();\n    }\n    /* next raster */\n    if(is_bad_line())\n      next_raster_at_+= kBadLineCycles;\n    else\n      next_raster_at_+= kLineCycles;\n    /* update raster */\n    raster_counter(++rstr);\n    if (rstr >= kScreenLines)\n    {\n      io_->screen_refresh();\n      frame_c_++;\n      raster_counter(0);\n    }\n  }\n  return true;\n}\n\n// DMA register access  //////////////////////////////////////////////////////\n\nuint8_t Vic::read_register(uint8_t r)\n{\n  uint8_t retval;\n  switch(r)\n  {\n  /* get X coord of sprite n*/\n  case 0x0:\n  case 0x2:\n  case 0x4:\n  case 0x6:\n  case 0x8:\n  case 0xc:\n  case 0xe:\n    retval = mx_[r >> 1];\n    break;\n  /* get Y coord of sprite n */\n  case 0x1:\n  case 0x3:\n  case 0x5:\n  case 0x7:\n  case 0x9:\n  case 0xb:\n  case 0xd:\n  case 0xf:\n    retval = my_[r >> 1];\n    break;\n  /* MSBs of sprites X coordinates */\n  case 0x10:\n    retval = msbx_;\n    break;\n  /* control register 1 */\n  case 0x11:\n    retval = cr1_;\n    break;\n  /* raster counter */\n  case 0x12:\n    retval = raster_c_;\n    break;\n  /* sprite enable register */\n  case 0x15:\n    retval = sprite_enabled_;\n    break;\n  /* control register 2 */\n  case 0x16:\n    retval = cr2_;\n    break;\n  /* sprite double height */\n  case 0x17:\n    retval = sprite_double_height_;\n    break;\n  /* memory pointers */\n  case 0x18:\n    retval = mem_pointers_;\n    break;\n  /** \n   * interrupt status register \n   * IRQ|  - |  - |  - | ILP|IMMC|IMBC|IRST|\n   */\n  case 0x19:\n    retval = (0xf & irq_status_);\n    if(retval!=0) retval |= 0x80; // IRQ bit \n    retval |= 0x70; // non-connected bits (always set)\n    break;\n  /** \n   * interrupt enable register \n   *   - |  - |  - |  - | ELP|EMMC|EMBC|ERST|\n   */\n  case 0x1a:\n    retval = (0xf0 | irq_enabled_);\n    break;\n  /* sprite priority register */\n  case 0x1b:\n    retval = sprite_priority_;\n    break;\n  /* sprite multicolor mode */\n  case 0x1c:\n    retval = sprite_multicolor_;\n    break;\n  /* sprite double width */\n  case 0x1d:\n    retval = sprite_double_width_;\n    break;\n  /* border color */\n  case 0x20:\n    retval = border_color_;\n    break;\n  /* background colors */\n  case 0x21:\n  case 0x22:\n  case 0x23:\n  case 0x24:\n    retval = bgcolor_[r-0x21];\n    break;\n  /* sprite colors */\n  case 0x25:\n  case 0x26:\n    retval = sprite_shared_colors_[r-0x25];\n    break;\n  case 0x27:\n  case 0x28:\n  case 0x29:\n  case 0x2a:\n  case 0x2b:\n  case 0x2c:\n  case 0x2d:\n  case 0x2e:\n    retval = sprite_colors_[r-0x27];\n    break;\n  /* unused */\n  case 0x2f:\n  case 0x30:\n  case 0x31:\n  case 0x32:\n  case 0x33:\n  case 0x34:\n  case 0x35:\n  case 0x36:\n  case 0x37:\n  case 0x38:\n  case 0x39:\n  case 0x3a:\n  case 0x3b:\n  case 0x3c:\n  case 0x3d:\n  case 0x3e:\n  case 0x3f:\n  default:\n    retval = 0xff;\n    break;\n  }\n  return retval;\n}\n\nvoid Vic::write_register(uint8_t r, uint8_t v)\n{\n  switch(r)\n  {\n  /* store X coord of sprite n*/\n  case 0x0:\n  case 0x2:\n  case 0x4:\n  case 0x6:\n  case 0x8:\n  case 0xc:\n  case 0xe:\n    mx_[r >> 1] = v;\n    break;\n  /* store Y coord of sprite n */\n  case 0x1:\n  case 0x3:\n  case 0x5:\n  case 0x7:\n  case 0x9:\n  case 0xb:\n  case 0xd:\n  case 0xf:\n    my_[r >> 1] = v;\n    break;\n  /* MSBs of X coordinates */\n  case 0x10:\n    msbx_ = v;\n    break;\n  /* control register 1 */\n  case 0x11:\n    cr1_ = (v&0x7f);\n    raster_irq_ &= 0xff;\n    raster_irq_ |= (v&0x80) << 1;\n    set_graphic_mode();\n    break;\n  /* raster irq */\n  case 0x12:\n    raster_irq_ = v | (raster_irq_ & (1 << 8));\n    break;\n  /* sprite enable register */\n  case 0x15:\n    sprite_enabled_ = v;\n    break;\n  /* control register 2 */\n  case 0x16:\n    cr2_ = v;\n    set_graphic_mode();\n    break;\n  /* sprite double height */\n  case 0x17:\n    sprite_double_height_ = v;\n    break;\n  /* memory pointers  */\n  case 0x18:\n    /* bits ----xxx- */\n    char_mem_   = (v&0xe) << 10;\n    /* bits xxxx---- */\n    screen_mem_ = (v&0xf0) << 6;\n    /* bit  ----x--- */\n    bitmap_mem_ = (v&0x8) << 10;\n    /* save reg value (last bit always set)*/\n    mem_pointers_ = v | (1 << 0);\n    break;\n  /* interrupt request register */\n  case 0x19:\n    /* acknowledge interrupts by mask */\n    irq_status_ &= ~(v&0xf);\n    break;\n  /* interrupt enable register */\n  case 0x1a:\n    irq_enabled_= v;\n    break;\n  /* sprite priority register */\n  case 0x1b:\n    sprite_priority_ = v;\n    break;\n  /* sprite multicolor mode */\n  case 0x1c:\n    sprite_multicolor_ = v;\n    break;\n  /* sprite double width */\n  case 0x1d:\n    sprite_double_width_ = v;\n    break;\n  /* border color */\n  case 0x20:\n    border_color_ = v;\n    break;\n  /* background colors */\n  case 0x21:\n  case 0x22:\n  case 0x23:\n  case 0x24:\n    bgcolor_[r-0x21] = v;\n    break;\n  /* sprite colors */\n  case 0x25:\n  case 0x26:\n    sprite_shared_colors_[r-0x25] = v;\n    break;\n  case 0x27:\n  case 0x28:\n  case 0x29:\n  case 0x2a:\n  case 0x2b:\n  case 0x2c:\n  case 0x2d:\n  case 0x2e:\n    sprite_colors_[r-0x27] = v;\n    break;\n  /* unused */\n  case 0x2f:\n  case 0x30:\n  case 0x31:\n  case 0x32:\n  case 0x33:\n  case 0x34:\n  case 0x35:\n  case 0x36:\n  case 0x37:\n  case 0x38:\n  case 0x39:\n  case 0x3a:\n  case 0x3b:\n  case 0x3c:\n  case 0x3d:\n  case 0x3e:\n  case 0x3f:\n  default:\n    break;\n  }\n}       \n\n// graphics //////////////////////////////////////////////////////////////////\n\n/**\n * @brief set current graphic mode \n */\nvoid Vic::set_graphic_mode()\n{\n  bool ecm = ((cr1_ & (1<<6))!= 0);\n  bool bmm = ((cr1_ & (1<<5))!= 0);\n  bool mcm = ((cr2_ & (1<<4))!= 0);\n\n  if(!ecm && !bmm && !mcm) \n    graphic_mode_ = kCharMode;\n  else if(!ecm && !bmm && mcm)\n    graphic_mode_ = kMCCharMode;\n  else if(!ecm && bmm && !mcm)\n    graphic_mode_ = kBitmapMode;\n  else if(!ecm && bmm && mcm)\n    graphic_mode_ = kMCBitmapMode;\n  else if(ecm && !bmm && !mcm)\n    graphic_mode_ = kExtBgMode;\n  else \n    graphic_mode_ = kIllegalMode;\n}\n\n/**\n * @brief retrieves a character from screen Memory\n */\nuint8_t Vic::get_screen_char(int column, int row)\n{\n  uint16_t addr = screen_mem_ + (row * kGCols) + column;\n  return mem_->vic_read_byte(addr);\n}\n\n/**\n * @brief retrives color RAM for given screen coords\n */\nuint8_t Vic::get_char_color(int column, int row)\n{\n  uint16_t addr = Memory::kAddrColorRAM + (row * kGCols) + column;\n  return (mem_->read_byte_no_io(addr) & 0x0f);\n}\n\n/**\n * @brief retrieves pixel data from character memory\n */\nuint8_t Vic::get_char_data(int chr, int line)\n{\n  uint16_t addr = char_mem_ + (chr * 8) + line;\n  return mem_->vic_read_byte(addr);\n}\n\n/**\n * @brief retrieves pixel data from bitmap memory\n */\nuint8_t Vic::get_bitmap_data(int column, int row, int line)\n{\n  uint16_t addr = bitmap_mem_ + (row * kGCols + column) * 8 + line;\n  return mem_->vic_read_byte(addr);\n}\n\n/**\n * @brief get sprite pointer \n *\n * n is sprite # (0-7)\n */\nuint16_t Vic::get_sprite_ptr(int n)\n{\n  uint16_t ptraddr = screen_mem_ + kSpritePtrsOffset + n;\n  return kSpriteSize * mem_->vic_read_byte(ptraddr);\n}\n \n// raster drawing  ///////////////////////////////////////////////////////////\n\nvoid Vic::draw_char(int x, int y, uint8_t data, uint8_t color)\n{\n  for(int i=0 ; i < 8 ; i++)\n  {\n    int xoffs = x + 8 - i + horizontal_scroll();\n    /* don't draw outside (due to horizontal scroll) */\n    if(xoffs > kGFirstCol + kGResX)\n      continue;\n    /* draw pixel */\n    if(ISSET_BIT(data,i))\n    {\n      io_->screen_update_pixel(\n        xoffs, \n        y,\n        color);\n    }\n  }\n}\n\nvoid Vic::draw_mcchar(int x, int y, uint8_t data, uint8_t color)\n{\n  for(int i=0 ; i < 4 ; i++)\n  {\n    /* color */\n    uint8_t c;\n    /* color source */\n    uint8_t cs = ((data >> i*2) & 0x3);\n    switch(cs)\n    {\n    case 0:\n      c = bgcolor_[0]; \n      break;\n    case 1:\n      c = bgcolor_[1];\n      break;\n    case 2:\n      c = bgcolor_[2];\n      break;\n    case 3:\n      c = color;\n      break;\n    }\n    int xoffs = x + 8 - i * 2 + horizontal_scroll();\n    io_->screen_update_pixel(\n      xoffs,\n      y,\n      c);\n    io_->screen_update_pixel(\n      xoffs + 1,\n      y,\n      c);\n  }\n}\n\nvoid Vic::draw_raster_char_mode()\n{\n  int rstr = raster_counter();\n  int y = rstr - kFirstVisibleLine;\n  if((rstr >= kGFirstLine) && \n     (rstr < kGLastLine) && \n     !is_screen_off())\n  {\n    /* draw background */\n    io_->screen_draw_rect(kGFirstCol,y,kGResX,bgcolor_[0]);\n    /* draw characters */\n    for(int column=0; column < kGCols ; column++)\n    {\n      /* check 38 cols mode */\n      if(!ISSET_BIT(cr2_,3))\n      {\n        if (column == 0) continue; \n        if (column == kGCols -1 ) continue; \n      }\n      int x = kGFirstCol + column * 8;\n      int line = rstr - kGFirstLine;\n      int row = line/8;\n      int char_row = line % 8;\n      /* retrieve screen character */\n      uint8_t c = get_screen_char(column,row);\n      /* retrieve character bitmap data */\n      uint8_t data = get_char_data(c,char_row);\n      /* retrieve color data */\n      uint8_t color  = get_char_color(column,row);\n      /* draw character */\n      if(graphic_mode_ == kMCCharMode && ISSET_BIT(color,3))\n        draw_mcchar(x,y,data,(color&0x7));\n      else\n        draw_char(x,y,data,color);\n    }\n  }\n}\n\nvoid Vic::draw_bitmap(int x, int y, uint8_t data, uint8_t color)\n{\n  uint8_t forec   = (color >> 4) & 0xf;\n  uint8_t bgc =  color & 0xf;\n  for(int i=0 ; i < 8 ; i++)\n  {\n    int xoffs = x + 8 - i + horizontal_scroll();\n    /* don't draw outside (due to horizontal scroll) */\n    if(xoffs > kGFirstCol + kGResX)\n      continue;\n    /* draw pixel */\n    if(ISSET_BIT(data,i))\n    {\n      io_->screen_update_pixel(\n        xoffs, \n        y,\n        forec);\n    }\n    else\n    {\n      io_->screen_update_pixel(\n        xoffs, \n        y,\n        bgc);\n    }\n  }\n}\n\nvoid Vic::draw_mcbitmap(int x, int y, uint8_t data, uint8_t scolor, uint8_t rcolor)\n{\n  for(int i=0 ; i < 4 ; i++)\n  {\n    /* color */\n    uint8_t c;\n    /* color source */\n    uint8_t cs = ((data >> i*2) & 0x3);\n    switch(cs)\n    {\n    case 0:\n      c = bgcolor_[0]; \n      break;\n    case 1:\n      c = (scolor >> 4) & 0xf;\n      break;\n    case 2:\n      c = scolor & 0xf;\n      break;\n    case 3:\n      c = rcolor;\n      break;\n    }\n    int xoffs = x + 8 - i * 2 + horizontal_scroll();\n    io_->screen_update_pixel(\n      xoffs,\n      y,\n      c);\n    io_->screen_update_pixel(\n      xoffs + 1,\n      y,\n      c);\n  }  \n}\n \nvoid Vic::draw_raster_bitmap_mode()\n{\n  int rstr = raster_counter();\n  int y = rstr - kFirstVisibleLine;\n  if((rstr >= kGFirstLine) && \n     (rstr < kGLastLine) && \n     !is_screen_off())\n  {\n    /* draw background */\n    io_->screen_draw_rect(kGFirstCol,y,kGResX,bgcolor_[0]);\n    /* draw bitmaps */\n    for(int column=0; column < kGCols ; column++)\n    {\n      int x = kGFirstCol + column * 8;\n      int line = rstr - kGFirstLine;\n      int row = line/8;\n      int bitmap_row = line % 8;\n      /* retrieve bitmap data */\n      uint8_t data = get_bitmap_data(column,row,bitmap_row);\n      /* retrieve color data */\n      uint8_t scolor = get_screen_char(column,row);\n      uint8_t rcolor = get_char_color(column,row); \n      /* draw bitmap */\n      if(graphic_mode_ == kBitmapMode)\n        draw_bitmap(x,y,data,scolor);\n      else\n        draw_mcbitmap(x,y,data,scolor,rcolor);\n    }\n  }\n}\n\nvoid Vic::draw_mcsprite(int x, int y, int sprite, int row)\n{\n  uint16_t addr = get_sprite_ptr(sprite);\n  for (int i=0; i < 3 ; i++)\n  {\n    uint8_t  data = mem_->vic_read_byte(addr + row * 3 + i);\n    for (int j=0; j < 4; j++)\n    {\n      /* color */\n      uint8_t c = 0;\n      /* color source */\n      uint8_t cs = ((data >> j*2) & 0x3);\n      switch(cs)\n      {\n      /* transparent */\n      case 0:\n        break;\n      case 1:\n        c = sprite_shared_colors_[0];\n        break;\n      case 2:\n        c = sprite_colors_[sprite];\n        break;\n      case 3:\n        c = sprite_shared_colors_[1]; \n        break;\n      }\n      /* draw if not transparent */\n      if(cs != 0)\n      {\n        io_->screen_update_pixel(\n          x + i*8 + 8 - j * 2,          \n          y,\n          c);\n        io_->screen_update_pixel(\n          x + i*8 + 8 - j * 2 + 1,          \n          y,\n          c);\n      }\n    }\n  }      \n}\n\nvoid Vic::draw_sprite(int x, int y, int sprite, int row)\n{\n  int swid = is_double_width_sprite(sprite) ? 2 : 1;\n  uint16_t addr = get_sprite_ptr(sprite);\n  for(int w=0; w < swid ; w++ )\n  {\n    for (int i=0; i < 3 ; i++)\n    {\n      uint8_t  data = mem_->vic_read_byte(addr + row * 3 + i);\n      for (int j=0; j < 8; j++)\n      {\n        if(ISSET_BIT(data,j))\n        {\n          int new_x = (x+w + (i*8*swid) + (8*swid) - (j*swid)) ;\n          int color = sprite_colors_[sprite];\n          int side_border_offset = 0;\n          int top_border_offset  = 0;\n          int btm_border_offset  = 0;\n          /* check 38 cols mode */\n          if(!ISSET_BIT(cr2_,3))\n            side_border_offset = 8;\n          /* check 24 line mode */\n          if(!ISSET_BIT(cr1_,3))\n          {\n            top_border_offset = 2;\n            btm_border_offset = 4;\n          }\n          /* check bounds */\n          if(new_x <= kGFirstCol+side_border_offset ||\n             y < kGFirstCol + top_border_offset ||\n             new_x > kGResX+kGFirstCol-side_border_offset ||\n             y >= kGResY+kGFirstCol - btm_border_offset)\n            color = border_color_;\n          /* update pixel */\n          io_->screen_update_pixel(\n            new_x,\n            y,\n            color);\n        }\n      }\n    }\n  }\n}\n\nvoid Vic::draw_raster_sprites()\n{\n  if(sprite_enabled_ != 0)\n  {\n    int rstr = raster_counter();\n    int y = rstr - kFirstVisibleLine;\n    int sp_y = rstr - kSpritesFirstLine;\n    /* loop over sprites reverse order */\n    for(int n=7; n >= 0 ; n--)\n    {\n      int height = is_double_height_sprite(n) ? kSpriteHeight * 2 : kSpriteHeight;\n      /* check if the sprite is visible */\n      if(is_sprite_enabled(n) && \n         sp_y >= my_[n] && \n         sp_y < my_[n] + height)\n      {\n        int row = sp_y - my_[n];\n        int x = kSpritesFirstCol + sprite_x(n);\n        if(is_double_height_sprite(n))\n        {\n          row = (sp_y - my_[n])/2;\n        }\n        if(is_multicolor_sprite(n))\n        {\n          draw_mcsprite(x,y,n,row);\n        }\n        else\n        {\n          draw_sprite(x,y,n,row);\n        }\n      }\n    }\n  }\n}\n\n// helpers ///////////////////////////////////////////////////////////////////\n\nvoid Vic::raster_counter(int v)\n{\n  raster_c_ = (uint8_t)(v&0xff);\n  cr1_ &= 0x7f;\n  cr1_ |= ((v >> 1)&0x80);\n}\n\nint Vic::raster_counter()\n{\n  return (raster_c_ | ((cr1_&0x80) << 1));\n}\n\n/**\n * @brief screen on/off\n *\n * Bit #4 of cr1 :\n *\n * 0 = Screen off, complete screen is covered by border. \n * 1 = Screen on, normal screen contents are visible.\n */\nbool Vic::is_screen_off()\n{\n  return ((cr1_&(1<<4)) == 0);\n}\n\n/**\n * @brief checks for bad line condition\n *\n * According to Christian Bauer's paper:\n * \n * A Bad Line Condition is given at any arbitrary clock cycle, \n * if at the negative edge of 0 at the beginning of the cycle \n * RASTER >= $30 and RASTER <= $f7 and the lower three bits \n * of RASTER are equal to YSCROLL and if the DEN bit was set \n * during an arbitrary cycle of raster line $30.\n *\n */\nbool Vic::is_bad_line()\n{\n  int rstr = raster_counter();\n  return (rstr >= 0x30 &&\n          rstr <= 0xf7 &&\n          (rstr & 0x7) == (vertical_scroll() & 0x7));\n}\n\n/**\n * @brief check if raster irq is enabled \n */\nbool Vic::raster_irq_enabled()\n{\n  return ISSET_BIT(irq_enabled_,0);\n}\n\n/** \n * @brief get vertical raster scroll\n */\nuint8_t Vic::vertical_scroll()\n{\n  return(cr1_&0x7);\n} \n \n/** \n * @brief get horizontal raster scroll\n */\nuint8_t Vic::horizontal_scroll()\n{\n  return(cr2_&0x7);\n}\n\n/**\n * @brief check if sprite #n is enabled\n */\nbool Vic::is_sprite_enabled(int n)\n{\n  return ISSET_BIT(sprite_enabled_,n);\n}\n\n/**\n * @brief check if sprite #n is in background\n */\nbool Vic::is_background_sprite(int n)\n{\n  return ISSET_BIT(sprite_priority_,n);\n}\n \n/**\n * @brief check if sprite #n is double width\n */\nbool Vic::is_double_width_sprite(int n)\n{\n  return ISSET_BIT(sprite_double_width_,n);\n}\n\n/**\n * @brief check if sprite #n is double height\n */\nbool Vic::is_double_height_sprite(int n)\n{\n  return ISSET_BIT(sprite_double_height_,n);\n}\n\n/**\n * @brief check if sprite #n is multicolor\n */\nbool Vic::is_multicolor_sprite(int n)\n{\n  return ISSET_BIT(sprite_multicolor_,n);\n}\n\n/**\n * @brief returns sprite x coordinate \n */\nint Vic::sprite_x(int n)\n{\n  int x = mx_[n];\n  if(ISSET_BIT(msbx_,n))\n    x |= 1 << 8;\n  return x;\n}\n"
  },
  {
    "path": "src/vic.h",
    "content": "/*\n * emudore, Commodore 64 emulator\n * Copyright (c) 2016, Mario Ballano <mballano@gmail.com>\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef EMUDORE_VIC_H\n#define EMUDORE_VIC_H\n\n#include \"io.h\"\n#include \"cpu.h\"\n#include \"memory.h\"\n\n/**\n * @brief MOS Video Interface Chip II (VIC-II)\n *\n * MOS 6567 NTSC\n * MOS 6569 PAL\n *\n * This class implements the PAL version of the chip\n */\nclass Vic\n{\n  private:\n    Memory *mem_;\n    Cpu    *cpu_;\n    IO     *io_;\n    /* sprites  */\n    uint8_t mx_[8];\n    uint8_t my_[8];\n    uint8_t msbx_;\n    uint8_t sprite_enabled_;\n    uint8_t sprite_priority_;\n    uint8_t sprite_multicolor_;\n    uint8_t sprite_double_width_;\n    uint8_t sprite_double_height_;\n    uint8_t sprite_shared_colors_[2];\n    uint8_t sprite_colors_[8];\n    /* background and border colors */\n    uint8_t border_color_;\n    uint8_t bgcolor_[4];\n    /* cpu sync */\n    unsigned int next_raster_at_;\n    /* frame counter */\n    unsigned int frame_c_;\n    /* control registers */\n    uint8_t cr1_;\n    uint8_t cr2_;\n    /* raster */\n    uint8_t raster_c_;\n    int raster_irq_;\n    /* interrupt control */\n    uint8_t irq_status_;\n    uint8_t irq_enabled_;\n    /* screen, character memory and bitmap addresses */\n    uint16_t screen_mem_;\n    uint16_t char_mem_;\n    uint16_t bitmap_mem_;\n    uint8_t  mem_pointers_;\n    /* helpers */\n    inline void raster_counter(int v);\n    inline int raster_counter();\n    inline bool is_screen_off();\n    inline bool is_bad_line();\n    inline bool raster_irq_enabled();\n    inline uint8_t vertical_scroll();\n    inline uint8_t horizontal_scroll();\n    inline bool is_sprite_enabled(int n);\n    inline bool is_background_sprite(int n);\n    inline bool is_double_width_sprite(int n);\n    inline bool is_double_height_sprite(int n);\n    inline bool is_multicolor_sprite(int n);\n    inline int sprite_x(int n);\n    /* graphics */ \n    inline void draw_raster_char_mode();\n    inline void draw_raster_bitmap_mode();\n    inline void draw_raster_sprites();\n    inline void draw_sprite(int x, int y, int sprite, int row);\n    inline void draw_mcsprite(int x, int y, int sprite, int row);\n    inline void draw_char(int x, int y, uint8_t data, uint8_t color);\n    inline void draw_mcchar(int x, int y, uint8_t data, uint8_t color);\n    inline void draw_bitmap(int x, int y, uint8_t data, uint8_t color);\n    inline void draw_mcbitmap(int x, int y, uint8_t data, uint8_t scolor, uint8_t rcolor);\n    inline uint8_t get_screen_char(int column, int row);\n    inline uint8_t get_char_color(int column, int row);\n    inline uint8_t get_char_data(int chr, int line);\n    inline uint8_t get_bitmap_data(int column, int row, int line);\n    inline uint16_t get_sprite_ptr(int n);\n    inline void set_graphic_mode();\n  public:\n    Vic();\n    bool emulate();\n    void memory(Memory *v){mem_ = v;};\n    void cpu(Cpu *v){cpu_ = v;};\n    void io(IO *v){io_ = v;};\n    void write_register(uint8_t r, uint8_t v);\n    uint8_t read_register(uint8_t r);\n    unsigned int frames(){return frame_c_;};\n    /* constants */\n    static const int kScreenLines = 312;\n    static const int kScreenCols  = 504;\n    static const int kVisibleScreenWidth  = 403;\n    static const int kVisibleScreenHeight = 284;\n    static const int kFirstVisibleLine = 14;\n    static const int kLastVisibleLine = 298;\n    static const int kLineCycles = 63;\n    static const int kBadLineCycles = 23;\n    static constexpr double kRefreshRate = 1 / 50.125; // ~50Hz (PAL)\n    static const int kSpritePtrsOffset = 0x3f8;\n    /* graphic modes */\n    enum kGraphicMode\n    {\n      kCharMode,\n      kMCCharMode,\n      kBitmapMode,\n      kMCBitmapMode,\n      kExtBgMode,\n      kIllegalMode,\n    };\n    kGraphicMode graphic_mode_;\n    /* graphics constants */\n    static const int kGResX = 320;\n    static const int kGResY = 200;\n    static const int kGCols = 40;\n    static const int kGRows = 25;\n    static const int kGFirstLine = 56;\n    static const int kGLastLine  = 256;\n    static const int kGFirstCol  = 42;\n    /* sprites */\n    static const int kSpriteWidth = 24;\n    static const int kSpriteHeight = 21;\n    static const int kSpriteSize = 64;\n    static const int kSpritesFirstLine = 6;\n    static const int kSpritesFirstCol = 18;\n};\n\n#endif\n"
  }
]