Giter Club home page Giter Club logo

gasm80's Introduction

Gasm80: Generic Z80 assembler

by Oscar Toledo G. Mar/03/2024

https://nanochess.org/

https://github.com/nanochess/gasm80

Gasm80 is a small assembler for Z80 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

It uses a command line syntax similar to nasm:

gasm80 game.asm -o game.rom -l game.lst

There is also the -d option for defining labels:

-dLABEL
-dANOTHER_LABEL=1

It 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 processors, and only are implemented the following directives:

IFDEF
IFNDEF
IF
ELSE
ENDIF
INCLUDE
INCLINE
INCBIN
TIMES
CPU Z80
EQU
DB
DW
RB

The 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 negation

The 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.

Building the assembler

The assembler is easily built in any platform because it uses standard C:

gcc g80asm.c -o g80asm

I've included one test case in the 'test' subdirectory that includes the complete Z80 instruction set.

gasm80's People

Contributors

nanochess avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.