6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 4:07 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 4:09 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
I'm playing with a w65c816sxb board
I had many problems with this board but I've been able to use it by replacing WDC firmware by my monitor
(my monitor works on 3 machines on the real 6502 the following code works

0400 LDA #$FE
0402 STA $04
0404 LDA #$FF
0406 STA $05
0408 LDY #$02
040A LDA ($04),Y
040C RTS

in both case it AC should contains 00
the location $00 and $01 contains the top address in ram
$8000 on replica 1 and $7F00 on w65c816sxb

when I run this code on the replica 1 it works I get the content of the memory at FFFE +2
Image
in this case, after the execution it returns to the registers it's normal

when I run this code on the w65c816sxb in emulation mode, I get a reset of the board
Image
in this case it shows the free memory, the banner and the registers
to get that it is necessary to call the cold start routine

not the display of registers is not complete in my monitor PC and IRQ are wrong
other registers are ok

already seen this problem ?
any idea ?

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 4:46 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The 816SXB resets when you access unimplemented memory areas.

Your pointer at $04/05 contains $fffe and Y is $02 so the address being accessed is $fffe + $02 = $01:0000 rather than $00:0000.

A 65(C)02 can only access 65K so the access wraps round. Indexed modes on the 816 can cross bank boundaries.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 6:49 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
in emulation mode, it should wrap like a 6502/65c02...

do you know if it's a problem specific to this board
or generic to a w65c816 processors...

I have more and more doubts about this processor or at least the emulation mode :(


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 7:32 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
dderny wrote:
in emulation mode, it should wrap like a 6502/65c02...
True. And yet the behavior suggests it's not in Emulation Mode. (If the access truly were to 00:0000, as per Emulation Mode, then why the reset?)

Just for luck, try starting your routine with code to explicitly enter Emulation Mode. :wink: I believe the necessary incantation is simply...
Quote:
SEC
XCE

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 7:51 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
In emulation mode the bank bytes are initialized to zero, but are not stuck there.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 8:19 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
GARTHWILSON wrote:
In emulation mode the bank bytes are initialized to zero, but are not stuck there.
Good point... implying that maybe the wrap does occur, but not in Bank 00.

And again, it's easy to remove any doubt:
Code:
LDA# 0
PHA
PLB    ;data bank register is now zero
(And yes, PLB and quite a few other '816 instructions do work normally in Emulation Mode.)

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 8:37 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
thanks All, it works

but now the problem is to understand how he left the emulation mode, I never explicitly set the native mode
is there a set of instructions to detect the mode native / emulation ?

something like:
XCE
PHP
XCE
PLP
BCC/BCS ?


or do I have to take the logic analyzer and use a trigger on E ?

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 8:41 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8487
Location: Midwestern USA
dderny wrote:
I'm playing with a w65c816sxb board
I had many problems with this board but I've been able to use it by replacing WDC firmware by my monitor
(my monitor works on 3 machines on the real 6502 the following code works

Code:
0400 LDA #$FE
0402 STA $04
0404 LDA #$FF
0406 STA $05
0408 LDY #$02
040A LDA ($04),Y
040C RTS

in both case it AC should contains 00, the location $00 and $01 contains the top address in ram, $8000 on replica 1 and $7F00 on w65c816sxb.

As others noted, it isn't clear if the '816 is in emulation or native mode. If the latter, what is the setting of the m bit in SR? If m is 0 your instruction at $0400 is grabbing $FE followed by the opcode at $0402, which would be $85. As that would constitute a 16-bit load, PC would advance to $0403, not $0402.

Quote:
when I run this code on the replica 1 it works I get the content of the memory at FFFE +2
Image
in this case, after the execution it returns to the registers it's normal

Unless your monitor's register dump displays the full values of the registers, i.e., 16-bit values instead of 8-bit values, you will not be seeing the complete picture. In Supermon 816, a register dump appears as follows:

Code:
  PB  PC   NVmxDIZC  .C   .X   .Y   SP   DP  DB
; xx 0000  00000000 0000 0000 0000 xxxx 0000 00

That will give you the complete picture.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 9:01 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I don't think emulation mode affects indexing across banks on the 816 when using abs,x abs,y or (ind),y. Only direct page indexing is wrapped (to the page when E=1 and to the bank when E=0).

I found this on page 98 following figure 7-5
Quote:
On the 6502, 65C02, and 65802, if an index plus its base would exceed $FFFF, it wraps to continue
from the beginning of the 64K bank zero; that is, when index is added to base, any carry out of the low-order sixteen bits lost. (See Figure 7.5.)

On the 65816, the same is true of direct page indexing: because the direct page is always located in
bank zero, any time the direct page, plus an offset into the direct page, plus an index exceeds $FFFF, the address wraps to remain in bank zero.

But as Figure 7.5 shows, whenever a 65816 base is specified by a 24-bit (long) address, or the base is specified by sixteen bits and assumes the data bank as its bank, then, if an index plus the low-order sixteen bits of its base exceeds $FFFF, it will temporarily (just for the current instruction) increment the bank. The 65816 assumes that the array being accessed extends into the next bank.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sat Oct 26, 2019 10:07 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
BitWise wrote:
I found this on page 98 following figure 7-5

To remove any mystery, that's in the "Programming the 65816—Including the 6502, 65C02 and 65802" 6502/65816 programmer's manual by David Eyes and Ron Lichty, the best 65xx programming manual available, and a must-have for every 65xx programmer!

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sun Oct 27, 2019 12:39 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
in fact I was wrong yesterday, it was not working
in my test, either in emulation or native,I get a reset

Image

I tested both native and emulation
(my mini assembler has no support for 65c816 so I code a nop then change the nop into XCE manually (FB)

I also added the display of the mode '-' for native and 'E' for emulation
in both case I got the display of the top memory and the banner from the reset code


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sun Oct 27, 2019 12:46 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 460
Location: Canada
What is the code RTS'ing to? RTS pulls the return address off the stack.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Sun Oct 27, 2019 5:53 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
in fact nothing special, it just return to the caller
I was not expecting a reset while crossing $FFFF in emulation mode


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Mon Oct 28, 2019 1:32 am 
Online
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
It might be nothing, but the only thing that strikes me as somewhat strange is the reported value of PC after your "RTS" to the monitor in both cases. What would happen if you replaced the RTS with a BRK and retested?

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816 bug ?
PostPosted: Mon Oct 28, 2019 9:12 pm 
Offline

Joined: Wed Oct 23, 2019 12:55 pm
Posts: 15
My monitor is still in development
PC is wrong
IRQ is forced to 0000 in the display
the other registers are OK
disassembler/assembler/load & save hexa are working
I'm about to start on the trace


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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: