Page 1 of 1

An ASM/C type lang

Posted: Thu Mar 12, 2009 7:03 pm
by nekros
I was thinking about how it would be awesome if we had a programming language that combined c and asm into something like this: (The code is pretty random but that's beside the point)

Code: Select all

#include "includfile.lh"
#defien YOURMOM 0xDEADBEEF

out32{          // this means all of the code between the braces is output as 32 bit

bool truefalse;
u8 byte;
u16 word;
u32 dword;
u64 qword;

struct rand
{
u8 val = 23; //allow for default values to be declared
}


start main() //declare the start function
{
  rand myrand;
  mov eax,dword; //mov data into register
 CR0 = 0; //normally you wouldn't do this but this is just an example

	if(myrand.val != 0)
	{
	    pntr p = &qword; //pointers
	    [p]  
	}

}

}

u8 randf(u8 pissbyte)
{
return(pissbyte*YOURMOM);
}
What makes me even more interested in this is that I've been studying compilers lately. So this might be something to try out.

Re: An ASM/C type lang

Posted: Thu Mar 12, 2009 7:15 pm
by steveklabnik
asm blocks are too much typing?

http://www.ibiblio.org/gferg/ldp/GCC-In ... HOWTO.html

C is already high level assembly. The reason that C was created was to make assembly be portable. You're taking away the whole reason that we use C in the first place.

Re: An ASM/C type lang

Posted: Thu Mar 12, 2009 7:24 pm
by nekros
I wasn't trying to add to C, I'm adding to asm. So people who just want a little extra with their asm will have it. :wink:

Re: An ASM/C type lang

Posted: Thu Mar 12, 2009 7:36 pm
by JohnnyTheDon
The problem is local variables (like rand in your example) clashing with registers. You would need to tell the compiler what registers it can use for calculations with local variables and what registers you're using.

Re: An ASM/C type lang

Posted: Thu Mar 12, 2009 10:12 pm
by Brynet-Inc
Sphinx C-- appears to be relevant to your interests, quite old though.. and it's for DOS.

Re: An ASM/C type lang

Posted: Fri Mar 13, 2009 12:00 am
by AndrewAPrice

Code: Select all

out32{          // this means all of the code between the braces is output as 32 bit
This might work better if you wrote a compiler and used it as a pragma.

Code: Select all

bool truefalse;
u8 byte;
u16 word;
u32 dword;
u64 qword;
Define/typedef in C/C++?

Code: Select all

start main()
Why would you need the "main()" keyword if "start" defines the start of your code?

I still like Lisp. Write a systems-level Lisp variation. When you parse the code it's already split into a graph showing the flow of data, making it easy to detect/remove dead code.