C-LONG

From Esolang
Jump to navigation Jump to search

C-LONG is an esoteric programming language by User:Zzo38 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 unless bit in first variable is 1
  • COND1IS0: 1 character giving conditional to skip command unless bit in first variable is 0
  • COND2IS1: 1 character giving conditional to skip command unless bit in second variable is 1
  • COND2IS0: 1 character giving conditional to skip command unless bit in second variable is 0
  • CONDSAME: 1 character giving conditional to skip command unless bit in first variable is same as bit in second variable
  • CONDDIFF: 1 character giving conditional to skip command unless bit in first variable is not same as bit in second variable
  • CONDXTRA: 1 character giving conditional to skip command unless 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.

The working value has the type of the first variable. If an operation is performed with incompatible types, it uses the type of the first operand, and the second operand is set to all zero bits or to all blank spaces.

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.

There are two stacks, one for bit-fields, and one for command-lines.

For bit-fields the operations are:

  • _ = Always returns all bits are 0 for read, but means no change for write
  • 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:

  • _ = Result is same as current command line for read, no change for write
  • 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:

  • COP = Copy NAME1 to NEXT field of var2
  • 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 *
  • 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
  • OD_ = Output working value as a decimal number
  • OH_ = Output working value as a hexadecimal number
  • 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
  • POP = Pop value from stack, store in var1
  • PUS = Push working value to stack
  • SYS = Interact with system. AXCHAR is the command code, working value is input, result is stored in var2

Examples

Hello world example:

--------++++++++--------++++++++-+-+-+-+-++++-+-+++++---
0000000100000002*******8HELLO_WO_______.________!@#$%OUT
0000000200000003*******4RLD*___________.________!@#$%OUT
00000003_____________________________________________END
*******8________________........________________________
*******4________________....____________________________
--------++++++++--------++++++++-+-+-+-+-++++-+-+++++---

Beer program:

--------++++++++--------++++++++-+-+-+-+-++++-+-+++++---
START___LOOP01_____________________________________99___
LOOP01__BEER____LOOP02__RETURN___________________@8$%COP
LOOP02__BEER____LOOP03__RETURN___________________@2$%COP
LOOP03__LOOP04__TEXT8___TAKE_ONE_______._________@_$%OUT
LOOP04__LOOP05__TEXT8____DOWN_AN_______._________@_$%OUT
LOOP05__LOOP06__TEXT8___D_PASS_I_______._________@_$%OUT
LOOP06__LOOP07__TEXT8___T_AROUND_______._________@_$%OUT
LOOP07__DECREMENTEXT1___*______________._________@_$%OUT
LOOP08__BEER____LOOP09__RETURN___________________@8$%COP
LOOP09__LOOP01__TEXT2___**_____________._________@_$%OUT
LOOP_Q__FINAL1__TEXT6___NO_MOR_________._____________OUT
FINAL1__BEER____FINAL2__RETURN___________________R8_ECOP
FINAL2_______________________________________________END
DECREMENDECR01__9_00____________________1_______8@0$*NEX
DECR01__DECR02__%_00__________________Z_1_______8@0*%NEX
DECR02__DECR03__9_$$__________________Z_________8R0$%___
DECR03__DECR04__9_%$__________________Z_________Q@_$%___
DECR04__LOOP#!__________________________________!@#$%___
BEER____BEER1___TEXT8@__$%_BOTTL_______._________@#$%OUT
BEER1___BEER2___TEXT8___ES_OF_BE_______._________@#$%OUT
BEER2___RETURN__TEXT#___ER_ON_TH______Z._________@#$%OUT
RETURN__________TEXT#R___E_WALL*______Z._________@#$%OUT
TEXT1___________________._______________________________
TEXT2___________________..______________________________
TEXT6___________________......__________________________
TEXT8___________________........________________________
TEXT8R___________________.......________________________
TEXT2R_________________________.________________________
9_00____________98765432109_____________________________
--------++++++++--------++++++++-+-+-+-+-++++-+-+++++---