JAJL

From Esolang
Jump to navigation Jump to search

JAJL is an esolang created by User:Gordinator. Its standard implementation is written in Python, but an official variant, JAJL-CS, is written in C#.

JAJL is designed to be simple to write a compiler or interpreter, simple to conceptualise, and also encourages the creation of self-obfuscating programs.

How JAJL Works

JAJL is a programming language that requires you to change the values of memory addresses using instructions. Some of these memory addresses can work with the stack, or the string buffer, or other pre-determined memory addresses.

Memory Addresses

JAJL can work with memory addresses from values 0000 to ffff, each of which can either be unallocated or contain data.

The Stack

The Stack is a special location where memory addresses can be transferred. Data is "pushed" to the stack from a memory address, and "popped" to a memory address. However, unlike a CPU ISA, the stack isn't an actual stack, but instead is a memory address outside of memory.

Functions

Functions work exactly as they do in other programming languages. They are defined using func <addr>, and functions are ended with endf.

Data Types

  • Unallocated

Must be allocated to be used.

  • Integer

Value can range from 0 to 63336.

  • Signed Integer

Value can from -65536 to 65536.

Instruction Set

  • int <addr>

Creates an integer with value 0 at address <addr>.

  • inc <addr>

Sets the value of <addr> to the value of <addr>+1.

  • dec <addr>

Sets the value of <addr> to the value of <addr>-1.

  • incb <addr>

Sets the value of <addr> to the value of address 00ab + 1.

  • decb <addr>

Sets the value of <addr> to the value of address 00ab - 1.

  • del <addr>

Deletes memory address <addr>.

  • sbfr

Converts the value of address aaaa into an ASCII character and appends that character to the string buffer.

  • prnt

Prints the contents of the string buffer to STDOUT.

  • sclr

Clears the string buffer.

  • push <addr>

Sets the value of the stack to the value of the stack + the value of <addr>.

  • pop <addr>

Sets the value of <addr> to the value of <addr> + the value of the stack.

  • pnt <addr>

Sets the pointer to <addr>.

  • free

Sets the pointer to the first unallocated address.

  • func <addr>

Defines a function at <addr>. All lines after the func definition are part of the function and are not executed.

  • endf

Ends the function definition. The function is "compiled" and can be run.

  • call <addr>

Call the function at address <addr>.

'Hello World'

; Hello world program
; (c) 2023 WinFan3672, some rights reserved.
; Licenced under GNU GPL2-only.

inc 00ab
push 00ab
pop 00ab
pop 00ab
inc 00ab
rstk
incb aaaa
sbfr ; H

push 00ab
pop fffe
push 00ab
push 00ab
pop 00ab
inc 00ab
incb aaaa
sbfr ; e

rstk
push fffe
int 00ab
pop 00ab
incb aaaa
sbfr ; l
sbfr ; l
rstk
push aaaa
pop efff

inc aaaa
inc aaaa
inc aaaa
rstk
push aaaa
pop effd
sbfr ; 0

rstk
push aaaa
pop ffff
rstk
int bbbb
inc bbbb
push bbbb
push bbbb
int bbbb
pop bbbb
push bbbb
int bbbb
pop bbbb
push bbbb
int bbbb
pop bbbb
push bbbb
int bbbb
pop bbbb
push bbbb
int bbbb
pop bbbb
int aaaa
pop aaaa
sbfr ; space

rstk
int aaaa
push ffff
push fffe
pop aaaa
inc aaaa
sbfr ; w

rstk
push effd
int aaaa
pop aaaa
sbfr ; o

inc aaaa
inc aaaa
inc aaaa
sbfr ; r

rstk
push ffff
int aaaa
pop aaaa
dec aaaa
dec aaaa
dec aaaa
sbfr ; l

inc 00ab
decb aaaa
sbfr ; d

inc bbbb
rstk
push bbbb
int aaaa
pop aaaa
sbfr ; !

prnt ; prints contents of string buffer

See Also