ACL

From Esolang
Jump to navigation Jump to search

ACL (Advanced Computer Language) is a language created in 2019 by User:Hanzlu. The language shall have a .adcl file extension.

The purpose of the language is to make a language dealing with binary memory in a very low level way.

The commands in the language are the hexadecimals 0-F.

Interpreters exist in Java and Python.

History and Turing Completeness

Originally, ACL is an advanced extension to another language I made, which I happened to call TCPL (The Computer Programming Language). That language consisted of ACL commands 1-7, where the 4 command immediately outputted the bit. That language would be a minimalist Turing-complete language similar to what is mentioned here. ACL was simply an extension to that language, increasing the usability and simplicity of TCPL. If you look at an ACL program like the Collatz sequence program further down on this page, you'll notice that still most commands used are 1-7, while other commands are simply for simplifying programming, allow more I/O, and more control flow.

Note

The language does operations on a binary memory, cell based, which starts of with only one cell (cell 0) set to the value 0. There is a pointer which moves around in memory pointing at cells at which operations can be performed. The pointer starts at location 0. Operations can only be done on the positive cells and the 0 cell.

The language has two output strings. Values are appended onto those strings, and the string can later be outputted. The binary output string (lower) can only hold strings of bits. The binary output string can be outputted. The binary number in that string can be translated to a decimal number (and further converted to an ASCII character) which is appended to the character output string (higher). The character output string allows for character and decimal output.

ACL allows for a condition check (if-clause), loops, and "functions". If-clauses and loops can be nested.

ACL does not understand negative numbers. Negative numbers should be able to be implemented in ACL programs however.

ACL has an error code 1111.

Versions

During July 31th I did a few edits to the commands. ACL version 1.1 is now complete and published at 17:16, July 31th 2019 (UTC). Version 1.0 made it mandatory to start every program with 1, and functions were inserted during execution which limited their usability.

August 2nd 2019 at 17:51 (UTC) version 1.2 of ACL is published. v1.2 allowes newlines in ACL source code files in order to increase readability.

August 3rd at 14:28 (UTC) version 1.3 of ACL is published. v1.3 brings functions back to their state in v1.0 as that appears to be the most structured way of dealing with them.

August 5th 2019 at 19: version 1.4 is published. v1.4 changes the loop command from 78 to 8.

Commands

Command Explanation
0 Moves the pointer to cell 0.
1 Moves the pointer to the right. If it comes to a non-existing cell it creates a cell and sets its value to 0.
2 Moves the pointer to the left. If the pointer goes to cell -1 it moves to the cell with the highest index.
3 Flips the bit under the pointer.
4 Appends the bit under the pointer to the binary output string. (See B and C for actual output)
5 Starts if clause. If the bit under the pointer is 1, code is continued to read, else it jumps to the if-clause's 6 command (else command), or to the 7 command (endif command) if a 6 command doesn't exist for the if-clause.
6 If a 6 command is read when the condition of the if-clause was 1, the reading of code continues from the 7 command (endif command) of the if-clause.
7 Does nothing on its own, but marks the end of an if-clause.
8 End of loop. This command can be placed instead of a 7 command in order to allow looping. If the bit under the pointer is 1, the reading of code jumps back to the if-clauses starting 5 command.
9 Sets the bit under the pointer randomly to either 0 or 1.
A Sets the bit under the pointer to an inputted bit. If the bit inputted is not 0 or 1, the error code is outputted and the program terminates.
B Outputs the content of the binary output string. The binary output string is emptied.
C The content of the binary output string is translated to a decimal number. If the bit under the pointer is 1, the decimal number is appended to the character output string, else the decimal number is converted to its ASCII character and that character is appended to the character output string. The binary output string is emptied afterwards. If the binary output string is empty, there will be no binary to decimal conversion. Instead the character output string will be outputted, and then emptied.
D Code between two D commands defines a function. The function's code is stored for the E command. Read the paragraph about functions below this table.
E Function call. Inserts the currently saved function's code into the source code so the function will be run.
F Terminates the program and outputs the 1111 error code.

Commenting the code is possible as the interpreter ignores the characters besides the command characters.

Only one function can be stored at a time, so every starting D will define a new function, replacing the old. Thus, functions can not be defined in another function. A function can be run by itself however. Functions are called as the code is read and executed. Thus, functions must be quite conserved, and may not for example include non-whole if-clauses.

Technical Regarding Interpreter

The ACL interpreter (Java) can be found here Interpreter. It asks you for your ACL source file's name. That file shall be in the same directory as the compiler or you can input full paths.

There are two sorts of if clauses 567 (simple) and 568 (loop). In both the 6 is optional. The memory size can be a maximum of the-positive-range-of-a-java-int cells.

There's also a python interpreter made by User:JonoCode9374 that can be found here. It is just a direct port of the Java version (comments, README.md, most control structures), etc. The only difference is that the whole entire bytes thing is kind of lost due to the type differences between python and Java (python doesn't exactly have a byte type in the same sense as Java does).

Example Code

Here is a GitHub repository for ACL programs I've written.

Hello World!

34344343444C
3443443434343C
34434344344C
34434344344C
34434344443C
34344444C
3434343434443C
34434344443C
34443443434C
34434344344C
34434434344C
3434444343CC

This program asks for the users name. ACL can only take bit input so each character in the name must be inputted bit by bit, as 7 bit ASCII codes. The user must also mark the end of their name by writing an eof command 1111111 as the last character. When one letter has been inputted it will output 1 to mark that. In the end it will greet the user. The program's code also shows an example of how comments can be written.

#creates_cells#
11111113

#prepare_greet_output#
034343434C
34344343444C
3443443434343C
34434344344C
34434344344C
34434344443C
34344444C 

#enter_input_loop#
250A41A41A41A41A41A41A4

#check_if_input_is_eof#
5252525252525

#greet_user_and_terminate#
B024343434CCF7777777537C024B8

Loop counter from 0 to 256. Increases the counter by 1, outputs the number and loops again. (Without the use of functions)

111111113525325325325325325325325F63763763763763763763763704141414141414141CC78

Palindrome of all commands. First 0-F, and then back to 0. Creates an infinite loop.

0123456789ABCDEFEDCBA9876543210

Guessing game. Guess 0 or 1. If correct continue, else terminate.

1135091A525116F7625F611778

Truth-machine

A54B64BF8

Cat

351A4B28

Infinite loop

358

Collatz sequence

This code does the Collatz sequence for the number 9.

//collatz sequence

//create memory
111131113 11111111 11111111 13

//output starting number
041414141414141402CC

//loop
5
01111111

//check if odd
5

//x *= three, then plus one
//copy x to y, shift y left and increase by one
51111111370111111
5111111137011111
511111113701111
51111111370111
5111111137011
511111113701
51111111370
5F7
022222222223

//add y and x, store result in z
5222222225022236022376222222225022377
022222222222
5222222225022223602225323637762222222250222532363777
0222222222222
5222222225022222360222253236377622222222502222532363777
02222222222222
5222222225022222236022222532363776222222225022222532363777
022222222222222
5222222225022222223602222225323637762222222250222222532363777
0222222222222222
5222222225022222222360222222253236377622222222502222222532363777
02222222222222222
5222222225022222222236022222222532363776222222225022222222532363777
022222222222222222
5222222225F602222222225323637762222222250222222222532363777

//move z to x
02250111111156376011111115377
0222501111115637601111115377
022225011111563760111115377
02222250111156376011115377
0222222501115637601115377
022222225011563760115377
02222222250156376015377
0222222222505637605377

//make y and z zero
022537253725372537253725372537253725372537253725372537253725372537

//if eval
6
//divide x by 2
//right shift x
0111111
51563761537722
51563761537722
51563761537722
51563761537722
51563761537722
51563761537722
5156376153772537

7

//output x
041414141414141402CC

//if x is one, terminate
05615615615615615615615023677777777

028