Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nanochess/gasm80
Gasm80: Generic assembler for Z80/6502
https://github.com/nanochess/gasm80
6502 6502-assembler z80 z80-asm z80-assembler z80asm
Last synced: 2 days ago
JSON representation
Gasm80: Generic assembler for Z80/6502
- Host: GitHub
- URL: https://github.com/nanochess/gasm80
- Owner: nanochess
- License: other
- Created: 2024-03-04T03:01:36.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T18:48:17.000Z (about 1 month ago)
- Last Synced: 2024-10-18T17:33:39.240Z (29 days ago)
- Topics: 6502, 6502-assembler, z80, z80-asm, z80-assembler, z80asm
- Language: C
- Homepage:
- Size: 226 KB
- Stars: 21
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Gasm80: Generic Z80/6502 assembler
### by Oscar Toledo G. Mar/03/2024[https://nanochess.org/](https://nanochess.org/)
[https://github.com/nanochess/gasm80](https://github.com/nanochess/gasm80)
Gasm80 is a small assembler for Z80/6502 programs. It was developed to support my new CVBasic compiler for Colecovision, in order to have a complete toolchain that can work in macOS and Linux.
It was developed in a single day based on my tinyasm 8088 assembler available at [https://github.com/nanochess/tinyasm](https://github.com/nanochess/tinyasm)
It uses a command line syntax similar to nasm:
gasm80 game.asm -o game.rom -l game.lst -s game.sym
There is also the -d option for defining labels:
-dLABEL
-dANOTHER_LABEL=1It returns a non-zero error code when the assembled file generates errors.
### Supported directives
Labels are started with letter, number sign, underscore or period. Case is insensitive.
Local labels are supported, and should start with period. The local labels final name is derived from concatenation of the last global label (not starting with period) and the local label.
There is only support for Z80 and 6502 processors, and only are implemented the following directives:
IFDEF
IFNDEF
IF
ELSE
ENDIF
INCLUDE
INCLINE
INCBIN
TIMES
CPU Z80
CPU 6502
EQU
DB
DW
RBThe following operators are implemented:
| Binary OR
^ Binary XOR
& Binary AND
<< Shift to left
>> Shift to right
+ Addition
- Subtraction
* Multiplication
/ Division (unsigned 16-bit)
% Modulo operator
(expr) Parenthesis
- Unary negationThe following numbers are implemented:
0b0000_0100 Binary, you can use underscore (it will be ignored)
0xabcd Hexadecimal.
$0abcd Hexadecimal (after $ the first digit must be a number)
'a' Character constant.
10 Decimal.
$$ Start address.
$ Current address.This assembler won't win a speed test ;) because the internal implementation uses a linear search for the instruction set, and it is also implemented as a kind of regular expression subset for easier coding.
The assembler also supports the undocumented Z80 instructions (IXH/IXL/IYH/IYL and the SLL instruction), and the undocumented 6502 instructions.
The symbol file generated is compatible with the format accepted by the OpenMSX debugger.
### Building the assembler
The assembler is easily built in any platform because it uses standard C:
gcc gasm80.c -o gasm80
I've included test cases in the 'test' subdirectory that includes the complete Z80 and 6502 instruction set.