Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- architecture x86 {
- registers:
- storage system_reg[96];
- view ssz = system_reg[0..32]; /* stack size */
- view spn = system_reg [32..64]; /* pointer to stack's beginning */
- view ser = system_reg [64..96]; /* error register code */
- memory:
- range __ram [0x0..0xFFFFFFFF] {
- cell = 8;
- endianess = little-endian;
- granularity = 0;
- }
- range __stack [0x0..0xFFFFFFFF] {
- cell = 8;
- endianess = little-endian;
- granularity = 0;
- }
- instructions:
- /* BASE // part 1 */
- encode __val field = immediate [32] data;
- encode __off field = immediate [32] offset; /* offset in memory */
- instruction nop = { 0000 0000 }; /* perform no operation */
- instruction ext = { 0000 0001 }; /* exits program */
- /* STACK // part 2 */
- instruction push = { 0001 0000, __val as val };
- instruction mpush = { 0001 0001, __off as off }; /* pushes from mem storage to stack */
- instruction pop = { 0001 0010 };
- instruction dpl = { 0001 0011 }; /* duplicates last element from stack */
- instruction sav = { 0001 0100, __off as off }; /* pops data from stack and stores it in memory */
- instruction swap = { 0001 0101 }; /* swaps two top value on the stack */
- instruction mem = { 0001 0110 }; /* считывает информацию по адресу кот записан в верхнем элементе и записывает на верх стека */
- instruction svs = { 0001 0111 }; /* pops data and place in memory to save */
- /* BITWISE OPERATIONS // part 3 */
- instruction shl = { 0010 0000 }; /* bitwise shift left val a on b */
- instruction shl1 = { 0010 0001 }; /* bitwise shift left on 1 */
- instruction shl2 = { 0010 0010 }; /* bitwise shift left on 2 */
- instruction shr = { 0010 0011 }; /* bitwise arithmetic shift right val a on b */
- instruction shr1 = { 0010 0100 }; /* bitwise arithmetic shift right on 1 */
- instruction shr2 = { 0010 0101 }; /* bitwise arithmetic shift right on 1 */
- instruction band = { 0010 0110 }; /* bitwise AND */
- instruction bor = { 0010 0111 }; /* bitwise OR */
- instruction bxor = { 0010 1000 }; /* bitwise XOR */
- instruction bnot = { 0010 1001 }; /* bitwise NOT */
- /* MATH // part 4 */
- instruction add = { 0011 0000 }; /* sum of two val */
- instruction sub = { 0011 0001 }; /* subtract of two val */
- instruction mul = { 0011 0010 }; /* multiply of two val */
- instruction div = { 0011 0011 }; /* divide of two val */
- instruction neg = { 0011 0100 }; /* negate of two val */
- instruction inc = { 0011 0101 }; /* +1 */
- instruction dec = { 0011 0110 }; /* -1 */
- /* COMPARISONS and JUMPS // part 5 */
- encode __lbl field = immediate [32] offset;
- instruction eql = { 0100 0000 }; /* 0 if top value equal, else 1*/
- instruction jmp = { 0100 0001, __lbl as lbl }; /* jump to instruction */
- instruction jez = { 0100 0010, __lbl as lbl }; /* jump to instruction if on stack top 0 */
- instruction jnz = { 0100 0011, __lbl as lbl }; /* jump to instruction if on stack top !0 */
- instruction call = { 0100 0100, __lbl as lbl }; /* куда прыгнуть */
- instruction ret = { 0100 0101 }; /* возвращает обратно */
- instruction com = { 0100 0110 }; /* v1 == v2 | pushes 00
- v1 > v2 | pushes 01
- v1 < v2 | pushes 11 */
- mnemonics:
- format plain1 is "{1}"; /* for numbers */
- format mem_ptr is "[{1}]"; /* for memory pointers */
- /* BASE // part 1 */
- mnemonic nop();
- mnemonic ext();
- /* STACK // part 2 */
- mnemonic push for push(val) plain1;
- mnemonic push for mpush(off) mem_ptr;
- mnemonic pop();
- mnemonic dpl();
- mnemonic sav for sav(off) mem_ptr;
- mnemonic swap();
- mnemonic mem();
- /* BITWISE OPERATIONS // part 3 */
- mnemonic shl();
- mnemonic shl1();
- mnemonic shl2();
- mnemonic shr();
- mnemonic shr1();
- mnemonic shr2();
- mnemonic band();
- mnemonic bor();
- mnemonic bxor();
- mnemonic bnot();
- /* MATH // part 4*/
- mnemonic add();
- mnemonic sub();
- mnemonic mul();
- mnemonic div();
- mnemonic neg();
- mnemonic inc();
- mnemonic dec();
- /* COMPARISONS and JUMPS // part 5 */
- mnemonic eql();
- mnemonic jmp for jmp(lbl) plain1;
- mnemonic jez for jez(lbl) plain1;
- mnemonic jnz for jnz(lbl) plain1;
- mnemonic call for call(lbl) plain1;
- mnemonic ret();
- mnemonic com();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement