Author Topic: Started?  (Read 15270 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Re: Started?
« Reply #15 on: August 17, 2012, 12:34:52 AM »
Quote
I was proud of you ...

Such a ordinary lie...

Peter

  • Full Member
  • ***
  • Posts: 161
Re: Started?
« Reply #16 on: August 17, 2012, 01:10:59 AM »
lol, what a funny thread.   :D

John

  • Hero Member
  • *****
  • Posts: 3639
Re: Started?
« Reply #17 on: August 17, 2012, 09:39:29 AM »
What the O2 translator is written in at this point is meaningless. What we need is C code emulating O2 functionality or an outline of the project. What automates that process and the platforms it supports is still on the table as I see it.


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4267
    • Oxygen Basic
Re: Started?
« Reply #18 on: August 17, 2012, 10:15:30 AM »
There's about 48000 lines of code to consider. And it has to be frozen while porting, since multiple versions would be unmanageable.

Getting  the C-emitter working is a much nearer goal. In terms of development time, it would be similar to implementing 64 bit code.

Charles

John

  • Hero Member
  • *****
  • Posts: 3639
Re: Started?
« Reply #19 on: August 17, 2012, 10:27:13 AM »
If I understand, the goal is to emit machine readable C code not meant for further interaction by humans.


John

  • Hero Member
  • *****
  • Posts: 3639
Re: Started?
« Reply #20 on: August 17, 2012, 10:31:59 AM »
Quote
I was proud of you ...

Such a ordinary lie...

In English, that was a gesture of being sincere.

John

  • Hero Member
  • *****
  • Posts: 3639
Re: Started?
« Reply #21 on: August 29, 2012, 07:34:48 PM »
Where does the O2C emitter stand at this moment? Is a Hello World translation possible?

Code: [Select]
PRINT "Hello World"
Code: [Select]
#include<stdio.h>

main()
{
    printf("Hello World\n");
}



Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4267
    • Oxygen Basic
Re: Started?
« Reply #22 on: August 29, 2012, 09:59:35 PM »
Not yet John. I'm still rearranging code and studying some of the hard stuff.

2 key commands proposed:

#file "Myprog.c" 'Activates C emitter (this directive is already used for exe and dll)

#emit { .. } 'To emit code (native headers etc) directly without translation.

Charles

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4267
    • Oxygen Basic
Re: Started?
« Reply #23 on: August 31, 2012, 04:17:21 AM »

Further extension the the #emit directive:

#emit enable
#emit disable


This allows local declarations to be made, but not passed on to the host compiler.

Charles




John

  • Hero Member
  • *****
  • Posts: 3639
Re: Started?
« Reply #24 on: August 31, 2012, 07:12:11 AM »
Charles,

Will there be a way to emit inline ASM in the outputted C source? (O2 native pre-assembled code)

John

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4267
    • Oxygen Basic
Re: Started?
« Reply #25 on: September 01, 2012, 12:35:49 AM »

Yes, maybe further down the list. The C emitter is primarily for device independence.

ehitam

  • Newbie
  • *
  • Posts: 7
Re: Started?
« Reply #26 on: October 23, 2012, 06:13:46 PM »

Yes, maybe further down the list. The C emitter is primarily for device independence.


With C emitter you can include a compiler too. I have checked tiny C compiler(tcc). Its code is almost over 10 times smaller than GCC(I haven't tested speed...).

I compiled following program in both GCC and TCC:

Code: [Select]
#include <stdio.h>

int main(){
    //Variable declarations:
    int age;

    char name[20];

    printf("Enter your name: ");
    gets(name);

    printf("\nHello %s! How are you?", name);

    printf("\nPlease Enter your age: ");

    scanf("%d", &age);

    if (age>= 18){
        printf("\nWelsome to voting booth Mr.%s. You may vote!", name);
    }
    else{
        printf("\nGet your dirty hands away from voting!!! stupid n00bish kiddu!");
    }


    return 0;

}

GCC output: 48.8 KB
TCC output: 1.5   KB

And TCC is less than a MB(934 KB).
« Last Edit: October 23, 2012, 06:59:03 PM by ehitam »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4267
    • Oxygen Basic
Re: Started?
« Reply #27 on: October 24, 2012, 06:30:50 AM »

Hi Ehitam, and welcome to the forum!

Yes, the main idea is to be able to generate source code for the native compiler supplied on any platform, which usually turns out to be GCC.

The main problem I am trying to resolve is how to handle constructs which are not directly supported by C. One possibility is dropping down to the lower level: LLVM. But this is a strange beast. Unlike Java byte code and Ms Common Intermediate language, it does not offer a stack.

Charles

efgee

  • Full Member
  • ***
  • Posts: 172
Re: Started?
« Reply #28 on: October 24, 2012, 08:53:18 AM »
Years ago I used tcc and Agner Fog's objconv to create different obj file formats because tcc only creates ELF obj files and objconv can convert any obj file format to any obj file format (x86-64 platforms: PE, COFF, ELF, OMF, MACHO).

With this I was able to test the 32bit/64bit obj file integrity from the obj files created by tcc.
The 64 bit obj file tcc created was NOT OK.

That's where I stopped using tcc.

The footprint and speed of tcc is awesome, but the tcc code-base is a mess.
And the folks at the tcc mailing list had no interest in fixing this problem.

ehitam

  • Newbie
  • *
  • Posts: 7
Re: Started?
« Reply #29 on: October 26, 2012, 07:01:57 AM »

Hi Ehitam, and welcome to the forum!

Yes, the main idea is to be able to generate source code for the native compiler supplied on any platform, which usually turns out to be GCC.

The main problem I am trying to resolve is how to handle constructs which are not directly supported by C. One possibility is dropping down to the lower level: LLVM. But this is a strange beast. Unlike Java byte code and Ms Common Intermediate language, it does not offer a stack.

Charles

BASIC don't have single good compiled implementation. FreeBASIC was going pretty well but most of the development seems to be done on first 5 months :P
Well it lacks 64 bit support which is biggest problem. While I generally support C solution but it should not because main way your language is implementation. This should be used to make language powerful for a while eternal crusade to win Assembler war should be continued. If academia  and professionals see that we have no plan to make assembler our primary back end they wouldn't take it much seriously and here goes lot of free publicity and availability of huge 3rd party resources.

Which constructs you need help with? I'm C-Fanatic :P so I might be able to help :)