IOTA-C0

Introduction IOTA-C0 is a processor specification created by User:Enoua5 in 2018. It was meant to work entirely off of computational RAM, its only native instruction being to copy the value in one memory address into another memory address. There were a few decisions in the creation of this specification that would make the IOTA-C0 very impractical to build, though it does make the programming a little easier. Processor Documentation Memory Basics RAM: 65536 16-bit addresses, from 0x0000 to 0xFFFF Registers: 2 16-bit registers for holding data read from RAM Layout of RAM

Clock Cycle The following procedure is run every clock cycle  Copy the value in memory address 0x8000 into register 0 Copy the value in the memory address pointed to by the value in register 0 into register 0 Increment the value in memory address 0x8000 Copy the value in memory address 0x8000 into register 1 Copy the value in the memory address pointed to by the value in register 1 into register 1 Increment the value in memory address 0x8000 Copy the value in the memory address pointed to by the value in register 1 into the memory address pointed to by the value in register 0</li> </ol> Or, in less verbose terms: <ol> R[0]=M[0x8000]</li> R[0]=M[R[0]]</li> M[0x8000]++</li> R[1]=M[0x8000]</li> R[1]=M[R[1]]</li> M[0x8000]++</li> M[R[0]]=M[R[1]]</li> </ol>

Computational RAM Computation RAM is how the IOTA-C0 performs all its computation. The values in this area (0x8000-0x807F) change between clock cycles based on nearby values, following the rules detailed in the table below. A hex number is a literal. A hex number in brackets is a value pointed to by the number. (a pointer) A hex number in double brackets is a value pointed to by the number at the address pointed to by the number. (a pointer pointer) Assembly Documentation Preprocessor A preprocessot instruction begins with a  character on its own line. The dot is followed by the command, then arguments seperated by spaces. Commands to the front of the name. <ul>  follows C variable naming rules.</li> Will replace all instances of  with  .</li> </ul> .var name Declares a varible that can be called by prepending  to the front of the name. <ul> Compiles into a .const declaration</li> The first .var will be given a  of 0xFFFF when compiled into a .const</li> Each successive .var will be given a value one less than the last.</li> </ul> .var name[number] Declares an array that can be called by prepending  to the front of the name and appending an index in brackets. <ul> Compiles into .var declarations and a .const declaration</li>  is a positive integer in base 10.</li> Compiles into  .var declarations, with names from   to , and a .const declaration with a value 0x8000 less than  </li> </ul> Preprocessor Example If we start with the following code; .var variable .var array[3] .const constant1 10 .const constant2 42 ADD :constant1 :constant2 :array[1] ADD :array[1] :array :variable First, vars will be compiled into consts to get this; .const variable 0xFFFF .const array[2] 0xFFFE .const array[1] 0xFFFD .const array[0] 0xFFFC .const array 0x7FFC .const constant1 10 .const constant2 42 ADD :constant1 :constant2 :array[1] ADD :array[1] :array :variable Then, the consts will be pasted into the code to get this; ADD 10 42 0xFFFF ADD 0xFFFE 0x7FFC 0xFFFF

Assembly <ul> One command per line</li> <li> denotes a comment</li> <li>Any amount of whitespace can go before or after a command</li> <li>One of more white space characters (excluding new line) can go between arguments</li> <li>Arguments can be any dec, hex, octal, or binary number from 0x000-0xFFFF</li> <li>dec is written as just a number (eg 42)</li> <li>hex is written as 0x and a number (eg 0x2A)</li> <li>octal is written as 0 and a number (eg 052)</li> <li>binary is written as a 0b and a number (eg 0b101010)</li> <li>* can be put before a number to to work as an address (eg *0x10 becomes 0x8010 when compiled)</li> </ul>

In this table: <ul> <li>An argument prepended with  will default to being prepended with , even if this is not put there in the program. This cannot be turned off.</li> <li>An argument in brackets means that it is optional. A section of compilation in brackets means that it will only be present if the optional argument is present</li> </ul>

Postprocessor A postprocessor instruction begins with a. character on its own line. All postprocessor instructions and targets are ignored by the assembler. with the address of the next instruction in memory

Example Programs Fill Fills the memory with 0x0F0F SET 0x0200  0x0F0F ADR 0x0108 MOV 0x01FF *0x0046 INC *0x0001 0x0001 QJP 0x01FF
 * 1) uses only draft 1

Fibonacci Calculates the Fibonacci sequence MOV 0x200 1 MOV 0x201 1 ADR 0x200 0x1FE ADR 0x201 0x1FF STA 0x202 LBL 0x1FB #add the two numbers together GET 0x1FE 0x1FC GET 0x1FF 0x1FD ADD *0x1FC *0x1FD #write the sum to the referenced address STV *0x33 #increment the pointers INC *0x1FE 0x1FE INC *0x1FF 0x1FF #the address of DFA INC *0x1 0x1 #jump to the start of the loop QJP 0x1FB
 * 1) uses only draft 2, which added more instructions
 * 2) initial state
 * 1) locations of the most recent numbers
 * 1) location of the next number
 * 1) start the loop

Factorial Calculates the factorials for the numbers 1 through 8 JMP &start_program .var results[8] .var n .var tot .lbl fact #init factorial MOV :tot 1 #start the body of the function .lbl fact_body #check if n is at or below 1 .var fact_reached_1 LOE :n 1 :fact_reached_1 #if it is, exit the function .var fact_jump_loc TNA :fact_reached_1 &fact_ret &fact_mult :fact_jump_loc QJP :fact_jump_loc #otherwise, tot=tot*(n--) .lbl fact_mult MUL :n :tot :tot DEC :n :n #recursion! CAL &fact_body #the exit .lbl fact_ret RET .lbl start_program .var i MOV :i 1 .var for_loop LBL :for_loop #i<=8 .var end_of_array LOE :i 8 :end_of_array .var for_jump TNA :end_of_array &continue_for &exit_for :for_jump QJP :for_jump .lbl continue_for #get i factorial into tot MOV :n :i CAL &fact #put it into results .var addr ADD :results :i :addr DEC :addr :addr ADR :addr :addr SET :addr :tot #i++ INC :i :i QJP :for_loop .lbl exit_for .lbl exit_program JMP &exit_program
 * 1) uses draft 3, which added pre and post processor
 * 1) for i=1

The Future I am considering creating another similar processor specification, the IOTA-C1. If I decide to go with it, the C1 would improve upon many of the C0's shortcomings.
 * The C0's GET and SET commands require a memory look-up, which cannot be reasonably done from the C-RAM of a physical processor. Therefore, those commands would have to be replaced or removed entirely. I don't know what to replace them with though.
 * The C0 has no interactive IO. The C1 would add a few bytes of C-RAM for the purpose of communicating with external devices.
 * The HLT command was put in before the LBL command was added. It doesn't provide any reasonable purpose now, and should be removed for the C1.
 * The C0 is very limited on memory. The C1 could (though this is more questionable) provide a way to bank-swap sections of RAM. It is possible that the literals section could be used for this purpose, but I'm not so sure of the idea of losing access to literals in order to save more data.