openc166 0.2.2__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. {openc166-0.2.2 → openc166-0.2.5}/CMakeLists.txt +1 -1
  2. {openc166-0.2.2 → openc166-0.2.5}/PKG-INFO +1 -1
  3. {openc166-0.2.2 → openc166-0.2.5}/docs/compatibility.md +58 -14
  4. {openc166-0.2.2 → openc166-0.2.5}/docs/tasking.md +1 -1
  5. {openc166-0.2.2 → openc166-0.2.5}/src/assembler.cpp +201 -34
  6. {openc166-0.2.2 → openc166-0.2.5}/src/assembler.hpp +20 -2
  7. {openc166-0.2.2 → openc166-0.2.5}/tests/CMakeLists.txt +1 -0
  8. openc166-0.2.5/tests/diff/cases/listing.a66 +32 -0
  9. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_cond.cpp +33 -0
  10. openc166-0.2.5/tests/unit/test_listing.cpp +162 -0
  11. {openc166-0.2.2 → openc166-0.2.5}/.gitattributes +0 -0
  12. {openc166-0.2.2 → openc166-0.2.5}/.github/workflows/ci.yml +0 -0
  13. {openc166-0.2.2 → openc166-0.2.5}/.github/workflows/wheels.yml +0 -0
  14. {openc166-0.2.2 → openc166-0.2.5}/.gitignore +0 -0
  15. {openc166-0.2.2 → openc166-0.2.5}/LICENSE +0 -0
  16. {openc166-0.2.2 → openc166-0.2.5}/README.md +0 -0
  17. {openc166-0.2.2 → openc166-0.2.5}/cli/CMakeLists.txt +0 -0
  18. {openc166-0.2.2 → openc166-0.2.5}/cli/main.cpp +0 -0
  19. {openc166-0.2.2 → openc166-0.2.5}/cmake/embed_files.cmake +0 -0
  20. {openc166-0.2.2 → openc166-0.2.5}/docs/debug-info.md +0 -0
  21. {openc166-0.2.2 → openc166-0.2.5}/docs/debugger-design.md +0 -0
  22. {openc166-0.2.2 → openc166-0.2.5}/docs/ghidra.md +0 -0
  23. {openc166-0.2.2 → openc166-0.2.5}/docs/mpl.md +0 -0
  24. {openc166-0.2.2 → openc166-0.2.5}/docs/phase1-feasibility.md +0 -0
  25. {openc166-0.2.2 → openc166-0.2.5}/docs/releasing.md +0 -0
  26. {openc166-0.2.2 → openc166-0.2.5}/docs/simulator.md +0 -0
  27. {openc166-0.2.2 → openc166-0.2.5}/editors/vscode/README.md +0 -0
  28. {openc166-0.2.2 → openc166-0.2.5}/editors/vscode/extension.js +0 -0
  29. {openc166-0.2.2 → openc166-0.2.5}/editors/vscode/package.json +0 -0
  30. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/README.md +0 -0
  31. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/bsl_shim.a66 +0 -0
  32. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/driver_patch.a66 +0 -0
  33. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/kline_hello.a66 +0 -0
  34. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/loader.a66 +0 -0
  35. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/marker.a66 +0 -0
  36. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/memory_dump.a66 +0 -0
  37. {openc166-0.2.2 → openc166-0.2.5}/examples/mtos/stage2_hello.a66 +0 -0
  38. {openc166-0.2.2 → openc166-0.2.5}/examples/payload.a66 +0 -0
  39. {openc166-0.2.2 → openc166-0.2.5}/examples/sections.a66 +0 -0
  40. {openc166-0.2.2 → openc166-0.2.5}/inc/REG167.INC +0 -0
  41. {openc166-0.2.2 → openc166-0.2.5}/include/openc166/openc166.h +0 -0
  42. {openc166-0.2.2 → openc166-0.2.5}/pyproject.toml +0 -0
  43. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/__init__.py +0 -0
  44. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/_native.py +0 -0
  45. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/bridge.py +0 -0
  46. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/dap.py +0 -0
  47. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/ghidra.py +0 -0
  48. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/py.typed +0 -0
  49. {openc166-0.2.2 → openc166-0.2.5}/python/openc166/sim.py +0 -0
  50. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_bridge.py +0 -0
  51. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_dap.py +0 -0
  52. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_elf.py +0 -0
  53. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_ghidra.py +0 -0
  54. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_openc166.py +0 -0
  55. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_sim.py +0 -0
  56. {openc166-0.2.2 → openc166-0.2.5}/python/tests/test_stock_5wy19.py +0 -0
  57. {openc166-0.2.2 → openc166-0.2.5}/src/CMakeLists.txt +0 -0
  58. {openc166-0.2.2 → openc166-0.2.5}/src/bundled.cpp +0 -0
  59. {openc166-0.2.2 → openc166-0.2.5}/src/bundled.hpp +0 -0
  60. {openc166-0.2.2 → openc166-0.2.5}/src/capi.cpp +0 -0
  61. {openc166-0.2.2 → openc166-0.2.5}/src/capi.map +0 -0
  62. {openc166-0.2.2 → openc166-0.2.5}/src/capi_sim.cpp +0 -0
  63. {openc166-0.2.2 → openc166-0.2.5}/src/debuginfo.cpp +0 -0
  64. {openc166-0.2.2 → openc166-0.2.5}/src/diag.hpp +0 -0
  65. {openc166-0.2.2 → openc166-0.2.5}/src/disasm.cpp +0 -0
  66. {openc166-0.2.2 → openc166-0.2.5}/src/disasm.hpp +0 -0
  67. {openc166-0.2.2 → openc166-0.2.5}/src/disasm_module.cpp +0 -0
  68. {openc166-0.2.2 → openc166-0.2.5}/src/elf.cpp +0 -0
  69. {openc166-0.2.2 → openc166-0.2.5}/src/encode.cpp +0 -0
  70. {openc166-0.2.2 → openc166-0.2.5}/src/encode.hpp +0 -0
  71. {openc166-0.2.2 → openc166-0.2.5}/src/expr.cpp +0 -0
  72. {openc166-0.2.2 → openc166-0.2.5}/src/expr.hpp +0 -0
  73. {openc166-0.2.2 → openc166-0.2.5}/src/isa/c166.tbl +0 -0
  74. {openc166-0.2.2 → openc166-0.2.5}/src/isa/isa.cpp +0 -0
  75. {openc166-0.2.2 → openc166-0.2.5}/src/isa/isa.hpp +0 -0
  76. {openc166-0.2.2 → openc166-0.2.5}/src/isa/isa_types.hpp +0 -0
  77. {openc166-0.2.2 → openc166-0.2.5}/src/lexer.cpp +0 -0
  78. {openc166-0.2.2 → openc166-0.2.5}/src/lexer.hpp +0 -0
  79. {openc166-0.2.2 → openc166-0.2.5}/src/m166.cpp +0 -0
  80. {openc166-0.2.2 → openc166-0.2.5}/src/m166.hpp +0 -0
  81. {openc166-0.2.2 → openc166-0.2.5}/src/mpl.cpp +0 -0
  82. {openc166-0.2.2 → openc166-0.2.5}/src/mpl.hpp +0 -0
  83. {openc166-0.2.2 → openc166-0.2.5}/src/operand.cpp +0 -0
  84. {openc166-0.2.2 → openc166-0.2.5}/src/operand.hpp +0 -0
  85. {openc166-0.2.2 → openc166-0.2.5}/src/output.cpp +0 -0
  86. {openc166-0.2.2 → openc166-0.2.5}/src/predef.cpp +0 -0
  87. {openc166-0.2.2 → openc166-0.2.5}/src/predef.hpp +0 -0
  88. {openc166-0.2.2 → openc166-0.2.5}/src/sim/boards.cpp +0 -0
  89. {openc166-0.2.2 → openc166-0.2.5}/src/sim/boards.hpp +0 -0
  90. {openc166-0.2.2 → openc166-0.2.5}/src/sim/cpu.cpp +0 -0
  91. {openc166-0.2.2 → openc166-0.2.5}/src/sim/debug.cpp +0 -0
  92. {openc166-0.2.2 → openc166-0.2.5}/src/sim/debug.hpp +0 -0
  93. {openc166-0.2.2 → openc166-0.2.5}/src/sim/machine.cpp +0 -0
  94. {openc166-0.2.2 → openc166-0.2.5}/src/sim/machine.hpp +0 -0
  95. {openc166-0.2.2 → openc166-0.2.5}/src/sim/peripherals.cpp +0 -0
  96. {openc166-0.2.2 → openc166-0.2.5}/src/sim/peripherals.hpp +0 -0
  97. {openc166-0.2.2 → openc166-0.2.5}/src/value.hpp +0 -0
  98. {openc166-0.2.2 → openc166-0.2.5}/tests/acceptance/minimon.py +0 -0
  99. {openc166-0.2.2 → openc166-0.2.5}/tests/capi/test_capi.c +0 -0
  100. {openc166-0.2.2 → openc166-0.2.5}/tests/check_binary.cmake +0 -0
  101. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/alignment.a66 +0 -0
  102. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/bit_section_errors.a66 +0 -0
  103. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/bit_sections.a66 +0 -0
  104. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/bits.a66 +0 -0
  105. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/branches.a66 +0 -0
  106. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/cond.a66 +0 -0
  107. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/cond_errors.a66 +0 -0
  108. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/controls.a66 +0 -0
  109. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/defs.a66 +0 -0
  110. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/directives.a66 +0 -0
  111. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/dpp.a66 +0 -0
  112. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/expressions.a66 +0 -0
  113. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/group_errors.a66 +0 -0
  114. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/groups.a66 +0 -0
  115. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/code.inc +0 -0
  116. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/comments.inc +0 -0
  117. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/count.inc +0 -0
  118. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/crlf.inc +0 -0
  119. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/ignored.inc +0 -0
  120. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/lit.inc +0 -0
  121. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/mpl.inc +0 -0
  122. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/nested.inc +0 -0
  123. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/noeol.inc +0 -0
  124. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/regs.inc +0 -0
  125. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/sub/deep.inc +0 -0
  126. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/inc/sub/level3.inc +0 -0
  127. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/include.a66 +0 -0
  128. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/label_errors.a66 +0 -0
  129. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/labels.a66 +0 -0
  130. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/bits/1main.a66 +0 -0
  131. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/bits/2lib.a66 +0 -0
  132. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/bits/3more.a66 +0 -0
  133. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/calls/1main.a66 +0 -0
  134. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/calls/2lib.a66 +0 -0
  135. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/combine/1first.a66 +0 -0
  136. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/combine/2second.a66 +0 -0
  137. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/combine/3third.a66 +0 -0
  138. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/fixups/1use.a66 +0 -0
  139. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/fixups/2def.a66 +0 -0
  140. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/groups/1main.a66 +0 -0
  141. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/groups/2lib.a66 +0 -0
  142. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/mixed/1seg.a66 +0 -0
  143. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/mixed/2flat.a66 +0 -0
  144. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/mixed/3seg.a66 +0 -0
  145. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/regbanks/1main.a66 +0 -0
  146. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/regbanks/2lib.a66 +0 -0
  147. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/sections/1first.a66 +0 -0
  148. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/sections/2second.a66 +0 -0
  149. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/sections/3third.a66 +0 -0
  150. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/segmented/1main.a66 +0 -0
  151. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/segmented/2lib.a66 +0 -0
  152. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/unresolved/1main.a66 +0 -0
  153. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/unresolved/2one.a66 +0 -0
  154. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/unresolved/3two.a66 +0 -0
  155. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/values/1use.a66 +0 -0
  156. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/link/values/2def.a66 +0 -0
  157. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/lit.a66 +0 -0
  158. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/lit_errors.a66 +0 -0
  159. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/locate.a66 +0 -0
  160. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/macro_args.a66 +0 -0
  161. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/macro_errors.a66 +0 -0
  162. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/macros.a66 +0 -0
  163. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl.a66 +0 -0
  164. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_exit.a66 +0 -0
  165. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_expr.a66 +0 -0
  166. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_fi.a66 +0 -0
  167. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_meta.a66 +0 -0
  168. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_paren.a66 +0 -0
  169. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_pattern.a66 +0 -0
  170. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_syntax.a66 +0 -0
  171. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/mpl_err_undefined.a66 +0 -0
  172. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/operands.a66 +0 -0
  173. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/primary.a66 +0 -0
  174. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/redefine.a66 +0 -0
  175. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/regbank_errors.a66 +0 -0
  176. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/regbanks.a66 +0 -0
  177. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/reloc.a66 +0 -0
  178. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/section_errors.a66 +0 -0
  179. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/section_length.a66 +0 -0
  180. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/segmented.a66 +0 -0
  181. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/type_operator_errors.a66 +0 -0
  182. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/cases/type_operators.a66 +0 -0
  183. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/gen_sweep.py +0 -0
  184. {openc166-0.2.2 → openc166-0.2.5}/tests/diff/keil_diff.py +0 -0
  185. {openc166-0.2.2 → openc166-0.2.5}/tests/expected/driver_patch.hex +0 -0
  186. {openc166-0.2.2 → openc166-0.2.5}/tests/expected/driver_patch.s28 +0 -0
  187. {openc166-0.2.2 → openc166-0.2.5}/tests/expected/payload.srec +0 -0
  188. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/helpers.hpp +0 -0
  189. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/main.cpp +0 -0
  190. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_assembler.cpp +0 -0
  191. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_bits.cpp +0 -0
  192. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_branches.cpp +0 -0
  193. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_debug.cpp +0 -0
  194. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_defs.cpp +0 -0
  195. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_dpp.cpp +0 -0
  196. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_encode.cpp +0 -0
  197. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_expr.cpp +0 -0
  198. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_groups.cpp +0 -0
  199. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_include.cpp +0 -0
  200. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_lexer.cpp +0 -0
  201. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_link.cpp +0 -0
  202. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_lit.cpp +0 -0
  203. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_macros.cpp +0 -0
  204. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_mpl.cpp +0 -0
  205. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_output.cpp +0 -0
  206. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_peripherals.cpp +0 -0
  207. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_regbanks.cpp +0 -0
  208. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_sections.cpp +0 -0
  209. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_sim.cpp +0 -0
  210. {openc166-0.2.2 → openc166-0.2.5}/tests/unit/test_tasking.cpp +0 -0
  211. {openc166-0.2.2 → openc166-0.2.5}/third_party/doctest/LICENSE.txt +0 -0
  212. {openc166-0.2.2 → openc166-0.2.5}/third_party/doctest/doctest.h +0 -0
  213. {openc166-0.2.2 → openc166-0.2.5}/tools/CMakeLists.txt +0 -0
  214. {openc166-0.2.2 → openc166-0.2.5}/tools/ghidra/ExportOpenc166Symbols.py +0 -0
  215. {openc166-0.2.2 → openc166-0.2.5}/tools/isagen.cpp +0 -0
@@ -1,6 +1,6 @@
1
1
  cmake_minimum_required(VERSION 3.20)
2
2
  project(openc166
3
- VERSION 0.2.2
3
+ VERSION 0.2.5
4
4
  DESCRIPTION "Keil A166-compatible assembler for the Infineon C166/C167 family"
5
5
  LANGUAGES CXX)
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openc166
3
- Version: 0.2.2
3
+ Version: 0.2.5
4
4
  Summary: Keil A166-compatible assembler for the Infineon C166/C167 microcontrollers
5
5
  Keywords: c166,c167,st10,assembler,keil,a166,infineon,ecu
6
6
  License-Expression: MIT
@@ -76,13 +76,15 @@ since OH166 starts a new record at each section.
76
76
  banks are placed as L166 places them), `NAME`, `SSKDEF`, `PECDEF` and
77
77
  `TYPEDEC`, with Keil's error checks. See
78
78
  [Register banks and linker directives](#register-banks-and-linker-directives).
79
- - **Accepted and ignored:** listing and object-file controls such as
80
- `$NOLIST`, `$TITLE(...)` and `$DEBUG`, which only matter to a printed
81
- listing or a debugger.
79
+ - **Accepted and ignored:** object-file controls such as `$DEBUG` and
80
+ `$OBJECT`, and `$PRINT`/`$NOPRINT`: the command line says which files
81
+ are written.
82
82
  - **Controls:** `$MOD167`, `$MOD166`/`$NOMOD166`, `$CASE`/`$NOCASE`,
83
83
  `$SEGMENTED`/`$NONSEGMENTED`, `$TABS`, `$MACRO`/`$NOMACRO`,
84
- `$MPL`/`$NOMPL`, `$GEN`/`$NOGEN`/`$GENONLY`, `$SAVE`/`$RESTORE`.
85
- `$MODV2` falls back to the C167 set, with warning OC2. Some controls must
84
+ `$MPL`/`$NOMPL`, `$GEN`/`$NOGEN`/`$GENONLY`, `$LIST`/`$NOLIST`,
85
+ `$SAVE`/`$RESTORE`, and the [listing controls](#listing-controls)
86
+ `$TITLE`, `$EJECT`, `$PAGING`, `$PAGELENGTH`, `$PAGEWIDTH`,
87
+ `$SYMBOLS`, `$SYMLIST` and `$XREF`. `$MODV2` falls back to the C167 set, with warning OC2. Some controls must
86
88
  come before the first statement; see [Controls](#controls).
87
89
 
88
90
  ## Not supported yet
@@ -232,17 +234,18 @@ Keil has two kinds of `$` controls:
232
234
  Primary controls that openc166 uses: `MOD167`/`M167`, `MOD166`/`M166`,
233
235
  `NOMOD166`/`NOM166`, `MODV2`, `CASE`, `NOCASE`, `INCDIR`/`ID`,
234
236
  `SEGMENTED`/`SG`, `NONSEGMENTED`/`NOSG`, `TABS`/`TA`, `MACRO`, `NOMACRO`,
235
- `MPL`, `NOMPL`. Those it ignores: `PAGELENGTH`/`PL`, `PAGEWIDTH`/`PW`, `SYMBOLS`/`SB`,
236
- `NOSYMBOLS`/`NOSB`, `XREF`/`XR`, `NOXREF`/`NOXR`, `DEBUG`/`DB`,
237
- `NODEBUG`/`NODB`, `PRINT`/`PR`, `NOPRINT`/`NOPR`, `OBJECT`/`OJ`,
238
- `NOOBJECT`/`NOOJ`, `ERRORPRINT`/`EP`, `NOERRORPRINT`/`NOEP`, `PAGING`,
239
- `NOPAGING`, `DATE`, `LINES`, `NOLINES`, `TYPE`, `NOTYPE`, `AMAKE`,
240
- `NOAMAKE`, `USEDEXTONLY`, `EXTMAC`, `EXPDECNUM`, `ABSOLUTE`, `NOABSOLUTE`.
237
+ `MPL`, `NOMPL`, `PAGELENGTH`/`PL`, `PAGEWIDTH`/`PW`, `PAGING`, `NOPAGING`,
238
+ `SYMBOLS`/`SB`, `NOSYMBOLS`/`NOSB`, `XREF`/`XR`, `NOXREF`/`NOXR`. Those it
239
+ ignores: `DEBUG`/`DB`, `NODEBUG`/`NODB`, `PRINT`/`PR`, `NOPRINT`/`NOPR`,
240
+ `OBJECT`/`OJ`, `NOOBJECT`/`NOOJ`, `ERRORPRINT`/`EP`, `NOERRORPRINT`/`NOEP`,
241
+ `DATE` (its argument is checked), `LINES`, `NOLINES`, `TYPE`, `NOTYPE`,
242
+ `AMAKE`, `NOAMAKE`, `USEDEXTONLY`, `EXTMAC`, `EXPDECNUM`, `ABSOLUTE`,
243
+ `NOABSOLUTE`.
241
244
 
242
245
  General controls that openc166 uses: `INCLUDE`/`IC`, `SET`, `RESET`, `IF`,
243
246
  `ELSEIF`, `ELSE`, `ENDIF`, `COND`, `NOCOND`, `GEN`/`GE`, `NOGEN`/`NOGE`,
244
- `GENONLY`/`GO`, `SAVE`/`SA`, `RESTORE`/`RS`. Those it ignores: `LIST`,
245
- `NOLIST`, `TITLE`/`TT`, `EJECT`/`EJ`, `SYMLIST`, `NOSYMLIST`, `REGUSE`.
247
+ `GENONLY`/`GO`, `SAVE`/`SA`, `RESTORE`/`RS`, `LIST`/`LI`, `NOLIST`/`NOLI`,
248
+ `TITLE`/`TT`, `EJECT`/`EJ`, `SYMLIST`, `NOSYMLIST`. It ignores `REGUSE`.
246
249
 
247
250
  These lists come from testing A166 V5.38. The manual calls `TITLE` and
248
251
  `NOCOND` primary, but A166 accepts them anywhere. An unknown control is
@@ -276,6 +279,40 @@ otherwise ignored, even controls and conditionals. Problems found at the end
276
279
  of the file; an unclosed `SECTION` or `PROC` (A106) on the `END` line (with
277
280
  no `END` at all, Keil reports only A89).
278
281
 
282
+ ### Listing controls
283
+
284
+ The listing has openc166's own layout, not Keil's, but these controls mean
285
+ what they mean in Keil:
286
+
287
+ - **`$EJECT`** starts a new page after its line: a form feed, then a header
288
+ with the title and the page number. An `$EJECT` that `$NOLIST` hides
289
+ does not.
290
+ - **`$TITLE(text)`** sets the title of the page headers. As in Keil, every
291
+ header shows the last title of the file. Without one the header names
292
+ the source file. The first page has no header.
293
+ - **`$PAGING`**, **`$PAGELENGTH(n)`** (18 to 65535) break the listing into
294
+ pages of `n` rows, 60 unless given, header included. `$NOPAGING` leaves
295
+ only the `$EJECT` breaks.
296
+ - **`$PAGEWIDTH(n)`** (72 to 132) wraps longer rows; the rest of a source
297
+ line continues in the source column.
298
+ - **`$NOSYMBOLS`** leaves out the symbol table, unless `$XREF` is given.
299
+ Symbols defined between **`$NOSYMLIST`** and `$SYMLIST` are left out of
300
+ it.
301
+ - **`$XREF`** adds to each symbol the line of its definition, marked `#`,
302
+ and the lines that use it in an expression.
303
+
304
+ A number out of range is A19, a missing argument A22, and an argument on a
305
+ control that takes none, as in `$EJECT(1)`, is A16, though as in Keil the
306
+ control still counts. Only the printed listing changes: the symbols of the
307
+ result, the debug information and the ELF file always have every symbol.
308
+ The symbol and section tables are not paged or wrapped.
309
+
310
+ Unlike Keil, openc166 does not break pages or wrap rows unless the source
311
+ asks for it (in Keil, `$PAGING`, `$PAGELENGTH(60)` and `$PAGEWIDTH(120)`
312
+ are the defaults), and it ignores `$DATE`: its headers have no date, so
313
+ the same source always gives the same listing. In TASKING sources these
314
+ controls are still ignored, except `LIST` and `NOLIST`.
315
+
279
316
  ## Conditional assembly
280
317
 
281
318
  Keil has two ways to leave lines out, and openc166 supports both:
@@ -329,6 +366,12 @@ COUNT EQU 4 ; ordinary symbols for IF
329
366
  after it are assembled, an `IF` statement when the lines before it are.
330
367
  `$NOCOND` leaves out every line after which assembly is off; `$COND`
331
368
  (the default) shows them again.
369
+ - **`$NOLIST`.** Leaves the following lines out of the listing, the
370
+ `$NOLIST` line included, until a `$LIST` line, which is listed. Lines of
371
+ include files count too, and a `$NOLIST` in an include file still holds
372
+ after the file ends. A line with an error or warning is listed anyway,
373
+ with its message. The lines are assembled as usual: only the listing
374
+ changes.
332
375
 
333
376
  ## LIT
334
377
 
@@ -454,7 +497,7 @@ SKIP:
454
497
  - **Listing.** Expanded lines are numbered and carry `+1`, `+2`, ... after
455
498
  the number for the depth of expansion. Under `$NOGEN` (the default) and
456
499
  `$GENONLY` they are hidden; `$GEN` shows them. `$SAVE` and `$RESTORE`
457
- keep and bring back the `GEN` setting, 10 levels deep (A14 beyond, and
500
+ keep and bring back the `LIST` and `GEN` settings, 10 levels deep (A14 beyond, and
458
501
  A13 for `$RESTORE` without `$SAVE`). A problem in an expanded line is
459
502
  reported at the line of the outermost call, or, for a `REPT`, `IRP` or
460
503
  `IRPC` written in the source, at its `ENDM` line.
@@ -1123,6 +1166,7 @@ follow are unchanged. Other bad items are dropped.
1123
1166
  | `-(L1 - L0)`, `NOT (L1 - L0)`, `-(L1 - 1)` | wrong value, no warning | error A63 |
1124
1167
  | `number - label` (`10H - L1`) | wrong value | error A63 |
1125
1168
  | decimal fraction such as `#1.0` | accepted as 0 | error A70 |
1169
+ | page breaks and wrapped rows in the listing | on by default (`$PAGING`, 60 rows, 120 columns) | only with `$PAGING`, `$PAGELENGTH` or `$PAGEWIDTH`; `$EJECT` always works |
1126
1170
  | instruction at an odd address | accepted | error A134 |
1127
1171
  | instruction outside a `PROC` | error A45 | accepted |
1128
1172
  | instruction or data outside any `SECTION` | error A44 | placed at `--origin` |
@@ -70,7 +70,7 @@ for `CASE`, `DEF` for `DEFINE`, ...).
70
70
  |---|---|
71
71
  | `CASE`, `NOCASE` | as in Keil: whether names are case sensitive |
72
72
  | `SEGMENTED`, `NONSEGMENTED` | as in Keil; see [Segmented mode](compatibility.md#segmented-mode-and-dpps) |
73
- | `INCLUDE(file)`, `GEN`, `NOGEN`, `SAVE`, `RESTORE`, `TABS` | as in Keil |
73
+ | `INCLUDE(file)`, `GEN`, `NOGEN`, `LIST`, `NOLIST`, `SAVE`, `RESTORE`, `TABS` | as in Keil |
74
74
  | `STDNAMES(file)` | reads a register file: see [Register names](#register-names) |
75
75
  | `DEFINE(name[, text])` | defines an m166 macro; without text it is `1` |
76
76
  | `EXTEND` | the C167 instructions (always on) |
@@ -638,7 +638,14 @@ constexpr PrimaryChoice kPrimaryChoices[] = {
638
638
  };
639
639
 
640
640
  constexpr std::string_view kIgnoredControls[] = {
641
- "LIST", "LI", "NOLIST", "NOLI", "TITLE", "TT", "EJECT", "EJ", "SYMLIST", "NOSYMLIST", "REGUSE",
641
+ "REGUSE",
642
+ };
643
+
644
+ // Listing controls that take no argument: one in parentheses is A16, though
645
+ // the control still counts.
646
+ constexpr std::string_view kBareListingControls[] = {
647
+ "LIST", "LI", "NOLIST", "NOLI", "EJECT", "EJ", "SYMLIST", "NOSYMLIST", "SYMBOLS", "SB", "NOSYMBOLS",
648
+ "NOSB", "XREF", "XR", "NOXREF", "NOXR", "PAGING", "NOPAGING",
642
649
  };
643
650
 
644
651
  // TASKING a166 controls, by full name: abbreviations that differ from
@@ -669,8 +676,7 @@ constexpr std::string_view kTaskingIgnored[] = {
669
676
  "ABSOLUTE", "AB", "NOABSOLUTE", "NOAB", "ASMLINEINFO", "A", "NOASMLINEINFO", "NOA", "DATE", "DA",
670
677
  "DEBUG", "DB", "NODEBUG", "NODB", "EJECT", "EJ", "ERRORPRINT", "EP", "NOERRORPRINT", "NOEP",
671
678
  "EXPANDREGBANK", "XRB", "NOEXPANDREGBANK", "NOXRB", "EXTPEC16", "EP16", "NOEXTPEC16", "NOEP16", "FLOAT",
672
- "FL", "GSO", "HEADER", "HD", "NOHEADER", "NOHD", "LINES", "LN", "NOLINES", "NOLN", "LIST", "LI",
673
- "NOLIST", "NOLI", "LISTALL", "LA", "NOLISTALL", "NOLA", "LOCALS", "LC", "NOLOCALS", "NOLC", "MISRAC",
679
+ "FL", "GSO", "HEADER", "HD", "NOHEADER", "NOHD", "LINES", "LN", "NOLINES", "NOLN", "LISTALL", "LA", "NOLISTALL", "NOLA", "LOCALS", "LC", "NOLOCALS", "NOLC", "MISRAC",
674
680
  "MC", "MODEL", "MD", "OBJECT", "OJ", "NOOBJECT", "NOOJ", "OPTIMIZE", "PAGELENGTH", "PL", "PAGEWIDTH",
675
681
  "PW", "PAGING", "PA", "NOPAGING", "NOPA", "PEC", "PC", "NOPEC", "NOPC", "PRINT", "PR", "NOPRINT", "NOPR",
676
682
  "RETCHECK", "RC", "NORETCHECK", "NORC", "STRICTTASK", "ST", "NOSTRICTTASK", "NOST", "SYMB", "SM",
@@ -682,7 +688,7 @@ constexpr std::string_view kTaskingIgnored[] = {
682
688
  // TASKING controls that work as in Keil.
683
689
  constexpr std::string_view kTaskingShared[] = {
684
690
  "INCLUDE", "IC", "CASE", "NOCASE", "SEGMENTED", "SG", "NONSEGMENTED", "NOSG", "SAVE", "SA", "RESTORE",
685
- "GEN", "GE", "NOGEN", "NOGE", "GENONLY", "GO", "TABS", "TA",
691
+ "GEN", "GE", "NOGEN", "NOGE", "GENONLY", "GO", "TABS", "TA", "LIST", "LI", "NOLIST", "NOLI",
686
692
  };
687
693
 
688
694
  enum class ProcKind : std::uint8_t { None, Near, Far, Interrupt };
@@ -826,6 +832,7 @@ private:
826
832
  struct Entry {
827
833
  Symbol sym;
828
834
  int pass = 0; // pass of the latest definition
835
+ std::vector<int> refs; // $XREF: lines of the final pass that use the symbol
829
836
  };
830
837
 
831
838
  struct SourceFile {
@@ -889,17 +896,29 @@ private:
889
896
  std::string macro_file_; // for a line of an expansion: where its body line was written
890
897
  int macro_line_ = 0;
891
898
  bool gen_ = false; // $GEN: list the lines of expansions
899
+ bool list_ = true; // $LIST: list the source lines ($NOLIST turns it off)
892
900
  bool macro_ = true; // standard macros allowed ($NOMACRO turns them off)
893
901
  bool mpl_ = true; // MPL macro processing: '%' is its metacharacter ($NOMPL and $NOMACRO turn it off)
894
902
  // MPL's output for the source and its include files, made in the first
895
903
  // pass; when MPL is on, the passes read these lines instead of the files.
896
904
  std::optional<std::vector<MplLine>> mpl_lines_;
897
905
  bool from_mpl_ = false; // this pass reads mpl_lines_: MPL has read the include files
898
- std::vector<bool> saved_gen_; // gen_ of each $SAVE
906
+ // list_ and gen_ of each $SAVE
907
+ struct SavedListing {
908
+ bool list, gen;
909
+ };
910
+ std::vector<SavedListing> saved_gen_;
899
911
  bool fatal_ = false; // stops the pass, like Keil's fatal errors
900
912
  bool primary_done_ = false; // a statement was seen: primary controls are no longer allowed
901
913
  std::map<std::string_view, std::set<std::string_view>> primary_seen_; // settings given for each group of primary controls
902
914
  int tabs_ = 8; // $TABS: tab stops for expand_tabs()
915
+ // Listing controls. Keil breaks pages by default; openc166 only when
916
+ // $PAGING or $PAGELENGTH asks for it.
917
+ bool symlist_ = true; // $SYMLIST: symbols defined now go in the symbol table
918
+ bool eject_ = false; // $EJECT on the current line
919
+ std::optional<bool> paging_;
920
+ std::optional<int> page_length_;
921
+ ListingOptions listing_options_;
903
922
  std::size_t file_ = 0; // files_ index of the current line
904
923
  int level_ = 0; // include nesting depth of the current line
905
924
  std::string joined_; // include file whose last line was joined to the current line
@@ -986,6 +1005,8 @@ private:
986
1005
  bool control_condition(std::string_view text, std::size_t after, int column, Reporter& rep);
987
1006
  void set_flags(std::string_view text, std::size_t from, std::size_t to, bool set);
988
1007
  void set_tabs(std::optional<std::string_view> arg, bool closed, int column);
1008
+ void control_number(std::string_view name, std::optional<std::string_view> arg, bool closed, int column, int low,
1009
+ int high, bool quotes, int& number);
989
1010
  bool contradicts(std::string_view name);
990
1011
  void include(std::string_view name, int column);
991
1012
  void add_incdirs(std::string_view dirs);
@@ -1086,6 +1107,8 @@ std::optional<Value> Assembler::lookup(std::string_view name) {
1086
1107
  forward_ref_ = true;
1087
1108
  ++forward_count_;
1088
1109
  }
1110
+ if (final_ && listing_options_.xref && (it->second.refs.empty() || it->second.refs.back() != line_no_))
1111
+ it->second.refs.push_back(line_no_);
1089
1112
  return it->second.sym.value;
1090
1113
  }
1091
1114
 
@@ -1113,7 +1136,12 @@ void Assembler::define(const Token& name, SymbolKind kind, const Value& v, bool
1113
1136
  throw AsmError("A25", "symbol redefinition", name.column);
1114
1137
  }
1115
1138
  if (kind != SymbolKind::Set && (inserted || !same_value(e.sym.value, v))) changed_ = true;
1116
- e.sym = Symbol{std::string(name.text), kind, v, line_no_, {}};
1139
+ e.sym = Symbol{};
1140
+ e.sym.name = std::string(name.text);
1141
+ e.sym.kind = kind;
1142
+ e.sym.value = v;
1143
+ e.sym.line = line_no_;
1144
+ e.sym.listed = symlist_;
1117
1145
  e.pass = pass_;
1118
1146
  }
1119
1147
 
@@ -1334,11 +1362,17 @@ void Assembler::run_lines() {
1334
1362
  macros_.clear();
1335
1363
  locals_ = 0;
1336
1364
  gen_ = false;
1365
+ list_ = true;
1337
1366
  macro_ = true;
1338
1367
  // TASKING has no MPL: '%' is the remainder operator.
1339
1368
  mpl_ = !tasking_ && initial_mpl(files_[0]->lines);
1340
1369
  primary_seen_.clear();
1341
1370
  tabs_ = 8;
1371
+ symlist_ = true;
1372
+ eject_ = false;
1373
+ paging_.reset();
1374
+ page_length_.reset();
1375
+ listing_options_ = ListingOptions{};
1342
1376
  saved_gen_.clear();
1343
1377
  m166_.reset();
1344
1378
  pre_rep_ = Reporter{};
@@ -1611,6 +1645,7 @@ void Assembler::process_line(std::string_view text) {
1611
1645
  lst.source = m166_source_.empty() ? std::string(text) : m166_source_;
1612
1646
  // Keil lists the lines after END but does nothing else with them.
1613
1647
  if (ended_) {
1648
+ lst.hidden = !list_;
1614
1649
  pre_rep_ = Reporter{};
1615
1650
  if (final_) res_.listing.push_back(std::move(lst));
1616
1651
  return;
@@ -1630,10 +1665,14 @@ void Assembler::process_line(std::string_view text) {
1630
1665
  }
1631
1666
  // Like Keil, a $IF line is numbered in the listing when the lines after
1632
1667
  // it are assembled, an IF statement when the lines before it are.
1633
- // $NOCOND leaves out every line after which assembly is off.
1668
+ // $NOCOND leaves out every line after which assembly is off, and
1669
+ // $NOLIST every line after which it is in effect: the $NOLIST line
1670
+ // itself, but not the $LIST line that ends it.
1634
1671
  const bool now_active = active();
1635
1672
  lst.skipped = m166_skipped_ || !(control_line ? now_active : was_active);
1636
- lst.hidden = (!now_active && !cond_listing_) || (macro_level_ > 0 && !gen_);
1673
+ lst.hidden = !list_ || (!now_active && !cond_listing_) || (macro_level_ > 0 && !gen_);
1674
+ // Like Keil, no new page for an $EJECT that $NOLIST hides.
1675
+ lst.eject = std::exchange(eject_, false) && list_;
1637
1676
  rep_ = nullptr;
1638
1677
  if (!final_) return;
1639
1678
  for (auto& d : rep.items()) {
@@ -2017,12 +2056,51 @@ void Assembler::controls(std::string_view text, std::size_t from, Reporter& rep)
2017
2056
  gen_ = true;
2018
2057
  } else if (name == "NOGEN" || name == "NOGE" || name == "GENONLY" || name == "GO") {
2019
2058
  gen_ = false;
2059
+ } else if (name == "EJECT" || name == "EJ") {
2060
+ eject_ = true;
2061
+ } else if (name == "TITLE" || name == "TT") {
2062
+ if (!list[k].paren) throw AsmError("A22", "')' expected: $TITLE takes a text in parentheses", column);
2063
+ listing_options_.title = std::string(arg(list[k]));
2064
+ } else if (name == "SYMLIST") {
2065
+ symlist_ = true;
2066
+ } else if (name == "NOSYMLIST") {
2067
+ symlist_ = false;
2068
+ } else if (name == "SYMBOLS" || name == "SB") {
2069
+ listing_options_.symbols = true;
2070
+ } else if (name == "NOSYMBOLS" || name == "NOSB") {
2071
+ listing_options_.symbols = false;
2072
+ } else if (name == "XREF" || name == "XR") {
2073
+ listing_options_.xref = true;
2074
+ } else if (name == "NOXREF" || name == "NOXR") {
2075
+ listing_options_.xref = false;
2076
+ } else if (name == "PAGING") {
2077
+ paging_ = true;
2078
+ } else if (name == "NOPAGING") {
2079
+ paging_ = false;
2080
+ } else if (name == "PAGELENGTH" || name == "PL") {
2081
+ int length = 0;
2082
+ control_number(name, list[k].paren ? std::optional(arg(list[k])) : std::nullopt, !list[k].unclosed,
2083
+ column, 18, 65535, false, length);
2084
+ page_length_ = length;
2085
+ } else if (name == "PAGEWIDTH" || name == "PW") {
2086
+ int width = 0;
2087
+ control_number(name, list[k].paren ? std::optional(arg(list[k])) : std::nullopt, !list[k].unclosed,
2088
+ column, 72, 132, false, width);
2089
+ listing_options_.page_width = width;
2090
+ } else if (name == "DATE") {
2091
+ // Keil V5.38 takes the text but still prints today's date.
2092
+ if (!list[k].paren) throw AsmError("A22", "')' expected: $DATE takes a text in parentheses", column);
2093
+ } else if (name == "LIST" || name == "LI") {
2094
+ list_ = true;
2095
+ } else if (name == "NOLIST" || name == "NOLI") {
2096
+ list_ = false;
2020
2097
  } else if (name == "SAVE" || name == "SA") {
2021
2098
  if (saved_gen_.size() >= kMaxSaveDepth) throw AsmError("A14", "SAVE stack overflow", column);
2022
- saved_gen_.push_back(gen_);
2099
+ saved_gen_.push_back({list_, gen_});
2023
2100
  } else if (name == "RESTORE" || name == "RS") {
2024
2101
  if (saved_gen_.empty()) throw AsmError("A13", "SAVE stack underflow", column);
2025
- gen_ = saved_gen_.back();
2102
+ list_ = saved_gen_.back().list;
2103
+ gen_ = saved_gen_.back().gen;
2026
2104
  saved_gen_.pop_back();
2027
2105
  } else if (name == "MACRO") {
2028
2106
  macro_ = true;
@@ -2044,6 +2122,10 @@ void Assembler::controls(std::string_view text, std::size_t from, Reporter& rep)
2044
2122
  throw AsmError("A7", "respecified primary control, line ignored: $" + name +
2045
2123
  " contradicts an earlier primary control",
2046
2124
  column);
2125
+ // Keil uses a listing control that has an argument it should not
2126
+ // have, and then reports it.
2127
+ if (!tasking_ && list[k].paren && contains(kBareListingControls, name))
2128
+ throw AsmError("A16", "unknown control or bad argument(s): $" + name + " takes no argument", column);
2047
2129
  }
2048
2130
  if (cond) cond_control(cond->name, text, cond->arg, cond->column, true, rep);
2049
2131
  }
@@ -2108,6 +2190,7 @@ void Assembler::command_control(const std::string& text) {
2108
2190
  rep.error(e.code(), e.message(), e.column());
2109
2191
  }
2110
2192
  rep_ = nullptr;
2193
+ eject_ = false;
2111
2194
  // Files from earlier controls are read first.
2112
2195
  if (include_) stack_.insert(stack_.end() - commanded_, Frame{*include_, 0, 1, nullptr}), ++commanded_;
2113
2196
  include_.reset();
@@ -2142,14 +2225,24 @@ bool Assembler::contradicts(std::string_view name) {
2142
2225
  // space; when only the ')' is missing, the number is still used.
2143
2226
  void Assembler::set_tabs(std::optional<std::string_view> arg, bool closed, int column) {
2144
2227
  tabs_ = 1;
2145
- if (!arg) throw AsmError("A22", "')' expected: $TABS takes a number in parentheses", column);
2228
+ control_number("TABS", arg, closed, column, 1, 16, true, tabs_);
2229
+ }
2230
+
2231
+ // The number of a control such as $TABS(4) or $PAGELENGTH(60): decimal, or
2232
+ // hexadecimal with an H. Outside low..high is A19; a missing parenthesis or
2233
+ // text after the number is A22, but then, like Keil, the number is still
2234
+ // used. 'quotes': a ' inside the number is skipped, as Keil does for $TABS.
2235
+ void Assembler::control_number(std::string_view name, std::optional<std::string_view> arg, bool closed, int column,
2236
+ int low, int high, bool quotes, int& result) {
2237
+ if (!arg)
2238
+ throw AsmError("A22", "')' expected: $" + std::string(name) + " takes a number in parentheses", column);
2146
2239
  std::size_t i = arg->find_first_not_of(" \t");
2147
2240
  std::string digits;
2148
2241
  for (; i < arg->size(); ++i) {
2149
2242
  const char c = (*arg)[i];
2150
2243
  if (std::isalnum(static_cast<unsigned char>(c)) || c == '.' || c == '_')
2151
2244
  digits += static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
2152
- else if (c != '\'')
2245
+ else if (c != '\'' || !quotes)
2153
2246
  break;
2154
2247
  }
2155
2248
  int base = 10;
@@ -2157,16 +2250,18 @@ void Assembler::set_tabs(std::optional<std::string_view> arg, bool closed, int c
2157
2250
  base = 16;
2158
2251
  digits.pop_back();
2159
2252
  }
2160
- int width = 0;
2253
+ int number = 0;
2161
2254
  bool good = !digits.empty();
2162
2255
  for (char c : digits) {
2163
2256
  const int d = std::isdigit(static_cast<unsigned char>(c)) ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10 : 99;
2164
2257
  good = good && d < base;
2165
- width = std::min(width * base + d, 1000);
2258
+ number = std::min(number * base + d, 1000000);
2166
2259
  }
2167
- if (!good || width < 1 || width > 16)
2168
- throw AsmError("A19", "numeric value out of range: $TABS takes 1 to 16", column);
2169
- tabs_ = width;
2260
+ if (!good || number < low || number > high)
2261
+ throw AsmError("A19", "numeric value out of range: $" + std::string(name) + " takes " + std::to_string(low) +
2262
+ " to " + std::to_string(high),
2263
+ column);
2264
+ result = number;
2170
2265
  if (!closed || (i < arg->size() && arg->find_first_not_of(" \t", i) != std::string_view::npos))
2171
2266
  throw AsmError("A22", "')' expected", column);
2172
2267
  }
@@ -4225,10 +4320,14 @@ AssemblyResult Program::run(const std::vector<Source>& sources) {
4225
4320
  }
4226
4321
  for (auto& c : r.chunks) out.chunks.push_back(std::move(c));
4227
4322
  if (m.cpu_ == isa::Cpu::C167) out.cpu = isa::Cpu::C167;
4323
+ ListingOptions o = m.listing_options_;
4324
+ o.page_length = m.paging_ == false ? 0 : m.page_length_ ? *m.page_length_ : m.paging_ ? 60 : 0;
4325
+ out.listing_options.push_back(std::move(o));
4228
4326
  std::set<std::string> exported;
4229
4327
  for (const auto& [k, def] : m.exported()) exported.insert(k);
4230
4328
  for (const auto& [k, e] : m.symbols_) {
4231
4329
  out.symbols.push_back(e.sym);
4330
+ out.symbols.back().refs = e.refs;
4232
4331
  out.symbols.back().module = static_cast<int>(i);
4233
4332
  out.symbols.back().exported = exported.count(k) > 0;
4234
4333
  }
@@ -4715,19 +4814,60 @@ std::string format_listing(const AssemblyResult& result) {
4715
4814
  std::vector<bool> shown_diag(result.diagnostics.size());
4716
4815
  const bool multi = result.modules.size() > 1;
4717
4816
  std::string main_file = result.listing.empty() ? std::string() : result.listing.front().file;
4718
- static constexpr const char* kHeader = "LOC OBJ LINE SOURCE\n\n";
4719
- std::string out = multi ? "" : kHeader;
4817
+ static constexpr const char* kHeader = "LOC OBJ LINE SOURCE";
4818
+ static constexpr std::size_t kSourceColumn = 39;
4819
+ std::string out;
4820
+ // Rows go through put(), which wraps them to the module's $PAGEWIDTH
4821
+ // and starts a new page, with a header, after $PAGELENGTH rows or an
4822
+ // $EJECT.
4823
+ static const ListingOptions kNoOptions;
4824
+ const ListingOptions* options = result.listing_options.empty() ? &kNoOptions : &result.listing_options.front();
4825
+ int page = 1, rows = 0;
4826
+ bool eject = false;
4827
+ std::function<void(std::string_view, std::size_t)> put = [&](std::string_view row, std::size_t indent) {
4828
+ const std::size_t width = options->page_width > 0 ? static_cast<std::size_t>(options->page_width) : SIZE_MAX;
4829
+ if (eject || (options->page_length > 0 && rows >= options->page_length)) {
4830
+ eject = false;
4831
+ rows = 0;
4832
+ std::string head = "openc166 " + (options->title.empty() ? main_file : options->title);
4833
+ const std::string number = "PAGE " + std::to_string(++page);
4834
+ const std::size_t line = std::min<std::size_t>(width, 120);
4835
+ if (head.size() + 2 + number.size() > line) head.resize(line - std::min(line, 2 + number.size()));
4836
+ head.resize(line - number.size(), ' ');
4837
+ out += "\f" + head + number + "\n\n";
4838
+ rows = 2;
4839
+ }
4840
+ if (row.size() <= width) {
4841
+ out += row;
4842
+ out += '\n';
4843
+ ++rows;
4844
+ return;
4845
+ }
4846
+ out += row.substr(0, width);
4847
+ out += '\n';
4848
+ ++rows;
4849
+ indent = std::min(indent, width - 1);
4850
+ for (std::size_t at = width; at < row.size(); at += width - indent) {
4851
+ const std::string rest = std::string(indent, ' ') + std::string(row.substr(at, width - indent));
4852
+ // By value: a page break inside put() must not see a dead view.
4853
+ put(rest, indent);
4854
+ }
4855
+ };
4856
+ if (!multi) {
4857
+ put(kHeader, 0);
4858
+ put("", 0);
4859
+ }
4720
4860
  auto print = [&](std::size_t i) {
4721
4861
  const Diagnostic& d = result.diagnostics[i];
4722
4862
  shown_diag[i] = true;
4723
- out += "*** ";
4724
- out += d.severity == Severity::Error ? "ERROR " : "WARNING ";
4725
- out += d.code + ": " + d.message;
4863
+ std::string row = "*** ";
4864
+ row += d.severity == Severity::Error ? "ERROR " : "WARNING ";
4865
+ row += d.code + ": " + d.message;
4726
4866
  if (d.line && d.file != main_file)
4727
- out += " (" + d.file + ", line " + std::to_string(d.line) + ")";
4867
+ row += " (" + d.file + ", line " + std::to_string(d.line) + ")";
4728
4868
  else if (!d.line && multi && !d.file.empty())
4729
- out += " (" + d.file + ")";
4730
- out += "\n";
4869
+ row += " (" + d.file + ")";
4870
+ put(row, 4);
4731
4871
  };
4732
4872
  // In a BIT section, the location counter counts bits; Keil shows it as
4733
4873
  // word address.bit (0..15).
@@ -4741,7 +4881,13 @@ std::string format_listing(const AssemblyResult& result) {
4741
4881
  if (multi && l.module != module) {
4742
4882
  module = l.module;
4743
4883
  if (static_cast<std::size_t>(module) < result.modules.size()) main_file = result.modules[module];
4744
- out += std::string(out.empty() ? "" : "\n") + "MODULE " + main_file + "\n\n" + kHeader;
4884
+ if (static_cast<std::size_t>(module) < result.listing_options.size())
4885
+ options = &result.listing_options[module];
4886
+ if (!out.empty()) put("", 0);
4887
+ put("MODULE " + main_file, 0);
4888
+ put("", 0);
4889
+ put(kHeader, 0);
4890
+ put("", 0);
4745
4891
  }
4746
4892
  if (l.hidden && l.diagnostics.empty()) continue;
4747
4893
  std::string loc = l.has_address ? address_text(l, 0) : l.value ? "=" + value_text(*l.value) : "";
@@ -4757,29 +4903,43 @@ std::string format_listing(const AssemblyResult& result) {
4757
4903
  char head[64];
4758
4904
  std::snprintf(head, sizeof head, "%-9s %-16s %-2s%6s%-2s ", loc.c_str(), obj.c_str(), level.c_str(),
4759
4905
  number.c_str(), macro.c_str());
4760
- out += head + l.source + "\n";
4906
+ put(head + l.source, kSourceColumn);
4761
4907
  // Long DB/DW lines continue on extra rows.
4762
4908
  while (shown < l.bytes.size()) {
4763
4909
  std::string more;
4764
4910
  std::size_t row = shown;
4765
4911
  for (; shown < l.bytes.size() && shown < row + 8; ++shown) more += hex(l.bytes[shown], 2);
4766
- std::snprintf(head, sizeof head, "%-9s %-18s\n", address_text(l, static_cast<std::int64_t>(row)).c_str(),
4912
+ std::snprintf(head, sizeof head, "%-9s %-18s", address_text(l, static_cast<std::int64_t>(row)).c_str(),
4767
4913
  more.c_str());
4768
- out += head;
4914
+ put(head, 0);
4769
4915
  }
4770
4916
  for (auto i : l.diagnostics) print(i);
4917
+ if (l.eject) eject = true;
4771
4918
  }
4772
4919
  if (multi) {
4773
4920
  main_file.clear();
4774
4921
  bool any = false;
4775
4922
  for (std::size_t i = 0; i < result.diagnostics.size(); ++i) any = any || !shown_diag[i];
4776
- if (any) out += "\n";
4923
+ if (any) put("", 0);
4777
4924
  }
4778
4925
  for (std::size_t i = 0; i < result.diagnostics.size(); ++i)
4779
4926
  if (!shown_diag[i]) print(i);
4780
4927
 
4781
- out += "\nSYMBOLS\n\n";
4928
+ // The tables are not paged or wrapped. $NOSYMBOLS leaves a module's
4929
+ // symbols out, unless it has $XREF, as in Keil.
4930
+ auto module_options = [&](int m) -> const ListingOptions& {
4931
+ return static_cast<std::size_t>(m) < result.listing_options.size() ? result.listing_options[m] : kNoOptions;
4932
+ };
4933
+ auto in_table = [&](const Symbol& s) {
4934
+ const ListingOptions& o = module_options(s.module);
4935
+ return s.listed && (o.symbols || o.xref);
4936
+ };
4937
+ const bool any_symbols = result.listing_options.empty() ||
4938
+ std::any_of(result.listing_options.begin(), result.listing_options.end(),
4939
+ [](const ListingOptions& o) { return o.symbols || o.xref; });
4940
+ if (any_symbols) out += "\nSYMBOLS\n\n";
4782
4941
  for (const auto& s : result.symbols) {
4942
+ if (!in_table(s)) continue;
4783
4943
  static constexpr const char* kKinds[] = {"LABEL", "EQU", "SET", "BIT", "LIT", "EXTERN"};
4784
4944
  std::string value;
4785
4945
  switch (s.value.type) {
@@ -4798,9 +4958,16 @@ std::string format_listing(const AssemblyResult& result) {
4798
4958
  if (s.exported) value += " PUBLIC";
4799
4959
  if (multi && static_cast<std::size_t>(s.module) < result.modules.size())
4800
4960
  value += " (" + result.modules[s.module] + ")";
4801
- char row[160];
4802
- std::snprintf(row, sizeof row, "%-32s %-6s %s\n", s.name.c_str(), kKinds[static_cast<int>(s.kind)], value.c_str());
4803
- out += row;
4961
+ // $XREF: the line of the definition, marked #, and the lines that
4962
+ // use the symbol.
4963
+ if (module_options(s.module).xref) {
4964
+ value += " " + std::to_string(s.line) + "#";
4965
+ for (int r : s.refs)
4966
+ if (r != s.line) value += " " + std::to_string(r);
4967
+ }
4968
+ char row[64];
4969
+ std::snprintf(row, sizeof row, "%-32s %-6s ", s.name.c_str(), kKinds[static_cast<int>(s.kind)]);
4970
+ out += row + value + "\n";
4804
4971
  }
4805
4972
  if (!result.sections.empty()) {
4806
4973
  out += "\nSECTIONS\n\n";
@@ -78,9 +78,11 @@ struct ListingLine {
78
78
  std::string macro_file;
79
79
  int macro_line = 0;
80
80
  bool skipped = false; // in a false IF block: not assembled, listed without a line number
81
- // Left out of the printed listing: by $NOCOND (assembly is off after
82
- // it), or a line of a macro expansion under $NOGEN (the default).
81
+ // Left out of the printed listing: by $NOLIST, by $NOCOND (assembly is
82
+ // off after it), or a line of a macro expansion under $NOGEN (the
83
+ // default). A hidden line with a diagnostic is still printed.
83
84
  bool hidden = false;
85
+ bool eject = false; // $EJECT: the listing starts a new page after this line
84
86
  bool has_address = false;
85
87
  // In a BIT section, the address counts bits: byte address * 8 + bit.
86
88
  bool bit_address = false;
@@ -103,6 +105,21 @@ struct Symbol {
103
105
  std::string text; // replacement text of a LIT; type of an EXTERN (WORD, DATA4, ...)
104
106
  int module = 0; // index into AssemblyResult::modules
105
107
  bool exported = false; // named by PUBLIC or GLOBAL, so other modules can use it
108
+ bool listed = true; // false if defined under $NOSYMLIST: left out of the printed symbol table
109
+ // $XREF: the listing lines that use the symbol, in order. Empty without $XREF.
110
+ std::vector<int> refs;
111
+ };
112
+
113
+ // What a module's listing controls ask of the printed listing.
114
+ struct ListingOptions {
115
+ bool symbols = true; // $NOSYMBOLS: no symbol table
116
+ bool xref = false; // $XREF: the symbol table shows where each symbol is defined and used
117
+ // Lines on a page, the page header included; 0 for no page breaks other
118
+ // than $EJECT (the default, unlike Keil; $PAGING or $PAGELENGTH turn
119
+ // them on).
120
+ int page_length = 0;
121
+ int page_width = 0; // $PAGEWIDTH: longer lines are wrapped; 0 for no limit
122
+ std::string title; // the last $TITLE, shown in the page headers
106
123
  };
107
124
 
108
125
  // Where a section went.
@@ -133,6 +150,7 @@ struct AssemblyResult {
133
150
  // that L166 would combine count as one section.
134
151
  std::vector<SectionInfo> sections;
135
152
  std::vector<std::string> modules; // file name of each source
153
+ std::vector<ListingOptions> listing_options; // of each module
136
154
  isa::Cpu cpu = isa::Cpu::C166;
137
155
  int passes = 0;
138
156
 
@@ -9,6 +9,7 @@ add_executable(openc166_tests
9
9
  unit/test_include.cpp
10
10
  unit/test_lit.cpp
11
11
  unit/test_cond.cpp
12
+ unit/test_listing.cpp
12
13
  unit/test_dpp.cpp
13
14
  unit/test_regbanks.cpp
14
15
  unit/test_output.cpp