Wednesday, March 30, 2022

Obfuscated SUBLEQ

SUBLEQ just isn't complicated enough.  We can make it better, stronger, slower, more obfuscated!

We start with standard SUBLEQ.  We then assign memory location zero as "Mode".  Mode gets checked before each instruction is read.  Mode can radically change the behavior of SUBLEQ.  There will be a varying number of words per instruction.  Data is treated as signed Integers ("Ai"), unless specified as Float ("Bf").  A is a literal.  *A is a pointer.  **A is an indirect pointer.  We'll keep the SUBLEQ+ convention that a negative address is also an indirect pointer (allowing an effective triple pointer).  

Mode    Words    Effect

-1      1        Halt

-2      1        *A <= stdin char, Mode=0

-3      1        A <= stdin char, Mode=0

-4      1        stdout <= char ABS(*A), Mode=0

-5      1        stdout <= char ABS(A), Mode=0

0x00    3        *B=*B-*A, if *B≤0 Jump C (standard SUBLEQ)

0x01    2        *B=*B-*A

0x02    3        *B=*B-A, if *B≤0 Jump C

0x03    2        *B=*B-A

0x10    4        *C=*B-*A, if *C≤0 Jump D

0x11    3        *C=*B-*A

0x12    4        *C=*B-A, if *C≤0 Jump D

0x13    3        *C=*B-A

0x20    4        **C=**B-**A, if **C≤0 Jump D

0x21    3        **C=**B-**A

0x22    4        **C=**B-*A if **C≤0 Jump D

0x23    3        **C=**B-*A

0x24    4        **C=**B-A if **C≤0 Jump D

0x25    3        **C=**B-A

0x26    4        **C=*B-*A if **C≤0 Jump D

0x27    3        **C=*B-*A

0x28    4        **C=*B-A if **C≤0 Jump D

0x29    3        **C=*B-A

0X30    3        *Bf=*Bf-*Af, if *Bf≤0 Jump C

0x31    2        *Bf=*Bf-*Af

0x32    3        *Bf=*Bf-Af, if *Bf≤0 Jump C

0x33    2        *Bf=*Bf-Af

0x34    3        *Bf=*Bf-*Ai, if *Bf≤0 Jump C

0x35    2        *Bf=*Bf-*Ai

0x36    3        *Bi=*Bi-*Af (floor), if *Bi≤0 Jump C

0x37    2        *Bi=*Bi-*Af (floor)

0X38    2        *Bf=*Ai

0x39    2        *Bf=Ai

0x3a    2        *Bi=*Af (floor)

0x3b    2        *Bi=Af (floor)

0x3c    2        *Bi=*Af (round down)

0x3d    2        *Bi=Af (round down)        

0x40    2        if *Af≤0 Jump B

0x41    2        *Bf=*Bf + *Af

0x42    2        *Bf=*Bf * *Af

0x43    2        *Bf=*Bf / *Af

0x44    2        *Bf=*Bf + Af

0x45    2        *Bf=*Bf * Af

0x46    2        *Bf=*Bf / Af

0x47    2        *Bf=*Bf raised to power of *Af

0x48    2        *Bf=*Bf raised to power of Af

0x49    2        *Bf=log base *Bf of *Af

0x4a    2        *Bf=log base *Bf of Af

0X4b    2        *Bf=*Af root of *Bf

0x4c    2        *Bf=Af root of *Bf

0x4d    2        *Bi=*Bf MOD *Ai

0x4e    2        *Bi=*Bf MOD Ai

0x50    2        if *Af>0 Jump B

0x51    3        *Cf=*Bf + *Af

0x52    3        *Cf=*Bf * *Af

0x53    3        *Cf=*Bf / *Af

0x54    3        *Cf=*Bf + Af

0x55    3        *Cf=*Bf * Af

0x56    3        *Cf=*Bf / Af

0x57    3        *Cf=*Bf raised to power of *Af

0x58    3        *Cf=*Bf raised to power of Af

0x59    3        *Cf=log base *Bf of *Af

0x5a    3        *Cf=log base *Bf of Af

0X5b    3        *Cf=*Af root of *Bf

0x5c    3        *Cf=Af root of *Bf

0x5d    3        *Ci=*Bf MOD *Ai

0x5e    3        *Ci=*Bf MOD Ai

0x60    1        *A=NOT *A

0x61    2        *B=*B AND *A

0x62    2        *B=*B OR *A

0x63    2        *B=*B XOR *A

0x64    2        *B=*B << *A bits

0x65    2        *B=*B >> *A bits

0x66    2        *B=*B AND A

0x67    2        *B=*B OR A

0x68    2        *B=*B XOR A

0x69    2        *B=*B << A bits

0x6a    2        *B=*B >> A bits

0x70    2        *B=NOT *A

0x71    2        *C=*B AND *A

0x72    2        *C=*B OR *A

0x73    2        *C=*B XOR *A

0x74    2        *C=*B << *A bits

0x75    2        *C=*B >> *A bits

0x76    2        *C=*B AND A

0x77    2        *C=*B OR A

0x78    2        *C=*B XOR A

0x79    2        *C=*B << A bits

0x7a    2        *C=*B >> A bits

0x80    2        if *A≤0 Jump B

0x81    2        *B=*B + *A

0x82    2        *B=*B * *A

0x83    2        *B=*B / *A

0x84    2        *B=*B MOD *A

0x85    2        *B=*B raised to *A power

0x86    2        *B=*B + A

0x87    2        *B=*B * A

0x88    2        *B=*B / A

0x89    2        *B=*B MOD A

0x8a    2        *B=*B raised to A power

0X8B    3        *B=*B / *A, *C=*B MOD *A

0x8c    3        *B=*B / A, *C=*B MOD A

0x80    2        if *A>0 Jump B

0x91    3        *C=*B + *A

0x92    3        *C=*B * *A

0x93    3        *C=*B / *A

0x94    3        *C=*B MOD *A

0x95    3        *C=*B raised to *A power

0x96    3        *C=*B + A

0x97    3        *C=*B * A

0x98    3        *C=*B / A

0x99    3        *C=*B MOD A

0x9a    3        *C=*B raised to A power

0X9B    4        *C=*B / *A, *D=*B MOD *A

0x9c    4        *C=*B / A, *D=*B MOD A






ESOLANG SUBLEQ

ESOLANG:  Esoteric (computer programming) Language

SUBLEQ:  Subtract and Branch on Less than or Equal (to zero)

I ran across Truttle1's videos on Esolangs last week, and have watched them with somewhat morbid fascination.  I remember messing around with one of these (either Subleq or DJN) on the Commodore 64 way back when.  Life has been stressful the last couple of weeks, and playing with these has been a good escape from reality.

My two favorites at the moment are Subleq and Starfish.  With Starfish (and its parent, Fish), I specifically like the stack of stacks.  That would be really clever and useful to implement with a Forth-like language.  Speaking of which, Factor appears to be the bastard mutant love child of Forth and Lisp.  What can I say, I'm a language junkie.

Anyway, I've been musing over improving/expanding Subleq, a computer language with only one command (B=B-A, branch to C if B≤0) in my sleepless nights.  Yes, I'm trying to optimize something that is deliberately obfuscated.  The language could be expanded by one more address as a target for the subtraction (C=B-A, branch to D if C≤0).  (In Subleq, every reference is a memory address, not directly a number.  So what you're really doing is taking the number at address A, subtracting it from the number found at address B, storing the result in address C, moving to the next instruction if the result was positive, or moving to the instruction at address D if the result was zero or negative.)  That would make moving memory around a bit easier.  

Having discovered Subleq+, which uses negative addresses for indirect addressing (the number in address B is the address of the number to be subtracted from), I wondered what more could be done with the negative address space.  Using address 0 as the instruction pointer seemed obvious.  I'm not certain how useful it will be, but it certainly can't hurt.  Oh, who am I kidding, of course it could seriously mess things up!  Where's the fun in avoiding that sort of confusion in an esolang?

Since -1 is used in Subleq for input (A)/output (B)/program halt (C), perhaps a few other low addresses could be used for different meta operations?  What is Subleq especially weak at?  Bitwise operations.  What does Subleq need?  A bitwise coprocessor, accessed through negative addressing!  For instructions -2 through -7, we access a coprocessor function by making it the target of the storage (C) word in the instruction.

Address   Contents
 0        Instruction Pointer (initially set to a self-referential 0)
-1        A: get character from stdin => C
          B: get character from stdin and negate it => C
          C: send result ABS(B-A) to stdout as character
          D: halt program

C:-2      NOT A => B
C:-3      A AND B => D
C:-4      A OR B => D
C:-5      A XOR B => D
C:-6      Left shift A by B bits => D
C:-7      Right shift A by B bits => D

We could continue to add functionality at the expense of address space, but why spoil the fun?  With 4 word instructions, 7 is a great place to stop.  

But if we wanted to add a coprocessor for floating point math, well, you need a whole separate space to hold the numbers.  Transferring integers to FP registers translates them.  Transferring floating point numbers back to integers rounds them down.

Address    Contents
-8           FP Constant E (2.718281828)
-9           FP Register F
-10          FP Register G
-11          FP Register H (results)
C:-12        B + A => H
C:-13        B - A => H
C:-14        B * A => H
C:-15        B / A => H
C:-16        Log base B of A (A:100 B:10 => H:2)
C:-17        B to the power of A (A:2 B:10 => H:100)
C:-18        A root of B (A:2 B:9 => H:3)
-19          FP Constant Pi (3.141592653)

But that's just crazy talk.  

Tuesday, March 22, 2022

More on Spacetime

To recap, Spacetime is the field which governs motion. It is also the field from which all other fields draw their energy. There is a maximum potential energy (purely theoretical inside the universe, of course, as everywhere has something going on), and a minimum of zero. Thus, black holes are hollow, with a shell of maximum density where the spacetime energy drops to zero. (It's all being used up by everything else.) Proper time depends on the available energy of spacetime, and where this is zero, there is no time, and thus no motion. Nothing at all happens inside a black hole, which is profoundly weird. The "time" portion of spacetime has gone to zero, so the "Space" portion essentially is a meaningless "divide by zero error". It is effectively a hole that everything else bunches up against. In the curves of physics, a2 + b2 = c2, where c=1, but only where 0≤a≤1 and 0≤b≤1. You can't have anything less than zero or more than one, so the range of possibilities is limited by the function that defines them. That which cannot exist, does not.

This definition shows that black holes must be hollow, and explains cosmic expansion in the early universe. Think of the space portion of spacetime as the Y axis, and time as the X axis, and the spacetime as the curve. Thus, where there is maximum potential energy (the horizontal limit at the top of quarter circle), time flows freely at its maximum rate where the tangent to the curve is horizontal, and space is not stretched at all. And where potential energy is zero, time does not flow at all where the tangent is vertical, but space is stretched to infinity (divide by zero error). That which cannot exist, does not. So the (quarter) circle formula of the observable universe where the laws of physics hold has limits of 0≤x≤1 and 0≤y≤1. Physics is undefined at the zero energy potential energy level. There can be no change, no motion, no time, no anything inside the hollow shell of a black hole. So where the lower limit must be greater than zero, the upper limit cannot ever truly equal one. So this devolves to 0<x<1 and 0<y<1 for particles with mass. (They would need gain or shed more energy than available to go that extra bit faster or slower.)  So we get back to an effectively hyperbolic definition of physics.

Addendum: The curves used to illustrate Alcubierre drives are good to show how momentum and red/blue shift curves work. Illustration stolen shamelessly from someone who stole it, etc.



Wednesday, March 16, 2022

Russian Military Performance

Every day the news tells us how terribly the Russians are doing, and how well the Ukrainians are defending their country.  And every day, the map shows the Russians advancing further and further into Ukraine. They now control over a third of Ukraine, and have surrounded the cream of the Ukrainian army. 

Yes, the action around the major cities is relatively slow. Sieges are like that. Sieges are how you keep from pissing your army away in pointless urban assaults. (Please note that with remarkably few exceptions, cities do not grow food, and have vast numbers of bellies to feed. Also note that the Russians have not yet turned off the lights or shut down the water and sewage plants.)

How to understand the lackluster performance of the Russian Army in Ukraine:

The Russian Army has all the flaws of the Soviet system with none of the strengths. They still have the two year, 6 month cycle conscription system, in which raw recruits go straight to their units, which teach their own version of basic training plus individual job training every six months. They then hold a regimental level field exercise at the end of each cycle to put everything together. Once a year the regiments get together to conduct a division level exercise. So, at any give time, at least one quarter of the troops in an average unit have *no idea* what they’re doing.

And it’s only that good in units where the commander doesn’t routinely rent out the conscripts as day laborers.

Their "elite" units, staffed with volunteers, are generally better trained and equipped, in that there is real training and most of the equipment will probably work right. Sort of like our military, but without an NCO corps and with a tiny budget.

It is impossible to overstate the importance of a healthy, robust NCO corps to modern military operations.  (Officers plan, NCOs do.)  That is what really separates the Western militaries from the second tier nations.

Example:  A couple decades ago, the US Army sent an airborne company (SETAF) to a demonstration in Kakakhstan.  All the former Soviet states attended likewise.  (For the purpose of brevity, these will be referred to as [Soviets].)    Grandstands were erected atop a small rise so the generals and officials could observe the festivities.  Each nation dropped their company of paratroopers onto their portion of the field.  They then assembled, moved to the starting line, advanced one kilometer to an objective, which they then assaulted.  

The US unit dropped last, but had taken the objective, reconsolidated, and was requesting further orders before the next fastest unit had finished assembling at the starting line.

This, needless to say, greatly impressed the [Soviet] generals, who asked to meet the officers commanding the Americans.  They were then introduced to the American officers, who were all sitting in the stands with them, observing their NCOs lead the troops through the exercise.  This utterly astonished the [Soviet] officers, as they could not conceive of such a thing.

Oh, and one other little thing.  This reliance upon officers instead of NCOs leads to a bit of rank inflation.  Majors command their companies and Captains their platoons, whereas Captains command our companies and Lieutenants our platoons.  They use Lieutenants as squad leaders, where we use Sergeants.  (And most of our platoons are really led by Sergeants, as well, even if a Lieutenant is nominally in charge.)

Learn from this. Remember what didn't work. Remember what did. This will all be on the test later.

Thursday, March 3, 2022

Us Army goes full Stasi

The US Army is now requiring soldiers to log and report their contacts with friends and family, in order to root out "White supremacists".  Army leaders are expected to contact their soldier's friends and families, in order to get them to rat out the troops' "undesirable" behaviors.

This is full-on East German Stasi surveillance.

Please pass on.  Sunlight is the best bleach for this sort of stain.

Here's the form currently in use in 3rd Corps, Fort Hood, Texas.