Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 16-bit words
- 8 registers of any size
- two stacks, one is active at a time
- 0000 - nop - do nothing
- 0001 - add - pop two numbers, push their sum
- 0010 - sub - pop two numbers, push their difference
- 0011 - pop - pop a number, and do nothing
- 0100 - dup - pop a number, push it twice
- 0101 - swap - pop two numbers, push them in the opposite order
- 0110 - ld - pop an address and a value, then store the value to that address
- 0111 - st - pop an address, and then push the contents of that address
- 1000 nnnn - ld #num - push 4-bit sign extended integer
- 1001 0nnn - ld reg - push contents of register n
- 1001 1nnn - st reg - pop, store to register n
- 1010 0nnn - add reg - pop, add register n's contents, push new value
- 1010 1nnn - sub reg - pop, subtract register n's contents, push new value
- 1011 0000 - mul - pop two numbers, push their product
- 1011 0001 - div - pop two numbers, push their quotient
- 1011 0010 - mod - pop two numbers, push their remainder
- 1011 0011 - and - pop two numbers, push their bitwise AND
- 1011 0100 - or - pop two numbers, push their bitwise OR
- 1011 0101 - xor - pop two numbers, push their bitwise XOR
- 1011 0110 - lsr - pop a number, push number>>1
- 1011 0111 - asr - pop a number, push number>>1 with top bit the same
- 1011 1000 - call - pop a number, jump to that location, push the old program counter to other stack
- 1011 1001 - return - pop a number from the other stack, and jump to it
- 1011 1010 - neg - pop a number, push -number
- 1011 1011 - cpl - pop a number, push ~number
- 1011 1100 - inc - pop a number, push number+1
- 1011 1101 - dec - pop a number, push number-1
- 1011 1110 - if - pop a number, pop an address. call address if number is nonzero
- 1011 1111 - ifelse - pop a number, pop two addresses, pop a number. call address if number is nonzero
- 1100 0000 - loop - pop two addresses. call the first address, if it produces a nonzero number call the second one, repeat
- 1100 0001 - eq? - pop two numbers, push -1 if ==, 0 if not
- 1100 0010 - ne? - pop two numbers, push -1 if !=, 0 if not
- 1100 0011 - gt? - pop two numbers, push -1 if >, 0 if not
- 1100 0100 - lt? - pop two numbers, push -1 if <, 0 if not
- 1100 0101 - le? - pop two numbers, push -1 if >=, 0 if not
- 1100 0110 - ge? - pop two numbers, push -1 if <=, 0 if not
- 1100 0111 0000 - pick - pops a number, pushes the number from N items down
- 1100 0111 0001 - pickout - pops a number, pushes the number from N items down and removes it from the stack
- 1100 0111 0010 - rotate - rotates the top three stack items
- 1100 0111 0011 - altstack - use the other stack from now on
- 1100 0111 0100 - -
- 1100 0111 0101 - -
- 1100 0111 0110 - -
- 1100 0111 0111 - -
- 1100 0111 1000 - -
- 1100 0111 1001 - -
- 1100 0111 1010 - -
- 1100 0111 1011 - -
- 1100 0111 1100 - -
- 1100 0111 1101 - -
- 1100 0111 1110 - -
- 1100 0111 1111 - -
- 1100 1nnn nnnn nnnn -(see note)- pushes address of next opcode, jumps n bytes ahead (up to 2048)
- 1101 0nnn - ld *reg - push the word pointed to by register
- 1101 1nnn - st *reg - pop a word, and store it in the memory location pointed to by register
- 1110 0nnn - inc reg - increment register
- 1110 1nnn - dec reg - decrement register
- 1111 nnnn nnnn nnnn - ld #num - push a full sized word
- 1100 1nnn nnnn nnnn is specified with a [ starting the area to be skipped over, and a ] ending it
- loop from 0 to 10:
- ld #0
- [
- dup
- ld #10
- ne?
- ]
- [
- inc
- dup
- ld #PrintDecimal
- call
- ]
- loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement