sixty-five-oh-two: An eDSL for writing 65(C)02 bytecode.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

An eDSL for writing 65(C)02 bytecode. Please see the README on GitHub at https://github.com/aearnus/sixty-five-oh-two#readme


[Skip to Readme]

Properties

Versions 1.0.0.0, 1.0.0.0, 1.1.0.0, 1.2.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), bytestring, containers, lens, mtl, sixty-five-oh-two [details]
License MIT
Copyright 2018 Tyler Limkemann
Author Tyler Limkemann
Maintainer tslimkemann42@gmail.com
Category DSL
Home page https://github.com/aearnus/sixty-five-oh-two#readme
Bug tracker https://github.com/aearnus/sixty-five-oh-two/issues
Source repo head: git clone https://github.com/aearnus/sixty-five-oh-two
Uploaded by aearnus at 2018-05-26T20:02:15Z

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for sixty-five-oh-two-1.0.0.0

[back to package description]

DSL.SixtyFiveOhTwo: A 65C02 Assembly eDSL in Haskell

Example image

... shut up, show me the code!

Here's some example code utilizing all of the features of the eDSL:

import SixtyFiveOhTwo.Instruction

accumulatorLoadNStore :: Instruction
accumulatorLoadNStore = do
    lda (Immediate 0x10)
    sta (Absolute 0x0200)
    rts (Implied)

myProgram :: Instruction
myProgram = do
    define "accumulatorLoadNStore" accumulatorLoadNStore
    call "accumulatorLoadNStore"

Here's a fun little snippet that adds 10 to the accumulator using Haskell Monad Magic™️:

test3f2 :: Instruction
test3f2 = replicateM_ 10 (inc (Accumulator))

Everything that this module exposes is in src/DSL/SixtyFiveOhTwo.hs. A quick browse through this file will reveal the full extent of the features of this eDSL.

What is this?

This is an embedded Domain Specific Language that allows a user to write code that runs on the 65C02 CPU. This is the CPU that runs devices such as the Apple II, Commodore 64, or the NES.

What does the language provide me?

lda :: AddressingMode -> Instruction
lda (Immediate b) = genericOp 169 b
lda (ZeroPage b) = genericOp 165 b
lda (ZeroPageX b) = genericOp 181 b
lda (Absolute b) = genericTwoByteOp 173 b
lda (AbsoluteX b) = genericTwoByteOp 189 b
lda (AbsoluteY b) = genericTwoByteOp 185 b
lda (ZeroPageIndirect b) = genericOp 178 b
lda (IndirectX b) = genericOp 161 b
lda (IndirectY b) = genericOp 177 b
data AddressingMode =
    Implied |
    Accumulator |
    Immediate Word8 |
    Relative Int8 | -- Signed
    ZeroPageRelative Int8 | -- Signed
    Absolute Word16 |
    AbsoluteX Word16 |
    AbsoluteY Word16 |
    ZeroPage Word8 |
    ZeroPageX Word8 |
    ZeroPageY Word8 |
    ZeroPageIndirect Word8 |
    Indirect Word16 |
    IndirectX Word8 |
    IndirectY Word8

Support or Donate

Please contact me if you have any wish to support this project or any other projects I've worked on. The information is in package.yaml.