Lines Matching refs:cpu
310 AddNative("add-cc:", false, SType.BLANK, cpu => { in T0Comp()
330 AddNative("cc:", false, SType.BLANK, cpu => { in T0Comp()
354 AddNative("preamble", false, SType.BLANK, cpu => { in T0Comp()
363 AddNative("postamble", false, SType.BLANK, cpu => { in T0Comp()
374 AddNative("make-CX", false, new SType(3, 1), cpu => { in T0Comp()
375 TValue c = cpu.Pop(); in T0Comp()
380 int max = cpu.Pop(); in T0Comp()
381 int min = cpu.Pop(); in T0Comp()
384 cpu.Push(tv); in T0Comp()
396 AddNative("CX", true, cpu => { in T0Comp()
417 cpu.Push(tv); in T0Comp()
426 AddNative("co", false, SType.BLANK, cpu => { in T0Comp()
438 AddNative(":", false, cpu => { in T0Comp()
479 AddNative("define-word", false, cpu => { in T0Comp()
480 int dout = cpu.Pop(); in T0Comp()
481 int din = cpu.Pop(); in T0Comp()
482 TValue s = cpu.Pop(); in T0Comp()
503 AddNative(";", true, cpu => { in T0Comp()
527 AddNative("immediate", false, cpu => { in T0Comp()
540 WordNative wliteral = AddNative("literal", true, cpu => { in T0Comp()
542 wordBuilder.Literal(cpu.Pop()); in T0Comp()
551 WordNative wcompile = AddNative("compile", false, cpu => { in T0Comp()
553 wordBuilder.Call(cpu.Pop().ToXT()); in T0Comp()
562 AddNative("postpone", true, cpu => { in T0Comp()
598 AddNative("exitvm", false, cpu => { in T0Comp()
606 AddNative("new-data-block", false, cpu => { in T0Comp()
608 cpu.Push(new TValue(0, new TPointerBlob(dataBlock))); in T0Comp()
615 AddNative("define-data-word", false, cpu => { in T0Comp()
616 string name = cpu.Pop().ToString(); in T0Comp()
617 TValue va = cpu.Pop(); in T0Comp()
637 AddNative("current-data", false, cpu => { in T0Comp()
642 cpu.Push(new TValue(dataBlock.Length, in T0Comp()
649 AddNative("data-add8", false, cpu => { in T0Comp()
654 int v = cpu.Pop(); in T0Comp()
665 AddNative("data-set8", false, cpu => { in T0Comp()
666 TValue va = cpu.Pop(); in T0Comp()
672 int v = cpu.Pop(); in T0Comp()
683 AddNative("data-get8", false, new SType(1, 1), cpu => { in T0Comp()
684 TValue va = cpu.Pop(); in T0Comp()
691 cpu.Push(v); in T0Comp()
697 AddNative("compile-local-read", false, cpu => { in T0Comp()
699 wordBuilder.GetLocal(cpu.Pop().ToString()); in T0Comp()
701 AddNative("compile-local-write", false, cpu => { in T0Comp()
703 wordBuilder.PutLocal(cpu.Pop().ToString()); in T0Comp()
706 AddNative("ahead", true, cpu => { in T0Comp()
710 AddNative("begin", true, cpu => { in T0Comp()
714 AddNative("again", true, cpu => { in T0Comp()
718 AddNative("until", true, cpu => { in T0Comp()
722 AddNative("untilnot", true, cpu => { in T0Comp()
726 AddNative("if", true, cpu => { in T0Comp()
730 AddNative("ifnot", true, cpu => { in T0Comp()
734 AddNative("then", true, cpu => { in T0Comp()
738 AddNative("cs-pick", false, cpu => { in T0Comp()
740 wordBuilder.CSPick(cpu.Pop()); in T0Comp()
742 AddNative("cs-roll", false, cpu => { in T0Comp()
744 wordBuilder.CSRoll(cpu.Pop()); in T0Comp()
746 AddNative("next-word", false, cpu => { in T0Comp()
751 cpu.Push(StringToBlob(s)); in T0Comp()
753 AddNative("parse", false, cpu => { in T0Comp()
754 int d = cpu.Pop(); in T0Comp()
756 cpu.Push(StringToBlob(s)); in T0Comp()
758 AddNative("char", false, cpu => { in T0Comp()
763 cpu.Push(c); in T0Comp()
765 AddNative("'", false, cpu => { in T0Comp()
767 cpu.Push(new TValue(0, new TPointerXT(name))); in T0Comp()
775 AddNative("execute", false, cpu => { in T0Comp()
776 cpu.Pop().Execute(this, cpu); in T0Comp()
779 AddNative("[", true, cpu => { in T0Comp()
783 AddNative("]", false, cpu => { in T0Comp()
786 AddNative("(local)", false, cpu => { in T0Comp()
788 wordBuilder.DefLocal(cpu.Pop().ToString()); in T0Comp()
790 AddNative("ret", true, cpu => { in T0Comp()
795 AddNative("drop", false, new SType(1, 0), cpu => { in T0Comp()
796 cpu.Pop(); in T0Comp()
798 AddNative("dup", false, new SType(1, 2), cpu => { in T0Comp()
799 cpu.Push(cpu.Peek(0)); in T0Comp()
801 AddNative("swap", false, new SType(2, 2), cpu => { in T0Comp()
802 cpu.Rot(1); in T0Comp()
804 AddNative("over", false, new SType(2, 3), cpu => { in T0Comp()
805 cpu.Push(cpu.Peek(1)); in T0Comp()
807 AddNative("rot", false, new SType(3, 3), cpu => { in T0Comp()
808 cpu.Rot(2); in T0Comp()
810 AddNative("-rot", false, new SType(3, 3), cpu => { in T0Comp()
811 cpu.NRot(2); in T0Comp()
822 AddNative("roll", false, new SType(1, 0), cpu => { in T0Comp()
823 cpu.Rot(cpu.Pop()); in T0Comp()
825 AddNative("pick", false, new SType(1, 1), cpu => { in T0Comp()
826 cpu.Push(cpu.Peek(cpu.Pop())); in T0Comp()
829 AddNative("+", false, new SType(2, 1), cpu => { in T0Comp()
830 TValue b = cpu.Pop(); in T0Comp()
831 TValue a = cpu.Pop(); in T0Comp()
834 cpu.Push(a); in T0Comp()
838 cpu.Push(StringToBlob( in T0Comp()
845 AddNative("-", false, new SType(2, 1), cpu => { in T0Comp()
852 TValue b = cpu.Pop(); in T0Comp()
853 TValue a = cpu.Pop(); in T0Comp()
857 cpu.Push(new TValue(a.x - b.x)); in T0Comp()
862 cpu.Push(a); in T0Comp()
864 AddNative("neg", false, new SType(1, 1), cpu => { in T0Comp()
865 int ax = cpu.Pop(); in T0Comp()
866 cpu.Push(-ax); in T0Comp()
868 AddNative("*", false, new SType(2, 1), cpu => { in T0Comp()
869 int bx = cpu.Pop(); in T0Comp()
870 int ax = cpu.Pop(); in T0Comp()
871 cpu.Push(ax * bx); in T0Comp()
873 AddNative("/", false, new SType(2, 1), cpu => { in T0Comp()
874 int bx = cpu.Pop(); in T0Comp()
875 int ax = cpu.Pop(); in T0Comp()
876 cpu.Push(ax / bx); in T0Comp()
878 AddNative("u/", false, new SType(2, 1), cpu => { in T0Comp()
879 uint bx = cpu.Pop(); in T0Comp()
880 uint ax = cpu.Pop(); in T0Comp()
881 cpu.Push(ax / bx); in T0Comp()
883 AddNative("%", false, new SType(2, 1), cpu => { in T0Comp()
884 int bx = cpu.Pop(); in T0Comp()
885 int ax = cpu.Pop(); in T0Comp()
886 cpu.Push(ax % bx); in T0Comp()
888 AddNative("u%", false, new SType(2, 1), cpu => { in T0Comp()
889 uint bx = cpu.Pop(); in T0Comp()
890 uint ax = cpu.Pop(); in T0Comp()
891 cpu.Push(ax % bx); in T0Comp()
893 AddNative("<", false, new SType(2, 1), cpu => { in T0Comp()
894 int bx = cpu.Pop(); in T0Comp()
895 int ax = cpu.Pop(); in T0Comp()
896 cpu.Push(ax < bx); in T0Comp()
898 AddNative("<=", false, new SType(2, 1), cpu => { in T0Comp()
899 int bx = cpu.Pop(); in T0Comp()
900 int ax = cpu.Pop(); in T0Comp()
901 cpu.Push(ax <= bx); in T0Comp()
903 AddNative(">", false, new SType(2, 1), cpu => { in T0Comp()
904 int bx = cpu.Pop(); in T0Comp()
905 int ax = cpu.Pop(); in T0Comp()
906 cpu.Push(ax > bx); in T0Comp()
908 AddNative(">=", false, new SType(2, 1), cpu => { in T0Comp()
909 int bx = cpu.Pop(); in T0Comp()
910 int ax = cpu.Pop(); in T0Comp()
911 cpu.Push(ax >= bx); in T0Comp()
913 AddNative("=", false, new SType(2, 1), cpu => { in T0Comp()
914 TValue b = cpu.Pop(); in T0Comp()
915 TValue a = cpu.Pop(); in T0Comp()
916 cpu.Push(a.Equals(b)); in T0Comp()
918 AddNative("<>", false, new SType(2, 1), cpu => { in T0Comp()
919 TValue b = cpu.Pop(); in T0Comp()
920 TValue a = cpu.Pop(); in T0Comp()
921 cpu.Push(!a.Equals(b)); in T0Comp()
923 AddNative("u<", false, new SType(2, 1), cpu => { in T0Comp()
924 uint bx = cpu.Pop().UInt; in T0Comp()
925 uint ax = cpu.Pop().UInt; in T0Comp()
926 cpu.Push(new TValue(ax < bx)); in T0Comp()
928 AddNative("u<=", false, new SType(2, 1), cpu => { in T0Comp()
929 uint bx = cpu.Pop().UInt; in T0Comp()
930 uint ax = cpu.Pop().UInt; in T0Comp()
931 cpu.Push(new TValue(ax <= bx)); in T0Comp()
933 AddNative("u>", false, new SType(2, 1), cpu => { in T0Comp()
934 uint bx = cpu.Pop().UInt; in T0Comp()
935 uint ax = cpu.Pop().UInt; in T0Comp()
936 cpu.Push(new TValue(ax > bx)); in T0Comp()
938 AddNative("u>=", false, new SType(2, 1), cpu => { in T0Comp()
939 uint bx = cpu.Pop(); in T0Comp()
940 uint ax = cpu.Pop(); in T0Comp()
941 cpu.Push(ax >= bx); in T0Comp()
943 AddNative("and", false, new SType(2, 1), cpu => { in T0Comp()
944 uint bx = cpu.Pop(); in T0Comp()
945 uint ax = cpu.Pop(); in T0Comp()
946 cpu.Push(ax & bx); in T0Comp()
948 AddNative("or", false, new SType(2, 1), cpu => { in T0Comp()
949 uint bx = cpu.Pop(); in T0Comp()
950 uint ax = cpu.Pop(); in T0Comp()
951 cpu.Push(ax | bx); in T0Comp()
953 AddNative("xor", false, new SType(2, 1), cpu => { in T0Comp()
954 uint bx = cpu.Pop(); in T0Comp()
955 uint ax = cpu.Pop(); in T0Comp()
956 cpu.Push(ax ^ bx); in T0Comp()
958 AddNative("not", false, new SType(1, 1), cpu => { in T0Comp()
959 uint ax = cpu.Pop(); in T0Comp()
960 cpu.Push(~ax); in T0Comp()
962 AddNative("<<", false, new SType(2, 1), cpu => { in T0Comp()
963 int count = cpu.Pop(); in T0Comp()
967 uint ax = cpu.Pop(); in T0Comp()
968 cpu.Push(ax << count); in T0Comp()
970 AddNative(">>", false, new SType(2, 1), cpu => { in T0Comp()
971 int count = cpu.Pop(); in T0Comp()
975 int ax = cpu.Pop(); in T0Comp()
976 cpu.Push(ax >> count); in T0Comp()
978 AddNative("u>>", false, new SType(2, 1), cpu => { in T0Comp()
979 int count = cpu.Pop(); in T0Comp()
983 uint ax = cpu.Pop(); in T0Comp()
984 cpu.Push(ax >> count); in T0Comp()
987 AddNative(".", false, new SType(1, 0), cpu => { in T0Comp()
988 Console.Write(" {0}", cpu.Pop().ToString()); in T0Comp()
990 AddNative(".s", false, SType.BLANK, cpu => { in T0Comp()
991 int n = cpu.Depth; in T0Comp()
993 Console.Write(" {0}", cpu.Peek(i).ToString()); in T0Comp()
996 AddNative("putc", false, new SType(1, 0), cpu => { in T0Comp()
997 Console.Write((char)cpu.Pop()); in T0Comp()
999 AddNative("puts", false, new SType(1, 0), cpu => { in T0Comp()
1000 Console.Write("{0}", cpu.Pop().ToString()); in T0Comp()
1002 AddNative("cr", false, SType.BLANK, cpu => { in T0Comp()
1005 AddNative("eqstr", false, new SType(2, 1), cpu => { in T0Comp()
1006 string s2 = cpu.Pop().ToString(); in T0Comp()
1007 string s1 = cpu.Pop().ToString(); in T0Comp()
1008 cpu.Push(s1 == s2); in T0Comp()
1404 CPU cpu = new CPU(); in ProcessInput()
1410 cpu.Enter(code, 0); in ProcessInput()
1415 Opcode op = cpu.ipBuf[cpu.ipOff ++]; in ProcessInput()
1416 op.Run(cpu); in ProcessInput()
1420 void CompileStep(CPU cpu) in CompileStep() argument
1443 w.Run(cpu); in CompileStep()
1452 cpu.Push(v); in CompileStep()
1454 w.Run(cpu); in CompileStep()