An ASM/C type lang

Programming, for all ages and all languages.
Post Reply
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

An ASM/C type lang

Post 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.
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: An ASM/C type lang

Post 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.
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Re: An ASM/C type lang

Post 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:
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: An ASM/C type lang

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: An ASM/C type lang

Post by Brynet-Inc »

Sphinx C-- appears to be relevant to your interests, quite old though.. and it's for DOS.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: An ASM/C type lang

Post 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.
My OS is Perception.
Post Reply