kkinos / zktc-asm

ZKTC assembler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zktc-asm

zktc-asm is an assembler for ZKTC implemented in Rust.

Install

cargo install --git https://github.com/kkinos/zktc-asm.git

Usage

Prepare an assembler file. For example, prepare the following file.

sample.asm

start:
	lil x1, msg@l
	lih x2, msg@h
	or x1, x2
	lw x2, x1, 0
	lw x3, x1, 2
msg:
	.word 0x6c6c
	.word 0x6548

You can assemble to a mem file. mem file is a text file.

zktc-asm sample.asm -o sample.mem
cat sample.mem
2d
0a
4e
00
20
2a
4a
01
6a
11
6c
6c
48
65

See zktc-asm -h for other options.

Assembler syntax

Basically, they are as follows

mnemonic destination register, source register, immediate value

Comments

// comment
addi x1, x0, 1 // comment

Directives

.byte 0x11
.word 0xffff

Labels

start:
	jal x0, start // loop

Symbols

start:
	lil x1, 0x1111@l // low 8 bits
	lih x2, start@h // high 8 bits

Tests

cargo test

About

ZKTC assembler

License:MIT License


Languages

Language:Rust 98.0%Language:Assembly 2.0%