Port of w65c816sxb-hacker to CC65.

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
SpaceCoaster
Posts: 33
Joined: 11 Apr 2019

Port of w65c816sxb-hacker to CC65.

Post by SpaceCoaster »

I have ported the WDC Tools based w65c816sxb-hacker to use the CC65 suite of tools. W65c816sxb-hacker was developed by Andrew Jacobs and is...
Quote:
A tool for modifying the firmware on your WDC W65C816SXB Development Board

The SXB development board has a 128K Flash ROM that can be updated under
software control. The design of the SXB board divides the ROM into four 32K
banks and maps one these into the memory area between $00:8000 and $00:FFFF.
A tool for modifying the firmware on your WDC W65C816SXB Development Board

The SXB development board has a 128K Flash ROM that can be updated under
software control. The design of the SXB board divides the ROM into four 32K
banks and maps one these into the memory area between $00:8000 and $00:FFFF.
Currently I generate a direct copy of the original binary found on Github. This original binary was lacking the last few commits that were made to the original repository. I will redo the missed commits and a few other oddities when I have had more time to test.

The new and not improved at all program can be found at https://github.com/derekmulcahy/w65c816sxb-hacker

As part of this I have extended the sxb.py tool developed by Karl Ljungkvist to write WDC Tools style binary files directly to the SXB board.

Share and Enjoy!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Port of w65c816sxb-hacker to CC65.

Post by BigEd »

Thanks for picking this up and porting it!
SpaceCoaster
Posts: 33
Joined: 11 Apr 2019

Re: Port of w65c816sxb-hacker to CC65.

Post by SpaceCoaster »

I have ported w65c265sxb-hacker. This produces output which is identical to the WDC Tools version. I am waiting for USPS to deliver my W65C265SXB board to test it.

One oddity that I noticed on both the sxb-hacker ports.

For the following instruction

Code: Select all

stz 0,x
The WDC Tools generated an instruction using an absolute address.

Code: Select all

9E 00 00
CA65 generates a direct page instruction.

Code: Select all

74 00
The same thing happens for LDA, STA, ORA, ROL and ASL with 0,X as operands.

It looks like a WDC code generation bug to me.
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Port of w65c816sxb-hacker to CC65.

Post by tmr4 »

SpaceCoaster wrote:
It looks like a WDC code generation bug to me.
The two assemblers just treat the values differently. From the WDC Assembler/Linker Users Guide, pg. 22:
Quote:
When the assembler is parsing addresses, it starts by assuming that an address is ABSOLUTE. ... To specify an address that is a direct page address, the `<' character precedes the address or expression.
In CA65 on the other hand, addresses default to the size of the segment based on the memory model. I assume you have the direct page set at page 0. See the CA65 documentation at Address sizes and Memory models.
Quote:
ca65 assigns each segment and each symbol an address size. ... The default address size of a segment depends on the memory model used.
It's easy to test. In CA65 see what you get with

Code: Select all

stz $200,x
BillG
Posts: 710
Joined: 12 Mar 2020
Location: North Tejas

Re: Port of w65c816sxb-hacker to CC65.

Post by BillG »

SpaceCoaster wrote:
One oddity that I noticed on both the sxb-hacker ports.

For the following instruction

Code: Select all

stz 0,x
The WDC Tools generated an instruction using an absolute address.

Code: Select all

9E 00 00
CA65 generates a direct page instruction.

Code: Select all

74 00
The same thing happens for LDA, STA, ORA, ROL and ASL with 0,X as operands.

It looks like a WDC code generation bug to me.
Is there any chance there is a space between the zero and the comma?

Some assemblers treat extra characters on a line as a comment while others require that the comment start with a delimiter such as a semicolon.

Edit: ignore the above. I now see that you are talking about the indexed forms of the instructions.

Does the assembler allow the use of '<' or '>' to force the address size?
SpaceCoaster
Posts: 33
Joined: 11 Apr 2019

Re: Port of w65c816sxb-hacker to CC65.

Post by SpaceCoaster »

Thanks, that makes it clearer.

Direct page could be anywhere so LDA 0,X is ambiguous unless the assembler has more info. By defaulting to the 16 bit address it won’t be wrong if zeropage was intended but it wll be wrong if direct page was intended AND the page is no longer at $0000. If you are using the direct page feature then you should tag your labels/addresses.

Defaulting to generating a direct page instruction is more fragile as changing the direct page elsewhere will break the program.

I have changed my mind, WDC’s choice is better for under-specified addresses as it doesn’t break 6502 code when used in a 65816 environment in which direct page might have been moved.
SpaceCoaster
Posts: 33
Joined: 11 Apr 2019

Re: Port of w65c816sxb-hacker to CC65.

Post by SpaceCoaster »

Quote:
Does the assembler allow the use of '<' or '>' to force the address size?
The CA65 assembler uses < and > to select the low byte and the high byte respectively. It uses ^ to select the bank byte.
The address size can be forced using z:, a: and f: as prefixes for 8, 16 and 24 bit addresses.
Quote:
It's easy to test. In CA65 see what you get with

Code: Select all

stz $200,x
In CA65 that generates the absolute address.

Code: Select all

9E 00 02
Cheers,
Derek
Post Reply