Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [settings]
- name = "BPEx2"
- [fields]
- empty
- "" 0000000000000000
- br
- "" 0
- "(" 0
- ")" 0
- "[" 0
- "]" 0
- op
- "" 0
- "+" 0
- "-" 1
- operator
- "" 0000
- "+" 0000
- "-" 0001
- "x" 0010
- "/" 0011
- "%" 0100
- BLO 0101
- DCD 1011
- storeCMP 1100
- cmp 1101
- cmpr 1110
- storage 1111
- BLO
- "" 000
- "<<" 000
- ">>" 001
- asr 010
- nand 011
- or 100
- and 101
- nor 110
- xor 111
- comparison
- nojmp 000
- CMP 000
- "==" 001
- ">=" 010
- ">" 011
- jmp 100
- "!=" 101
- "<" 110
- "<=" 111
- register
- zr 00000
- r1 00001
- r2 00010
- r3 00011
- r4 00100
- r5 00101
- r6 00110
- r7 00111
- r8 01000
- r9 01001
- r10 01010
- r11 01011
- r12 01100
- r13 01101
- r14 01110
- r15 01111
- r16 10000
- r17 10001
- r18 10010
- r19 10011
- r20 10100
- tmp1 10101
- tmp2 10110
- sp 10111
- flags 11000
- in 11001
- out 11010
- keyboard 11011
- screen 11100
- clock0 11101
- clock1 11110
- counter 11111
- [patterns]
- /*
- =====================
- ==== Destination ====
- =====================
- */
- // Register
- pattern destReg()
- %r(register)
- 00 00000000 00000000 00000000 000rrrrr
- // Tables
- pattern destTableImm()
- %r(register)[%i:U16(immediate)]
- %v = %r + %i
- 00 00000000 00000000 00000000 000vvvvv
- pattern destTableReg()
- %r(register)[%g(register))]
- 00 00000000 00000000 000ggggg 000rrrrr
- pattern destRamTableImm()
- %i:U16(immediate)[%u:U16(immediate)]
- %h = %u << 2
- %v = %i + %h
- 01 00000000 00000000 vvvvvvvv vvvvvvvv
- pattern destRamTableReg()
- %i:U10(immediate)[%r(register)]
- 10 00000000 00000000 0iiiiiii iiirrrrr
- pattern destRamTableRegImm()
- %i:U10(immediate)[%r(register) + %u:U10(immediate)]
- %h = %u << 2
- %v = %i + %h
- 10 00000000 00000000 0vvvvvvv vvvrrrrr
- // Pointers
- pattern destRegPointer()
- *%x(br)%g(register)%y(br)
- 00 00000000 00000000 000ggggg 00000000
- pattern destRegDereferencePlsImm()
- &%x(br)%r(register) + %i:U16(immediate | empty)%y(br)
- %v = %r + %i
- 00 00000000 00000000 00000000 000vvvvv
- pattern destRegDereferenceMnsImm()
- &%x(br)%r(register) - %i:U16(immediate | empty)%y(br)
- %v = %r - %i
- 00 00000000 00000000 00000000 000vvvvv
- pattern destRegRegDereference()
- &%x(br)%r(register) %p(op) %g(register)%y(br)
- 00 00000000 00000000 p00ggggg 000rrrrr
- pattern destRegPlsImm()
- %x(br)%r(register) + %i:U16(immediate | empty)%y(br)
- %v = %r + %i
- 00 00000000 00000000 00000000 000vvvvv
- pattern destRegMnsImm()
- %x(br)%r(register) - %i:U16(immediate | empty)%y(br)
- %v = %r - %i
- 00 00000000 00000000 00000000 000vvvvv
- // RAM
- pattern destRamImm()
- ram[%i:U16(immediate)]
- 01 00000000 00000000 iiiiiiii iiiiiiii
- pattern destRamRegImm()
- ram[%r(register) %p(op) %i:U10(immediate)]
- 10 00000000 00000000 piiiiiii iiirrrrr
- pattern destRamRegReg()
- ram[%r(register) %p(op) %g(register)]
- 11 00000000 00000000 p00ggggg 000rrrrr
- // Destination
- pattern dest()
- %d[destReg() | destTableImm() | destTableReg() | destRamTableImm() | destRamTableReg() | destRamTableRegImm() | destRegPointer() | destRegDereferencePlsImm() | destRegDereferenceMnsImm() | destRegRegDereference() | destRegPlsImm() | destRegMnsImm() | destRamImm() | destRamRegImm() | destRamRegReg()]
- %type = %d[34:32]
- tt dddddddd dddddddd dddddddd dddddddd
- /*
- =====================
- ======= Go to =======
- =====================
- */
- // Immediate value
- pattern gotoImm()
- %i:U16(immediate)
- %v = %i - 1
- 01 00000000 00000000 vvvvvvvv vvvvvvvv
- // Labels
- pattern gotoLabel()
- %i(label)
- %v = %i >> 3
- 01 00000000 00000000 vvvvvvvv vvvvvvvv
- pattern gotoLabelPlsImm()
- %x(br)%l(label) + %i:U16(immediate)%y(br)
- %h = %l >> 3
- %v = %h + %i
- 01 00000000 00000000 vvvvvvvv vvvvvvvv
- pattern gotoLabelMnsImm()
- %x(br)%l:U16(label) - %i:U16(immediate)%y(br)
- %h = %l >> 3
- %v = %h - %i
- 01 00000000 00000000 vvvvvvvv vvvvvvvv
- // Register
- pattern gotoRegImm()
- %x(br)%r(register) %p(op) %i:U10(immediate | empty)%y(br)
- 00 00000000 00000000 piiiiiii iiirrrrr
- // RAM
- pattern gotoRamImm()
- ram[%i:U16(label)]
- 10 00000000 00000000 iiiiiiii iiiiiiii
- pattern gotoRamReg()
- ram[%r(register)]
- 11 00000000 00000000 00000000 000rrrrr
- pattern gotoRamRegReg()
- ram[%x(br)%r(register) %p(op) %g(register | empty)%y(br)]
- 11 00000000 00000000 p00gggggg 000rrrrr
- // GOTO
- pattern goto()
- %d[gotoRegImm() | gotoImm() | gotoLabel() | gotoLabelPlsImm() | gotoLabelMnsImm() | gotoRamImm() | gotoRamReg() | gotoRamRegReg()]
- %type = %d[34:32]
- tt dddddddd dddddddd dddddddd dddddddd
- /*
- =====================
- ===== Arguments =====
- =====================
- */
- pattern empty()
- %e:U16(empty)
- 000 00000000 00000000 eeeeeeee eeeeeeee
- // Immediate values
- pattern imm16()
- %i:S16(immediate | label)
- 000 00000000 00000000 iiiiiiii iiiiiiii
- pattern imm32()
- %i:S32(immediate | label)
- 000 iiiiiiii iiiiiiii iiiiiiii iiiiiiii
- // Registers
- pattern regImm()
- %x(br)%r(register) %p(op) %i:U10(immediate | empty)%y(br)
- 001 00000000 00000000 piiiiiii iiirrrrr
- pattern regReg()
- %x(br)%r(register) %p(op) %g(register)%y(br)
- 010 00000000 00000000 p00ggggg 000rrrrr
- // Tables
- pattern TableImmPls()
- %r(register)[%i:U10(immediate)]
- %v = %r + %i
- 011 00000000 00000000 00000000 000vvvvv
- pattern TableImmPlsImm()
- %r(register)[%i:U10(immediate) + %u:U10(immediate)]
- %v = %r + %i + %u
- 011 00000000 00000000 00000000 000vvvvv
- pattern TableImmMnsImm()
- %r(register)[%i:U10(immediate) - %u:U10(immediate)]
- %v = %r + %i - %u
- 011 00000000 00000000 00000000 000vvvvv
- pattern TableReg()
- %r(register)[%g(register)]
- 011 00000000 00000000 000ggggg 000rrrrr
- // Pointers
- pattern regPointer()
- *%x(br)%g(register)%y(br)
- 011 00000000 00000000 000ggggg 00000000
- pattern regRegPointer()
- *%x(br) %r(register) %p(op) %g(register)%y(br)
- 011 00000000 00000000 p00ggggg 000rrrrr
- pattern dereferencePointer()
- &%r(register)
- 000 00000000 00000000 00000000 000rrrrr
- // RAM
- pattern ramImm()
- ram[%i:U16(immediate)]
- 101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii
- pattern ramRegImm()
- ram[%r(register) %p(op) %i:U10(immediate | empty)]
- 110 00000000 00000000 piiiiiii iiirrrrr
- pattern ramRegReg()
- ram[%r(register) %p(op) %g(register)]
- 111 00000000 00000000 p00ggggg 000rrrrr
- // CMP
- pattern cmpToReg()
- %c(comparison)
- 000 00000000 00000000 00000000 00000ccc //r16 to r20, tmp1 and tmp 2
- // ARGUMENT
- pattern arg()
- %a[empty() | imm16() | imm32() | regImm() | regReg() | TableImmPls() | TableImmPlsImm() | TableImmMnsImm() | TableReg() | regPointer() | regRegPointer() | dereferencePointer() | ramImm() | ramRegImm() | ramRegReg() | cmpToReg()]
- %type = %a[34:32]
- ttt aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
- /*
- =====================
- ===== Operators =====
- =====================
- */
- pattern MATH()
- %o(operator)
- 0000%o[3:0]
- pattern BLO()
- %c(BLO)
- %c[2:0]0101
- pattern CMP()
- %c(comparison)
- %c[2:0]1100
- pattern operator()
- %o[MATH() | BLO() | CMP()]
- 0%o[6:0]
- /*
- ======================
- ==== Conditionals ====
- ======================
- */
- pattern imm11()
- %i:S11(immediate)
- 001 iiiiiiii iii
- pattern reg11()
- %r(register)
- 010 000rrrrr 000
- pattern DCD()
- %x(br)%r(register) %c(comparison) %i[imm11() | reg11()]%y(br)
- ccc %i[13:11] 00000000 00000000 %i[10:0]rrrrr
- pattern IsRegTRUE()
- %x(br)%r(register)%y(br)
- 101 001 00000000 00000000 00000000 000rrrrr
- /*
- =====================
- ==== Comparisons ====
- =====================
- */
- pattern cmpReg()
- %c(register) //r16 to r20, tmp1 and tmp 2
- 1110 00000ccc
- pattern cmpImm()
- %c(comparison)
- 1101 00000ccc
- pattern comparison()
- %c[cmpReg() | cmpImm()]
- %type = %c[11:8]
- tttt 00000ccc
- [instructions]
- // do nothing
- nop
- 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
- // ====== General ======
- %dest[dest()] = %a[arg()] %o[operator()] %b[arg()]
- oooooooo %dest[33:32]%a[34:32]%b[34:32] %dest[15:0] %a[15:0] %b[15:0]
- // ====== Stack ======
- stack.push%z(br)%b[arg()]%x(br)
- 00011111 10000%b[34:32] 00000000 00010111 %b[31:0]
- # Sends %b to stack. Decreases sp by 4.
- %dest[dest()] = stack.pop()
- 00101111 %dest[33:32]110000 %dest[15:0] 00000000 00010111 00000000 00000000
- # Pops first value from stack to %dest. Increases sp by 4.
- stack.pop()
- 00101111 00110000 00000000 00000000 00000000 00010111 00000000 00000000
- # Pops first value from stack. Increases sp by 4.
- %dest[dest()] = stack.peek()
- 00000000 %dest[33:32]110000 %dest[15:0] 00000000 00010111 00000000 00000000
- # Copies the first value on stack to %dest.
- // ====== Conditionals ======
- %dest[dest()] = %DCD[DCD() | IsRegTRUE()] ? %b(register) : %i[imm11() | reg11()]
- 0%DCD[37:35]1011 %dest[33:32]%DCD[34:32]%i[13:11] %dest[15:0] %DCD[15:0] %i[10:0]bbbbb
- if %DCD[DCD() | IsRegTRUE()] then %dest[dest()] = %b(register) %o(operator) %i[imm11() | reg11()]
- 0%DCD[37:35]oooo %dest[33:32]%DCD[34:32]%i[13:11] %dest[15:0] %DCD[15:0] %i[10:0]bbbbb
- // ====== Jumps ======
- goto %dest[goto()] if %a[arg()] %c[comparison()] %b[arg()]
- %operator= %c[11:8]
- ccc0%operator[3:0] %dest[33:32]%a[34:32]%b[34:32] %dest[15:0] %a[15:0] %b[15:0]
- # Jumps to %dest if %a %c %b
- goto %dest[goto()]
- 00101101 %dest[33:32]000000 %dest[15:0] 00000000 00000000 00000000 00000000
- # Jumps to %dest.
- // ====== Cycles ======
- // External FOR cycle using Register
- %forend(label) (%current(register) = %start[arg()]; %throwaway(register) %comp(comparison) %final[arg()]; %increment[arg()])
- %start_type = %start[34:32]
- %increment_type = %increment[34:32]
- %final_type = %final[34:32]
- %h = %forend >> 3
- %value = %h + 1
- %inverseComp = %comp ^ 4
- 00000000 00%start_type[2:0]000 00000000 000%current[4:0] %start[15:0] 00000000 00000000 00101111 10000001 00000000 00010111 00000000 00000000 00000000 01011111 10001101 00000000 00000000 01011111 00000000 00000000 00000000 00000000 00000000 00001%increment_type[2:0] 00000000 000%current[4:0] 00000000 000%current[4:0] %increment[15:0] %inverseComp[2:0]01101 01001%final_type[2:0] %value[15:0] 00000000 000%current[4:0] %final[15:0]
- // END for external FOR cycle.
- // To be used with forendlabel such as for1:end.
- end
- 10001101 11000000 00000000 00010111 00000000 00000000 00000000 00000000 00000000 00001000 00000000 00010111 00000000 00010111 00000000 00000100
- ;%m:U2(dest_type)%d:U16(immediate)%z(bracket) = %f:U3(type)%a:U16(immediate) %o:U4(operant)
- ;0000oooo mmfff000 dddddddd dddddddd aaaaaaaa aaaaaaaa 00000000 00000000
- ;%m:U2(dest_type)%d:U16(immediate)%z(bracket) = %f:U3(type)%a:U16(immediate) %o:U4(operant) %g:U3(type)%b:U16(immediate)%x(bracket)
- ;0000oooo mmfffggg dddddddd dddddddd aaaaaaaa aaaaaaaa bbbbbbbb bbbbbbbb
- /*
- //
- // IO instructions
- //
- %m:U2(dest_type)%d:U16(immediate)%z(bracket) = %f:U3(type)%a:U16(immediate)%y(bracket) %o:U4(operant) %g:U3(type)%b:U16(immediate)%x(bracket)
- 0000oooo mmfffggg dddddddd dddddddd aaaaaaaa aaaaaaaa bbbbbbbb bbbbbbbb
- nop
- 00000000 00000000 00000000 00000000
- # Does nothing.
- ;%a(register) = in
- ;00000001 aaaa0000 00000000 00000000
- ;# Loads an input and stores it in %a.
- out = %b(register)
- 00000010 00000000 0000bbbb 00000000
- # Sends %b to output.
- out = %a:U16(immediate)
- 00010010 00000000 aaaaaaaa aaaaaaaa
- # Sends %a to output.
- %a(register) = kb
- 00000011 aaaa0000 00000000 00000000
- # Loads keyboard input and stores it to %a.
- screen[%a(register)] = %b(register)
- 00000100 0000aaaa 0000bbbb 00000000
- # Stores the value of %b in screen setting %a.
- screen[%a(register)] = %b:U16(immediate)
- 00010100 0000aaaa bbbbbbbb bbbbbbbb
- # Stores the value of %b in screen setting %a.
- %a(register) = time0
- 00000101 aaaa0000 00000000 00000000
- # Loads the lower four bytes of the time value and stores it to %a.
- %a(register) = time1
- 00000110 aaaa0000 00000000 00000000
- # Loads the upper four bytes of the time value and stores it to %a.
- %a(register) = counter
- 00000111 aaaa0000 00000000 00000000
- # Loads the counter value and stores it to %a.
- %a(register) = counter + %b:U16(immediate)
- 00010111 aaaa0000 bbbbbbbb bbbbbbbb
- # Loads the counter value and stores it to %a.
- %a(register) = counter + %b(register)
- 00000111 aaaa0000 0000bbbb 00000000
- # Loads the counter value and stores it to %a.
- //
- // Register instructions
- //
- %a(register) = %b(register)
- 00100001 aaaa0000 0000bbbb 00000000
- # Moves a value to %a from %b.
- %a(register) = R|%b:U4(immediate)
- 00100001 aaaa0000 0000bbbb 00000000
- # Moves a value to %a from %b.
- %a(register) = neg(%b(register))
- 00100101 aaaa0000 0000bbbb 00000000
- # Negates a %b and stores it in %a.
- %a(register) = !%b(register)
- 00100011 aaaa0000 0000bbbb 00000000
- # Toggles the bits of %b and stores it in %a.
- %a(register) = %b(register) nand %c(register)
- 00100000 aaaabbbb 0000cccc 00000000
- # NAND %b and %c and stores the result in %a.
- %a(register) = %b(register) or %c(register)
- 00100001 aaaabbbb 0000cccc 00000000
- # OR %b and %c and stores the result in %a.
- %a(register) = %b(register) and %c(register)
- 00100010 aaaabbbb 0000cccc 00000000
- # AND %b and %c and stores the result in %a.
- %a(register) = %b(register) nor %c(register)
- 00100011 aaaabbbb 0000cccc 00000000
- # NOR %b and %c and stores the result in %a.
- %a(register) = %b(register) xor %c(register)
- 00100100 aaaabbbb 0000cccc 00000000
- # XOR %b and %c and stores the result in %a.
- %a(register) = %b(register) << %c(register)
- 00100101 aaaabbbb 0000cccc 00000000
- # Logical shifts left %b by %c and stores the result in %a.
- %a(register) = %b(register) >> %c(register)
- 00100110 aaaabbbb 0000cccc 00000000
- # Logical shifts right %b by %c and stores the result in %a.
- %a(register) = %b(register) + %c(register)
- 00100111 aaaabbbb 0000cccc 00000000
- # ADD %b and %c and stores the result in %a.
- %a(register) = %b(register) - %c(register)
- 00101000 aaaabbbb 0000cccc 00000000
- # SUB %b and %c and stores the result in %a.
- %a(register) = %b(register) asr %c(register)
- 00101001 aaaabbbb 0000cccc 00000000
- # Arithmetic shift right %b by %c and stores the result in %a.
- %a(register) = %b(register) * %c(register)
- 00101010 aaaabbbb 0000cccc 00000000
- # MUL %b and %c and stores the result in %a.
- %a(register) = %b(register) / %c(register)
- 00101011 aaaabbbb 0000cccc 00000000
- # DIV %b and %c and stores the result in %a.
- %a(register) = %b(register) mod %c(register)
- 00101100 aaaabbbb 0000cccc 00000000
- # DIV %b and %c and stores the result in %a.
- cmp %a(register), %b(register)
- 00101101 1111aaaa 0000bbbb 00000000
- # Compares %a and %b and stores the result in the 'flags' register.
- %a(register) = merge32(%b(register),%c(register))
- 00101110 aaaabbbb 0000cccc 00000000
- # Arithmetic shift right %b by %c and stores the result in %a.
- %a(register) = lower16(%b(register))
- 00101111 aaaa0000 0000bbbb 00000000
- # Toggles the bits of %b and stores it in %a.
- %a(register) = upper16(%b(register))
- 00111001 aaaabbbb 00000000 00010000
- # Toggles the bits of %b and stores it in %a.
- if %a(register) == %b(register) goto %c:U16(immediate | label)
- 00101010 1111aaaa 0000bbbb 00000000 01010001 00001111 cccccccc cccccccc
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are equal.
- if %a(register) == %b(register) goto %c(register)
- 00101010 1111aaaa 0000bbbb 00000000 01000001 00001111 0000cccc 00000000
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are equal.
- if %a(register) != %b(register) goto %c:U16(immediate | label)
- 00101010 1111aaaa 0000bbbb 00000000 01011001 00001111 cccccccc cccccccc
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are not equal.
- if %a(register) != %b(register) goto %c(register)
- 00101010 1111aaaa 0000bbbb 00000000 01001001 00001111 0000cccc 00000000
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are equal.
- if %a(register) <= %b(register) goto %c(register)
- 00101010 1111aaaa 0000bbbb 00000000 01000101 00001111 0000cccc 00000000
- if %a(register) >= %b(register) goto %c(register)
- 00101010 1111aaaa 0000bbbb 00000000 01001100 00001111 0000cccc 00000000
- //
- // Immediate instructions
- //
- %a(register) = %b:S16(immediate | label)
- 00110001 aaaa0000 bbbbbbbb bbbbbbbb
- # Moves a value to %a.
- %a(register) = neg(%b:U16(immediate | label))
- 00110101 aaaa0000 bbbbbbbb bbbbbbbb
- # Negates a value and stores it in %a.
- %a(register) = !%b:S16(immediate | label)
- 00110011 aaaa0000 bbbbbbbb bbbbbbbb
- # Toggles the bits of a value and stores it in %a.
- %a(register) = %b(register) nand %c:S16(immediate | label)
- 00110000 aaaabbbb cccccccc cccccccc
- # NAND %b and %c and stores the result in %a.
- %a(register) = %b(register) or %c:S16(immediate | label)
- 00110001 aaaabbbb cccccccc cccccccc
- # OR %b and %c and stores the result in %a.
- %a(register) = %b(register) and %c:S16(immediate | label)
- 00110010 aaaabbbb cccccccc cccccccc
- # AND %b and %c and stores the result in %a.
- %a(register) = %b(register) nor %c:S16(immediate | label)
- 00110011 aaaabbbb cccccccc cccccccc
- # NOR %b and %c and stores the result in %a.
- %a(register) = %b(register) xor %c:S16(immediate | label)
- 00110100 aaaabbbb cccccccc cccccccc
- # XOR %b and %c and stores the result in %a.
- %a(register) = %b(register) << %c:S16(immediate | label)
- 00110101 aaaabbbb cccccccc cccccccc
- # Logical shifts left %b by %c and stores the result in %a.
- %a(register) = %b(register) >> %c:S16(immediate | label)
- 00110110 aaaabbbb cccccccc cccccccc
- # Logical shifts right %b by %c and stores the result in %a.
- %a(register) = %b(register) + %c:S16(immediate | label)
- 00110111 aaaabbbb cccccccc cccccccc
- # ADD %b and %c and stores the result in %a.
- %a(register) = %b(register) - %c:S16(immediate | label)
- 00111000 aaaabbbb cccccccc cccccccc
- # SUB %b and %c and stores the result in %a.
- %a(register) = %b(register) asr %c:S16(immediate | label)
- 00111001 aaaabbbb cccccccc cccccccc
- # Arithmetic shifts right %b and %c and stores the result in %a.
- %a(register) = %b(register) * %c:S16(immediate | label)
- 00111010 aaaabbbb cccccccc cccccccc
- # MUL %b and %c and stores the result in %a.
- %a(register) = %b(register) / %c:S16(immediate | label)
- 00111011 aaaabbbb cccccccc cccccccc
- # DIV %b and %c and stores the result in %a.
- %a(register) = %b(register) mod %c:S16(immediate | label)
- 00111100 aaaabbbb cccccccc cccccccc
- # DIV %b and %c and stores the result in %a.
- cmp %a(register), %b:U16(immediate)
- 00111101 1111aaaa bbbbbbbb bbbbbbbb
- if %a(register) == %b:U16(immediate) goto %c:U16(immediate | label)
- 00111010 1111aaaa bbbbbbbb bbbbbbbb 01010001 00001111 cccccccc cccccccc
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are equal.
- if %a(register) != %b:U16(immediate) goto %c:U16(immediate | label)
- 00111010 1111aaaa bbbbbbbb bbbbbbbb 01011001 00001111 cccccccc cccccccc
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a and %c are not equal.
- if %a(register) > %b:U16(immediate) goto %c(register)
- 00111010 1111aaaa bbbbbbbb bbbbbbbb 01001101 00001111 0000cccc 00000000
- # Compares %a and %b, stores the result in the 'flags' register and jumps to %c if %a > %c.
- //
- // Jump instructions
- //
- je %a:U16(immediate | label)
- 01010001 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the values were equal (reading results from 'flags').
- jb %a:U16(immediate | label)
- 01010010 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was below (unsigned) the second (reading results from 'flags').
- jb %a(register)
- 01000010 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was below (unsigned) the second (reading results from 'flags').
- jbe %a:U16(immediate | label)
- 01010011 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the First value was below (unsigned) or equal to the second (reading results from 'flags').
- jbe %a(register)
- 01000011 00001111 0000aaaa 00000000
- # Jumps to %a if the First value was below (unsigned) or equal to the second (reading results from 'flags').
- jl %a:U16(immediate | label)
- 01010100 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was less (signed) than the second (reading results from 'flags').
- jl %a(register)
- 01000100 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was less (signed) than the second (reading results from 'flags').
- jle %a:U16(immediate | label)
- 01010101 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was less (signed) or equal to the second (reading results from 'flags').
- jle %a(register)
- 01000101 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was less (signed) or equal to the second (reading results from 'flags').
- jmp %a(register)
- 01001000 00001111 0000aaaa 00000000
- # Jumps to %a.
- jmp %a:U16(immediate | label)
- 01011000 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a.
- jne %a:U16(immediate | label)
- 01011001 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the values were not equal (reading results from 'flags').
- jae %a:U16(immediate | label)
- 01011010 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was above (unsigned) or equal to the second (reading results from 'flags').
- jae %a(register)
- 01001010 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was above (unsigned) or equal to the second (reading results from 'flags').
- ja %a:U16(immediate | label)
- 01011011 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was above (unsigned) the second (reading results from 'flags').
- ja %a(register)
- 01001011 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was above (unsigned) the second (reading results from 'flags').
- jge %a:U16(immediate | label)
- 01011100 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was greater (signed) or equal to the second (reading results from 'flags').
- jge %a(register)
- 01001100 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was greater (signed) or equal to the second (reading results from 'flags').
- jg %a:U16(immediate | label)
- 01011101 00001111 aaaaaaaa aaaaaaaa
- # Jumps to %a if the first value was greater (signed) than the second (reading results from 'flags').
- jg %a(register)
- 01001101 00001111 0000aaaa 00000000
- # Jumps to %a if the first value was greater (signed) than the second (reading results from 'flags').
- //
- // Storage instructions
- //
- %dest(register) = load8[%adr(register)]
- 01100000 dddd0000 0000aaaa 00000000
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = load8[%adr:U16(immediate)]
- 01110000 dddd0000 aaaaaaaa aaaaaaaa
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = load16[%adr(register)]
- 01100001 dddd0000 0000aaaa 00000000
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = load16[%adr:U16(immediate)]
- 01110001 dddd0000 aaaaaaaa aaaaaaaa
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = load32[%adr(register)]
- 01100010 dddd0000 0000aaaa 00000000
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = load32[%adr:U16(immediate)]
- 01110010 dddd0000 aaaaaaaa aaaaaaaa
- # Loads address %adr from main memory and stores it to %dest.
- %dest(register) = pload[%adr(register)]
- 01100011 dddd0000 0000aaaa 00000000
- # Loads address %adr from persistent memory and stores it to %dest.
- %dest(register) = pload[%adr:U16(immediate)]
- 01110011 dddd0000 aaaaaaaa aaaaaaaa
- # Loads address %adr from persistent memory and stores it to %dest.
- store8[%adr(register)] = %value(register)
- 01100100 0000vvvv 0000aaaa 00000000
- # Stores %value to address %adr in main memory.
- store8[%adr:U16(immediate)] = %value(register)
- 01110100 0000vvvv aaaaaaaa aaaaaaaa
- # Stores %value to address %adr in main memory.
- store16[%adr(register)] = %value(register)
- 01100101 0000vvvv 0000aaaa 00000000
- # Stores %value to address %adr in main memory.
- store16[%adr:U16(immediate)] = %value(register)
- 01110101 0000vvvv aaaaaaaa aaaaaaaa
- # Stores %value to address %adr in main memory.
- store32[%adr(register)] = %value(register)
- 01100110 0000vvvv 0000aaaa 00000000
- # Stores %value to address %adr in main memory.
- store32[%adr:U16(immediate)] = %value(register)
- 01110110 0000vvvv aaaaaaaa aaaaaaaa
- # Stores %value to address %adr in main memory.
- pstore[%adr(register)] = %value(register)
- 01100111 0000vvvv 0000aaaa 00000000
- # Stores %value to address %adr in persistent memory.
- pstore[%adr:U16(immediate)] = %value(register)
- 01110111 0000vvvv aaaaaaaa aaaaaaaa
- # Stores %value to address %adr in persistent memory.
- //
- // Stack instructions
- //
- stack.push(%a(register))
- 00111000 11101110 00000000 00000100 01100110 0000aaaa 00001110 00000000
- # Pushes %a onto the stack. This instruction is a synonym for: sub sp, sp, 4 store_32 [sp], %a
- %a(register) = stack.peek()
- 01100010 aaaa0000 00001110 00000000
- # Retrieve topmost value from stack without removing it.
- stack.pop()
- 00110111 11101110 00000000 00000100
- # Decreases the stack counter which removes the topmost value from the stack
- %a(register) = stack.pop()
- 01100010 aaaa0000 00001110 00000000 00110111 11101110 00000000 00000100
- # Pops %a off the stack. This instruction is a synonym for: load_32 %a, [sp] add sp, sp, 4
- //
- // Cycle instructions
- //
- // Internal register
- for (i = %a:S16(immediate); i < %b:S16(immediate); %c:S16(immediate))
- 00110001 11000000 aaaaaaaa aaaaaaaa 00110001 11010000 cccccccc cccccccc 00101110 11011100 00001101 00000000 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 bbbbbbbb bbbbbbbb 00111000 11001100 aaaaaaaa aaaaaaaa 00111011 11001100 cccccccc cccccccc 00010111 11010000 00000000 00001000 00101110 11011100 00001101 00000000 01100010 11000000 00001110 00000000 00110111 11101110 00000000 00000100 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00111000 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (i = %a:S16(immediate); i > %b:S16(immediate); %c:S16(immediate))
- 00110001 11000000 aaaaaaaa aaaaaaaa 00110001 11010000 cccccccc cccccccc 00101110 11011100 00001101 00000000 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 bbbbbbbb bbbbbbbb 00111000 11001100 aaaaaaaa aaaaaaaa 00111011 11001100 cccccccc cccccccc 00010111 11010000 00000000 00001000 00101110 11011100 00001101 00000000 01100010 11000000 00001110 00000000 00110111 11101110 00000000 00000100 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00111000 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (i = %a:S16(immediate); i >= %b:S16(immediate); %c:S16(immediate))
- 00110001 11000000 aaaaaaaa aaaaaaaa 00110001 11010000 cccccccc cccccccc 00101110 11011100 00001101 00000000 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 bbbbbbbb bbbbbbbb 00111000 11001100 aaaaaaaa aaaaaaaa 00111011 11001100 cccccccc cccccccc 00110111 11001100 00000000 00000001 00010111 11010000 00000000 00001000 00101110 11011100 00001101 00000000 01100010 11000000 00001110 00000000 00110111 11101110 00000000 00000100 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00111000 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (i = %a:S16(immediate); i <= %b:S16(immediate); %c:S16(immediate))
- 00110001 11000000 aaaaaaaa aaaaaaaa 00110001 11010000 cccccccc cccccccc 00101110 11011100 00001101 00000000 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 bbbbbbbb bbbbbbbb 00111000 11001100 aaaaaaaa aaaaaaaa 00111011 11001100 cccccccc cccccccc 00110111 11001100 00000000 00000001 00010111 11010000 00000000 00001000 00101110 11011100 00001101 00000000 01100010 11000000 00001110 00000000 00110111 11101110 00000000 00000100 00111000 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00111000 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- %a(register) = (i)
- 01100010 aaaa0000 00001110 00000000 00101111 aaaa0000 0000aaaa 00000000
- endfor
- 01100010 11000000 00001110 00000000 00110111 11101110 00000000 00000100 00111001 11011100 00000000 00010000 00100111 11001100 00001101 00000000 01100010 11010000 00001110 00000000 00110111 11101110 00000000 00000100 00111000 11101110 00000000 00000100 01100110 00001100 00001110 00000000 00111000 11011101 00000000 00000001 00101111 11000000 00001101 00000000 00111101 11111100 00000000 00000000 00111001 11001101 00000000 00010000 01001101 00001111 00001100 00000000 00110111 11101110 00000000 00000100
- // User Defined Register
- for (%d(register) = %a:S16(immediate); %e(register) > %b:S16(immediate); %c:S16(immediate))
- 00110001 dddd0000 aaaaaaaa aaaaaaaa 00110001 11000000 bbbbbbbb bbbbbbbb 00110101 11001100 aaaaaaaa aaaaaaaa 00111100 11001100 cccccccc cccccccc 00000111 11010000 00000000 00000000 00110100 11011101 00000000 00001100 00101110 11011100 00001101 00000000 00110101 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 cccccccc cccccccc 00110101 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (%d(register) = %a:S16(immediate); %e(register) < %b:S16(immediate); %c:S16(immediate))
- 00110001 dddd0000 aaaaaaaa aaaaaaaa 00110001 11000000 bbbbbbbb bbbbbbbb 00110101 11001100 aaaaaaaa aaaaaaaa 00111100 11001100 cccccccc cccccccc 00000111 11010000 00000000 00000000 00110100 11011101 00000000 00001100 00101110 11011100 00001101 00000000 00110101 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 cccccccc cccccccc 00110101 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (%d(register) = %a:S16(immediate); %e(register) >= %b:S16(immediate); %c:S16(immediate))
- 00110001 dddd0000 aaaaaaaa aaaaaaaa 00110001 11000000 bbbbbbbb bbbbbbbb 00110101 11001100 aaaaaaaa aaaaaaaa 00111100 11001100 cccccccc cccccccc 00110100 11001100 00000000 00000001 00000111 11010000 00000000 00000000 00110100 11011101 00000000 00001100 00101110 11011100 00001101 00000000 00110101 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 cccccccc cccccccc 00110101 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- for (%d(register) = %a:S16(immediate); %e(register) <= %b:S16(immediate); %c:S16(immediate))
- 00110001 dddd0000 aaaaaaaa aaaaaaaa 00110001 11000000 bbbbbbbb bbbbbbbb 00110101 11001100 aaaaaaaa aaaaaaaa 00111100 11001100 cccccccc cccccccc 00110100 11001100 00000000 00000001 00000111 11010000 00000000 00000000 00110100 11011101 00000000 00001100 00101110 11011100 00001101 00000000 00110101 11101110 00000000 00000100 01100110 00001101 00001110 00000000 00110001 11000000 cccccccc cccccccc 00110101 11101110 00000000 00000100 01100110 00001100 00001110 00000000
- endfor %d(register)
- 01100010 11000000 00001110 00000000 00110100 11101110 00000000 00000100 00100100 dddddddd 00001100 00000000 01100010 11010000 00001110 00000000 00110100 11101110 00000000 00000100 00110101 11011101 00000000 00000001 00101111 11000000 00001101 00000000 00111010 11111100 00000000 00000000 00111000 11001101 00000000 00010000 01001101 00001111 00001100 00000000
- //
- // Function instructions
- //
- call(%a(label))
- 00000111 11110000 00000000 00000000 00110111 11111111 00000000 00010100 00110101 11101000 00000000 00000100 01100110 00001111 00001110 00000000 01011000 00001111 aaaaaaaa aaaaaaaa
- # Calls %a. Overwrites the flag register. This instruction is a synonym for: counter flags add flags, flags, 20 sub sp, sp, 4 store_32 [sp], flags jmp %a
- return
- 01100010 11110000 00001110 00000000 00110111 11101110 00000000 00000100 01001000 00001111 00001111 00000000
- # Returns from the last function call. Overwrites the flag register. This instruction is a synonym for: load_32 flags, [sp] add sp, sp, 4 jmp flags
- */
Add Comment
Please, Sign In to add comment