Looping statement
bAdkOde has one looping-statement, which is analogous to a while loop.
Usage: { [logic-operator] [src] ... [statements] ... }
There are four logic operators which are = or equal to zero, ! or not equal to zero, + or greater than zero and - or lesser than zero. The source parameter can either be a register or a memory location. The loop will run as long as the condition specified by the logic operator and source parameter is true.
Examples: # Loop while the value in register a is not zero {!a ... } # Loop while the value in location pointed to by register b is zero {=[b ... } # Loop while the value in register a is positive {+a ... } # Loop while the value in location pointed to by register b is negative {-[b ... }
Macros
Usage: Macro definition: @[macro-name]([param1], ..., [paramN]) = [block of bAdkOde statements that use param1, ..., paramN]; Macro usage: &[macro-name]([param1], ..., [paramN])
Macros are a useful feature in many assemblers. They provide a convenient way to re-use blocks of code. I decided to implement macros in bAdkOde as well. Notice the semi-colon at the end of the macro definition. This tells the parser that the definition has ended.
Examples: # Macro to convert ASCII representation of integer to actual # integer value @atoi(CHR) = -48CHR; # Macro to convert integer value to ASCII representation of # integer value @itoa(NUM) = +48NUM; # Input a character ?a # Convert to actual integer value &atoi(a) # Store the number 9 in location pointed to by value in # register a >9[a # Convert 9 to ASCII value of the character '9' (57) &itoa([a)
Note: Macros aren't specified in the EBNF because they really aren't part of the language itself. They're simply concise representations of a set of instructions.
Labels
Labels are place-holders for "magic numbers". They make the code much easier to read.
Usage: Label definition: *[label-name] = [label-value]; Label usage: $[label-name]$
In the following example, I'm going to use a label to replace the number '48':
Examples: # Define the offset that we're going to use *OFFSET = 48; # Macro to convert ASCII representation of integer to actual # integer value @atoi(CHR) = -$OFFSET$CHR; # Macro to convert integer value to ASCII representation of # integer value @itoa(NUM) = +$OFFSET$NUM;
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).
Steve
@Steve O
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.
p2bc6d
jukv39
ciulzw
w1w5ku
jk9opn
e9ltgz
zpls52
e88jk9
dv5mj2
6a0krx
rjc16y