6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 23, 2024 7:29 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: W65C816SXB ANS-Forth
PostPosted: Tue Apr 19, 2016 10:46 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I've been cleaning up my 65C816 forth for the W65C816SXB so that it can be used. Its not perfect yet but the bulk of it does work. All of the code can be found here:

https://github.com/andrew-jacobs/w65c816sxb-forth

This is a direct threaded implementation which executes in native mode with A, X and Y normally set to 16-bits. A is switched to 8-bits for C@, C! and C,. The forth instruction pointer is kept in Y and the dispatch code (TYX,INY,INY,JMP (0,X)) is inlined through out the code by means of the CONTINUE macro. The direct page register is used as the data stack pointer.

I have a version of the project for the W65C265SXB as well and will upload it tomorrow.

Portions of the code have been translated from Brad's Camel forth implementations for the Z80 and 1802.

I'll continue to add documentation and fix bugs as I find them.

_________________
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: W65C816SXB ANS-Forth
PostPosted: Wed Apr 20, 2016 7:53 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1930
Location: Sacramento, CA, USA
Very nice, Andrew! A couple of respectful but off-the-cuff comments:

It looks like you forgot a PLY in CMOVE>.

Your X register seems to be underutilized, and you're doing a lot of TDC ... TCD operations to modify your data stack pointer, which is a very common activity. Have you weighed the possibility of going back to X as a data stack pointer? Or how about using X for IP, and leaving Y as a scratch register for your primitives?
Code:
CONTINUE:
    inx
    inx
    jmp  (-2,x)


If you try X (or even Y) for your data stack pointer, what would TOS-in-A look like?
Code:
PLUS:
    clc
    adc  1,x
    inx
    inx
    CONTINUE
    ...
MINUS:
    eor  #$ffff
    inc  a
    bra  PLUS


If you keep Y as IP:
Code:
CONTINUE:
    iny
    phy
    iny
    rts

... oh, wait, that's not quite correct ... or is it? I still get confused ...

Keep the DTC candle burning brightly, my 65xx brother!

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: W65C816SXB ANS-Forth
PostPosted: Wed Apr 20, 2016 4:22 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Really cool! I'm looking forward to reading the code.


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

All times are UTC


Who is online

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