msinger / binutils-sm83

Binutils port for the Sharp SM83 (Game Boy CPU)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binutils for GameBoy
====================


Build binutils like this:

  ./configure --target=sm83-gb-coff
  make all
  # as root:
  make install


Example file:

  ; Handler for RST28 instruction (max. 8 bytes)
  .section .rst28
    ret

  ; Handler for interrupt 4 (joypad) (max. 8 bytes)
  .section .irq4
    reti

  ; Entry point (max. 4 bytes)
  .section .entry
    nop
    jp start

  ; GameBoy Header
  .section .hdrlogo
    .db 0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D
    .db 0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99
    .db 0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
  .section .hdrname
    .db "hram-rw"
  .section .hdrgc
    .db "TEST"
  .section .hdrcgb
    .db 0x00
  .section .hdrmc
    .db "ZZ"
  .section .hdrsgb
    .db 0x00
  .section .hdrtype
    .db 0x08
  .section .hdrrom
    .db 0x00
  .section .hdrram
    .db 0x02
  .section .hdrdest
    .db 0x01
  .section .hdrver
    .db 0x00

  ; Code for Bank 0 (starts at 0x150)
  .section .bank0
  start:
  .global start
    di

    call foo  ; call routine in bank 1

    ; Copy routine for initializing HRAM
    ld c, _ehdata
    ld hl, __load_stop_hdata - 1
  loop:
    ld a, _hdata - 1
    dec c
    cp c
    jp z, loop2  ; jumps to address 0xff80
    ld a, (hld)
    ld (c), a
    jr loop

  ; Code loaded into HRAM (starts at 0xff80)
  .section .hdata
  loop2:
    jr loop2

  ; Code for Bank 1 (starts at 0x4000)
  .section bank1
  foo:
    rst 0x28  ; call reset 0x28 handler
    ret


Build example with:

  sm83-gb-coff-as -o example.o example.s
  sm83-gb-coff-ld -o example.gb example.o

Then use rgbfix from the Rednex Game Boy Development System (rgbds):
  rgbfix -fhg example.gb

About

Binutils port for the Sharp SM83 (Game Boy CPU)

License:GNU General Public License v2.0


Languages

Language:C 42.9%Language:Makefile 16.7%Language:Assembly 14.3%Language:D 10.9%Language:DTrace 6.6%Language:C++ 3.7%Language:Scheme 1.4%Language:Roff 0.8%Language:Shell 0.5%Language:M4 0.4%Language:R 0.3%Language:Scala 0.3%Language:Yacc 0.3%Language:Lex 0.2%Language:TeX 0.2%Language:Perl 0.1%Language:Ada 0.1%Language:Pascal 0.0%Language:DIGITAL Command Language 0.0%Language:C# 0.0%Language:GDScript 0.0%Language:Common Lisp 0.0%Language:CWeb 0.0%Language:HTML 0.0%Language:Raku 0.0%Language:Terra 0.0%Language:GAP 0.0%Language:MATLAB 0.0%Language:CMake 0.0%Language:Emacs Lisp 0.0%Language:PHP 0.0%Language:sed 0.0%Language:Rebol 0.0%Language:E 0.0%Language:SAS 0.0%Language:Module Management System 0.0%Language:SuperCollider 0.0%Language:Eiffel 0.0%Language:Awk 0.0%Language:Rust 0.0%Language:Mathematica 0.0%Language:Tcl 0.0%Language:Batchfile 0.0%Language:Elixir 0.0%Language:PicoLisp 0.0%Language:GDB 0.0%