M0

From Esolang
Jump to navigation Jump to search

The M0 assembly language is the simplest assembly language you can create that enables the creation of real world programs with practical application. It includes only a single keyword: DEFINE and leverages the language properties of Hex2 along with extending the behavior to populate immediate values of various difference sizes and formats.

Thus a programmer is able to write a series of defines like so:

DEFINE LOADR 2E0
DEFINE LOADR8 2E1
DEFINE LOADRU8 2E2

and then use them to create a rather readable assembly program:

# We still support these comments
;; We also added support for hex inserts like so
:My_Global
'00440044'
;; And we also support strings, that we null pad to 4byte boundaries to make disassembly easier.
:My_String
"Hello world!"

:Prompt_Loop
	LOADXU8 R0 R3 R4            ; Get a char
	CMPSKIPI.NE R0 0            ; If NULL
	JUMP @Prompt_Done           ; We reached the end
	FPUTC                       ; Write it to TTY
	ADDUI R3 R3 1               ; Move to next char
	JUMP @Prompt_Loop           ; And loop again

And more impressive programs have been created in it such as C compilers. such as the cc_* family of C compilers written in assembly.