Copy Link
Add to Bookmark
Report

NULL mag Issue 04 13 Dos Assembler with batch files

eZine's profile picture
Published in 
null magazine
 · 26 Dec 2020

  

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, 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.

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 there’s also source you can assemble on
subsequent builds with the assembler.

Why? We aren't 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 where's the sport in that?

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT