bootstrapping from COPY CON

Dave Long dave.long at bluewin.ch
Wed Apr 13 13:57:24 EDT 2011


>> Imagine being given a 1982 era IBM PC with a floppy drive and a
>> single disk that contains a bootable MS-DOS system with IO.SYS,
>> MSDOS.SYS and COMMAND.COM (the minimum required to boot to a usable
>> (for various values of “usable”) system at the time) and a stack of
>> reference materials. Your goal (assuming you are a programmer) is to
>> write a program that does something simple, like, play a game
>> (however badly) of tic-tac-toe. No editor. No assembler. No
>> compiler. No linker. Just COMMAND.COM and a stack of reference
>> materials.
>
> Using modern tools as cognitive aids (so I didn’t have to
> hand-assemble) and to diagnose problems allowed me to do this in a few
> hours.  It might have taken a few days in Sean’s scenario.

Being the dinosaur that I am[0], I can partially explain why your  
approach was not too far off.  Early PC's might have appeared to lack 
[1] development tools, but circa 1982 I had access to a microcomputer  
project (eventually killed by the PC's dominance), and although self- 
hosted tools did appear by the end of development, all of the initial  
work was done in a timeshared unix environment: sources were edited  
and cross-compiled on the mini(s) and the resulting executables  
transferred to the micros.  No IDE's or mice, but they had full  
screen editors, makefiles, and a gcc-like toolchain.  Set your xterm  
to 24x80 green-on-black[2] and the cross-compiling you were doing  
wouldn't be far off at all from industry practice 30 years ago.

I haven't tried this myself yet, as some combination of Q, Freedos,  
or laptop prevents me from entering ALT-numerics in the dos box.   
However, I'd think two other tricks might come in handy for a pure  
bootstrap:
- having command.com means you have batch files.  granted, .bats have  
impoverished control structure, but it might save on some machine  
code in the bootstrap
- copy also concatenates files; one could thus minimize transcription  
errors by using COPY CON for relatively short sequences, then splicing 
[3] them together to form the final executable.

-Dave

[0] I have, once in my life, programmed (an application, not an  
exercise) using front panel switches and the reference manual
[1] this is not strictly true; it appears that DEBUG.COM was already  
present in MS-DOS 1.0, and already incorporated the symbolic  
assembler by 2.0
http://www.armory.com/~rstevew/Public/Tutor/Debug/debug-manual.html
cf http://en.literateprograms.org/Hello_World_(IBM_PC_bootstrap)
[2] http://upload.wikimedia.org/wikipedia/commons/2/23/Vt100- 
adventure.jpg
[3] choose naturally concatenative machine code sequences, and it  
might even be about as easy as programming via DEBUG; after all, they  
both lack decent symbol table/dictionary support



More information about the Kragen-discuss mailing list