Saturday, August 7, 2010

Chapter I Review

Start at the Beginning
Table of Contents

This review will be on DOS and RHIDE.

When a DOS computer boots up, it places you at the command prompt. From here you'll navigate your disks, manage files and directories, and start programs.

Every disk in your computer is assigned a letter. On the virtual machine we're using, we're only going to have one primary disk: C, our hard drive. Occasionally I'll have you load a file from the A drive, a floppy disk drive.

At all times DOS keeps track of the current disk drive you're working with. To change drives, type the drive letter you want to change to, followed by a colon, followed by Enter. For example, to change to a hypothetical H drive, you would type H: and press Enter.

If DOS can't change to a disk drive (for example, if you try to change to the A drive if no disk is in the drive) it will display an error messaging asking whether to Abort, Ignore, Retry, or Fail. If you can fix the problem (e.g. by inserting a disk), you can use Retry (press R) to complete the operation. Abort, Ignore, and Fail all do basically the same thing - cancel the operation and leave you with no current disk (the prompt will just say >). Switch back to the C drive by typing C:

Your disk in DOS is a hierarchy of directories. Each directory can contain other directories as well as files. All directories on a disk are contained inside the root directory, \.

When working in the command prompt, you have a "current directory". This indicates where you are in the directory heiarchy. The command prompt shows you your current directory and your current drive. For example, when you first start your virtual machine up, the current drive will be C and the current directory will be \. The prompt, therefore, will read:

C:\>

If you were in the "myfiles" directory on drive A, the prompt would read:

A:\myfiles>

To view the contents of the current drive and directory, type 'dir' followed by Enter (from now on, when explaining a DOS command, I won't tell you that you have to explicitly press Enter. You always do though - the Enter key is what tells DOS to actually perform the command).

The dir command can also take switches. Type dir /w to get a columnar view, dir /p to get a paginated view, or dir /w /p (or dir /p /w - the order of switches doesn't matter) to combine the two.

Everything DOS does is relative to the current directory. For example, suppose the root directory on a floppy in drive A contains a directory (a subdirectory) called 'files', containing a file called 'a_file'. If the current directory is the root and the current drive is A, we can display the contents of 'a_file' with the command

type files\a_file

But if the current directory is 'files', then we only have to type

type a_file

And if we're on another drive entirely, we'll need to type

type A:\files\a_file

To change the current directory, type cd, followed by a space and the directory you wish to change to. For example, to change to the directory 'gameprg', you would type cd gameprg - assuming 'gameprg' is a subdirectory of the current directory. To jump back up to the parent directory of a subdirectory, type

cd ..

Typing this while in the root directory has no effect.

DOS has several built-in commands like 'cd' and 'dir' that can be typed anywhere. If DOS doesn't recognize the first "word" of your input as a built-in command, it tries to find a program with that name appended with one of the "extensions" .EXE or .COM in the current directory (i.e. if you type in rhide, it will look for 'rhide.exe' or 'rhide.com'). EXE and COM stand for EXEcutable and COMmand, respectively. If it can't find anything in the current directory, it'll check for a special "environment variable" (basically a DOS setting you can change) called PATH. PATH should contain a list of directories that contain programs that can be run from anywhere. If the program you ask for isn't in the current directory, it'll check each of the directories in the PATH for it. If it can't find it in there, DOS displays an error.

The program we'll be using most often is called RHIDE. The EXE for RHIDE is stored in the C:\DJGPP\BIN directory, and is called rhide.exe. Because C:\DJGPP\BIN is in the PATH variable (you can see this by typing set at the DOS prompt), you can run RHIDE from anywhere - just type rhide. DOS will find rhide.exe in C:\DJGPP\BIN, load it into memory, and give it control of the computer. When you quit RHIDE, it hands control back to DOS.

Optionally, you can ask RHIDE to load a specific file automatically by typing rhide followed by the name of the file you want to load. For instance, if you want to load the file 'main.c' into RHIDE, you'd type

rhide main.c

Here, 'main.c' is what we call a "command-line argument".

The two most helpful keys in RHIDE are F2 to save and Alt+X to quit. Other useful commands are displayed on a banner running across the bottom of the screen.

You can navigate around a file with the usual combination of arrow keys and Home/End/PageUp/PageDown. As you'd expect, typing letters inserts them into the file. Delete and backspace removes characters from a file. F10 opens the main menu bar. Alt+(a menu hot key) opens a specific menu. Arrow keys move around menus. The Enter key activates a menu option. TAB navigates through the various widgets in a window box. Cut, copy, and paste are Shift+Del, Ctrl+Ins, and Shift+Ins, respectively.

Try exploring RHIDE and the various options it presents to you. Look up short cuts in the menu. Navigate different menus and windows. Create a new file, type something up, play around with RHIDE's commands. Experiment. Even if you accidentally screw something up terribly - and that's fairly unlikely - just exit Bochs and replace your virtual hard disk image with a fresh copy (remember to change the FILES and BUFFERS settings again).

Now's the time to get comfy with your editor. We're going to be seeing a lot of it.

No comments:

Post a Comment