1. Using IBM PC Compatible Computer for CSCI 2370 Assembly Language Programming
When using a PC system do programming in assembly language you will need to use the following programs.
An editor to type in your programs. This can be Notepad, or WordPerfect/Word saved in ASCII form, or a text editor like PFE (will assume PFE).
TASM the turbo assembler, use it to assemble your program into machine language.
TLINK the turbo linker, use it to get your program into executable form.
TD the debugger, use it to test and execute your program.
PrintKey a freeware program that allows you to print the screen easily
The sequence of events for entering and running an assembly language program is:
-------------------------------------------------------------------------------
a) Turn on the system.
b) Click the START button, move to PROGRAMS, move to DEPARTMENTAL PROGRAMS, MATH & COMP. SCI., and DOS-BASED PROGRAMS.
c) A DOS screen appears and the drive indicator is H. The above programs are then available on drive H, on subdirectory TD2.
d) Press ALT-ENTER to get to the taskbar. Run Printkey and PFE32 . Type your program into PFE. The file should be placed on your disk in drive A and have an extension of ASM. Save it on your disk when it its correct.
e) Switch to the DOS window.
f) Assemble the program by typing TASM /ZI A:filename,A:,A: to create the object file and a full assembly listing file or TASM /ZI A:filename,A:; to not create the LST file
g) If errors occurred during assembly they will appear on the screen and in the listing file, A:filename.LST . Reenter PFE (or Notepad), make your corrections, save the file, and reassemble. You can look at the listing file by using opening A:filename.LST in the notepad or text editor.
h) When you have no assembly errors, you next want to link your object file into an executable file by typing TLINK /V A:filename .
i) To execute your program you will enter the debugger by typing
TD A:filename .
j) When you enter the Turbo Debugger, TD, three areas will be displayed: the source module with your code, the watch area to show the data, and the registers. These change as the program is executed. Next go up to your data segment in the code. Put the cursor on each variable you would like to observe in the watch area and press CTRL-W . The variable will appear in the watch area with its current value in decimal and hex.
k) Find the MOV AH,4CH instruction in the code of your main program and press the F2 key to set a breakpoint there. If you don't set this breakpoint, the debugger will say PROGRAM TERMINATED when the program finishes executing and the registers won't hold the correct values. At this point you may want to set other breakpoints in the same manner.
l) Execute your program using F9 key to run it to the next breakpoint. Or the F8 key will execute (step) the next instruction in the code, or the F7 key to trace to the next executable instruction. (The difference between F8=step and the F7=trace keys is that at a CALL instruction Step will execute the entire procedure while Trace will go into the subprogram.)
m) When the program breaks at the breakpoint, check the locations in the watch area to see if they are correct and decide if the program worked. If it did, print out the results by using the PRTSC key (you need to be on a system with a printer or on the network). If the results are not correct, then exit TD by hitting ALT-F and Q and go back to your editor.
The assembler and debugger:
Are in subdirectory TD2 of drive H. They are all the files beginning with T and RTM.EXE. You will also need Good Copy of TDCONFIG.TD in case the configuration file gets corrupted.
PrintKey:
A freeware program on TD2 consisting of two files. Activate by pressing the PrintScrn key or pointing to the hand icon on the taskbar and right-clicking.
PFE = Programmer's File Editor:
A freeware, windows text editor also located in TD2. It consists of three files.
In the NT labs you will need to do a little extra work to make TD look correctly. Once it is open, with the mouse pointer on the top blue area of the window, right-click and select Properties. Select Font and change the size to 8x8, then hit ENTER and ENTER again. The window will change size. Now drag the bottom right corner of the TD window down until you can see all of the watch window and the registers plus the help line at the very bottom.
You can use a batch file to assemble, link and start the debugger. It helps so you don't have to remember the exact syntax of the three lines of DOS commands. In mine I have a pause in case there are errors in the program, so it doesn't go all the way to the debugger before I can stop it.
2. Using the assembler, TASM
TASM assembles your assembly language program into an object file, which
can be executed after it is linked.
TASM is called by typing
TASM /ZI sourcefile,objectfile,listfile,crossreffile
The sourcefile is your assembly language program. The objectfile is the result of the assembly process. The listfile is listing of all the sourcefile with the hexadecimal contents of each location, a list of all symbols used, and all the errors marked by an error message. The crossreffile lists all the variables and all the lines where they are referenced (if your variables and labels are named well, you won't need it). The /ZI option tells the assembler to include debugging information in the object file. The defaults for the objectfile is defaultdrive:sourcefile.OBJ. The default for the listfile is defaultdrive:NUL.LST (ie. no listing created). The default for the crossreffile is defaultdrive:NUL.CRF . The extensions used above are defaults and are not necessary when specifying a file (the default extension for the sourcefile is ASM). If you want, you can be prompted for each of the files by just typing TASM.
Egs. H>TASM /ZI A:LAB1,A:,A:; uses sourcefile A:LAB1.ASM
objectfile A:LAB1.OBJ
listfile A:LAB1.LST
no crossref file
H>TASM /ZI A:LAB1,A:; uses sourcefile A:LAB1.ASM
objectfile A:LAB1.OBJ
no listfile or crossref file
H>TASM /ZI A:LAB1,A:;>PRN:
uses sourcefile A:LAB1.ASM
objectfile A:LAB1C.OBJ
no listfile or crossref file
errors sent to printer
In your program
INCLUDE filespec brings in the contents of another file as source at the
point the INCLUDE statement appears.
3. Using the linker, TLINK
TLINK takes the object file or files created by the assembler and creates an
executable file that can either be directly executed from DOS or run under
the debugger.
TLINK is called by typing
TLINK /V objectfilelist,runfile,mapfile,liblist
The objectfilelist is a list of object files separated by +'s. The default object file extension is OBJ. The runfile is the executable file created by the linker. It's default is defaultdrive:objectfile.EXE . The mapfile is a linker map containing an entry for each segment in the object files. Its default is defaultdrive:NUL.MAP . The liblist is a list of the libraries your program is going to use. The library files are separated by +'s .The /V option tells the linker to include debugging information in the run file.
Eg. TLINK /V A:LAB1 uses objectfile A:LAB1.OBJ
runfile A:LAB1.EXE
mapfile A:LAB1.MAP
no library
4. Using the Turbo Debugger, TD
TD allows you to test your program so that you can execute it while monitoring the program.
Enter TD by typing
TD A:filename
The following is an example screen

This setup has the source window, register window, and watch window. There are others available. Look at the View menu for the list but these are the most useful in working with assembly language.
Window operations
ALT-n moves to window n (in the example, the register window is 2)
Alt-F3 closes a window
Once in a window, CTRL-F5 allows you to move or resize the window
This program is fairly complicated with lots of options and a great deal of flexibility. Not much of it can be explained in a short document. But here is some help.
Special keys
The top menu bar and the included options can be accessed by pressing F10 or by pressing ALT with the first letter with the menu option. When the pulldown menu appears you may see some shortcuts next to it.
The function keys are listed along the bottom line. If you hold down the ALT or CTRL key, the options available through those keys are listed on the bottom line.
To set a breakpoint (the program stops when it gets here) press F2 at the point in the code, the line will be highlighted
the breakpoint can be conditional, ie. only stops if a specified condition is true
also has global breakpoints where it stops on the first instruction where a
condition is satisfied (like a specified variable changes) see Breakpoints then Changed Memory in HELP
To remove a breakpoint
press F2 on the highlighted breakpoint
To run the program to the first breakpoint
press F9
To step through the program (skips to next instruction after subprogram call)
press F8
To trace the program (goes into the subprogram on CALL statement)
press F7
To start execution earlier in the program you must reload the program, CTRL-F2 does a program reset & reloads
as if you just entered the debugger, however the watches and breakpoints are still in effect
To watch a variable
put the cursor on the variable in the code and press CTRL-W
To remove a variable from being watched
put the cursor on the variable in the watch window and press ALT-F10
To view the output screen
press ALT-F5
To modify data
depends on the type of data, go to the watch window for a single byte or word: press CTRL-C (or ALT-F10 to access watch local menu) for more than one location: ALT-V will get you to the View Menu, select CPU, go to the first byte to change and type the new values
To restore the configuration file
Go to OPTIONS, then RESTORE OPTIONS, and select the file Good Copy of TDCONFIG.TD. Then SAVE OPTIONS using the filename TDCONFIG.TD .
To exit
press ALT-X or ALT-F and then Q