ByteByte

From Esolang
Jump to: navigation, search
This article is a stub, which means that it is not detailed enough and needs to be expanded. Please help us by adding some more information.

The inital idea was by me (user:Javamannen) but I don't consider myself the "page owner". Anyone who feels he/she has something to contribute (spammers excluded) can edit this page directly. You don't have to go via the Talk page. --Javamannen 20:30, 14 October 2010 (UTC)

ByteByte is a class of byte move machines similar to ByteByteJump but with no jump address, only MOVE source and destination (hence "ByteByte"). Unlike Eugene Styer's byte MOVE machines however, there's not even a memory-mapped PC. Instead ByteByte has an n-bit cyclical program counter with wraparound behavior, where the goal is to make n as small as possible. Thus the machine runs in an endless loop consisting of 2n address words (or 2n bytes, depending on the machine implementation) at the start of memory.

Example: C implementation (untested) of a ByteByte machine with 32-bit addresses and an 8-bit program counter.

unsigned char mem[MEMSIZE]; // byte-addressable memory
unsigned int *mem32 = (unsigned int *)mem; //32-bit address words
unsigned char pc; // 8-bit program counter with wraparound
unsigned int a,b;
for (;;) {
  a = mem32[pc++];
  b = mem32[pc++];
  mem[b] = mem[a];
}

ByteByte can be extended to use any number of bits for the MOVE operation. The bigger machine family could be called "WordWord", and its simplest member "BitBit", whose operation simply is to copy a single bit from A to B (in a way the simplest possible OISC).

There are 3 basic machine parameters:

  • Data width. This is the number of bits copied; 8 bits for ByteByte. Can be any size in the general case of WordWord machines.
  • Address width; 32 bits in the above example, giving 4 GiB of addressable memory. Addresses must be 2 or more times bigger than data words for the machine to be able to compute with tables instead of an ALU.
  • Program counter width; 8 bits in the above example, chosen here mostly to make an easily understandable example (by using an unsigned char for the program counter we get the desired wraparound behavior for free).

The above example machine runs in an endless self-modifying loop with 128 MOVE instructions (256 address words) in the first 1024 bytes of memory. To simulate jumps you'd have to be able to fit the equivalent of a ByteByteJump interpreter into those 128 instruction slots. If that works, then the question becomes: how small can you make the loop (what's the smallest possible number of bits for the program counter)?