C-LONG
From Esolang
C-LONG is a esoteric program language with long lines (it doesn't have anything to do with C programming, though.)
Each line is the same length and is filled by these characters:
- 0 to 9 - digits
- A to Z - letters (uppercase only)
- _ - blank
- . - period
- * - special character representing newline
- !@#$% - when used, is automatically replaced with value of register before execution of command line
The line format is:
- LABEL: 8 characters giving line label
- NEXT: 8 characters giving the line it will go to next (regardless of condition true/false)
- NAME1: 8 characters giving first variable name
- NAME2: 8 characters giving second variable name
- COND1IS1: 1 character giving conditional to skip command if bit in first variable is 1
- COND1IS0: 1 character giving conditional to skip command if bit in first variable is 0
- COND2IS1: 1 character giving conditional to skip command if bit in second variable is 1
- COND2IS0: 1 character giving conditional to skip command if bit in second variable is 0
- CONDSAME: 1 character giving conditional to skip command if bit in first variable is same as bit in second variable
- CONDDIFF: 1 character giving conditional to skip command if bit in first variable is not same as bit in second variable
- CONDXTRA: 1 character giving conditional to skip command if an additional condition is true
- AXCHAR: 1 character is an additional character that might be used by some commands
- INIT: 1 character giving operation to figure out initial value of working value, var1 (operation) var2
- BITADJ: 4 characters telling which bits to toggle in working value
- SHIFT: 1 character telling how many bit positions to shift left (wraps around to right) a digit 0 to 9 or letters for A=10, B=11 etc, you can use blank instead of 0 if you want to
- SAVE1: 1 character telling operation of what to store to var 1, set var1 = var1 (operation) working value
- SAVE2: 1 character telling operation of what to store to var 2, set var2 = var2 (operation) working value
- SAVEREG: 5 characters telling what characters will be stored in !@#$% registers
- COMMAND: 3 characters giving an additional command to execute, use ___ for no extra command
This shows you the fields in 1 line:
--------++++++++--------++++++++-+-+-+-+-++++-+-+++++---
Variables can be 2 types, bit-fields or command-lines. If it is a command-line with same line label as variable name then it is a command-line type that is modification of that command-line (for doing self-modifying codes). The label does not count as part of the value. A bit-field is 32 bits, any name that isn't a line label, it is initialized to zero.
Bit positions of a bit-field is labeled like this:
ABCDEFGH IJKLMNOP QRSTUVWX YZ012345
In any condition (COND) field you can use _ (blank) for don't use this condition.
For bit-fields the operations are:
- 0 = Always returns all bits are 0
- 1 = AND
- 2 = Result bits will be 1 only if first source is 0 and second source is 1
- 3 = Result is same as second source
- 4 = Result bits will be 1 only if first source is 1 and second source is 0
- 5 = Result is same as first source
- 6 = XOR
- 7 = OR
- 8 = NOR
- 9 = XNOR
- A = NOT of first
- B = Result bits will be 0 only if first source is 1 and second source is 0
- C = NOT of second
- D = Result bits will be 0 only if first source is 0 and second source is 1
- E = NAND
- F = Always returns all bits are 1
- I = Add numbers together
- J = Subtract second from first
- Z = First source is shift left 1 space (wraps)
- . = Input a bit-field and store that value
For command-lines the operations are:
- 0 = All characters are AXCHAR
- 1 = Result is same as first source
- 2 = Result is same as second source
- A = First source with all characters matching AXCHAR replaced with character in same position from second source
- B = Second source with all characters matching AXCHAR replaced with character in same position from first source
For CONDXTRA of bit-fields variables you can use:
- 0 = If both variables have same value
- 1 = If both variables do not have same value
- 2 = If var1 value is zero
- 3 = If var1 value is not zero
- 4 = If var1 value is less than var2 value
- Y = Always true
- Z = Always false
- * = Always false
For CONDXTRA of command-line variables you can use:
- 0 = If both variables have same value
- 1 = If both variables do not have same value
- 2 = If var1 value does not contain any characters matching AXCHAR
- 3 = If var1 value does contain any characters matching AXCHAR
- Y = Always false
- Z = Always true
- * = Always false
For a command-line value, the BITADJ field is used by the first character indicating the type and the other 3 are parameters x,y,z:
- _ = Nothing
- 0 = Change all characters matching parameter x to parameter y
- 1 = Change all characters matching x to y, y to x
- 2 = Change all characters matching x to y, y to z, z to x
- 3 = Change all characters matching x to character in position of var1
- 4 = Change all characters matching x to character in position of var2
- 5 = Change all characters not matching x to y
- 6 = Change all characters matching x to y, and all that don't match x to z
Additional commands that can be used in COMMAND field:
- END = Program terminates
- HEX = Set ! register to a 0-9A-F of least significant nybble in working value, set @ register to 0-9A-F of second least significant nybble, # register of third, $ register of fourth, % register of fifth. Only the registers will be set if that field in the command-line is set to * (newline)
- INP = Input a character, store in any registers that the field in command-line is set to *
- OUT = Output the working value, either a bit-field, or if it is a command-line then only the parts that are the same position as characters in var1 matching AXCHAR
- COP = Copy NAME1 to NEXT field of var2
- OD_ = Output working value as a decimal number
- OH_ = Output working value as a hexadecimal number
- NEX = If working value is a command-line then it will change all registers that the field is * to the one right after that one in the working value, wraps to beginning

