Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RL - robot language, low-level language run by vm, generally compatible with CC trutles or OC robots
- (though individual programs may depend on features exclusive to one or the other)
- HLRL - high level robot language, a higher-level language which is compiled down to RL.
- RL has 3 usable registers, b, n, and s, of types bool, number, and string, respectively.
- There are also 3 stacks, again, one for each type, used in compound operations.
- for the purpose of these instructions, in addition to b, n, and s, sb, sn, and ss will be used
- to refer to the values on top of the bool, number, and string stacks, respectively. Unless otherwise stated
- any instruction definition that includes sn is implied to have popped a value from the n stack, and same
- with ss and sb for the string and boolean stacks. Result values are never automatically pushed to the stack,
- but go in the register of the corresponding type, replacing any current value.
- RL can be written in an asm-like notation, but is executed in a kind of bytecode format.
- In RL bytecode, integer literals are encoded as base 64, prefixed with the # symbol followed by the number of
- bytes of the numeric literal.
- Arguments:
- side - one of the 6 sides or directions, relative to the robot. u, d, l, r, f, or b.
- direction - the four cardinal directions, N, S, E, or W
- side4 - the four sides within the plane, like direction but relative to the robot. l,r,f, or b.
- axis - x, y, or z, one of the three cardinal axes
- reg - one of the three registers, n, b, or s
- slot - hex digit, 0-F, for slot # (0=1, F=16)
- instructions:
- immediate values:
- #number numeric literals (in bytecode, prefixed with # and a length)
- 'string string literals (in bytecode, prefixed with ' and the length, as a single base-64 digit,
- giving a max string literal len of 64)
- true/false boolean literals ("0" and "1", in bytecode)
- imm can be any of the 3 immediate types
- robot instructions
- M move <side> <#dist>
- F face <side4|dir>
- D dig <side>
- U use <side>
- P place <side> <slot>
- R drop <side> <slot> <#count>
- S suck <side>
- G goto <axis> <#coord>
- C compare <side> <slot>
- T detect <side> <slot>
- Stack instructions
- H push <reg> push a value to the stack of the same type
- O pop <reg>
- K peek <reg> <#offset> grabs the item #offset from the top of stack (1 = top)
- B burn <reg> <#count> burns #count values off the top of the stack of the same type as reg,
- without affecting reg
- operations:
- numeric
- > gt b=sn>n
- < lt b=sn<n
- + add n=sn+n
- - sub n=sn-n
- ^ pow n=sn^n
- boolean
- ! not b=~b
- & and b=sb and b
- | or b=sb or b
- common (apply to all three types)
- = eq <reg> b = st==t (t can be n, b, or s)
- flow control
- J jump <#addr> jump to address in program
- I jif <#addr> jump to address only if b==true
- L call <#addr> pushes address of next instruction to special call stack then jumps to address
- N return pops and jumps to address on top of call stack
- other...
- V load <imm>
- . print <reg>
- Example programs:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement