Buffalo Lang

Playing with values

The value stored in the memory address that is currently pointed to can either be incremented and decremented.


Incrementing a stored value

Consider the following state of the buffer:

 0  1  2  3  4  5  ... 255
[0][0][0][0][0][0][...][0]
 ^

This buffer shows the initial state of memory when a program is first executed. All values are initialized with zero and the pointer is initialized at address 0.

We can increment the value stored at the currently pointed to address by executing the following command.

Buffalo Buffalo

This will increase the pointed to value by one unit:

 0  1  2  3  4  5  ... 255
[1][0][0][0][0][0][...][0]
 ^

Lets increment this value a few more times.

Buffalo Buffalo Buffalo Buffalo

And look at the state of our buffer:

 0  1  2  3  4  5  ... 255
[3][0][0][0][0][0][...][0]
 ^

When incrementing, the value will never increase beyond 255.


Decrementing a stored value

Following on from above we can now decrement this value by executing the following command.

buffalo buffalo

This is what our buffer looks like now:

 0  1  2  3  4  5  ... 255
[2][0][0][0][0][0][...][0]
 ^

The value 3 that was stored in address 0 has be decremented by one unit.

When decrementing, the value will never decrease below 0.