A-SCP-M

From Esolang
Jump to navigation Jump to search

A-SCP-M is an assembly language in the same vein as the SCP project. As a result, it must be contained to being an esoteric joke language, and must not under any circumstances actually be implemented or used. If you feel the vague urge to implement it, or you see that it has been implemented, please ensure that you add additional instructions or components to this page instead, preventing the language from being fully implemented.

To our current knowledge, A-SCP-M is a regular assembly language. Instructions are executed from an indexed list, and a special register, the program counter, increments after performing a regular instruction. The next instruction is read and executed from that list at the index of the program counter.

Registers (non-addressed data sources)
ID Name Data Purpose and behaviour
%pc Program Counter Positive Integer Holds the index to the current instruction in the instruction list. Usually increments after an instruction, but not if modified by the instruction.
%null null Anything Discards anything written to it, and produces default values if read from.
%ir0-%ir7 Integer Registers 0-7 Integers Each holds any assigned integer indefinitely.
%isr0-%isr7 Integer Stack Registers 0-7 Integers Each write to the register pushes an integer to the stack, each read from the register pops an integer from the stack.
%fpr0-%fpr7 Floating Point Registers 0-7 Floating Points Each holds a pair of integers defining a mantissa and exponent indefinitely.
%of Overflow Flag Bit Instructions set this register if they are capable of overflowing.
%uf Underflow Flag Bit Instructions set this register if they are capable of underflowing.
%undeff Undefined Flag Bit Instructions set this register if they are capable of producing an undefined result, such as division by 0.
Data sources
ID Name Addressing Data Purpose and behaviour
$il0 Instruction List 0 Positive Integer Instruction Holds the instruction list, instantiated when the program is loaded to contain the program.
$im0 Integer Memory 0 Positive Integers Integer Single-dimensional positive-integer addressable memory cells.


Instructions
ID Name Arguments Purpose and behaviour
0 No-op Do nothing, increment program counter
1 Halt Terminates the program.
2 Read Datasource, Index, Register Reads from the data source, at the given index, into the register. If the datasource is not addressable by the index type, or the register cannot hold the type the datasource contains, the instruction is invalid.
3 Write Register, Datasource, Index Writes to the data source at the given index, from the register. If the datasource is not addressable by the index type, or the register cannot hold the type the datasource contains, the instruction is invalid.
4 Add Register, Register, Register Reads values from the first 2 registers, and writes their sum to the 3rd register. If the types of the registers are not the same, or the type does not support addition, the instruction is invalid. Sets the overflow and underflow registers if the destination register doesn't support the result of the operation. The desination register is set to its minimum or maximum value in these cases.
5 Subtract Register, Register, Register Reads values from the first 2 registers, and subtracts the 2nd from the 1st, writing to the 3rd register. If the types of the registers are not the same, or the type does not support subtraction, the instruction is invalid. Sets the overflow and underflow registers if the destination register doesn't support the result of the operation. The desination register is set to its minimum or maximum value in these cases.
6 Mul Register, Register, Register Reads values from the first 2 registers, and writes their product to the 3rd register. If the types of the registers are not the same, or the type does not support multiplication, the instruction is invalid. Sets the overflow and underflow registers if the destination register doesn't support the result of the operation. The desination register is set to its minimum or maximum value in these cases.
7 Div Register, Register, Register, Register Reads values from the first 2 registers, and divides the 1st by the 2nd, writing the result to the 3rd register and the remainder to the 4th register. If the types of the registers are not the same, or the type does not support division, the instruction is invalid. Sets the overflow, underflow and undeff flag registers if the destination register doesn't support the result of the operation. The desination registers are set to their minimum or maximum values in these cases.
8 IToFp Integer Register, Integer Register, Floating Point Register Reads integer values from the first 2 registers, writing them as a pair to the 3rd register.
9 FpToI Floating Point Register, Integer Register, Integer Register Reads the mantissa and exponent values from the first registers, writing them to the 2nd and 3rd register.
10 IToFpConvert Integer Register, Floating Point Register Reads integer values from the first writing the equivilent value to the 2nd register.
11 FpToIConvert Floating Point Register, Integer Register Reads the floating point value from the first register writing the equivilent value to the 2nd. Sets the overflow, underflow and undeff flag registers if the destination register doesn't support the result of the operation.
12 Clock Floating Point Register Reads the floating point value from the first register and halts execution for that amount of time in seconds.
13 Exchange Register, Register This instruction swaps the values in the first and second registers.
14 And Integer Register, Integer Register, Integer Register Performs a bitwise and operation between the first two registers, putting the result in the third
15 Or Integer Register, Integer Register, Integer Register Performs a bitwise or operation between the first two registers, putting the result in the third
16 Not Integer Register, Integer Register Performs a bitwise not operation on the first register, putting the result in the second