Q:

Creating an a.out executable from scratch

I have created a programming language, from scratch with C. I have built a compiler which processes the code in the input file and converts it to tokens and checks that the tokens are in the correct order. I am on the final step of the compiler: Output/Executable. I want to create an output that can run in terminal. I want to create an a.out output but the only resource I could find was this from nasm which doesn't really help me.
So my question is, how do I create an a.out file (unix executable) that I can run in terminal?

A:

well you wrote you are on the final step of the compiler ...

are you sure ?
what type of language is it ?
for example non asm languages like Pascal/C/C++ require engine

as have been mentioned before in comments you can:

use existing assembler compiler/linker from your app

this is the simplest way
you need to create language runtime engine code in asm
then compile your source to asm
put these 2 sources together
and call compiler/linker
but you can forget about breakpoints and trace ...
also there are C/C++ compilers/linkers out there if you dislike asm

create own compiler linker

first you need to study executable fileformat
create an template for it
second you need to write your own asm compiler
do not need to be for complete instruction set
just to have all necessary things to translate your language to the machine code
then just compile your language to machine code
and fill the template with code and all necessary data
save it as a.out ...

The language runtime engine:

it is something like OS for your program
set of subroutines your language supports
like interface between terminal/real OS and your program
memory/resources management
handles local/global/static variables
heap/stack ...
threads
debugging
and much more ...

