All Projects → piotr-wiszowaty → foco65

piotr-wiszowaty / foco65

Licence: GPL-3.0 license
Forth cross-compiler targeting 6502 processors.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to foco65

Beebjit
A very fast BBC Micro emulator.
Stars: ✭ 81 (+523.08%)
Mutual labels:  6502
C64 Devkit
All you need to start programming 6510 assembler for the Commodore 64 on Microsoft Windows or Linux.
Stars: ✭ 149 (+1046.15%)
Mutual labels:  6502
Json65
A JSON parser written in 6502 assembly language.
Stars: ✭ 208 (+1500%)
Mutual labels:  6502
Days Of Thunder Nes Unpublished
Source code for an unpublished Days of Thunder game for the NES, not to be confused with the published game released by the same publisher this game was developed for, Mindscape, in 1990.
Stars: ✭ 98 (+653.85%)
Mutual labels:  6502
Plasma
Proto Language AsSeMbler for All (formerly Apple)
Stars: ✭ 142 (+992.31%)
Mutual labels:  6502
Millfork
Millfork: a middle-level programming language targeting 6502- and Z80-based microcomputers and home consoles
Stars: ✭ 163 (+1153.85%)
Mutual labels:  6502
C64 Prods By Awsm
Sources for most of my C64 productions
Stars: ✭ 26 (+100%)
Mutual labels:  6502
Nesicide
Integrated Development Environment for the 8-bit Nintendo Entertainment System
Stars: ✭ 244 (+1776.92%)
Mutual labels:  6502
Lzsa
Byte-aligned, efficient lossless packer that is optimized for fast decompression on 8-bit micros
Stars: ✭ 146 (+1023.08%)
Mutual labels:  6502
Mednes
A cycle-accurate, cross-platform NES emulator written in C++
Stars: ✭ 189 (+1353.85%)
Mutual labels:  6502
Symon
A MOS Technologies 6502 System Simulator
Stars: ✭ 108 (+730.77%)
Mutual labels:  6502
Durexforth
Modern C64 Forth
Stars: ✭ 139 (+969.23%)
Mutual labels:  6502
Nes
A Javascript NES Emulator
Stars: ✭ 168 (+1192.31%)
Mutual labels:  6502
Chipdisk Nac Vol.1
Chipdisk Nacional Vol.1
Stars: ✭ 81 (+523.08%)
Mutual labels:  6502
Punes
Nintendo Entertaiment System emulator and NSF/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
Stars: ✭ 217 (+1569.23%)
Mutual labels:  6502
Embeddednes
A portable NES simulator for embedded processors
Stars: ✭ 26 (+100%)
Mutual labels:  6502
Py65
Emulate 6502-based microcomputer systems in Python
Stars: ✭ 162 (+1146.15%)
Mutual labels:  6502
mos
An assembler, code formatter, language server and debug adapter for the MOS 6502 CPU.
Stars: ✭ 27 (+107.69%)
Mutual labels:  6502
X6502
Yet another 6502 emulator that one day dreams of being an Atari 2600.
Stars: ✭ 220 (+1592.31%)
Mutual labels:  6502
Pcjs
The original IBM PC and other machine emulations in JavaScript
Stars: ✭ 171 (+1215.38%)
Mutual labels:  6502

foco65

Forth cross-compiler targeting 6502 processors. Outputs xasm compatible assembly source code containing Forth runtime and compiled user program.

Runtime

Generated Forth runtime is 16-bit indirect-threaded.

Parameter stack is full-descending and addressed by X register. Address and size of the parameter stack are by default $600 and 256 respectively and are user-configurable.

Hardware stack is used as return stack.

The runtime uses 12 bytes on zero page: 2-byte instruction pointer ip and 5 2-byte work registers: w, z, cntr, tmp, tmp2 which may be used in user-defined words (note than on every word entry these registers' contents are undefined).

On entry runtime initializes instruction pointer and enters user-defined word main which is supposed to never exit (i.e. contain an infinite loop).

Generated Source Code

Generated assembly source code for words/data/code blocks is logically grouped into sections. Default order of sections is: init, boot, data, text.

Sections:

  • init - top of the output, typically contains user-provided assembly code block with org directive
  • boot - forth runtime
  • data - user data
  • text - core words and user program

User-defined data is output into the most recently declared data section (with [data-section] word), everything else is output into the most recently declared text section (with [text-section] word).

Syntax

Identifiers

Identifiers are case sensitive.

Constant and data identifiers consist of alphanumeric characters, '_'s, '-'s and '?'s and must start with a letter, '_', '-' or '?'. In generated assembly labels every '-' is replaced by '_' and every '?' is replaced by '_is_'.

Word identifiers consist of printable ASCII characters. Word identifiers consisting only of alphanumeric characters, '_'s, '-'s, '?'s and starting with a letter, '_', '-' or a '?' are translated automatically to valid assembly labels. Other word identifiers require user-defined label specification (see below).

Section identifiers consist of printable ASCII characters.

Comments

Syntax:


\ this is a one-line comment
( this is a multi-line
  comment)

Numbers

Syntax:


123   \ decimal number
$BA98 \ hexadecimal number

Word definitions

Syntax:

: name [ [label] asm-label ] words ;

or:

: name [ [label] asm-label ] [code]

; inline-assembly

[end-code] ;

Examples:


: foo begin end-flag until ;

: bar
[code]
 lda #1
 sta $D5E8
 jmp next
[end-code] ;

: +7 ( n1 -- n2 )
  [label] plus_7
  7 + ;

Data declarations

One-cell variable:

variable name

Two-cell variable:

2variable name

Assembly label at current program counter:

create name

Compile a one-cell value:

value ,

Compile a one-byte value:

value c,

Allocate a byte-array:

length allot

Allocate Atari XL/XE Antic counted string:

,' text'

Allocate ASCII counted string:

," text"

Allocate Atari XL/XE Antic string:

' text'

Allocate ASCII string:

" text"

Constants

Syntax:

value constant name

Example:


$230 constant dladr

Inline assembly blocks

Syntax:

[code]

; assembly code

[end-code]

Compiler directives

Syntax:

[text-section] name

or:

[data-section] name

Words

: @ 0= 1- 1+ 2/ 2* 2@ 2! and c! c@ cmove count d- d+ d= do drop dup fill i j loop +loop lshift <= < >= > - + or over rshift rsp sp swap unloop u< u> while <> >r r> = ! [ ] [code] [end-code] cell cells not [text-section] [data-section] variable 2variable constant create , c, ,' ' ," " allot lit \ ( recursive [label] * / m*

Usage

foco65 [OPTIONS] INPUT-FILE

OPTIONS:

-h                           display help
-p ADDR,--pstack-bottom=ADDR parameter stack bottom address
-s SECTS,--sections=SECTS    specify comma separated list of sections
                             default: init,boot,data,text
-S INT,--pstack-SIZE=INT     parameter stack size

Example:

$ foco65 foo.forth > foo.asx

Examples

Typical Atari XL/XE executable program structure.


[text-section] init

[code]
 org $2000
[end-code]

\ constant definitions
\ data declarations
\ word definitions

[text-section] text

: main
  \ user program initialization
  begin
    \ user program main loop
  again ;

[code]
 run boot
[end-code]

Atari XL/XE example: display character table.


[text-section] init

[code]
 org $3000
[end-code]

[text-section] text

$230 constant dladr

variable screen
variable cursor
variable line

: cursor-next   ( -- u )
  cursor @ dup 1+ cursor ! ;

: put-char      ( c -- )
  cursor-next c! ;

: set-cursor    ( u -- )
  screen @ + cursor ! ;
  
: main
  dladr @ 4 + @ screen !

  0 line !
  16 0 do
    line @ set-cursor
    line @ 40 + line !
    16 0 do
      i j 4 lshift or put-char
    loop
  loop

  begin again ;

[code]
 run boot
[end-code]

Atari XL/XE example of defining word in assembly: wait for keypress and push the pressed key's code on the parameter stack.


: get-char    ( -- c )
[code]
 lda #0
 dex
 sta pstack,x
 stx w
 jsr do_gc
 ldx w
 dex
 sta pstack,x
 jmp next

do_gc
 lda $E425
 pha
 lda $E424
 pha
 rts
[end-code] ;

Increase cell at the given address. Shows defining words not being a valid assembler label.


create array 16 cells allot

\ increase cell at given address
: ++          ( addr -- )
  [label] plus_plus
  dup @ 1+ swap ! ;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].