GithubHelp home page GithubHelp logo

js80's Introduction

     __         ______ _______
    |__| ______/  __  \\   _  \
    |  |/  ___/>      </  /_\  \
    |  |\___ \/   --   \  \_/   \
/\__|  /____  >______  /\_____  /
\______|    \/       \/       \/

js80 is a library and an assembler for z80 cpu.

Installation

Using NPM:

npm install js80 -g

Binaries for Windows:

  1. Download [https://github.com/samsaga2/js80/releases]
  2. Add the directory bin to your PATH.

Command line

js80asm help:

  Usage: js80asm [options] <file ...>

  Options:

    -h, --help                     output usage information
    -V, --version                  output the version number
    -o, --output <file>            create binary compiled file (default a.out)
    -I, --include <dir1:dir2:...>  add directories into the search list
    -s, --sym <file>               create sym file

Examples:

js80asm test.asm

js80asm test2.asm -o test2.rom -s test2.sym

js80asm test3.asm -I include:../include2

JS80 API

New instance

var JS80 = require('js80');
var js80 = new JS80();

methods

  • asm js80.asm(code) ··Compile assembler code.
  • defineLabel js80.defineLabel(label, value) ·· Defines a new label.
  • secondPass js80.secondPass() ··Execute the second pass. The compiler evaluates the expressions because labels can be declared later.
  • buildImage js80.buildImage() ··Returns an array of bytes with the compiled code.
  • saveImage js80.saveImage(fileName) ··Save compiled code to a file.
  • saveSymbols js80.saveSymbols(fileName) ··Save symbols to a file (useful for debugging).

Example:

var JS80 = require('js80');
var js80 = new JS80();
js80.asm('xor a');
js80.secondPass();
js80.saveImage('a.out');

Assembler

Inst Desc
label: Declares a variable
.label: Declares a local label
// comment // Comment code
/* comment */ Comment code
; comment Comment code
inst1\inst2\···\inst-n Multipe instructions per line
module Declares a module
endmodule Ends module declaration
macro Declares a macro
endmacro Ends macro declaration
ifdef Branch if label is defined
ifndef Branch if label is not defined
if Branch if cond is not zero
else Else branch
endif Ends branching
repeat Repeat block of code times
endrepeat End repeats code block
include "filename" Include another source file
incbin "filename", ?skip, ?length Include a binary file
rotate Rotate macro variable arguments
map TODO
# TODO
org * TODO
defpage , , TODO
page TODO
echo e1, e2, ... TODO
error "msg" TODO
db e1, e2, ... TODO
dw e1, e2, ... TODO
dw TODO
equ TODO
struct Declares a struct
endstruct Ends struct declaration
code Does nothing (for sjasm compatibility)
data Does nothing (for sjasm compatibility)

Expressions

Expr Desc
11001100b, 0b11001100b binary number
0x1a, 01ah, $1a hexadecimal number
$ current address
-n negate a number
i-j substract two numbers
i+j sum two numbers
i*j mult two numbers
i/j div two numbers
i%j division module
(i) group expression
i<<j shift left
i>>j shift right
i^j xor
i|j or
i&j and
"str" string
'i' char
# nbytes get map and move it nbytes
@0 macro arguments length
@number get macro argument (start from 1)
str() convert identifier to string
i==j compare two expressions
i!=j compare two expressions
i<=j compare two expressions
i>=j compare two expressions
i<j compare two expressions
i>j compare two expressions

Examples

run: ld b,100
.1:  ld a,(hl)
     inc a
     ld (hl),a
     inc hl
     djnz .1
     ret
unuseful:
     jr run.1
      module mod1
util: xor a
      ret
      endmodule

      // no module
main: call mod1.util ; calling a module label
      ret
macro noargs
    xor a
endmacro
macro withargs i, j
    ld a,i+j
endmacro
macro withdefaults i, j:1, k:2
    ld a,i+j+k
endmacro
macro varargs i, 1..*
    repeat @0
        ld a,i+@1
        rotate 1
    endrepeat
endmacro
struct spr
    y   # 1
    x   # 1
    col # 1
    pat # 1
endstruct

ld ix,sprite_data
ld a,(ix+spr.y)
ld b,(ix+spr.x)
ld hl,spr.size

Assembler modules

  • bios.asm: MSX 2 Bios functions and variables (bios.WRTVRM, bios.H_KEYI, ...)
  • rom16k.asm: MSX 16kb rom setup (start label is the entry point)
  • rom32k.asm: MSX 32kb rom setup (start label is the entry point)
  • megarom.asm: MSX megarom setup (start label is the entry point)
  • extensions.asm: Misc utility macros
  • math.asm: Misc math funcs
  • debug.asm: OpenMSX debug output

js80's People

Contributors

samsaga2 avatar

Watchers

maraoz avatar James Cloos 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.