Page 3 of 24

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 28 May 2016, 10:19
by PT_
I'm very happy to say that parsing a mathematical expression is almost done! :)
It now 'chains' operators, i.e. A*B+3, instead of the seperate routines for A*B and A+3 for example. Out of the 14 booleans/operators (+ - * / or xor and -> => <= > < = !=) I've finished 10. I only need >= <= > < to do, and after that, I'm ready with parsing such string (yet without functions). I haven't implemented auto-opt yet, but I will definitely do. Here is an example of what it can do:
String = A+4*B/(1-C)+3
Output =
Code: Select all
ld a, ($D05301)    ; B
add a, a
add a, a
push af
   ld a, 1
   ld hl, $D05302  ; C
   sub a, (hl)
pop hl
ld l, 1
mlt hl
call _DivHLByA
ld a, l
ld hl, $D05300     ; A
add a, (hl)
add a, 3
ret
The only good optimization I see is replacing the "push af" with "ld h, a" and remove the "pop hl".

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 28 May 2016, 11:09
by Adriweb
Nice ! Good luck for the rest :D

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 28 May 2016, 20:42
by Epharius
Yeah! You finally did it! What are you gonna do then?

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 28 May 2016, 22:07
by PT_
Epharius wrote:Yeah! You finally did it! What are you gonna do then?

Version 1.0.0: June XX, 2016
☑ Adding, substracting, multiplication, dividing
☑ Parenthesis
☑ Booleans, comparisons
☑ Storing, variables
☑ Run inline ASM
☑ Display integers
☑ ClrHome
☐ If, Repeat, While
☐ Lbl, Goto

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 01 Jun 2016, 10:33
by Flip
good job, I'm waiting for your first release... :)

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 01 Jun 2016, 18:12
by PT_
I DID IT!!!!!!!!!

I'm so happy now :) I succesfully compiled a normal program, without any errors :D

Ofc, I've finally a gif for you guys!
Image

The program is still far from perfect, but I'm more than happy with this now :D

EDIT:
Image
Image

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 01 Jun 2016, 19:07
by Adriweb
Awesome, congratulations 8-)

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 02 Jun 2016, 18:15
by Epharius
Congratulation, is there a link somewhere to download the program? I would like to know how does it work, or if you don't want to share the code, just try it ;)

Good job!

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 02 Jun 2016, 19:03
by PT_
Epharius wrote:Congratulation, is there a link somewhere to download the program? I would like to know how does it work, or if you don't want to share the code, just try it ;)

Good job!

I haven't uploaded it yet, because v1.0 is not ready. You want to know how this works? Well, ofc I can explain it! It reads the program line by line. For example, if it reads a "ClrHome", it adds the corresponding code to the program data, and continues with the next line (if there is one). Or it reads the If-token. Now it first expresses the remains of the line (after the If-token), adds that to the program data, pushes some values here and there, and reads the next line. If that is a "Then", it pushes an End (kind of), and otherwise, that line will be parsed, and the values will be popped, because the If-statement is over. That is basically how it works. Hope that that is enough :)

Re: ICE - an interpreter/compiler of CE-BASIC

PostPosted: 02 Jun 2016, 19:35
by Epharius
Yea, I did something similar with that program.

Anyway, I'll wait for the first release to try ICE ;)