Registers, Memory, and Stack
There are two registers, a and b. You can also use these registers as pointers, so [a and [b mean "The memory addresses identified by the values in register a and register b". For example, if a contained the value 10, then [a refers to memory address 10. Memory is unlimited (theoretically, but in practice is limited by the amount of physical memory you have), and so is the Stack. You cannot directly refer to the stack and there is no stack pointer (so there is no way to directly manipulate the stack). In processors, memory is typically addressed by BYTES, WORDS, LONGWORDS, or QUADWORDS. There is no such addressing scheme in bAdkOde. Also, in normal memory, the largest value a typical memory location (usually a byte) can hold is FF16 (25510). In bAdkOde however, the largest number a location can hold really depends on the implementation. I implemented this grammar in Perl and so depending on how it was built, you can have -253 to 253 (32-bit ints and double floats), or -263 to 264 - 1 (64-bit ints and double floats), or -2113 to 2113 (64-bit ints and quadruple floats). These limits also apply to the value that can be stored in the registers or on the stack.
There are three binary operators: > or move, + or add, and - or subtraction.
> or move
Usage: > [src] [dest]
The move operator takes two operands. The first operand (source) can either be a number, register, or a memory location. The second operand (destination) can either be a register or a memory location.
Examples: # move the value 10 to register a >10a #move the value 10 to the location that a points to >10[a #move the value in a to the location pointed to by a >a[a
+ or add
Usage: + [src] [src2/dest]
The add operator takes two parameters. It adds the values represented by both operands and stores it in the location represented by the second. The first operand (source) can either be a number, register, or a memory location. The second operand (destination) can either be a register or a memory location.
Examples: # add the values of the a and b register and store the result in b +ab # add the value in the a register and the value in the memory # location that a points to, and then store the result in that # memory location +a[b #add 3 to the value in register a +3a # add two memory locations together and store the value in # the second +[a[b
- or subtract
Usage: - [src] [src2/dest]
The subtract operator takes two parameters. It subtracts the value represented by the first operand from the value represented by the second operand and stores it in the location represented by the second. The first operand (source) can either be a number, register, or a memory location. The second operand (destination) can either be a register or a memory location.
Examples: # negate the value in register a >0b -ab # subtract two memory locations together and store the value in # the second -[a[b
4 thoughts on “bAdkOde”
Ugh. Macros are the devil incarnate. Nothing makes grep-ing through large amounts of source code more painful than macros. Nice post though. I’m impressed with your use of EBNF and creative ability with new programming languages! This also lead me to look up several other esoteric languages (i.e. Brainfuck).
Oh yeah, a large number of macros can make things really hairy. But I think that’s probably due to macro abuse! I made macros here just because that’s what I was familiar with when I was doing assembly programming. Then again, this isn’t meant to be a language for serious software projects! I’m glad you liked the EBNF and I’m also glad that you found bAdkOde creative. I guess all those theoretical computer-science classes I took at ASU weren’t for nothing! 😉 Haha!
Esoteric programming languages are pretty neat. I think you realize how much you take for granted in high-level languages when you work with some of the more limited ones, like Brainfuck. On the other hand, they really make you think in novel ways and also completely change the way you approach problems. I think it’s a good thing.