6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 10, 2024 9:00 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: 65816 Assembler in Forth
PostPosted: Thu Apr 20, 2006 1:20 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I've done it! I've successfully spent about 8 hours writing a full-featured 65816 assembler, in Forth, for Forth. Below's a sample of how it's used. The only things to add onto it are words to save the binary images in Commodore PRG and/or raw-binary format. S-Record or iHex formats ought not be too hard to implement, should the need arise. Source code will be on my website soon.

The assembler is written for use with GForth, but it ought to be trivially ported to other, even non-ANSI, Forth environments.

Code:
decimal
include 65816.fs

create temp 65536 allot
temp 65536 0 fill

\ Set host base (hbase) so assembler knows what buffer to
\ stuff bytes into.  Set target base (tbase) and current location
\ counter (*) so JMP and other absolute addresses are correct.

temp hbase !  0 tbase !  $1C01 *!

\ clear screen for Commodore 128

*@ CONSTANT SCNCLR   ( I need a convenience word for defining labels )

$fc dp, lda, pha,
$fd dp, lda, pha,

0 #b, lda, $fc dp, sta, tay, tax,
4 #b, lda, $fd dp, sta,

32 #b, lda,

begin,
  begin,
    $fc (),y, sta,
    iny,
  untileq,

  $fd dp, inc,
  inx,
  4 #b, cpx,
untileq,


pla, $fd dp, sta,
pla, $fc dp, sta,
rts,

temp $1c00 + 256 dump

bye


Are you looking to bring up a 65816 into native mode and launch the FTS/Forth port for it?

Code:
decimal
include 65816.fs

create ROM-image 8192 allot
ROM-image 8192 $42 fill  \ fill with WDM opcodes by default

\ Set host base (hbase) so assembler knows what buffer to
\ stuff bytes into.  Set target base (tbase) and current location
\ counter (*) so JMP and other absolute addresses are correct.

ROM-image hbase !  $E000 tbase !

\ ...

$FFC0 *!
*@ CONSTANT COLDBOOT

   clc, xce, $30 #b, rep,
   $01FF #w, lda, tas,
   $00FF #w, ldx,
   WARMBOOT $, jmp,

$FFE4 *!
   CopHandler *,w
   BrkHandler *,w
   AbtHandler *,w
   NmiHandler *,w
   0 *,w
   IrqHandler *,w

$FFF4 *!
   CopHandler *,w
   0 *,w
   AbtHandler *,w
   NmiHandler *,w
   COLDBOOT *,w
   IrqHandler *,w


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Apr 20, 2006 5:16 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The URL for the assembler is here:

http://falvotech.foxybanana.com/content ... th/target/

NOTE: This is a temporary URL until the DNS cuts over. It will eventually be this:

http://www.falvotech.com/content/kestrel/forth/target

Thanks.


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

All times are UTC


Who is online

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