Search code examples
esoteric-languages

subleq confusion and understanding


Can some one explain subleq to me better? I am looking at http://esolangs.org/wiki/Subleq

There example:

3 4 6
7 7 7
3 4 0

the first instruction, at address zero, subtracts 7 (address 3) from 7 (address 4). The result in address 4 is 0, so jump to 6. Starting at address 6 is the instruction 3 4 0 which again subtracts 7 from now 0 and jumps back to 0. Here is a sequence of execution (A and B are shown after subtraction)

0: 3 4 6 A=7 B=0
6: 3 4 0 A=7 B=-7
0: 3 4 6 A=7 B=-14
6: 3 4 0 A=7 B=-21
0: 3 4 6 A=7 B=-28
...

My first question is address 0 "3 4 6 A=7 B=0"? Where did they get 7? Is it from the first two number? I thought it has to do with subtraction :S


Solution

  • If we look at the matrix:

    3 4 6
    7 7 7
    3 4 0
    

    As a memory map addressed in the following manner (sequentially):

    0 1 2 
    3 4 5
    6 7 8
    

    The quoted text is making a perfect sense. There is 7s in the addresses 3 and 4, and the next instruction is 3 4 0 located at address 6.