5iasm

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

5iasm stands for "5 Instruction ASseMbly language". Like the name suggests, it has 5 commands.

Instructions

Instructions:
Mnemonic Meaning What it does
inc [register] INCrement Increments a register
dec [register] DECrement Decrements a register
jmp [line]/[label] JuMP Jumps to a line or a label
isz [register] Instruction Skip if Zero Skips the next instruction if register is 0
stp SToP Halts

The first line in program is line 1. There are 10 registers : A,B,C,D,E,F,G,H,X, and Y. There are two special registers:

Special registers
Name Action on read (by isz) Action on write(by inc or dec)
I Prompts one-character input (like brainfuck.) EOF=0 Acts like a normal register but is set to the last inputted value after input.
O Returns 1 Prints its contents as a Unicode character
N Returns 0 After operation,if the contents is divisible by 3, enable I/O. This is used to output higher ASCII values without printing the lower values

Labels and comments

To define a label:

label:

To jump to a label:

jmp label

Comments:

;comments are prepended with semicolons

Examples

Addition

; Clear C
clearC:
isz C
jmp decC
jmp clearX
decC:
dec C
jmp clearC
; Clear X
clearX:
isz X
jmp decX
jmp processA
decX:
dec X
jmp clearX
; Copy A to X and C
processA:
isz A
jmp inc
jmp restoreA
inc:
dec A
inc X
inc C
jmp processA
; Now A is in X and C, but A=0
; Now restore A from X
restoreA:
isz X
jmp incA
jmp processB
incA:
inc A
dec X
jmp restoreA
; Now we copy the value from B to X and C
; X is 0, so it becomes a backup copy again.
; And in C is the sum afterwards.
processB:
isz B
jmp inc2
jmp restoreB
inc2:
dec B
inc X
inc C
jmp processB
; We restore the value in B from X.
restoreB:
isz X
jmp incB
jmp done
incB:
inc B
dec X
jmp restoreB
; Done.
done: 
stp