Author Topic: [Cross Platform IR] Cor0x  (Read 6977 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
[Cross Platform IR] Cor0x
« on: April 20, 2011, 10:21:27 pm »
I have decided what I shall do to combine the knowledge of all the assembly languages I know -- making an assembly-like language that is less specific than direct assembly and less generic than low-level C -- basically a notation language to carry out certain processes on different processors that compiles to 99% optimized assembly code on each platform!  Such as an example of Cor0x code:

Code: [Select]
LOAD[reg1(16),$80]
PUSH[regSP(16),reg1(16),INC [regSP(16),2]]
RETURN[POP,regPC(16),regSP(16),2]

Would be something like this in z80:

Code: [Select]
ld hl,$80
push hl
ret

And in something like 68K or SH3 the same thing, while trying to stick to the model as close as possible.

Of course, the idea would not to be coding something for x86 and z180 at the same time, but maybe something like SH3 and ARM or x86 and a3 at the same time.

I know what I posted is described poorly, but I hope you get what I am meaning ;)

This will be a lot more work than making a normal compiler -- this will require a lot more attention at the tables and acceptable conversion methods -- and a really tough syntax to the coder.  However, it would be more than work it :)

« Last Edit: April 22, 2011, 09:57:18 am by Ashbad »

Ashbad

  • Guest
Re: Cor0x
« Reply #1 on: April 21, 2011, 07:49:22 am »
According to Tari @cemetech, LLVM already does most of what I intended for Cor0x.  However, even LLVM doesn't provide as specific instructions as I hope to provide, so I'm not out yet ;) plus, going off an old quote someone told me, "If C++ was good enough for everything, then why the hell do we have over 2000 different programming languages?"

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Cor0x
« Reply #2 on: April 21, 2011, 10:36:32 am »
If it is possible do you think that some of the instruction mnemonics could be shortened. And I would highly recommend doing this for the SH3 and the ARM. So I think what you are saying is this would be just like assembly language in the instruction simplicity and speed part. but all of the complex data handling normally found on a RISC style processor would be handled by the compiler. Just as example on the SH3 to load word or longword data into a register you need to use a displacement that points to a data table. But in this language the coder could give a literal value and the compiler would set up the table and the displacement.   

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Cor0x
« Reply #3 on: April 21, 2011, 11:29:56 am »
I have decided what I shall do to combine the knowledge of all the assembly languages I know -- making an assembly-like language that is less specific than direct assembly and less generic than low-level C -- basically a notation language to carry out certain processes on different processors that compiles to 99% optimized assembly code on each platform!  Such as an example of Cor0x code:

It compiles to optimized code? That's cool. So it will work in the same processors that x86 works?

Ashbad

  • Guest
Re: Cor0x
« Reply #4 on: April 21, 2011, 09:08:39 pm »
If it is possible do you think that some of the instruction mnemonics could be shortened. And I would highly recommend doing this for the SH3 and the ARM. So I think what you are saying is this would be just like assembly language in the instruction simplicity and speed part. but all of the complex data handling normally found on a RISC style processor would be handled by the compiler. Just as example on the SH3 to load word or longword data into a register you need to use a displacement that points to a data table. But in this language the coder could give a literal value and the compiler would set up the table and the displacement.   

Of course, I'll try to make the really unnessicary low level parts be don by the compiler like table making, however most parts are going to be done by hand coding -- this is basically a way to code in assembly for two entirely different but somewhat similar in data handling processors at the same time -- while maybe you won't be coding in and IDE for this, maybe you can make a HLL compile to this as an intermediary, and then use the Cor0x compiler to compile to all specified platforms.  ;)

The thing is, this is really as close to assembly as you can get without doing specific-platform ASM -- and it shows in the complex syntax (which I can try to shorten).

One thing that will make this so cool is the creation of user-defined 'instructions' that take an unlimited amount of parameters and of any type, and can be used to create totally different code for each platform while still holding the same idea.  So, if you made a SIN[] instruction, for the x86 it would set up registers and perform the sine instruction built in, but for z80 it would insert code for manually calculating the sine output without a built in instruction.  And even cooler, with two separate ways to compile instructions, you can technically program for a windows 7 computer, a calculator, and a commodore 64 at the same time.  However, good luck making something rather large ;)

Also, another thing: the variable system is a LOT different in this -- these are the types of bars: Int(bytesize), Short(bytesize), Word(bytesize), byte(size), bit, trit, quit, nibble(bytesize), port(address size), register(size), constant(length, base), char(range, base), string(range, base, type), address(size)

register and port sound weird to be called variables, but maybe for cross-compilation between z80 and x86, you want an IN[] instruction to have the input go to A from port $02 on z80, but to EAX from port $607C on x86.  That way, Reg1 equals something constant for each platform, and same with port ;) (port has more to do with actual hardware surrounding the processor, but that is taken care of with 'specific machine compilation', which you can define ports with different values between processors AND devices ;))

And, with that, I realize this must be a massive wall of text for you to read.  :P

Ashbad

  • Guest
Re: Cor0x
« Reply #5 on: April 22, 2011, 09:45:42 am »
I am making the executable for the compiler in Java right now, though I'm debating on whether I should switch to C++ or not, not due to ease for me programming but rather for compatibility with a C compiler.  I'm thinking though that I'll make my own C compiler (Or make my own OOP HLL that uses Cor0x as an IR) instead that is fine with a java executable.

Also, I've been theorizing some more and I think that it wouldn't be terribly hard to implement my concept of Lo-OO (a concept I had for using object oriented things at a lower-than-C level, right above specific assembly) into Cor0x.  Methods and traits of an object would be sorted by type in an address table, in which specific-named traits or methods are access by location on table rather than name.  Such as this: Object A is from Class A, which has a constructor, deconstructor, and one method, along with an int and an 80-bit FP real.  The methods are first, with the constructor first on list, a deconstructor second (with address == $0 if not existent or defined), and the next few methods -- these methods have a 32 bit label to them that defines them as a method, and give a few other attributes and a virtual name.  The int has it's own label, same with the 80 bit FPR.  If you want to access the int, you look in the class structure for the address of the int on the table, and look at the object's address table's 4 entry for more details.

A really simple approach to OOP that could be implemented at a really fast speed on any platform, including the Zilog z80.  In fact, if I hadn't been discouraged from it, I would have finished my 80% done OOP axiom that implements this.  Oh well.  At least this will use the theory.

REQUEST: even if you don't know assembly or won't use this, can you post some ideas here to be implemented? The more the merrier. ;)
« Last Edit: April 22, 2011, 09:46:18 am by Ashbad »

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: [Cross Platform IR] Cor0x
« Reply #6 on: April 22, 2011, 12:55:19 pm »
I am don't know much about assembly but I do see that something like this would definitely be a little easier to use if you made it OOP Language.
I don't know if this is possible but that is my main idea on the project
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Cross Platform IR] Cor0x
« Reply #7 on: April 22, 2011, 12:58:13 pm »
I am don't know much about assembly but I do see that something like this would definitely be a little easier to use if you made it OOP Language.
I don't know if this is possible but that is my main idea on the project

OOP Assembly seems promising indeed.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: [Cross Platform IR] Cor0x
« Reply #8 on: April 22, 2011, 01:08:50 pm »
Python like syntax(no semicolons/braces just tabs and spaces(wow that rhymes)) would make this pretty easy to code and a very interesting project. I wonder is it even possible?
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Ashbad

  • Guest
Re: [Cross Platform IR] Cor0x
« Reply #9 on: April 22, 2011, 01:30:56 pm »
I don't think I can make the syntax easy as I have to have a lot of information crammed into each line :( like LLVM IR, its not gonna be an easy thing to code in.

However, I will include Lo-OO, so it will be OOP -- but the way you'll code in it is much more different and much harder than you think. ;)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Cross Platform IR] Cor0x
« Reply #10 on: April 22, 2011, 02:22:07 pm »
I don't think I can make the syntax easy as I have to have a lot of information crammed into each line :( like LLVM IR, its not gonna be an easy thing to code in.

However, I will include Lo-OO, so it will be OOP -- but the way you'll code in it is much more different and much harder than you think. ;)

It's a form of Assembly, I actually expected it to be hard.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: [Cross Platform IR] Cor0x
« Reply #11 on: April 22, 2011, 02:34:26 pm »
Request: Please don't make it too objected oriented. One of the main points of OOP is to make safe, reliable programs by hiding the data and machine specific details from the programmer. That directly conflicts with two of Assembly's most powerful features: the unrestricted manipulation of data and machine specific optimizations.

EDIT: Also, rather than having an instruction for every instruction on a particular processor, a compact instruction set is often much better. RISC is easier to write than CISC  ;)
« Last Edit: April 22, 2011, 02:36:25 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Ashbad

  • Guest
Re: [Cross Platform IR] Cor0x
« Reply #12 on: April 22, 2011, 03:41:36 pm »
Good idea: though the OOP design of Lo-OO isn't really the same found in C++ or Java -- it's more of a way to access them rather than all the crap found at higher levels ;) just think of it more as Lua tables than real objects -- because to tell the truth, Lo-OO is kind of the bridge between High level OOP and assembly.  It's more of a way to organize the objects and such rather than doing complex crap with them.  I totally get your concern though, and I'll make sure I don't go too high level ;)

Also, I do plan to have a basic RISC design that works on all processors, but many people want to do stuff like access complex x86 instructions that are far from the RISC design -- so I'll have the RISC stuff work fine for everything, but some processors will have live saving instructions to include as well.  However, instructions in Cor0x can be low level machine opcodes of any length -- therefore a sine instruction on x86 can be a more complex sine subroutine on z80 -- the point is to be as supportive of everything as possible, unlike LLVM which would not be suitable for writing the same code in 2 processors.

Plus, LLVM handles OOP horribly IMHO, so there's a lot of fixable points to be Made :)

Ashbad

  • Guest
Re: [Cross Platform IR] Cor0x
« Reply #13 on: April 22, 2011, 09:13:31 pm »
I have decided that now since the simple parsing works, I can now start thinking of the processors that Cor0x 1.0 will support -- I'm thinking of 10 easy-to-transfer platforms for now, and add more myself and allow others to make .corlib files for other processors and .cordev files for specific device specs and how they can be treated.

Here is my list of processors so far:

- z80
- z180
- ez80
- SH3
- ARM

any more you guys have in mind?  I know I'm missing about 20 real obvious ones :P
« Last Edit: April 22, 2011, 09:13:46 pm by Ashbad »