__ ______ _______
|__| ______/ __ \\ _ \
| |/ ___/> </ /_\ \
| |\___ \/ -- \ \_/ \
/\__| /____ >______ /\_____ /
\______| \/ \/ \/
js80 is a library and an assembler for z80 cpu.
Using NPM:
npm install js80 -g
Binaries for Windows:
- Download [https://github.com/samsaga2/js80/releases]
- Add the directory bin to your PATH.
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
var JS80 = require('js80');
var js80 = new JS80();
- 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');
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 |
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 |
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
- 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