Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: zero44 on December 23, 2012, 03:55:36 pm

Title: [Axe] BrainFuck 83+
Post by: zero44 on December 23, 2012, 03:55:36 pm
Hey,

I made a parser and an emulator for BrainFuck language on calc.
Parser is not completed, so there are bugs : never use [][]

Feel free to send me bug reports / improvements ideas.

Enjoy
Title: Re: [Axe] BrainFuck 83+
Post by: Sorunome on December 23, 2012, 03:58:39 pm
nice, i guess 9 is > and 8 is < ?
And is there , ?
Title: Re: [Axe] BrainFuck 83+
Post by: Keoni29 on December 24, 2012, 05:16:20 am
My brainfuck interpreters all have a break function. When you have an infinite loop you simply press a key and you break from the program.
Title: Re: [Axe] BrainFuck 83+
Post by: zero44 on December 26, 2012, 04:19:31 pm
Yes, I made a break function too.

Interpreter is fully complete (?) and supports ',' command, but it's badly done :(
I forgot to say that I added the * func (exit program) to the brainfuck, so when you compile a program it's recognized by parser as "hey, stop me NOW !" ;)

But the input fonction doesn't work actually in the parser.
And I fixed parser's loop bug, but not uploaded it .__.
Title: Re: [Axe] BrainFuck 83+
Post by: Sorunome on December 26, 2012, 04:21:24 pm
I started brainfuck madness >.<
lol
and it sounds cool, the interpreters/compilers
Title: Re: [Axe] BrainFuck 83+
Post by: Builderboy on December 26, 2012, 04:33:54 pm
You know what would be interesting, a BrainFuck compiler that takes brainfuck code and converts it into Axe code.  Then you would compile the generated Axe code for super speed!
Title: Re: [Axe] BrainFuck 83+
Post by: Sorunome on December 26, 2012, 04:35:56 pm
Brain=fucked
Do it Builderboy. NOW
Wait
That isn't too hard
lol, because of pointers :D
Title: Re: [Axe] BrainFuck 83+
Post by: Builderboy on December 26, 2012, 04:36:35 pm
Indeed, the wikipedia page even has a C equivalent to each of the symbols, and it's super easy haha.
Title: Re: [Axe] BrainFuck 83+
Post by: zero44 on December 26, 2012, 04:39:28 pm
bf compiler which compiles to axe source ? for speed ? too easy and slow ^^ I'll surely do it.

but I have a bf compiler which compiles directly to hexa asm :) that's epic ..
you mean for example ++++++++ is compiled to +1+1+1+1+1+1+1+1 or to +8 ?
Title: Re: [Axe] BrainFuck 83+
Post by: Sorunome on December 26, 2012, 04:41:53 pm
it would output something like
first
get some free space and point it to P
and set N equal to 0
and then for +
it would be {A+N}++
for - {A+N}--
for >
N++
for <
N--
for , some input to store to {A+N}
for .
text({A+N}>Char
for []
while {A+N}
code
end
Title: Re: [Axe] BrainFuck 83+
Post by: zero44 on December 26, 2012, 04:47:00 pm
this is what I said, easy.

in asm :
> 2C increase L register
< 2D decrease L
+ 56257E or somthing like this : take byte from address pointed by HL, increases and replace it
- guess it
. 7EEF0445 takes it to A and disps A as a char
, nothing yet
[ 7ECA**** jumps after ] if pointing zero
] 7EC2**** jumps after [ if pointing non-zero

Easy, I said. :)
Title: Re: [Axe] BrainFuck 83+
Post by: Builderboy on December 26, 2012, 04:59:26 pm
Yeah making a Brainfuck to Asm compiler would probably be much easier now that I think about it haha.  The compiler could still be in Axe too! It just would have to do some annoying byte counting for the jumps.
Title: Re: [Axe] BrainFuck 83+
Post by: Keoni29 on December 26, 2012, 05:24:54 pm
How do you create executables using axe software?
Title: Re: [Axe] BrainFuck 83+
Post by: zero44 on December 27, 2012, 08:39:55 am
...
I'm asking me if you understood ...
I created an on-calc compiler, written in Axe, which takes a BrainFuck source code program (prgmBF) and automatically compiles it to an asm program (prgmCALCFUCK) which is veryveryvery fast : you cannot see it displaying letters, for Hello World. And this compiler takes care of [[]] loops, but the online-released version creates a crashing asm program with [][] loops (a bug I've fixed yet, but not released)

Keoni29 : GetCalc(Name,Size)→Pointer example : GetCalc("prgmBF",1600)→P
And to make it an asm program, you'll have to be serious... and read an hexadecimal assembly tutorial (a sort of thing which can say you some things like saying that $C9 returns and $21 assign the 2-bytes following value to HL ...
Title: Re: [Axe] BrainFuck 83+
Post by: Keoni29 on December 27, 2012, 08:56:28 am
I know how machine code works, but I never learned z80 asm. Perhaps because I can't work with tasm/spasm/whichever outdated z-80 asm assemblers are out there. It'd be interesting to see a more modern interface for those. Iirc there was an oncalc assembler released.
Title: Re: [Axe] BrainFuck 83+
Post by: Sorunome on December 27, 2012, 01:32:21 pm
Iirc there was an oncalc assembler released.
It is called mimas.
Title: Re: Re: Re: [Axe] BrainFuck 83+
Post by: TheNlightenedOne on December 28, 2012, 02:18:25 am
Iirc there was an oncalc assembler released.
It is called mimas.

There is also ASMDREAM.
Title: Re: [Axe] BrainFuck 83+
Post by: mdr1 on December 28, 2012, 10:09:07 am
Really good project, it gave me the idea of doing my own but for TI-Nspire : http://ourl.ca/18020/331338 (http://ourl.ca/18020/331338)  ;D