GBZ80 (gameboy) assembler written in B
Go to file
2019-11-15 13:03:19 -06:00
test Moved test to subdirectory 2019-11-15 13:03:19 -06:00
gbas.b Update gbas.b 2019-06-29 09:44:12 -05:00
readme.md Update readme.md 2019-07-16 10:57:51 -05:00

gbas

Usage: gbas [infile] [-o outfile] [options]
-o              Change outfile name
-w              Disable warnings
-werror         Promote warnings to errors
-wfatal         Abort after 1 error
-h,-?           This help

Introduction

gbas is a small assembler for specifically the GBZ80 architecture, written as a sort of personal "hello world" program to the B language (also I wanted to make an assembler). The single-file source can be compiled with Yasha's B Compiler (https://github.com/Leushenko/ybc). gbas will generate error and warning messages, but will not abort translation if it encounters an error (unless you use -wfatal). It will report nothing if successful, and tries to be very simple and minimal.

Implementation

The implementation is essentially a line-by-line single pass (tokenize then translate), which turns one line into one instruction. A 'fixup phase' for forward references at the end of translation uses information stored in parallel arrays (B has no structs) to fill in label addresses/values (whether relative or absolute).

Basic syntax

Label:
    instruction [operands...] ;comment

Supported directives

  • equ (e.g., dmaproc equ $ff80)
  • db,dw
  • incbin 'file.dat'
  • org $0150 (also sets file position)

Other features

  • Local labels
  • Decimal/hexadecimal ($ prefix) integers
  • String literals