0x10c-tools
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:tools for the 0x10c DCPU-16 processor (C and lua)
# About

This is my attempt at DCPU-16 assembler, disassembler, and emulator.

The implementation is a mix of lua and C.

## Features

  * lua parser (using PEG grammar), support for macros
  * lua assembler (big and little endian output)
  * support DCPU-16 specification v1.7.
  * implements software and hardware interrupts
  * implements clock peripheral 0x12d0b402 v1

# Prerequisites

The assembler uses lpeg (lua implementation of PEG) to parse the input file.  The following are a minimum requirement
for running the assembler.

        apt-get install lua5.1 liblua5.1-lpeg-dev liblua5.1-0-dev liblua5.1-posix1

# Assembler

Here is how one could assemble a program:

        $ lua/dcpu-asm examples/sample.dasm
        output going to sample.out

        $ hexdump sample.out
        0000000 7c01 0030 7de1 1000 0020 7803 1000 c00d
        0000010 7dc1 001a a861 7c01 2000 2161 2000 8463
        0000020 806d 7dc1 000d 9031 7c01 0018 7dc1 001a
        0000030 9037 61c1 7dc1 001a                    

sample.asm is a file obtained from the DCPU-16 documentation.  It is used to 
verify that the code generated by this tool is correct.

# Emulator

Here is an example of a test case run...

        $ dcpu test/hardware-interrupts.dasm | head
        0000: 1600 88a3 87b3 7f81 000e 1620 7c12 b402
        0008: 7c32 12d0 17c1 0028 7f81 0001 7fd2 ffff
        0010: 0028 7f81 0021 8401 8821 7a40 0028 8801
        0018: 7a40 0028 0821 8801 7a40 0028 0832 7f81
        0020: 001b 84e0 7f81 0021 7c21 8000 0022 8560
        TIME(d)  ---A ---B ---C ---X ---Y ---Z ---I ---J   --PC --SP --EX --IA  SK  OP------------- ISN------------------------------
        0000(0)  0000 0000 0000 0000 0000 0000 0000 0000   0000 0000 0000 0000      1600            HWN Z
        0002(2)  0000 0000 0000 0000 0000 0001 0000 0000   0001 0000 0000 0000      88a3            SUB Z, 0x0001
        0004(2)  0000 0000 0000 0000 0000 0000 0000 0000   0002 0000 0000 0000      87b3            IFN EX, 0x0000
        0006(2)  0000 0000 0000 0000 0000 0000 0000 0000   0003 0000 0000 0000  sk  7f81 000e       SET PC, 0x000e


# Macros

In addition to supporting the standard DCPU-16 assembly it can also process Notch-style macros:

        #macro push(reg) {
            SET PUSH, reg
        }

        #macro pop(reg) {
            SET reg, POP
        }

        push(A)
        pop(A)

Known bugs with macros:

  * macros cannot be nested or define partial commands
  * no support for #include, #define, #ifdef, etc


本源码包内暂不包含可直接显示的源代码文件,请下载源码包。