DOWNLOAD (very small)
Section 1: Included Files
DOC.TXT BDAMD Documentation BDM.C Interpreter Code BDM.EXE Interpreter TEST.BDM Sample Program
Section 2: The Interpreter
The Interpreter is a 'C' program written very quickly. It only functions with second-dimension BDAMD programs. The Interpreter also has a 50000 instruction limit to prevent endless loops, and a limit of 128x128 Instruction and data arrays.
The Interpreter is called from the command line as follows:
BDM filename.bdm
Warning: The compiler treats the newline character as the start of the next line of the array. You cannot use the swap-pointer command with a change direction and a increment y movement.
Section 3: Features of the Language
Program code is written in an array. Each command is one byte long (for two-dimensional arrays). The first five bits is the command, the last three bits specifies the next command.
Program data is stored in an array. Each cell can be assumed to start with the value of zero. The data array is of the same number of dimensions as the code. Two pointers (here after referred to as A and B) are available.
BDAMD allows positions within the array to be stored and recalled from data. This simulated data pointers.
Data may be output as an ASCII character or as a decimal number.
Section 4: Commands
Each command is 1 byte in the following pattern: nnnnn nnn. The five command bits are as follows:
Increment/Decrement 10000 Increment variable at data pointer A 10001 Decrement variable at data pointer A Input/Output 10100 Read character to data pointer A 10101 Read integer to data pointer A 10110 Print character from data pointer A 10111 Print integer from data pointer A Conditional 11nnn If data pointer A is zero use nnn as next instruction Pointer Movement 010nn Move data pointer A (absolute movement) 011nn Move data pointer B (absolute movement) 00100 Copy [A,B] to pointer A location 00101 Copy [A,B] to pointer B location 00001 Swap point A and B locations Data Copy 00110 Exchange values at pointers A and B 00111 Copy value at A to B Pointer Saving 00010 Save pointer A (x,y) to (A,B) 00011 Save pointer B (x,y) to (A,B) These are the final three bits to move the code pointer: First bit: 0 = Relative Coordinate The movement is based on the last movement. 0/1 The second bit specifies if the direction (+ or -) is to be changed. 0/1 The last bit specifies if the axis should be changed. 1 = Absolute Coordinate The movement is described explicitly. 0/1 Zero means increment, 1, decrement 0/1 Zero is the x-axis, 1, the y.Section 5: Sample Code
84 > 84 > 84 > 84 > 84 > 84 > 84 > 85
\/
85 < 86 < 86 < 86 < 86 < 86 < 0E < 66
\/ /\
84 > 84 > 0C > 8C > E5 > 0F 84 > 85
\/ /\ \/
85 < 86 < 86 < 3E < 0E 84 > 83 < 86
\/ /\ \/
84 > 84 > 84 > 84 > 84 > 0F 84 > 85
\/
00 < 00 < 00 < B6 < 0E < B6 < 0E < 86
Execution starts with the 84 in the upper left corner. It proceeds in the positive x direction until it reaches the 85 command. The 101 in the next hop field specifies that the next command is down. (At this point in the program data cell 0,0 is equal to 8).
The 66 command moves the B data pointer to cell (1,0). Then the 0E switches the A and B pointers. The variable at A is incremented eight times, the pointers are switched, and A is now decremented. Then a conditional E5 is called. If A==0 then the code moves down, otherwise it continues to the right. (This is similar to the BrainF*ck method of multiplication)
After the multiplication loop is complete A is 0 and B is 64. The 64 is copied to both pointer locations. Eight is added to one pointer and nine, the other. (The 83 command moves the code pointer in the opposite direction as previously, other axis, other direction)
This brings the code the final line where the two variables are outputted as characters, then the program is allowed to reach the side of the array, ending the program.
Section 6: Higher Dimensions
When used in Higher Dimensions, BDAMD commands will gain additional bits so that all movement directions and all transitions.