Author Topic: ICE Compiler  (Read 22426 times)

0 Members and 1 Guest are viewing this topic.

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
ICE Compiler
« on: March 25, 2016, 04:21:23 am »
Hello everyone!

I can imagine many, many people are waiting for this post, but yeah, one must be the first to start such project ;)
I want to introduce this program:

ICE - an interpreter/compiler of CE-BASIC

Hooray! It would look like Axe Parser, but then for the newest calculator, the TI-84+CE.
Now are there many people who have questions, about what is possible with it, how long would it take to complete, what are the pros/cons?
Let me answer some questions.

What is ICE?
ICE is an interpreter/compiler of CE-BASIC. Normally, the OS reads a BASIC programs, and compiles it to some ASM commands, and then execute it. ICE does almost the same, but only read it, and compiles it to ASM commands, but instead of executing, it stores them into another program! In that way, you can turn your BASIC program into an ASM one, which is 1000x faster.

Why ICE?
Because I want to make a cool project (and not only games), and I think this program would be very useful for many people, so I decided to give it a try :)

What is possible with ICE?
I've no details yet, because I'm in an early stage, but I want to make it possible to keep it as BASIC as possible. I mean, you should be able in the future to compile all the BASIC programs to ASM. I never gonna reach that.... Like Axe Parser, it doesn't work with the TI-OS variables, because they are sloooowwwww. Instead, all the variables are in the RAM.

What are the pros and cons of ICE?
You can compile almost all the BASIC programs to ASM, which is 1000x faster. Since the CE has a memory-mapped screen, I'm going to implement a bunch of graph routines as well. A disadvantage is that you're a bit limited with the BASIC commands. I hope I can explain this later

When will you finish it?
In these weeks, I'm busy with school stuff, so I can't really do something with programming. But after that, I hope to finish it as fast as possible. Depending on the difficulties, I hope to finish it in some monts :)

How works ICE?
The hardest part is to express a string (and eventually store it to a variable). I will implement the Shunting-Yard-Algorithm for that (I will explain later). Once I got that ready, I need to write routines that replaces BASIC commands, like ClrHome would be call _HomeUp / call _ClrTxtShdw or whatever. Once THAT is ready, or enough of them, I will release a beta :)`

How smart is ICE?
For now, it is pretty smart, and by "smart" I mean, that if you display 2 strings which are exactly the same, it will be only once in RAM, an example:
Code: [Select]
Disp "ICE","ICE"would be this:
Code: [Select]
   call _NewLine
   ld hl, _pointer_disp_0
   call _PutS
   call _NewLine
   ld hl, _pointer_disp_0
   call _PutS
   ret

_pointer_disp_0:
   .db "ICE", 0
which saves some RAM.

Example of Shunting-Yard-Algorithm:
Let's say I have this code:
Code: [Select]
F/2+3->AThe algorithm converts this to:
Code: [Select]
F 2 / 3 + A ->Now I gonna read this sentence, and convert it to this (for example code)
Code: [Select]
   ld a, (address_of_variable_F)
// Now I now that I need to divide A by 2, which is a power of 2, so just rotate the byte
   or a
   rra
// Now to add 3, which is a value, not a variable
   add a, 3
// Now store it to variable A, so
   ld (address_of_variable_A), a
This is basically how the algorithm works, but then a bit more complicated :P especially when you have a long string.

Progress:
As some of you may know, it's very hard to work in ASM :P. That is why I decided to first create this in PHP (that's why I asked how to read .8xp with PHP). After I finished that, I will port it to ASM. I'm now in the stage for developing the Shunting-Yard-Algorithm, which is the main and hardest part.

I know,  there are still a ton of questions, so feel free to ask anything if you don't understand it, or whatever you want to say! :)




Originally posted on Cemetech: https://www.cemetech.net/forum/viewtopic.php?t=12616&highlight=
« Last Edit: December 01, 2017, 05:05:04 pm by PT_ »

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #1 on: March 25, 2016, 10:30:44 am »
This sounds pretty interesting/fun, I wish you good luck with it!
I sure hope it'll go far :)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #2 on: March 25, 2016, 01:45:02 pm »
Hi PT_!

Programmers (of any sort) will always be welcome to Omnimaga (questionably 'simply the best', hehe!). I'm a somewhat oldish guy that happens to have done a lot of Z80 work in past, from OSes development to IDEs (no games, tho), but oh well, that was like 30 years ago and let's say I'm not in the mood anymore to return to that programming model.

That said, I'm aware that many, mostly young people, still like to program for that hardware platform. Mind you, there are also quite a few around here, so, I must admit that Z80 (or direct derivatives: ez80 or an ARM emulating a z80) is/are still very popular. And "against evidences there are no (plausible) arguments", period! An 'old saying', BTW.

Your nick 'PT_' also took me a bit by surprise, probably you don't know (?) that 'pt' suffix is the Portugal internet country code (Yeah, I'm Portuguese, but I've also spent a couple of years in Holland. By now, I already know that your are 'a sweet Dutch boy'  ;) ).

Well, all this talk just to say hello to you seems a bit much to me. I'm not going to dive into the technical advantages of your proposal for now, but I want to wish you good luck with your project and 'Tot ziens'.


Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #3 on: March 26, 2016, 06:00:35 am »
Hi PT_!

Programmers (of any sort) will always be welcome to Omnimaga (questionably 'simply the best', hehe!). I'm a somewhat oldish guy that happens to have done a lot of Z80 work in past, from OSes development to IDEs (no games, tho), but oh well, that was like 30 years ago and let's say I'm not in the mood anymore to return to that programming model.

That said, I'm aware that many, mostly young people, still like to program for that hardware platform. Mind you, there are also quite a few around here, so, I must admit that Z80 (or direct derivatives: ez80 or an ARM emulating a z80) is/are still very popular. And "against evidences there are no (plausible) arguments", period! An 'old saying', BTW.

Your nick 'PT_' also took me a bit by surprise, probably you don't know (?) that 'pt' suffix is the Portugal internet country code (Yeah, I'm Portuguese, but I've also spent a couple of years in Holland. By now, I already know that your are 'a sweet Dutch boy'  ;) ).

Well, all this talk just to say hello to you seems a bit much to me. I'm not going to dive into the technical advantages of your proposal for now, but I want to wish you good luck with your project and 'Tot ziens'.
I would say "Dank u wel!" for your response :)
Probably you saw this post on CodeWalrus too? ;) I'm indeed a sweet Dutch boy, 17 years old, and I love programming and math. PT are the shortcuts of my full name  ::) and because I think a username with 2 letters is too small, I added the _  :hyper:
Anyway, I hope to make good progress with this project in the next weeks!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #4 on: March 26, 2016, 05:44:58 pm »
Sounds pretty snazzy, good luck!

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #5 on: March 30, 2016, 02:50:16 am »
Sounds pretty snazzy, good luck!
Thanks! :)

While I had some free time, I wrote some pseudocode for the main algorithm, evaluating a mathematical expression. You can find it here.
And I have a question for you: what is the best code to represent the BASIC " and "? Let's say I have 3 in register A and 0 in register B, how can I know if both registers are not zero? Just "and b" doesn't work, because if you have 1 in A, and 2 in B, the result is still 0 :|
Any help is appreciated! :)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #6 on: March 31, 2016, 09:34:41 am »
I would do something like:
Code: [Select]
or a \ jr z,$+4 \ xor a \ or b
It returns the z flag set (z) if one or both are zero, else it returns (nz) if both are non-zero.

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #7 on: March 31, 2016, 05:13:07 pm »
Today I've started creating an image, as for the homescreen of the ASM port, and as a logo for my documentation. This is the result:



Do you like it? Wanna change something? :)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #8 on: March 31, 2016, 05:23:51 pm »
It's looking awesome! Just the "OPTIONS:" text is kinda useless IMO

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #9 on: April 01, 2016, 02:01:42 pm »
While I had much free time today, I've implemented the operators in the Shunting Yard Algorithm in ASM, including their precedence. It now builds 2 stacks, one at (saveSScreen), the other at (saveSScreen+1000), one for the actual stack, and the first one for the output, which I need to read after that. Unfortunately, I have no screenshots of that :(
I hope to make good progress these weeks! :thumbsup: :)

Offline Dudeman313

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 106
  • Rating: +2/-0
  • I am the embodiment of honorificabilitudinity.
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #10 on: April 02, 2016, 09:45:07 pm »
I love that title screen.  :o
Does this qualify as a signature?
The answer is "Sure."

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #11 on: May 17, 2016, 05:29:28 am »
Small post despite my final exams: I've 'implemented' an API. That is, when running ICE from an ASM program, it will skip the header and directly search and compile the program. An example would be this:
Code: [Select]
  ld hl, ICEname
  call _Mov9ToOP1
  call _ChkFindSym
  ex de, hl
  ; skip header
  inc hl
  inc hl
  push hl    ; save for later
    ld hl, varname
    call _Mov9ToOP1
  pop hl
  ld (callAdress), hl
callAdress = $+1
  call $000000
  ; continue
Of course, you can modify it for your own, but the program name should be in OP1 and to skip the ICE header, increment twice the starting data point.
My ICE program would look like this:
Code: [Select]
  jr noAPI
  jr APIContinue
noAPI:
  header....
APIContinue:
  call _ChkFindSym
etc

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #12 on: May 17, 2016, 11:01:19 am »
The 84 and 84CE BASIC are pretty similar. How hard would it be to port this the 84? I don't have any color calcs but this would be really cool! I don't know how different the z80 and the ez80 chips are though... Either way great work!
I'm still around... kind of.

Offline PT_

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +7/-0
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #13 on: May 17, 2016, 01:25:12 pm »
The 84 and 84CE BASIC are pretty similar. How hard would it be to port this the 84? I don't have any color calcs but this would be really cool! I don't know how different the z80 and the ez80 chips are though... Either way great work!
That is what we have Axe Parser for :)
If there wasn't something like Axe, the processors are totally different, so porting this would be the same as starting from scratch.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: ICE - an interpreter/compiler of CE-BASIC
« Reply #14 on: May 19, 2016, 11:32:08 am »
The processors are actually the same. All that would need to be changed are graphics and maybe some memory management.