From 8fdeb287e13eb7e58f431d738132e9eb72e0eab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Henrik=20Sk=C3=A5rstedt?= Date: Wed, 28 Oct 2015 21:08:23 -0700 Subject: [PATCH] Bug fixes - Fixed section alignment - Fixed nested scopes - Fixed a borked parameter sent to label pools - Added -all as a command line option for dump_x65 --- README.md | 9 +++++++-- dump_x65/dump_x65.cpp | 3 +++ x65.cpp | 37 ++++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 62aacf6..b9761d3 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ x65.cpp requires struse.h which is a single file text parsing library that can b * [6502 opcodes](http://www.6502.org/tutorials/6502opcodes.html) * [6502 opcode grid](http://www.llx.com/~nparker/a2/opcodes.html) * [Codebase64 CPU section](http://codebase64.org/doku.php?id=base:6502_6510_coding) +* [6502 illegal opcodes](http://www.oxyron.de/html/opcodes02.html) +* [65816 opcodes](http://wiki.superfamicom.org/snes/show/65816+Reference#fn:14) ## Command Line Options @@ -239,6 +241,8 @@ The following lines will place all sections named Code sequentially at location There is currently object file support (use -obj argument to generate), the recommended file extension for object files is .x65. In order to access symbols from object file code use XDEF prior to declaring a label within the object. +To inspect the contents of x65 objects files there is a 'dump_x65' tool included in this archive. + **LOAD** ``` @@ -799,12 +803,13 @@ FindFirstSpace ### Development Status -Currently the assembler is in a limited release and while all features are in place and tested, more testing is needed to verify the completeness. Primarily tested with personal archive of sources written for Kick assmebler, DASM, TASM, XASM, etc. and passing most of Apple II Prince of Persia and Pinball Construction set. +Fish food! Assembler has all important features and switching to make a 6502 project for more testing. Currently the assembler is in a limited release. Primarily tested with personal archive of sources written for Kick assmebler, DASM, TASM, XASM, etc. and passing most of Apple II Prince of Persia and Pinball Construction set. **TODO** * irp (indefinite repeat) **FIXED** +* Nested scopes and label pools broke recently and was fixed, section alignment wasn't working. * Link file issues fixed, added a dump tool to show the contents of object files for debugging. * Rastan for Apple II gs assembles and links. * Merlin LNK, ENT, ADR, ADRL functional @@ -846,7 +851,7 @@ Currently the assembler is in a limited release and while all features are in pl * TEXT directive converts ascii to petscii (respect uppercase or lowercase petscii) (simplistic) Revisions: -* 8 - Linking tested and passed with external project (Apple II gs Rastan) +* 8 - Fish food / Linking tested and passed with external project (Apple II gs Rastan) * 7 - 65816 support * 6 - 65C02 support * 5 - Merlin syntax diff --git a/dump_x65/dump_x65.cpp b/dump_x65/dump_x65.cpp index df429f5..0b3efa8 100644 --- a/dump_x65/dump_x65.cpp +++ b/dump_x65/dump_x65.cpp @@ -294,6 +294,9 @@ int main(int argc, char **argv) } else if (arg.same_str("late_eval")) { show = prv_show | SHOW_LATE_EVAL; prv_show = show; + } else if (arg.same_str("all")) { + show = prv_show | SHOW_SECTIONS | SHOW_RELOCS | SHOW_LABELS | SHOW_MAP_SYMBOLS | SHOW_LATE_EVAL; + prv_show = show; } } else if (!file) file = argv[a]; diff --git a/x65.cpp b/x65.cpp index f860d5b..6c15c84 100644 --- a/x65.cpp +++ b/x65.cpp @@ -1788,7 +1788,8 @@ unsigned char* Asm::BuildExport(strref append, int &file_size, int &addr) StatusCode status = AppendSection(*i, allSections[last_fixed_section]); if (status != STATUS_OK) return nullptr; - end_address = allSections[last_fixed_section].start_address + + Section &s = allSections[last_fixed_section]; + end_address = s.start_address + (int)allSections[last_fixed_section].size(); } } @@ -1914,6 +1915,20 @@ StatusCode Asm::AppendSection(Section &s, Section &curr) int section_size = (int)s.size(); int section_address = curr.GetPC(); + + // calculate space for alignment + int align_size = s.align_address <= 1 ? 0 : + (s.align_address-(section_address % s.align_address)) % s.align_address; + + // Get base addresses + curr.CheckOutputCapacity(section_size + align_size); + + // add 0's + for (int a = 0; a