https://hackaday.com/2018/12/10/
bootstrapping-an-msdos-assembler-with-batch-files/more-336004
Bootstrapping An MSDOS Assembler With Batch Files
You have a clean MSDOS system, and you need to write some software for
it. What do you do? You could use debug, of course. But there are no
labels so while you can get machine code from mnemonics, youll still
need to figure out the addresses on your own. That wasnt good enough
for mniip, who created an assembler using mostly batch files.
https://github.com/mniip/BOOTSTRA
There are a few .COM files and it looks as if the first time you use
debug to create those, but theres also source you can assemble on
subsequent builds with the assembler.
Why? We arent entirely sure. But it is definitely a hack. The
technique sort of reminded us of our own universal cross assembler -
sort of.
There are a few things that make this work. First, there are not many
8086 instructions to worry about. Second, you have to use a special
format - essentially prefixing the op codes with CALL. This keeps the
assembler from having to parse op codes. You actually call a batch
file with the name of the instruction. For example:
CALL PUSH CS
CALL POP DS
CALL MOV DX WORD String
CALL LABEL String
REM H e l l o , w
CALL DB 72 101 108 108 111 44 32 119
That code snippet shows another nuance. You have to CALL LABEL to
introduce a label. To use the label in an instruction, you have to
surround it with percent signs.
Of course, as a practical matter, you could use gcc to build a proper
assembler. But wheres the sport in that?