Qwertycode

From Esolang
Jump to navigation Jump to search

Qwertycode is an esoteric programming language created by nullbyte00, that has a command and operation for every character on a standard QWERTY keyboard, hence its name. However, the only characters that do not have a command associated with them are whitespace and 0-9, which for obvious reasons can not be used. Qwertycode is similar to brainfuck in that it makes use of a tape, but has many more commands and supports subroutines, looping, conditionals, and gotos.

Commands

Qwertycode has over 50 commands and operators represented by a single character. They are:

Command Description
A Assigns a value to a byte
B Value of current byte
C Assigns a constant value to a byte
D Value of previous byte
E Exits the program
F Sets all bytes to 0
G Greater than
H Outputs the ASCII value of all bytes
I Outputs int value of all bytes
J Change the pointer to the specified value
K Stops the program, and returns an error message
L Less than
M Multiplies all bytes by 2
N Divides all bytes by 2
O Sorts the bytes from lowest to highest
P Pauses the program
Q Total number of bytes
R Random value between 0 and 255
S Stops the program
T Value of next byte
U Increase all bytes by 1
V Decrease all bytes by 1
W Pauses for a specified number of microseconds
X Performs either E, H, K, M, N, O, P, S, U, V, or Y at random
Y Sorts all bytes by random
Z Value of the pointer
~ Defines a subroutine
` Outputs int value of a byte
! Inequality comparison
@ Label
#...#(n) Everything in between the #'s gets repeated n times
$ Call to subroutine
% Square roots a byte
^ Squares a byte
& Greater than or equal to
| Less than or equal to
* Multiplies a byte
_ Prints a new line
- Decrements a byte
+ Increments a byte
= Equality comparison
: Goto
; Accepts input in form of an int, then stores in a byte
"..." Conditional, where everything in between the "'s is the condition
'...' Comment, where everything in between the 's is a comment
< Decrements the pointer
> Increments the pointer
, Accepts input in form of ASCII, then stores in a byte
. Outputs ASCII value of a byte
? Begins conditional
/ Divides a byte by 2
\ True if two values are within a range of 1
(...) Group (many commands need their arguments within a group)
[...] Index
{...} Conditional and subroutine block

Although all commands are listed in uppercase, Qwertycode is case-insensitive so lowercase is alright. Whitespace is also ignored, but preferred for readability.

How To

This section will explain how to do simple tasks, such as declaring subroutines.

Assign a value to a byte

When assigning a value to a byte, you simply list the byte you want to assign the value to, followed by an A or C (if you want it constant), then the int value in a group. Here are three examples:

This assigns 65 to the current byte:

BA(65)

This assigns 5 to the 8th byte:

B[7]A(5)

This assigns a random value to the current byte:

BA(R)

Output the value of a byte

To output the value of a byte, you simple list the byte who's value you want outputted, then either a . or a ` (dpending on whether you want the int value or the ASCII value outputted). Here are two examples:

This assigns 65 to the current byte, and outputs its ASCII value (which is A):

BA(65)
B.

This assigns 66 to the 2nd byte, and outputs its int value (which is 66):

B[1]A(66)
B[1]`

Use subroutines

To declare a subroutine, you use the ~ followed by a group of numbers which is the name of the subroutine.

This declares a subroutine called 2:

~(2)

To then put code inside the subroutine, the group is followed by an opening curly, your code, then a closing curly. Example:

~(2){
UB.
}

Finally, to make a call to a subroutine, you use the $, followed by a group containing the name of your subroutine. Example:

~(2){
UB.
}
$(2)

Create a loop

To create a loop, every command you want looped goes between two #s, then a group saying how many times it should loop.

This will output A 10 times:

BA(65)
#B.#(10)

Use gotos

To use a goto, you must first create a label by using the @ character, followed by a group of numbers, which is the name.

This will create a label named 1:

@(1)

To jump, or goto, that label, use the : character followed by a group containing the name of the label. Example:

@(1)'some code goes here':(1)

This would of course create an infinite loop however.

Use conditionals

To use conditionals, you use the ? character followed by a condition surrounded in "s. Example:

?"B=(10)"

To then execute code if the condition is true, you use a pair of curly brackets. Example:

?"B=(10)"{UB.}

There are a limited amount of functions you can perform in a condition. You can check for equality, inequality, etc. See the list of commands for everything you can use.

Examples

Below are a few examples of Qwertycode programs.

Hello World!

BA(72)B.
BA(101)B.
BA(108)#B.#(2)
BA(111)B.
BA(32)B.
BA(87)B.
BA(111)B.
BA(114)B.
BA(108)B.
BA(100)B.
BA(33)B.

99 Bottles of Beer

BA(99)>
~(1){
BA(32) B.
BA(98) B.
BA(111) B.
BA(116) B.
BA(116) B.
BA(108) B.
BA(101) B.
BA(115) B.
BA(32) B.
BA(111) B.
BA(102) B.
BA(32) B.
BA(98) B.
BA(101) B.
BA(101) B.
BA(114) B.
BA(32) B.
BA(111) B.
BA(110) B.
BA(32) B.
BA(116) B.
BA(104) B.
BA(101) B.
BA(32) B.
BA(119) B.
BA(97) B.
BA(108) B.
BA(108) B.
BA(44) B.
BA(32) B.
}
~(2){
BA(32) B.
BA(98) B.
BA(111) B.
BA(116) B.
BA(116) B.
BA(108) B.
BA(101) B.
BA(115) B.
BA(32) B.
BA(111) B.
BA(102) B.
BA(32) B.
BA(98) B.
BA(101) B.
BA(101) B.
BA(114) B.
BA(33) B.
BA(32) B.
BA(84) B.
BA(97) B.
BA(107) B.
BA(101) B.
BA(32) B.
BA(111) B.
BA(110) B.
BA(101) B.
BA(32) B.
BA(100) B.
BA(111) B.
BA(119) B.
BA(110) B.
BA(44) B.
BA(32) B.
BA(112) B.
BA(97) B.
BA(115) B.
BA(115) B.
BA(32) B.
BA(105) B.
BA(116) B.
BA(32) B.
BA(97) B.
BA(114) B.
BA(111) B.
BA(117) B.
BA(110) B.
BA(100) B.
BA(44) B.
BA(32) B.
}
~(3){
BA(32) B.
BA(98) B.
BA(111) B.
BA(116) B.
BA(116) B.
BA(108) B.
BA(101) B.
BA(115) B.
BA(32) B.
BA(111) B.
BA(102) B.
BA(32) B.
BA(98) B.
BA(101) B.
BA(101) B.
BA(114) B.
BA(32) B.
BA(111) B.
BA(110) B.
BA(32) B.
BA(116) B.
BA(104) B.
BA(101) B.
BA(32) B.
BA(119) B.
BA(97) B.
BA(108) B.
BA(108) B.
BA(33) B.
}
#< B`>$(1)< B`>$(2)< B- B`>$(3)_ #(99)

CAT Program

@(1)B,B.:(1)

Alphabet

B[1]A(32)
B[2]A(91)
B[3]A(93)
B[4]A(65)
B[5]A(83)
B[6]A(67)
B[7]A(73)
B[8]A(60)
B[9]A(62)
B[10]A(84)
B[11]A(66)
B[12]A(76)
B[13]A(69)
B[14]A(82)
B[15]A(68)
B[16]A(47)
B[17]A(32)
B[18]A(72)
B[19]A(67)
B[20]A(79)
B[21]A(34)
B[22]A(61)
B[23]A(49)
B[0]A(65)
B[8].
B[10].
B[4].
B[11].
B[12].
B[13].
B[17].
B[11].
B[20].
B[14].
B[15].
B[13].
B[14].
B[22].
B[21].
B[23].
B[21].
B[9].
B[8].
B[10].
B[14].
B[9].
B[8].
B[10].
B[15].
B[9].
B[8].
B[11].
B[9].
B[19].
B[18].
B[4].
B[14].
B[8].
B[11].
B[17].
B[16].
B[9].
B[8].
B[10].
B[15].
B[17].
B[16].
B[9].
B[8].
B[10].
B[15].
B[9].
B[8].
B[11].
B[9].
B[4].
B[5].
B[6].
#B[7].#(2)
B[8].
B[11].
B[17].
B[16].
B[9].
B[8].
B[10].
B[15].
B[17].
B[16].
B[9].
#
B[8].
B[10].
B[14].
B[9].
B[8].
B[10].
B[15].
B[9].
B[0].
B[8].
B[10].
B[15].
B[17].
B[16].
B[9].
B[8].
B[10].
B[15].
B[9].
B[0]`
B[8].
B[10].
B[15].
B[17].
B[16].
B[9].
B[8].
B[10].
B[14].
B[17].
B[16].
B[9].
B[0]+
#
(26)
B[8].
B[10].
B[4].
B[11].
B[12].
B[13].
B[17].
B[16].
B[9].

External resources