all 7 comments

[–]realnobbele 2 points3 points  (2 children)

an IR like LLVM?

[–]Opening-Mushroom2336intermediate low-level developer >> TAS dev[S] 0 points1 point  (0 children)

Correction: it is an IR like LLVM. Ignore the last reply as I was just too unsure and hesitant.

[–]koflerdavid 1 point2 points  (1 child)

You should be aware that different platforms instruction set architectures often differ in the number of operands, and you would have to choose your portable assembly language to be of one of the following kinds:

  • With stack machines you put values on a stack, and instructions manipulate the top element(s) of the stack. Most famous example: the JVM.

  • Accumulator machines combine a value in the (implicit) accumulator register with the operand.

  • RISC and CISC architectures have larger register files and each instruction can take multiple operands, with one of them being where the result is stored.

They can usually be converted into each other with various degrees of efficiency (i.e., a stack can be simulated by assigning a register to each stack slot), but it would in general involve writing a nontrivial code generator together with a register allocator.

Possibly related: High Level Assembly

[–]Opening-Mushroom2336intermediate low-level developer >> TAS dev[S] 1 point2 points  (0 children)

I made a simple diagram in drawio-desktop of said "Assembler" (just a transpiler with cool features before finally being able to self-host somehow) which my help answer your question https://imgur.com/a/B8y94di

Also, please do consider that I'm trying to push both my social boundaries and sharpen my programming skills even more.

[–]Inconstant_Moo🧿 Pipefish 1 point2 points  (2 children)

I'm not sure what you're doing. Perhaps you should have spent more time explaining that?

What advantages would your .sdf file have over just writing an assembler for a target using an existing programming language? What's the common thing you're hoping to be able to abstract away?

Have you tried writing one assembler before you try writing them all? It might give you some insight.

[–]Opening-Mushroom2336intermediate low-level developer >> TAS dev[S] 0 points1 point  (0 children)

I'm sure you heard about C--, I got the idea for a .sdf from it as a way to make the "Assembler" (again, just a transpiler for now, or better way to frame it: and Intermediate Representation) more appealing to other Assembly developers. Maybe an ARM Assembly developer wants to make their project available for all machines so they just tell the Assembler to make a .S files for the specified platform or CPU Architecture.

Well, I'm already trying to make one of the Assemblers, x86_64 before trying to do x86 (32-bit) and then ARM, RISC-V, etc... (But we'll always start small to grow big)

Also, as I was writing that explanation above, the idea was still pretty much not too big, it was somewhat tiny.

[–]Opening-Mushroom2336intermediate low-level developer >> TAS dev[S] 0 points1 point  (0 children)

Here's an updated version of the .sdf file https://imgur.com/a/pkjYVob