[1;30mhttps://hackaday.com/2018/12/10/[0m
[1;30mbootstrapping-an-msdos-assembler-with-batch-files/#more-336004[0m

[1mBootstrapping An MSDOS Assembler With Batch Files[0m


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, you’ll still
need to figure out the addresses on your own. That wasn’t good enough
for [mniip], who created an assembler using mostly batch files.

[1;31mhttps://github.com/mniip/BOOTSTRA[0m

There are a few .COM files and it looks as if the first time you use 
debug to create those, but there’s also source you can assemble on 
subsequent builds with the assembler.

Why? We aren[1;31m'[0;37;40mt 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:
	
[1mCALL[0;37;40m PUSH[1;36m CS[0m
[1mCALL[0;37;40m POP [1;36m DS[0m
[1mCALL[0;37;40m MOV[1;36m [0;37;40m [1;36mDX WORD %String%[0m
 
[1mCALL[0;37;40m LABEL [1;36mString[0m
[1mREM [36mH e l l o , w[0m
[1mCALL[0;37;40m [1;36mDB 72 101 108 108 111 44 32 119[0m

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 where[1m'[0;37;40ms the sport in that?
