LESSON 2 — THE FILE IS THE PROGRAM

click the black screen first to grab the keyboard · this lesson wants a real keyboard — you are here to type assembly, and no on-screen panel makes that pleasant · back to the arcade
This is a real DOS machine, and you are at its prompt. Type MAKE.

1 · ASSEMBLE IT

MAKE Three programs, built by the assembler sitting on the same disk. Nothing was downloaded to do it.

2 · LOOK AT IT

HEX HELLO.COM HELLO Eighteen bytes, all of them on one line. That file has no header: DOS loads it and jumps straight to the first byte.

3 · CHANGE IT

HEX HELLO.COM 12 WORLD HELLO Without assembling anything. The source still says HELLO. The program does not.

4 · AND THE EXE

HEX HELLO2.EXE The same program with a header, a relocation table and a stack of its own — 81 bytes to do what 18 did.

WHAT THIS PAGE IS

The second lesson of the series, with the machine attached. Everything you need is already in the tab: three assembly sources, the assembler that builds them, and a DOS to run the result on. Nothing is installed and nothing is downloaded. Reload the page and you get a fresh machine with the sources back as they were, so there is nothing you can break.

Type HELP at any point and the machine prints the list again.

WHAT YOU ARE LOOKING AT WHEN YOU TYPE HEX HELLO.COM

0000: BA 0C 01 B4 09 CD 21 B8 00 4C CD 21 48 45 4C 4C  ......!..L.!HELL
0010: 4F 24                                            O$

Twelve bytes of instructions, then the word itself. BA 0C 01 is put 010Ch into DX — the address of the text, and 010Ch is where the text landed because a COM file starts at offset 100h. That is why the patch in step 3 writes at offset 12: it is the first letter, and it is simply lying there in the file.

THE EDITOR IS HERE TOO

If you would rather change the source than the finished program:

EDIT HELLO.ASM

That opens flat assembler's own DOS editor. Change the text, save with F2, leave with Esc, and type MAKE again.

WHY THERE IS NO FILE MANAGER IN HERE

The recorded lesson uses one to look at the bytes. It could not come with you: that program is shareware, free to use and not free to hand out, and this page is meant to be opened by somebody who agreed to nothing and downloaded nothing. So the byte viewer you are using is a program of ours, written in the language this lesson is about and built by the assembler this lesson uses — and you rebuilt it yourself when you typed MAKE.

the lesson's sources and notes · back to the arcade · the assembler is flat assembler, and the DOS is DOSBox compiled to WebAssembly via js-dos