Decorat
Jump to navigation
Jump to search
Decorat is a type of assembly language designed by islptng.
Syntax
Each line is:
keyword argument
For example:
put 15
To define a label, write
labelname: put 15
To use a label, enclose it in <> :
jnz <labelname>
Comment, like other assembly, is a semicolon.
nop 0 ; This line does nothing!
How it works
It has a register to store a value.
The arguments are just part of the memory (and thus we can modify them).
For example:
get <const30> ; reg = 30 put <r> ; memory[r] = 30 r: jmp 19 ; now "jmp 30" after the above line is executed const30: nop 30 ; define a constant
Advanced label
We can use braces in label definitions. An advanced example:
ifzero: jnz <else> { ; some code here } jmp <endif> else: { ifneg: jlz <else> { ; some code here } jmp <endif> else: { ; some code here } endif: } endif:
which, without braces, looks like:
ifzero: jnz <else1> ; some code here jmp <endif1> else1: ifneg: jlz <else2> ; some code here jmp <endif2> else2: ; some code here endif1: endif2:
Instruction set
Dumb decorat
0 sub : reg -= mem[arg]; 1 dmp : mem[arg] = reg; reg = 0; 2 leq : if(reg <= 0) goto arg;
Reduced decorat
0 jnz : if(reg != 0) goto arg; 1 jlz : if(reg < 0) goto arg; 2 jmp : goto arg; 3 get : reg = mem[arg]; 4 put : mem[arg] = reg; 5 dec : reg -= mem[arg]; 6 nor : reg = ~(reg | mem[arg]); 7 shr : reg >>= mem[arg];