Kevin's Development Environment for DCPU
$ python3 kasm.py notch.s
Additional Syntax Supported:
.equAssign a literal value to a label. For example
.equ answer 42will replace all occurrences of
answer(after its declaration) with the value 42.
.orgSet the program counter to the specified value. Can be used multiple times in a program.
.nolistEnable and disable actual code generation. Equates and macros are processed regardless.
.includeTakes a double quote enclosed string of a filename to include.
.macroPreprocessor macros. Terminated with
.macro SUM(x,y) x+y .end, then
dat SUM(1,1)will produce
0x0002. Macros can span multiple lines.
Character literals Single quotes around one character (e.g.
'a') will be translated to numerical literals. If the quotes are prefixed with character p, two character will be packed together.
.rep 2 dat 0xbeef .endwill produces
0xbeef 0xbeef. The repeated block can be any instructions over multiple lines.
Current address variable
$gives the address of the current statement.
Packed Strings Prefixing a string with the character p will pack the data. p"1234" will produce 0x3132 0x3334.
Local Labels Labels that start with '.' will be rewritten as
global.localwhere local is the name after the '.' and global is the last declared label which does not start with '.'.
Directives can be prefixed with '.' or '#'.
Short labels: When labels resolve to a value less than 0x20, the will be encoded as short literals in the instruction.
Relative moves: When doing
set PC, label, if label is within 0x20 bytes of the set instruction it will be replaced with an
add PC, [...](or sub).
NOP removal Instructions which can be determined to assign to a literal value, and will not modify the
Oregister, will be removed.
- Relocatable Binaries:
Binaries can be produced with a builtin loader that will correct label
based addresses to account for the program starting at an arbitrary origin.
Use of the origin directive is disabled when creating relocatable binaries.
The cost is
14+nwords of memory and
12+10ncycles where n is the number of label references.
-l warnEnables logger warnings; Currently notifies of divide by zero, and org w/ relocatable
--disable-optimizationsDisable all of the previously mentioned optimizations.
--strictDo not allow relaxed syntax. This includes colon on the right labels and repeated data.
--relocatableMake the produced binary relocatable
$ python3 kdis.py a.out
$ python3 ksim.py a.out
-dStart an interactive debugging session. Information on the available commands is available by typing
helpat the command prompt. The default behavior without this flag is equivalent to calling:
continue info memory render
Flags for all programs
--little-8-bitTreat binary code as byte-wise 8 bit little endian for compatibility with some other programs.
-o [file]Where to send output. The assembler defaults to
a.out, the disassembler and simulator default to stdout.