Assembliera

From Esolang
Jump to navigation Jump to search

Assembliera is designed by Steve Abel. It just like a real ASseMbly Language, but is has more function.

Commands and Syntax

Commands
Assembliera From Mean
add a, b ADDition Add B to A. B can be a constant or a variable, or a register. A must not a constant.
sub a, b SUBtraction Subtract B from A. B can be a constant or a variable, or a register. A must not a constant.
mul a, b MULtiply Multiply A by B. B can be a constant or a variable, or a register. A must not a constant.
div a, b DIVision Divide A by B. B can be a constant or a variable, or a register. A must not a constant. B must not zero.
mod a, b MODulo Divide A by B and then return remain. B can be a constant or a variable, or a register. A must not a constant. B must not zero.
pow a, b POWer Multiply A by A for B times. B can be a constant or a variable, or a register. A must not a constant.
dis x DISplay Display X as a value. X can be a integer or a float. X can be a var/const/reg.
duc x Display as UniCode Display X as a Unicode character. X can be a integer or a character(byte or word). X can be a var/const/reg.
def *name, (type), [value] DEFine Define a variable with *name as name, (type) as type and [value] as value. *name must be retained. (type) and [value] can be omitted.
asn *var, [value] ASSigN Assign *var to [value].
jmp <label> JuMP Jump to label.
loop <label> LOOP Repeat the <label> until CX is 0.
inc p INCrease Add 1 to P. P must not be a constant.
dec p DECrease Same as above, but the operation is reversed. (Subtract 1 from P)
dvr *var Display VaRiable Display *var.
dst "str" Display STring Display "str".
cmp x, y CoMPare Compare X and Y.
jab <label> Jump if ABove Jump to <label> if X>Y. There must be a cmp command before it.
jbl <label> Jump if BeLow Jump to <label> if X<Y. There must be a cmp command before it.
jeq <label> Jump if EQual Jump to <label> if X=Y. There must be a cmp command before it.
jne <label> Jump if Not Equal Jump to <label> if X≠Y. There must be a cmp command before it.
jna <label> Jump if Not Above Jump to <label> if X≤Y. There must be a cmp command before it.
jnb <label> Jump if Not Below Jump to <label> if X≥Y. There must be a cmp command before it.
join JOIN Store the result of the accumulator in a buffer. Can be used multiple times, so the results will be chained from left to right, but with a space between the values.
dbf Display BuFfer Display the value of buffer as value.
dbfs Display BuFfer with Space Display the value of buffer as value. There will be spaces between two value.
dbu Display Buffer as Unicode Display the value of buffer as character.
dbus Display Buffer as Unicode with Space Display the value of buffer as character. There will be spaces between two value.
mov *reg, x MOVe Copy the value of X to *reg. X can be constant, variable or another register.
push *reg PUSH Push the value from the register and put in the accumulator.
pop *reg POP Pop the value from the accumulator and restore in the register.
qt QuiT End program.
inp x INPut Prompt for user input and store the result in the X. X must not a constant.
incl [[[lib]]] INCLude Imports [[[lib]]] to program.
and x, y AND Bitwise AND. Y can be a constant or a variable, or a register. X must not a constant.
or x, y OR Bitwise OR. The argument is same as above.
not x NOT Bitwise NOT. X must not a constant.
pas PAuSe Pauses the program until User input. the prompt of pas command is: Press any key to continue......
slp x SLeeP Pauses the program for X milliseconds.

It uses AX, AH, AL, BX, BH, BL, CX, DX, CS, IP, SS, SP, DS, DP, DH, DL, CH, CL, OF, DF, IF, TF, SF, ZF, AF, PF, CF, ES, SI, DI, BP and RGUN, RGDI, RGTR, RGQD, RGQT, RGSX, RGSP, RGOC, RGNN, RGDC, STOR for registers.

STOR is for store any data.

One line comment:

<?COMMENT TEXT?>

Multi line comment:

<???
c
o
m
m
e
n
t
 
t
e
x
t
??>

Sub-program and label:

SubProgramName segment
<?your code?>
SubProgramName ends

LabelName labelseg
<?your code?>
LabelName endls

The main code must wrapped in main segment and main ends.

Examples

Hello, world!

main segment
dst (join "Hello, world!", 13)
pas
qt
main ends

FizzBuzz

main segment
mov CX, 99 <Set the number of cycles to 100.>
mov AX, 1
loopUN labelseg
    mov STOR (mod AX, 3)
    cmp STOR, 0
    je fizz
    mov STOR (mod AX, 5)
    cmp STOR, 0
    je buzz
    non labelseg
        dis AX
    non endls
    duc 13
    inc AX
    fizz labelseg
        dst "Fizz"
    fizz endls
    buzz labelseg
        dst "Buzz"
    buzz endls
loopUN endls
loop loopUN
pas
qt
main ends

Cat Program

main segment
def *cat, (str), [NULL]
ipt *cat
dvr *cat
pas
brk
main ends

Truth Machine

main segment
ipt AX
mov BX, AX
cmp BX, 0
je nope
cmp BX, 1
jnb yes
nope labelseg
    dis AX
    pas
    qt
nope endls
yes labelseg
    dis AX
    jmp yes
yes ebdls
main ends

Categories