intecode.txt interpreter coding prototype (not all is official) I've made a decision on 2010.12.01 to make each instruction an op-word for performance reasons. (One 2-byte endian conversion across platforms versus a 2-8 Big Endian octet read per instruction.) It's 16-bit now, but you can still carry a second operation in the lower byte. Registers F: frame; parameter start and end I: instruction pointer A: accumulator; result X: auxiliary Opcode bits o: operation; see table below s: secondary operation, if no value oooooaaa abbsssss primary addressing modes (a) n form descr. 0 A,b reg 1 X,b reg 2 [X]+,b ldx 3 -[S],b pop 4 xxx,A/X ldp, param (S) 8 *xxx,A/X rel, instr (I) C #xxx,A/X imm secondary addressing modes (b) 0 A 1 X 2 A,[X]+ stx 3 X,[S]+ psh Value (xxx): Immediates (imm) and Relatives (rel) for the low 8 bits: 0x81 expands to a half size; 1 (int) or 2 (num) words 0x80 expands to a full size; 2 (int) or 4 (num) words otherwise, a signed byte. 2/4 bytes integer, sign extended 4/8 bytes number; zero extended double Line-zero primary codes hex abbr description 0060 lnk link; pushes reg, inits F pending 0181 ulk unlink; pulls reg, exg, resets F pending 01C0 ret return; pulls I/F 01E0 jmp jump; sets I 04 bra branch (regardless of A) 05 bza branch if zero A 06 fma fused multiply add; [X]+*A+#num -> reg 08 prl push relative and reg; reg+*rel 0A stp store parameter (reg) 0C str store relative (reg) 0E sti store immediate ([S]) 0F phi push immediate Line-zero secondary lo abbr desc. 0 none 1 exg exchange A/X Operation table dec abbr desc. unary 2 mov move (can use an immediate) 3 sqr square root (can be done 2x in one) 4 abs absolute value 5 neg negate 6 not bin. not (uint) 7 bno bool not (uint) dyadic 8 ban bool and (uint) 9 bor bool or (uint) 10 and bin. and (uint) 11 ior bin. or (uint) 12 eor exclusive-or (uint) 13 asr arithmetic shift right (sint), (int) 14 shr shift right 15 shl shift left 16 add add or append 17 sub subtract 18 mcl multiply or call (push I/F, set I/F) 19 pow raise to power 20 div divide 21 dvs divide signed 22 mod modulus 23 mds modulus signed 24 clt compare less than 25 cge .. greater or equal 26 cgt .. greater 27 cle .. lesser or equal 28 ceq .. equal 29 cne .. not equal 30 cid .. identical data 31 cni .. not identical data Calling method The multiply operation doubles as the call function. mcl X,A ; if X is a func, call; otherwise multiply mcl foo ; foo is relative to an object Normal use with parameters ... ; parameters 02 lnk A ; save A and F 90 mcl foo ; call foo (relative to ptr) 08 ulk A ; restore A and F #f ff(p) { p.1 + p.(2) } ==ff== mov p Directives #cs #ci case [in]sensitive #f [florin] define function Mnemonics 5B00 ior #0 ; uin (zero extension) 6B00 asr #0 ; sin (sign extension) 7B00 add #0 ; ref (force reference) 8B00 sub #0 ; nop (no-operation) Character encodings ISO-8859-1's characters from C0-FF, except for D7 (times) and F7 (divide), are all Latin letters 3100 not X ¬ String ops `+` appends if both are strings, adds to ptr if num/int `-` subtracts length; negative clips length (all others would currently force a conversion to number) Storing -> . ## plain .+ ## incremental Comments ## end-of-line comment #[ block comment ]# EOF e32s1m95 floating point type (128 bits) int32 exp [sgn.1] [man.95]