Execution time is limited to 1000ms.

Information

C15 is a 32-bit, 100 MHz softcore microprocessor synthesized using an FPGA. The processor contains three registers, all 32 bits wide: register A, register B, and register R, which are used for arithmetic operations. There are four flags: zero, greater than, less than, and out of time (indicating the exhaustion of the execution time).

Press "Run" to assemble/compile, upload, and execute the machine code. You can program the processor by either using C15 assembly or the C programming language.

Using the C Compiler

To use the C compiler, click on the button and add .c to end of your filename. The compiler has support for struct, array and 32-bit primitive data types: uint, int, and float. There is currently no support for recursion due to the limited stack space in the processor.

There are a few intrinsics provided:

Try out these sample files by clicking on the links to load them into the editor:

Using the C15 Assembler

To use the assembler, click on the button and add .asm to end of your filename. Additionally, you can view the disassembly of C files by clicking on the View Disassembly button.

Instructions are 32-bits in size, except for STORE and STOREPUSH, which are 64-bits in size. Opcodes are 8-bits in size. Arguments/operands are 12-bits in size, except for the immediate values of STORE and STOREPUSH.

HALT

Halts the execution of the processor.

SAVE ADDRESS

Saves the value in register R to the given address.

SAVEA ADDRESS

Saves the value in register A to the given address.

SAVEB ADDRESS

Saves the value in register B to the given address.

SAVEPUSH

Pushes the value in register R to the top of the general-purpose stack.

SAVETOA

Saves the value in register R to register A.

SAVETOB

Saves the value in register R to register B.

STORE VALUE ADDRESS

Writes the given immediate value to the address.

The given immediate value is 32-bits in size.

STOREPUSH VALUE

Pushes the given immediate value to the top of the general-purpose stack.

The given immediate value is 32-bits in size.

QSTORE VALUE ADDRESS

Writes the given immediate value to the given address.

GETA ADDRESS

Loads the value located at the given address into register A.

GETB ADDRESS

Loads the value located at the given address into register B.

GETAVB ADDRESS VALUE

Loads the value located at the given address into register A and loads the given immediate value into register B.

GETPOPA

Pops the value at the top of the general-purpose stack and saves it into register A.

GETPOPB

Pops the value at the top of the general-purpose stack and saves it into register B.

GETPOPR

Pops the value at the top of the general-purpose stack and saves it into register R.

VGETA VALUE

Loads the given immediate value into register A.

VGETB VALUE

Loads the given immediate value into register B.

VPUSH VALUE

Pushes the given immediate value to the top of the general-purpose stack.

PUSH ADDRESS

Pushes the value at the given address to the top of the general-purpose stack.

POP ADDRESS

Pops the value from the top of the general-purpose stack and saves it at the given address.

POPNOP

Pops the value from the top of the general-purpose stack and discards it.

SWAP

Swaps the values of register A and B.

SETLED

Sets the on-board 8-bit LEDs to represent the value in register A.

RAND

Generates a 32-bit random number and places the random number into register A.

TICK

Places the number of clock cycles since execution began into register R.

NOP

Performs no operation.

CALL ADDRESS

Pushes the next address after the current address to the call stack and jumps to the given address.

RCALL ADDRESS

Pushes the next address after the current address to the call stack and jumps to the address located at the given address.

RTN

Pops the address at top of the call stack and jumps to it.

JMP ADDRESS

Jumps to the given address (sets the program counter to the given address).

JA ADDRESS

Jumps to the given address if the value in register R is non-zero.

JNA ADDRESS

Jumps to the given address if the value in register R is zero.

JZ ADDRESS

Jumps to the given address if the zero flag is set to 1.

JNZ ADDRESS

Jumps to the given address if the zero flag is set to 0.

JLT ADDRESS

Jumps to the given address if the less than flag is set to 1.

JLTE ADDRESS

Jumps to the given address if the greater than flag is set to 0.

JGT ADDRESS

Jumps to the given address if the greater than flag is set to 1.

JGTE ADDRESS

Jumps to the given address if the less than flag is set to 0.

MOV SOURCE DESTINATION

Copies the value from the source address to the destination address.

MOVIN SOURCE

Copies the value from the source address to the destination address defined in register R.

MOVINPOP

Pops the source address from the top of the stack and copies the value from the source address to the destination address defined in register R.

MOVOUT DESTINATION

Copies the value located at the source address defined in register R to the destination address.

MOVOUTPUSH

Pushes the value located at the source address defined in register R to the top stack.

LAND

If the value in register A and register B are non-zero, then 1 is saved into register R, otherwise 0 is saved into register R.

LOR

If the value in register A or register B (or both) are non-zero, then 1 is saved into register R, otherwise 0 is saved into register R.

NOT

Performs bitwise NOT on the value in register A and saves the result into register R. (~A)

AND

Performs bitwise AND on the values in register A and register B and saves the result into register R. (A & B)

OR

Performs bitwise OR on the values in register A and register B and saves the result into register R. (A | B)

XOR

Performs bitwise XOR on the values in register A and register B and saves the result into register R. (A ^ B)

SHIFTL

Left shifts the value in register A by the value in register B and saves the result into register R. (A << B)

SHIFTR

Right shifts the value in register A by the value in register B and saves the result into register R. (A >> B)

FLTOINT

Converts a single-precision floating-point in register A to an integer and places the result in register R. (int)A

INTTOFL

Converts an integer in register A to a single-precision floating-point and places the result in register R. (float)A

INC

SINC

FINC

Increments the value of register A and saves the result back into register A. (A++)

DEC

SDEC

FDEC

Decrements the value of register A and saves the result back into register A. (A--)

ADD

SADD

FADD

Sums the values in register A and B and saves the result in register R. (A + B)

For unsigned/signed addition, the zero flag will be set to 1 if the result is zero (which may occur because of an arithmetic overflow).

SUB

SSUB

FSUB

Subtracts the values in register A and B and saves the result in register R. (A - B)

For unsigned/signed substraction, the zero flag will be set to 1 if the result is zero (which may occur because of an arithmetic underflow).

MULT

SMULT

FMULT

Multiplies the values in register A and B and saves the result in register R. (A × B)

For unsigned/signed multiplication, the zero flag will be set to 1 if the result is zero.

DIV

SDIV

FDIV

Divides the values in register A and B and saves the quotient in register R. (A ÷ B)

For unsigned/signed division, the zero flag will be set to 1 if the result is zero.

REM

SREM

Divides the values in register A and B and saves the remainder in register R. (A % B)

CMP

Compares the values in registers A and B and sets the following flags:

CMPLT

SCMPLT

FCMPLT

Compares the values in register A and B and places a 1 if A < B, otherwise 0 in register R.

CMPGT

SCMPGT

FCMPGT

Compares the values in register A and B and places a 1 if A > B, otherwise 0 in register R.

CMPLTE

SCMPLTE

FCMPLTE

Compares the values in register A and B and places a 1 if A <= B, otherwise 0 in register R.

CMPGTE

SCMPGTE

FCMPGTE

Compares the values in register A and B and places a 1 if A >= B, otherwise 0 in register R.

CMPE

SCMPE

FCMPE

Compares the values in register A and B and places a 1 if A == B, otherwise 0 in register R.

CMPNE

SCMPNE

FCMPNE

Compares the values in register A and B and places a 1 if A != B, otherwise 0 in register R.

NEG

SNEG

FNEG

Places a 1 in register R if the value in register A is zero.
Places a 0 in register R if the value in register A is non-zero.

QADD VALUE VALUE

Sums the given immediate values A and B and saves the result in register R. (A + B)

QLADD ADDRESS VALUE

Sums the value located at the given address with the immediate value and saves the result in register R. (A + B)

QSUB VALUE VALUE

Substracts the given immediate values and saves the result in register R. (A - B)

QLSUB ADDRESS VALUE

Substracts the value located at the given address with the given immediate value and saves the result in register R. (A - B)