All Projects → safiire → n65

safiire / n65

Licence: GPL-2.0 license
An assembler for the 6502 microprocessor written in Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to n65

6502-npp-syntax
Notepad++ Syntax Highlighting for 6502 Assembly (and NESASM)
Stars: ✭ 21 (+75%)
Mutual labels:  nes, 6502, 6502-assembly
nes-breakout
Breakout meets Inception on the NES
Stars: ✭ 13 (+8.33%)
Mutual labels:  nes, 6502-assembly
asm6f
A fork of loopy's ASM6, a 6502 assembler.
Stars: ✭ 79 (+558.33%)
Mutual labels:  nes, 6502
Gearnes
NES / Famicom emulator for iOS, Mac, Raspberry Pi, Windows, Linux and RetroArch.
Stars: ✭ 23 (+91.67%)
Mutual labels:  nes, 6502
Punes
Nintendo Entertaiment System emulator and NSF/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
Stars: ✭ 217 (+1708.33%)
Mutual labels:  nes, 6502
Fearless-NES
A NES emulator written in Rust
Stars: ✭ 112 (+833.33%)
Mutual labels:  nes, 6502
disc-elite-beebasm
Fully documented and annotated source code for the disc version of Elite on the BBC Micro
Stars: ✭ 19 (+58.33%)
Mutual labels:  6502, 6502-assembly
Embeddednes
A portable NES simulator for embedded processors
Stars: ✭ 26 (+116.67%)
Mutual labels:  nes, 6502
apple2 rwts18
Roland Gustafsson's RWTS18 source code.
Stars: ✭ 17 (+41.67%)
Mutual labels:  6502, 6502-assembly
6502.Net
A .Net-based Cross-Assembler for Several 8-Bit Microprocessors
Stars: ✭ 44 (+266.67%)
Mutual labels:  nes, 6502
nes-pipeline
🔄 Continuous integration for NES homebrew that adds screenshots taken in the cloud.
Stars: ✭ 88 (+633.33%)
Mutual labels:  nes, 6502
Nes
A Javascript NES Emulator
Stars: ✭ 168 (+1300%)
Mutual labels:  nes, 6502
Millfork
Millfork: a middle-level programming language targeting 6502- and Z80-based microcomputers and home consoles
Stars: ✭ 163 (+1258.33%)
Mutual labels:  nes, 6502
elite-a-beebasm
Fully documented and annotated source code for Angus Duggan's Elite-A on the BBC Micro
Stars: ✭ 24 (+100%)
Mutual labels:  6502, 6502-assembly
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 (+716.67%)
Mutual labels:  nes, 6502
openNES-Snake
Simple rebuilt of the classic Snake game for the NES in C using the cc65 cross compiler.
Stars: ✭ 18 (+50%)
Mutual labels:  nes, 6502
Jsnes
A JavaScript NES emulator.
Stars: ✭ 5,354 (+44516.67%)
Mutual labels:  nes, 6502
6502 Npp Syntax
Notepad++ Syntax Highlighting for 6502 Assembly (and NESASM)
Stars: ✭ 17 (+41.67%)
Mutual labels:  nes, 6502
retrore
A curated list of original and reverse-engineered vintage 6502 game sourcecode.
Stars: ✭ 22 (+83.33%)
Mutual labels:  nes, 6502
nestronic
Nestronic Game Music Synthesizer Alarm Clock
Stars: ✭ 24 (+100%)
Mutual labels:  nes, 2a03

N65 NES assembler

This is an assembler for the Nintendo Entertainment System's 2A03 microprocessor.

N65

The 2A03 is an 8-bit processor based on the MOS 6502.

  Usage: ./n65 <infile.asm> -o outfile.nes

Scrolling NES Demo

This is a pretty straightfoward assembler, which is currently set up to produce iNES formatted ROM binaries from 6502 assembly language files.

Here is a recent blog post that goes through creating a program with this n65, showing the essential syntax and more. Best thing until I create some real documentation.

Inside An NES cartridge there are basically some number of ROM chips which contain banks of either program code or character (graphics) data. A PROG ROM bank is generally 16KB, and a CHAR ROM bank is generally 8KB. At least one PROG ROM bank is required, and the NES can address 2 PROG ROM banks and 1 CHAR ROM bank without the use of a mapper.

This assembler works on the idea of defining these banks, and allowing you to specify their contents. When you then assemble your output ROM this assembler translates the assmebly code in your your PROG banks into executable binary segments, and also lets you organize and address data in your CHAR banks. In the end it jams all these banks together one after another, PROG first, then CHAR, and slaps an iNES header on the front of it.

It is good at knowing which addressing modes are and are not allowed for each instruction, and contains some examples of correct syntax.

This assembler can now handle bankswitching if you set a valid mapper in the header, write more than 2 PROG banks, and then and write whatever bankswitching code is nessessary for the mapper you've chosen.

This assembler supports symbolic labels which can be scoped. When writing assembly it can be easy to run out of effective names for labels when they are scoped globally. I have seen other assemblers using anonymous labels to get around this but I decided I didn't like that syntax very much. Instead I opted to allow opening a new scope where you can reuse symbol names. You can give scopes names or allow them to be anonymous. If you choose to name a symbol scope you can use a dot syntax to address any symbols that are outside your current scope. I should put some example code up here showing this.

I hoped to make writing NES libraries more effective since you can basically namespace your symbols into your own file and not mess with anyone else's code. I also have also been able to use this to create C style structs in the memory layout, ie sprite.x.

The assembler does two passes over your code, any symbols that are used which it hasn't seen the definition for yet return a "promise", that are stored for the second pass. A "promise" is a fancy name for a lambda/closure which promises to come up with a value later, while your code continues on. It then evaluates all these "promises" during the assembler's second pass, which fills in the missing addresses etc.

I have used this to compile some code for the NES, and it ran correctly on FCEUX, got it to make some sounds, load tiles, sprites, and scrolling.

There is an example file included (shown below) that is a modified port of the NES101 tutorial by Michael Martin.

Some new additions:

  • .byte can now handle hex and binary literals, and symbols
  • First version of Midi to NES music converter
  • added .inc directive, to include other .asm files
  • nes.asm library include file created, naming popular NES addresses
  • C Style in memory structs using .scope and .space directives
  • Explicit usage of zero page instructions with the zp suffix
  • Split the Parser into its own class
  • New MemorySpace class
  • Rewrote the Assembler class
  • Rewrote the Instruction class
  • Rewrote all directive's classes
  • Split the assembler from the commandline front-end
  • Scoped Symbol Table
  • Anonymous Scopes
  • Lower case mnemonics and hex digits
  • Ported NES101 tutor to this assembler.
  • Added msb and lsb byte selectors on address labels
  • added .org directive
  • added .dw directive
  • added .bytes directive
  • added .incbin directive
  • added .ascii directive
  • added .segment directive
  • added .scope directive
  • added .space directive
  • Invented my own iNES header directive that is JSON
  • Split the project up into separate files per class
  • Wrote some more unit tests
  • Added OptionParser for commandline opts
  • Tested a ROM with Sound output
  • Tested a ROM that changes background color

Some Todos:

  • Make macros that can be used interchangably inline or as a subroutine
  • Create a library for common operations, DMA, sound, etc both inline and subroutine options
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].