6969 Assembler

From Esolang
Jump to navigation Jump to search
The 6969 Assembler logo

6969 Assembler (sometimes 6969 ASS-embler) is a assembler-like programming language made by User:CMinusMinus in 2020. The goal is to create a language hard enough so no usable program can be created with it in reasonable time. Idea: List of ideas: Partially silly ideas

The language is based out of three-letter instructions:

Instruction Operation Explanation version
MEM int Creates memory with <int> slots. 0.1.0-today
DFS str Defines %s with the value of <str>. 0.1.0-today
DFI int Defines %i with the value of <int>. 0.1.0-today
DFF float Defines %i with the value of <float>. 0.1.0-today
MOV dest::var Push variable somewhere 0.1.0-today
ADD str::str Defines %s with left str + right str 0.1.1-today
FLW src::dest Erases, then writes <src> to file <dest> 0.1.1-today
FLR src::dest Reads a file <src> into variable <dest> 0.1.1-today
MAD float Calculates %f = f% + <float> 0.1.2-today
MSB float Calculates %f = f% - <float> 0.1.2-today
MML float Calculates %f = f% * <float> 0.1.2-today
MDV float Calculates %f = f% / <float> 0.1.2-today
CST float/int Converts <float> or <int> to str %s 0.1.2-today
CIN float/str Converts <float> or <str> to int %i 0.1.2-today
CFL str/int Converts <str> or <int> to float %f 0.1.2-today
JMP str/int Jumps to pointer or line number 0.1.2-today
PNT str Sets a pointer 0.1.2-today
CMP str Compares two values 0.1.3-today

Variables

Real variables doesn't exist, because all data is stored in the 'memory slot', which is actually an array. There are 3 types of variables

Raw variables

These variables are just normal text (no spaces!).

Example:

; Output text "xyz"
MOV C*::xyz
>>> xyz

Defined variables

There are 3 variables that you can define and 1 that takes an user input. These are the only instructions that allow spaces. You don't need quotes for strings. Some instructions save their outputs in these variables.

Type Variable Instruction
String %s DFS
Integer %i DFI
Float %f DFF
String %i DFS

Example:

; Define string
DFS My cool text!
; Output text x
MOV C*::%s
>>> My cool text!

Memory variables

These variables are saved as memory slots. You can access them with M*[N] where N is the slot-number. You first need to create the memory slots with the MEM instruction.

Example:

; Create 5 memory slots
MEM 5
; Define string
DFS My cool text!
; put "My cool text!" into memory slot 2
MOV M*[2]::%s
; Output memory slot 2
MOV C*::M*[2]
>>> My cool text!

Beginner's explanation

The memory is a basic array (list) of elements (here: "slots"). It looks like this: ["apple","banana","car","truck"] The memory now has a length of 4. At the program's beginning, the memory is always empty. To add things to it, you have to create the slots first. To do so, use the MEM instruction. Start:

[]

After {MEM 5}

["","","","",""]

This created 5 empty slots. Whenever you use the MEM instruction, the memory is reset.

Files

Writing

You can use the FLW instruction to write to a file. The file gets erased every time you use the FLW instruction. The instruction (FLW src::dest) is easy:

  • src is the source, it can be every type of variable
  • dest is the destination, so the filename. It also can be every type of variable

Example:

; Write the text from memory slot 1 into myfile.txt
FLW M*[1]::myfile.txt
; Write the text from %s into the file called [output of memory slot 2]
FLW %s::M*[2]
; Write the text "mycooltext" into the file called [output of %s]
FLW mycooltext::%s

Reading

You can use the FLR instruction to read a file. this instruction (FLR src::dest) is also easy:

  • src is the source, it can be every type of variable
  • dest is the destination, it can be either %s or a memory slot

Example:

; Read file called (output of memory slot 1) into memory slot 2
FLR M*[1]::M*[2]
; Read file called myfile.txt into %s
FLR myfile.txt::%s

Instructions

MOV

The MOV instruction moves a variable into a slot or to the output. It looks like this:

MOV A::B

where A is the destinaton and B is the source

Memory M*

Examples:

; Pushes the value of %s into memory position 2 
MOV M*[2]::%s
; Pushes hello into memory position 2 
MOV M*[2]::hello

; Copies the value of memory slot 3 to memory slot 2
MOV M*[2]::M*[3]

Console C*

Examples:

; Outputs the value of %s
MOV C*::%s
; Outputs hello
MOV C*::hello

; Outputs the value of memory slot 3
MOV C*::M*[3]

JMP

The JMP (jump) instruction lets you jump to a specific line in the code.

Ways

There are two ways you can use a jump.

With line-number
1 | ; Outputs "hi\n"
2 | MOV C*::hi^n
3 | JMP 2
4 | ; Jump to line 2 forever

With pointers

You can place a pointer wherever you want, it will be callable from everywhere.

1 | ; Create a pointer called "mystart"
2 | PNT mystart
3 | ; Outputs "hi\n"
4 | MOV C*::hi^n
5 | JMP mystart
6 | ; Jump to pointer "mystart" forever

Jump-If

Using the CMP instruction, you can do a jump-if. To do so, just place a "?" in front of the line-number or pointer Example:

; if %s==%? (str = user-input)
; True: %i = 1
; False: %i = 0
CMP %s=%?
; Jump to mypointer if %i == 1
JMP ?mypointer

CMP

The CMP (Compare) instructions compares two values. There are 3 operators (= | > | <). If the comparison is TRUE, %i is set to 1, otherwise to 0. Example:

; If the user-input (%?) is equal to %s (an unknown string), %i = 1, else %i = 0
CMP %s=%?

Examples

Hello World

; Move Hello,_World! to C* (output)
MOV C*::Hello,_World!

>>> Hello,_World!

or

; Move Hello, World! to %s
DFS Hello, World!
MOV C*::%s
>>> Hello, World!

or

; Create 10 memory slots
MEM 10
; Move Hello, World! to %s
DFS Hello, World!
; Move %s to memory slot 4
MOV M*[4]::%s
; Output memory slot 4
MOV C*::M*[4]
>>> Hello, World!

Cat

; Take user input (%i) and move it into C* (console output)
MOV C*::%i

While Loop

; Move "Hello, World!\n" into %s
DFS Hello, World^n
; Set pointer "loop"
PNT loop
; Output %s
MOV C*::%s
; Jump to pointer "loop"
JMP loop

Links