6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 08, 2024 1:31 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Fri Mar 11, 2022 3:42 am 
Offline

Joined: Thu Apr 11, 2019 12:31 pm
Posts: 33
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!


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 11, 2022 7:49 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Thanks for picking this up and porting it!


Top
 Profile  
Reply with quote  
PostPosted: Sun Mar 13, 2022 9:24 pm 
Offline

Joined: Thu Apr 11, 2019 12:31 pm
Posts: 33
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:
stz 0,x
The WDC Tools generated an instruction using an absolute address.
Code:
9E 00 00
CA65 generates a direct page instruction.
Code:
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 14, 2022 3:27 am 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
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:
stz $200,x


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 14, 2022 3:32 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
SpaceCoaster wrote:
One oddity that I noticed on both the sxb-hacker ports.

For the following instruction
Code:
stz 0,x
The WDC Tools generated an instruction using an absolute address.
Code:
9E 00 00
CA65 generates a direct page instruction.
Code:
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?


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 14, 2022 12:15 pm 
Offline

Joined: Thu Apr 11, 2019 12:31 pm
Posts: 33
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 14, 2022 6:45 pm 
Offline

Joined: Thu Apr 11, 2019 12:31 pm
Posts: 33
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:
stz $200,x
In CA65 that generates the absolute address.
Code:
9E 00 02

Cheers,
Derek


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: