Sunday, April 10, 2022

Esolang: OISC:2

Continuing the attempt to make Subleq more concise.  Not faster or easier, mind.  I really like this one.  Not too easy, but more useful than standard Subleq.

Many thanks to Lawrence Woodman and also to the Truttle1 videos.

Two word instruction:  A B

If A&B are both positive; [B]=[B]-[A]
If A&B are both negative; [[B]]=[[B]]-[[A]]

If A is positive and B is negative; IF [A] <= 0 Jump |B|
If A is negative and B is positive; IF [[A]] <= 0 Jump B

If A is 0 and B is positive; STDIN -> [B]
If A is 0 and B is negative; STDIN -> [[B]] 

If A is positive and B is 0; [A] -> STDOUT
If A is negative and B is 0; [[A]] -> STDOUT

If A&B are 0; HALT

Negative memory can be addressed by indirection, but instructions are only in positive memory.

Mem    Function

-1        IP (initialized to 0)
-2        NEXT (always IP+2)
-3        RETURN (set to NEXT before Jump]
-4        Register a
-5    
    Register b
-6    
    Register c
-7    
    Instruction Mode (activates on a,b,c; then resets to 0=NOP)
-8        Flag (currently unimplemented and left to the user)
-9...     Data


Instruction Mode:  Takes immediate action on a,b,c, then resets to 0.

IM       Effect

0        No Op
1        c = NOT b
2        c = b AND a
3        c = b OR a
4        c = b XOR a
5        c = b << a bits
6        c = b >> a bits
7        c = integer b*a
8        c = b//a (floored integer division) (HALT on /0)
9        c = b%a (Mod) (floored) (HALT on %0)
10        c = Sign of b (+1, 0, -1)
11        c = Floor of b
12        Int c --> Float c
13        Float c --> Int c
14        Int a,b --> Float a,b
15        Float a,b --> Int a,b
16        c = b-a
17        c = b+a
18        c = b*a
19        c = b/a (HALT on /0)
20        c = power a of b
21        c = root a of b (HALT on root 0)
22        c = Log base b of a (HALT on base 0)
23        c = SIN b
24        c = COS b
25        c = TAN b
26        c = CSC b
27        c = SEC b
28        c = COT b
29        c = ASIN b
30        c = ACOS b
31        c = ATAN b
32        c = ACSC b
33        c = ASEC b
34        c = ACOT b
35        a = pi, b = e, c = phi
36        a = 1.0, b = 0.0, c = -1.0
37        c = b Rad --> Deg
38        c = b Deg --> Rad

Extensions to Mode are left to the user.

No comments:

Post a Comment

I reserve the right to remove egregiously profane or abusive comments, spam, and anything else that really annoys me. Feel free to agree or disagree, but let's keep this reasonably civil.