Yael

Yael is a simple machine architecture invented by User:ehird in 2007.

It has 8 registers and 8-bit-addresses worth of memory.

Values in registers and memory are 8 bits, and initialized to 0.

When read in, a program is copied into position 0 in memory. You can store data after a program by ending the code with a halt instruction.

The standard file extension for Yael binaries is ymc.

Standard ports
Terminal (stdout and stdin) Computer speaker (input is an address in memory, the value at the address and the one next to it is the pitch, the next two values are the length)  All other ports are implementation defined.

Instructions

 * 0000 AAA BBBBBBBB
 * Stores the value B in register A.


 * 0001 AAA BBB
 * Moves the data in register B to register A.


 * 0010 AAA BBB
 * Stores the result of (A xor B) in A.


 * 0011 AAA BBB
 * Stores the result of (A and B) in A.


 * 0100 AAA BBB
 * Stores the result of (A or B) in A.


 * 0101 AAA BBB
 * Adds A to B, and stores the result in A.


 * 0110 AAA BBB
 * Subtracts A from B, and stores the result in A.


 * 0111 AAA
 * Stores the memory whose address is in register A in register A.


 * 1000 AAA BBB
 * Store - in the memory whose address is in register B - the data in register A.


 * 1001 AAA BBB
 * Multiplies A by B and stores the result in A.


 * 1010 AAA BBB
 * Divides A by B, stores the quotient in A, and the remainder in B.


 * 1011 AAA BBB CCC
 * If the value in register A equals the value in register B, jump forwards C bits.


 * 1100 AAA BBB CCC
 * If the value in register A equals the value in register B, jump backwards C bits.


 * 1101 AAA BBB
 * Send the value in B to the port in A.


 * 1110 AAA
 * Read one value from the port in A, and store the value in A.


 * 1111
 * Halt execution.

Programs
Note that to execute any of these you must enter the binary in a file literally, then put any data right next to it.

Infinite loop
1011 000 000 000

Cat
This is a cat program. 0000 000 0001101 #Store bits to jump forward on NULL input 0000 001 0000111 #Store bits to jump backward on non NULL input 1110 010        #Get a character from input 1011 010 011 000 #If character from input is NULL jump to Halt command 1100 000 000 001 #Else jump back to input command 1111            #Halt execution Note: This assumes 3 things:
 * 1) End of input is NULL (character 0)
 * 2) Jump forward command jumps from the end of the command (not beginning)
 * 3) Jump backwards command jumps from the beginning of the command (not end)

Hello, World!
This is a basic Hello, World! program. This sets the ASCII value of each letter and prints it in turn. Another way would be to hardcode the string into the program then loop and use 0111 command to read the characters from memory 0000 000 01001000 # H 1101 001 000 0000 000 01100101 # e 1101 001 000 0000 000 01101100 # l 1101 001 000 0000 000 01101100 # l 1101 001 000 0000 000 01101111 # o 1101 001 000 0000 000 00101100 #, 1101 001 000 0000 000 00100000 # 1101 001 000 0000 000 01010111 # W 1101 001 000 0000 000 01101111 # o 1101 001 000 0000 000 01110010 # r 1101 001 000 0000 000 01101100 # l 1101 001 000 0000 000 01100100 # d 1101 001 000 0000 000 00100001 # ! 1101 001 000 1111