test | ||
gbas.b | ||
readme.md |
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