making my own programming language

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
sneakyn8





Posts: 989
Joined: Thu Dec 14, 2006 1:48 pm

making my own programming language

Post by sneakyn8 »

okay this is completely hypothetical but what would i need to make my own programming language like python vb c# etc.?
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

A lot of time, you could make it in C# easily(when I say easy I mean it would be easy but take an eternity!).
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

If you have to ask you're not going to do it and make it usable any time soon.
sneakyn8





Posts: 989
Joined: Thu Dec 14, 2006 1:48 pm

Post by sneakyn8 »

thats why i announced it was hypothetical im just curious
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

Well it really would depend what you want it to compile into, would you want it to compile to native machine code or an intermediate code like .net or java.
sneakyn8





Posts: 989
Joined: Thu Dec 14, 2006 1:48 pm

Post by sneakyn8 »

OwnZ joO wrote:Well it really would depend what you want it to compile into, would you want it to compile to native machine code or an intermediate code like .net or java.
like .net
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

sneakyn8 wrote:
OwnZ joO wrote:Well it really would depend what you want it to compile into, would you want it to compile to native machine code or an intermediate code like .net or java.
like .net
I don't think you really understand what OwnZ joO means.

If you make an application inside the .NET environment your application, regardless if it was written in C#/VB/C++/J#, is going to be converted into an intermediate language called IL. That intermediate language needs the .NET runtime files so your application can be executed on the operating system.

If you compile your application into native machine code it's not anymore bound to any environments/runtimes/operating systems but only bound to the instructions the processor can execute (like MMX , SSE , SSE2 , 3DNow!).

If you want to use the .NET environment for your applications your compiler would have to convert your custom code syntax structures into the IL code format (taking a guess here, don't even know if this is possible).

Your best bet would be using native machine code for execution but this is far from easy. Basically your custom syntax code gets converted into assembly directly (of course you would have to follow the PE files format).

Example:

C++:

Code: Select all

#include <stdio.h>
#include <string.h>



int main()
{
    char name[1024], sumstr[5], serial[] = "0000000000000000000";
	unsigned int len = 0, sum = 0, i = 0;

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

	len = strlen(name);

	for (; i < len; i++)
		sum += name[i];

	sum &= 0x0000FFFF;

	sprintf(sumstr, "%04X", sum);

	serial[5] = sumstr[0];
	serial[4] = sumstr[1];
	serial[18] = sumstr[2];
	serial[0] = sumstr[3];

	printf("Your serial is: %s\n", serial);

	
    system("PAUSE");
    return EXIT_SUCCESS;
}
ASM:

Code: Select all

00401390  /$  55            PUSH EBP
00401391  |.  89E5          MOV EBP,ESP
00401393  |.  81EC 68040000 SUB ESP,468
00401399  |.  83E4 F0       AND ESP,FFFFFFF0
0040139C  |.  B8 00000000   MOV EAX,0
004013A1  |.  83C0 0F       ADD EAX,0F
004013A4  |.  83C0 0F       ADD EAX,0F
004013A7  |.  C1E8 04       SHR EAX,4
004013AA  |.  C1E0 04       SHL EAX,4
004013AD  |.  8985 B4FBFFFF MOV [LOCAL.275],EAX
004013B3  |.  8B85 B4FBFFFF MOV EAX,[LOCAL.275]
004013B9  |.  E8 E2BD0000   CALL Keygen.0040D1A0
004013BE  |.  E8 1DBA0000   CALL Keygen.0040CDE0
004013C3  |.  A1 00004400   MOV EAX,DWORD PTR DS:[440000]                 ; |||
004013C8  |.  8985 C8FBFFFF MOV [LOCAL.270],EAX                           ; |||
004013CE  |.  A1 04004400   MOV EAX,DWORD PTR DS:[440004]                 ; |||
004013D3  |.  8985 CCFBFFFF MOV [LOCAL.269],EAX                           ; |||
004013D9  |.  A1 08004400   MOV EAX,DWORD PTR DS:[440008]                 ; |||
004013DE  |.  8985 D0FBFFFF MOV [LOCAL.268],EAX                           ; |||
004013E4  |.  A1 0C004400   MOV EAX,DWORD PTR DS:[44000C]                 ; |||
004013E9  |.  8985 D4FBFFFF MOV [LOCAL.267],EAX                           ; |||
004013EF  |.  A1 10004400   MOV EAX,DWORD PTR DS:[440010]                 ; |||
004013F4  |.  8985 D8FBFFFF MOV [LOCAL.266],EAX                           ; |||
004013FA  |.  C785 C4FBFFFF>MOV [LOCAL.271],0                             ; |||
00401404  |.  C785 C0FBFFFF>MOV [LOCAL.272],0                             ; |||
0040140E  |.  C785 BCFBFFFF>MOV [LOCAL.273],0                             ; |||
00401418  |.  C70424 140044>MOV DWORD PTR SS:[ESP],Keygen.00440014        ; |||ASCII "Enter your name: "
0040141F  |.  E8 ACF30000   CALL <JMP.&msvcrt.printf>                     ; ||\printf
00401424  |.  8D85 F8FBFFFF LEA EAX,[LOCAL.258]                           ; ||
0040142A  |.  890424        MOV DWORD PTR SS:[ESP],EAX                    ; ||
0040142D  |.  E8 8EF30000   CALL <JMP.&msvcrt.gets>                       ; |\gets
00401432  |.  8D85 F8FBFFFF LEA EAX,[LOCAL.258]                           ; |
00401438  |.  890424        MOV DWORD PTR SS:[ESP],EAX                    ; |
0040143B  |.  E8 70F30000   CALL <JMP.&msvcrt.strlen>                     ; \strlen
00401440  |.  8985 C4FBFFFF MOV [LOCAL.271],EAX
00401446  |>  8B85 BCFBFFFF /MOV EAX,[LOCAL.273]
0040144C  |.  3B85 C4FBFFFF |CMP EAX,[LOCAL.271]
00401452  |.  73 23         |JNB SHORT Keygen.00401477
00401454  |.  8D45 F8       |LEA EAX,[LOCAL.2]
00401457  |.  0385 BCFBFFFF |ADD EAX,[LOCAL.273]
0040145D  |.  2D 00040000   |SUB EAX,400
00401462  |.  0FBE10        |MOVSX EDX,BYTE PTR DS:[EAX]
00401465  |.  8D85 C0FBFFFF |LEA EAX,[LOCAL.272]
0040146B  |.  0110          |ADD DWORD PTR DS:[EAX],EDX
0040146D  |.  8D85 BCFBFFFF |LEA EAX,[LOCAL.273]
00401473  |.  FF00          |INC DWORD PTR DS:[EAX]
00401475  |.^ EB CF         \JMP SHORT Keygen.00401446
00401477  |>  8D85 C0FBFFFF LEA EAX,[LOCAL.272]                           ; |||
0040147D  |.  8120 FFFF0000 AND DWORD PTR DS:[EAX],0FFFF                  ; |||
00401483  |.  8B85 C0FBFFFF MOV EAX,[LOCAL.272]                           ; |||
00401489  |.  894424 08     MOV DWORD PTR SS:[ESP+8],EAX                  ; |||
0040148D  |.  C74424 04 260>MOV DWORD PTR SS:[ESP+4],Keygen.00440026      ; |||ASCII "%04X"
00401495  |.  8D85 E8FBFFFF LEA EAX,[LOCAL.262]                           ; |||
0040149B  |.  890424        MOV DWORD PTR SS:[ESP],EAX                    ; |||
0040149E  |.  E8 FDF20000   CALL <JMP.&msvcrt.sprintf>                    ; ||\sprintf
004014A3  |.  0FB685 E8FBFF>MOVZX EAX,BYTE PTR SS:[EBP-418]               ; ||
004014AA  |.  8885 CDFBFFFF MOV BYTE PTR SS:[EBP-433],AL                  ; ||
004014B0  |.  0FB685 E9FBFF>MOVZX EAX,BYTE PTR SS:[EBP-417]               ; ||
004014B7  |.  8885 CCFBFFFF MOV BYTE PTR SS:[EBP-434],AL                  ; ||
004014BD  |.  0FB685 EAFBFF>MOVZX EAX,BYTE PTR SS:[EBP-416]               ; ||
004014C4  |.  8885 DAFBFFFF MOV BYTE PTR SS:[EBP-426],AL                  ; ||
004014CA  |.  0FB685 EBFBFF>MOVZX EAX,BYTE PTR SS:[EBP-415]               ; ||
004014D1  |.  8885 C8FBFFFF MOV BYTE PTR SS:[EBP-438],AL                  ; ||
004014D7  |.  8D85 C8FBFFFF LEA EAX,[LOCAL.270]                           ; ||
004014DD  |.  894424 04     MOV DWORD PTR SS:[ESP+4],EAX                  ; ||
004014E1  |.  C70424 2B0044>MOV DWORD PTR SS:[ESP],Keygen.0044002B        ; ||ASCII "Your serial is: %s
"
004014E8  |.  E8 E3F20000   CALL <JMP.&msvcrt.printf>                     ; |\printf
004014ED  |.  C70424 3F0044>MOV DWORD PTR SS:[ESP],Keygen.0044003F        ; |ASCII "PAUSE"
004014F4  |.  E8 97F20000   CALL <JMP.&msvcrt.system>                     ; \system
004014F9  |.  B8 00000000   MOV EAX,0
004014FE  |.  C9            LEAVE
004014FF  \.  C3            RETN

In ASM you can nicely see that some functions like sprintf (putting a string array into buffer) is being called inside the msvcrt (Microsoft Visual C Runtime)...but maybe now you get a general idea if you haven't already.
...left for good
Post Reply