User:Johnburger/Demo/Host
The development environment for a software engineer is a personal choice. I've used PCs most of my professional life, but I have used mainframes, minicomputers, SGI/HP/Sun Unix workstations and Macs too.
On the PCs I've used DOS, Linux and Windows, and I probably miss DOS the most. Hey, I'm an embedded engineer - I want to be close to the machine I'm working on! By using various virtualization programs I can still get the runtime environment I need, as described in Target Machine.
For this project, I did most of the development work under Windows 7 and VMware player.
Assembler
I wrote all the code in assembly. The assembler choice needed to be made up front, since different assemblers have different syntax or directives. I wanted you to be able to work with the code, so I also wanted to use a readily-available one. But since I've used Intel syntax for all my x86 life, I didn't want to make the mind-switch to Gnu's assembler - I'd be sure to make mistakes with the reversed opcodes!
So I've used NASM - and taken full advantage of two of my favourite features that it offers: local/hierarchical identifiers and macros.
The command line to assemble the source depends on how you want to use the output:
For CD: | nasm -o Demo.iso Demo.asm
|
For USB: | nasm -o Demo.usb Demo.asm
|
For Floppy: | nasm -o Demo.flp Demo.asm
|
For Hard Disk: | nasm -o Demo.bin Demo.asm
|
No, I'm not using some kind of fancy NASM macro to examine the output file name: this source code generates a single binary that can be used for any of the above media! You can tailor the code to invalidate any of the output types: for example, if you comment out the following line in Demo/Demo, you can still output a .iso
file, it just won't work like one!
;%define IMAGE.ISO ; Write as bootable CD (ISO-9660 and El Torito)
IDE
I don't want to start a Holy War about the relative merits of different IDEs - I've used around a dozen in my decades of programming, and none are perfect. For this project I used a freeware editing environment called PSPad. Some of its advantages include:
- Simple text-based editing environment;
- Hex editor for binary files;
- Simple text-based project file (see below);
- Syntax highlighting;
- Invoke a build command, and capture and process the output for one-click jumps to errors;
- Above all: hierarchical project specification.
The following is the PSPad Project (.ppr
) file. It's fairly straightforward in its layout: after a few project-specific settings, the file layout is there for all to see. You've probably guessed that there's a Wiki page for each of the files...
Demo/Demo.ppr
[Config] Compilator.FileName=C:\NASM\NASM.exe Compilator.PSPar=-l %Name%.lst %Name%%Ext% Compilator.Log=%Name%.lst Compilator.Run=CMD /c COPY %Name% %Name%.iso && COPY %Name% %Name%.flp Compilator.SaveAll=1 Compilator.Capture=1 Compilator.ParsLog=%F:%L:* ; NASM Compilator.HideOutput=1 Compilator.LogType=0 DefaultCPIndex=0 LogtoEnd=0 DontOpen=0 AbsolutePath=0 FileFormat=0 ProjectFilesOnly=0 [Project tree] Demo Demo.asm Demo.inc Demo.lst Demo.map Demo +x86 x86\x86.inc x86\EFlags.inc x86\Seg.inc x86\CR0.inc x86\Desc.inc x86\TSS.inc x86\IVT.inc +BIOS BIOS\BIOS.inc BIOS\A20.inc BIOS\RAMMap.inc BIOS\Key.inc BIOS\VGA.inc BIOS\Disk.inc BIOS\MBR.inc BIOS\MemMap.inc +Dev Dev\Dev.inc Dev\A20.inc Dev\PIC.inc Dev\Timer.inc Dev\Key.inc Dev\VGA.inc +Boot Boot\Boot.inc Boot\Entry.inc Boot\CPU.inc Boot\Load.inc Boot\IDT.inc Boot\RAM.inc Boot\A20.inc Boot\Key.inc Boot\VGA.inc Boot\PM.inc Data.inc +Ints Ints\Ints.inc Ints\IDT.inc Ints\Fault.inc Ints\Vectors.inc Ints\User.inc Ints\Single.inc +Debug Ints\Debug\Debug.inc Ints\Debug\Init.inc Ints\Debug\Key.inc Ints\Debug\Show.inc Ints\Debug\Regs.inc Ints\NoSeg.inc Ints\IRQs.inc Ints\Timer.inc Ints\Key.inc Ints\Util.inc +User User\User.inc User\LDT.inc User\Data.inc User\Code.inc User\Frame.inc +Exec Exec\Exec.inc Exec\Init.inc +Ints Exec\Ints\Ints.inc Exec\Ints\Debug.inc Exec\Ints\Trace.inc Exec\Ints\NoSeg.inc Exec\Ints\Double.inc Exec\Ints\BadStack.inc Exec\Ints\BadTSS.inc Exec\Ints\Fault.inc Exec\PICs.inc Exec\Timer.inc Exec\Key.inc +Start Exec\Start\Start.inc Exec\Start\LDT.inc Exec\Start\TSS.inc +Alloc Exec\Alloc\Alloc.inc Exec\Alloc\RAM.inc Exec\Alloc\DT.inc Exec\Alloc\IDT.inc Exec\Alloc\GDT.inc Exec\Alloc\LDT.inc Exec\Alloc\TSS.inc Exec\LDT.inc Exec\GDT.inc +Pad Pad\Sizes.inc Pad\HardDisk.inc +ISO Pad\ISO\ISO.inc Pad\ISO\Defn.inc Pad\ISO\Primary.inc Pad\ISO\Boot.inc Pad\ISO\Terminator.inc Pad\ISO\Catalog.inc Pad\ISO\PathTable.inc Pad\ISO\RootDir.inc Pad\Floppy.inc [Open project files] [Selected Project Files] Main=Demo.asm