Screw

From Esolang
Jump to: navigation, search

Screw is an esoteric programming language created by User:DumpRegs. The language is inspired by brainfuck, which is considered to be the most famous esoteric programming language. Where Screw differs from brainfuck is that some symbols have been changed and a few commands have been added. Screw was originally released on July 6, 2019.

Recognized symbols

Symbol Description
+ Increment Cell by 1
- Decrement Cell by 1
{ Begin Loop (Skip over loop if current cell = 0)
} End Loop
 ? Input Char
. Output Char
< Shift One Cell Left
> Shift One Cell Right
* Cell Dump
^ Enumeration Symbol (As in 0 to 5 == 0^5)
0..9 Screw Recognizes Numbers 0 to 9
A Add Given Number to Current Cell
S Subtract Given Number from Current Cell
 ; Comment
~ End of Program

Extra features

Add

Using 'A' followed by a non-negative integer will add that integer to the contents of the current cell being pointed to. An error is thrown if the sum is greater than 127 since the traditional, non-extended, ASCII Table only goes that high. For example:

   ; THIS PROGRAM OUTPUTS '5' TO THE SCREEN
   A53   ; Add 53 (Integer 5) to Cell 0 
   .     ; Print Contents of Cell 0
   >     ; Shift to Cell 1
   A10   ; Add 10 (new-line character) to Cell 1
   .     ; Print Contents of Cell 1
   ~     ; End Program

Subtract

Using 'S' followed by a non-negative integer will subtract that integer from the contents of the current cell being pointed to. An error is thrown if the difference is below 0 since negative numbers do not exist on the ASCII Table. For example:

   ; THIS PROGRAM PRINTS OUT 9, THEN SUBTRACTS 4 AND PRINTS OUT 5
   A57.    ; Add 57 (Integer 9) to Cell 0 and Output to Screen
   >A10.   ; Add 10 to Cell 1 and Output '\n' to Screen
   <       ; Go Back to Cell 0
   S4      ; Subtract 4 from Cell 0 (Which already holds Integer 9)
   .	   ; Output '53' (Integer 5)
   >.	   ; Move Back to Cell 2 and Output '\n'
   ~	   ; End Program

Cell Dump

Using '*' followed by a non-negative integer (from 0..9), followed by '^', then followed another non-negative integer (from 0..9) will result in a Cell Dump. When this occurs all cells within the bounds (inclusive) will have their contents output to the screen and then the cells themselves will be reset to their default state, which is 0. For example:

    ; THIS PROGRAM OUTPUTS "5 + 3 = 8"
    A53    ; Add 53 (Integer 5) to Cell 0
   >A32	   ; Add 32 ' ' (space) to Cell 1
   >A43	   ; Add 43 '+' to Cell 2
   >A32	   ; Add 32 ' ' (space) to Cell 3
   >A51	   ; Add 51 (Integer 3) to Cell 4
   >A32	   ; Add 32 ' ' (space) to Cell 5
   >A61	   ; Add 61 '=' to Cell 6
   >A32	   ; Add 32 ' ' (space) to Cell 7
   >A56	   ; Add 56 (Integer 8) to Cell 8
   >A10	   ; Add '\n' to Cell 9
   *0^9	   ; Dump Cells 0-9
   ~

Classic examples

Aside from the extra features, Screw can still run code that is nearly identical to brainfuck.

Add 3 and 5

   ; THIS PROGRAM ADDS 3 AND 5 TOGETHER AND OUTPUTS 8
   +++                   ; ADD 3 TO CELL 1
   >+++++		 ; ADD 5 TO CELL 2
   {		         ; ADD 1 TO CELL 1 AND SUB 1 FROM CELL 2 UNTIL CELL 2 == 0
       <+
       >-
   }
   +++++ +++ 	         ; ADD 8 TO CELL 2
   {
   <+++++ +		 ; ADD 6 TO CELL 1
   >-			 ; SUB 1 FROM CELL 2
   }
   <.			 ; OUTPUT ANSWER IN CELL 1 (SUM = 8)
   >+++++ +++++.	 ; SHIFT TO CELL 2 AND INCREMENT 10 TIMES AND OUTPUT NEW LINE CHARACTER
   ~

Hello World

   ; THIS PROGRAM PRINTS "Hello World!"
   >+++++ ++++                   ;ADD 9 TO CELL 1
   {
       <+++++ +++                ;LOOP UNTIL CELL 0 = 72 AND CELL 1 = 0
       >-
   }
   <.	                         ;PRINT "H"
   {-}                           ;0 OUT CELL 0
   >+++++ +++++                  ;ADD 10 TO CELL 1
   {
       <+++++ +++++              ;LOOP UNTIL CELL 0 = 100 AND CELL 1 = 0
       >-
   }
   <+.                           ;ADD 1 TO CELL 0, SO IT EQUALS 101 AND PRINT 'e'
   +++++ ++..+++.	         ;PRINT "llo"
   {-}                           ;0 OUT CELL 0
   >+++++ +++                    ;ADD 8 TO CELL 1
   {
       <++++	                 ;LOOP UNTIL CELL 0 = 32
       >-
   }
   <.	                         ;PRINT SPACE
   >+++++ +++++ +                ;ADD 11 TO CELL 1
   {
       <+++++                    ;LOOP UNTIL CELL 0 = 87
       >-
   }
   <.	                         ;PRINT 'W'
   >+++++ +                      ;ADD 6 TO CELL 1
   {
       <++++                     ;LOOP TO ADD 24 TO CELL 0 SO CELL 1 = 111
       >-
   }
   <.+++.----- -.----- ---.      ;PRINT "orld"
   {-}                           ;0 OUT CELL 1
   >+++++ +++                    ;ADD 8 TO CELL 1
   {
       <++++                     ;LOOP UNTIL CELL 0 = 32
       >-
   }
   <+.                           ;INCREMENT TO 33 AND PRINT '!'
   >++++++++++.                  ;PRINT NEW LINE
   ~                             ;END PROGRAM

Executing Screw code

Screw code is executed through an interpreter called SCRINT, which appropriately stands for Screw Interpreter. SCRINT is programmed in the C programming language and will only run Screw files. Screw files are distinguished by having a ".scw" extension.

External resources

The most updated version of SCRINT can be found and downloaded from here