Skip to content

Latest commit

 

History

History
475 lines (453 loc) · 8.22 KB

CHEATSHEET.md

File metadata and controls

475 lines (453 loc) · 8.22 KB

Y2K Command Cheat Sheet

This provides a quick rundown of how to perform various commands.

All commands follow the same basic flow:

Command ID -> Command Fields -> Command Value

Command IDs

Every Y2K command should start by referencing a command ID. If you wanted to print something, your command would start with 9, if you wanted to create a new variable, your command would start with 8, and so on.

Command Description ID
PRINT Print variable or string 9
CREATE Create a new variable 8
MODIFY Modify an existing variable 7
CONDITION Create a condition 6
META Modify interpreter state 5
CONTINUE Continue (in loop) 4

Command Fields

After the command ID, the next N digits should complete the required fields for the specified command. If a command has 3 fields, then the next 3 digits would be assigned to those fields, for example.

Command ID Fields
9 (PRINT)
  1. Type
    • 1 --> String
    • 2 --> Variable
  2. Size
8 (CREATE)
  1. Variable ID
  2. Type
    • 1 --> String
    • 2 --> Integer
    • 3 --> Float
      • Size should be # digits + 1, with the first digit used for decimal placement.
      • Example: 3.14 would require Size = 4, with the first digit set to 1 (1314).
    • 9 --> Copy
  3. Size
7 (MODIFY)
  1. Variable ID
  2. Function
    • 1 --> +=
    • 2 --> -=
    • 3 --> *=
    • 4 --> /=
    • 5 --> **= (exponentiation)
    • 9 --> =
  3. Argument Is Variable
    • 0 --> No
    • 1 --> Yes (value will be treated as a variable ID)
  4. Argument Size
6 (CONDITION)
  1. Variable ID
  2. Comparison
    • 1 --> ==
    • 2 --> <
    • 3 --> >
    • 4 --> Is evenly divisible by
  3. Loop
    • 0 --> if
    • 1 --> while
  4. Argument Size
5 (META)
  1. Debug Mode
    • 0 --> Off
    • 1 --> On
  2. # of digits
    • Updates the number of digits parsed on each pass of the interpreter

Command Value

After the command ID and fields are set, the next step is to read in a value that matches the "Size" field (if applicable). For example, if you're creating a new variable, and the variable size is set to 4, the next 4 digits would contain the variable's value. If you're modifying an existing variable, and the argument size is 3, the next 3 digits would contain the argument value for the modifier function.

PRINT statements don't have a size field. Depending on the Type specified, a print statement either:

  • String: Converts the following digits into characters until a 2-space sequence is reached. See Character Codes for help.
  • Variable: Use the next digit as a variable ID, and prints that variable

Once the command value is set, the interpreter returns to the start and looks for the next command ID to repeat this process over again.

Character Codes

Alphabet

Number Character Number Character
0 (whitespace)
1 a 27 A
2 b 28 B
3 c 29 C
4 d 30 D
5 e 31 E
6 f 32 F
7 g 33 G
8 h 34 H
9 i 35 I
10 j 36 J
11 k 36 K
12 l 37 L
13 m 38 M
14 n 39 N
15 o 40 O
16 p 41 P
17 q 42 Q
18 r 43 R
19 s 44 S
20 t 45 T
21 u 46 U
22 v 47 V
23 w 48 W
24 x 49 X
25 y 50 Y
26 z 51 Z

Numeric

Number Character
52 1
53 2
54 3
55 4
56 5
57 6
58 7
59 8
60 9
61 0

Symbols

!@#$%^&*()+-<>.,

Number Character
62 !
63 @
64 #
65 $
66 %
67 ^
68 &
69 *
70 (
71 )
72 +
73 -
74 <
75 >
76 .
77 ,