What's a good language to use if I want to write portable assembly language but C is (mostly) too high-level for me...

What's a good language to use if I want to write portable assembly language but C is (mostly) too high-level for me? Is there such a thing as an abstract, elegant assembly language that compiles to many different instruction sets? I'd want the language to have no built-in stack abstraction, no built-in procedure abstraction (I know that some assembly languages do have them, but I don't want one)... basically I just want a linear memory abstraction, math operations, and conditional setting of the instruction pointer. This might seem weird because it's actually rather high-level, but ideally I don't want registers either... I just want a linear memory abstraction with register stuff handled by the compiler.

Attached: Thinker_WithComputerMonitorTrimmed.jpg (247x286, 16K)

Other urls found in this thread:

llvm.org/docs/LangRef.html
twitter.com/AnonBabble

>I want C but not C
If you don't want registers, and you want it to compile to more than one processor? How tf is C too high level

What do you think assembly is
>inb4 hurr assembly is magically faster

uhh you could try just writing LLVM IR
llvm.org/docs/LangRef.html

Hurr assembly is magically faster, also op is obviously retarded.

No it's not. It has the *potential* to be faster, if you know what you're doing. In most cases, compiler optimization will be basically as good.

Otherwise, assembly you write by hand will normally be slower than compiled C, because the compiler optimized it more than you did.

You realize you can compile C into assembly, right? If you compile that assembly into a binary, it's not magically faster than if you just compiled the C directly.

>How tf is C too high level
Because it has stack/heap abstractions, a function abstraction, and multiple control flow abstractions. I want something much much simpler - basically just flat linear memory with the ability to (1) copy values from address to address, (2) do math, (3) treat values as addresses, and (4) set the address of the next instruction. Basically, I want to operate directly on a flat linear memory model with 'goto' as the only control flow mechanism, but have the language be portable and have registers handled for me. A minimalistic, abstract quasi-assembly language that compiles to actual machine code.

OP here. I'm looking for a balance of conceptual elegance and good performance, not necessarily for the absolute fastest performance possible.

>that compiles to actual machine code
C does this you dum dum

If you need lower level than C, use asm, or inline asm w/ C.

Interesting! I'll check it out. Looks like it might be really close to what I want.
Well yeah, I know C does it. I want something significantly lower-level than C, but a bit higher-level than asm.

LLVM IR is not portable between architecture widths and uses a virtual register model not a linear memory model.

Really, OP should just try writing C without using functions or variables until his faggotry passes.

>I want something significantly lower-level than C, but a bit higher-level than asm.
the only thing significantly lower level than C IS asm, dumbass

you know registers are a feature of the processor, not the language, right?

>LLVM IR is not portable between architecture widths and uses a virtual register model not a linear memory model.
OP here. Yeah, I noticed that when I read about LLVM a bit just now. LLVM IR seems to be somewhat in the spirit of what I want, but there are major differences.
C without functions and variables, and using gotos, would be getting somewhat close to what I want. How would I dynamically write data to memory and then execute it as code, though?

There's certainly no reason why that has to be true. I'm not even sure it is true when one looks at actually existing languages.

Yes, I know that. That's the main reason why I want registers to be abstracted away in the language I sketched out. I want to program in an abstract instruction set, not a real one.

please name a language that fits the critera
practically there's no reason for anything inbetween
what's wrong with assembly?

*Well, I should clarify... I want to program in an abstract instruction set unless I have some concrete specific reason to program in a real one.

sounds like you should make your own virtual machine with an assembler language to fit your requirements

I don't think there's anything wrong with assembly, I just would prefer something a bit conceptually simpler (basically, something with fewer concepts) and less directly tied to the details of specific hardware instruction sets. As part of my desire for simplicity, I would prefer to operate on an abstract linear memory rather than a mixed linear memory/registers model.
>please name a language that fits the criteria
Compiler IR, viewed as a language. Some would perhaps also argue Forth, although in Forth's case one could also argue that it's higher-level than C. It's conceptually simpler than C, though, as far as I can tell.
Different assembly languages are not even all at the same point on the low-to-high-level spectrum.

Yeah, I want to do that. That's one of the reasons I'm inquiring about people's opinions. I'm wondering what sort of good ideas are already out there along these lines.

Search for shellcode examples. You can cast your data pointer to a function pointer and invoke it.

Interesting, I just read about shellcode a bit. It's not quite what I want, since if I used that approach I'd basically be using two languages joined at the hip. But it's interesting to know about. Thanks, user.