Sunday, April 17, 2022

Esolang OISC:3d

Updated:  18 April 2022

No, I can't leave well enough alone.  I think we've established that by now.  This one might be more useful.  Too useful?  Negative addresses were a pain in the previous versions, and most instructions aren't indirect, so I've swapped functionality to simplify the interpreter.  It should also make programming easier and negative memory much more useful.  Note that memory address 0 is still impossible to directly address.  

Positive memory is loaded as integers only.
A jump to negative memory Halts & Fails.

Instruction    Function
A B C            [C] = [B] - [A]
0 B C            If [B] <= 0, Jump to C//[-C]
A 0 C            If [A] <= 0, Relative jump by C
A B 0            [[B]] = [[B]] - [[A]]  (indirect addressing)
A 0 0            Input [A] as character
0 B 0            Output [B] as character  (if [B] < 0, Halt & Fail)
0 0 C            Output [C] as number
0 0 0            Halt & Succeed

Address        Function
-1                IP (initially 0)
-2                NEXT (always IP+3)
-3                RETURN (initially 0, set to NEXT before any jump.)
-4                Register a
-5                Register b
-6                Register c
-7                Mode (activates a, b, c; then resets to 0)
-8                MaxPos memory size
-9                MaxNeg memory size
-10...           Data (address: start from 0, add 10, negate)

Mode    Function
0          NOP
1          c = ~b (bitwise not)
2          c = b & a (bitwise and)
3          c = b | a (bitwise or)
4          c = b ^ a (bitwise xor)
5          c = b << a (shift b left by a bits)
6          c = b >> a (shift b right by a bits)
7          sign of b, +1, 0, -1
8          floor of b (integer)
9          truncate b (round down, integer)
10        c = b - a
11        c = b + a
12        c = b * a
13        c = b // a (integer division)
14        c = b % a (mod, integer remainder)
15        c = b / a
16        c = b to power of a
17        c = a root of b
18        c = log base b of a
19        c = sin(b)
20        c = cos(b)
21        c = tan(b)
22        c = asin(b)
23        c = acos(b)
24        c = atan(b)
25        c = sinh(b)
26        c = cosh(b)
27        c = tanh(b)
28        c = asinh(b)
29        c = acosh(b)
30        c = atanh(b)
31        c = sqrt(b**2 + a**2)  (hypotenuse)
32        a = pi, b = e, c = phi (golden ration)
33        c radians <-- b degrees
34        c degrees <-- b radians
35        c = gcd(b, a)  (greatest common divisor)
36        c = a permutations of b items (unique)
37        c = a combinations of b items (not unique)
38        c = b! (factorial)
39        c = sum of 0..b (integers, works with negatives)



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.