head	1.5;
access;
symbols;
locks
	yap:1.5; strict;
comment	@# @;


1.5
date	97.09.30.17.49.29;	author yap;	state Exp;
branches;
next	1.4;

1.4
date	97.09.26.21.23.58;	author yap;	state Exp;
branches;
next	1.3;

1.3
date	97.09.24.17.13.23;	author yap;	state Exp;
branches;
next	1.2;

1.2
date	97.09.22.16.39.31;	author yap;	state Exp;
branches;
next	1.1;

1.1
date	97.09.17.18.17.41;	author yap;	state Exp;
branches;
next	;


desc
@@


1.5
log
@*** empty log message ***
@
text
@<html>
<title>
	V22.0201.002 (Fall 97)
</title>
<body bgcolor=ffffff>

<center>
	<h3><font color=aa0000>
	V22.0201.002, Machine Organization I, Fall 97
	</font> </h3>
	<h2><font color=aa00ff>
	TURBO ASSEMBLER INFORMATION
	</font>
	</h2>
</center>
<hr>

<h3><font color=ff0000>Introduction</font></h3>
The Turbo Assembler from Borland
is called TASM.  This software
is assumed for this class, and provided in the PC labs.
You can purchase your own copy from the NYU bookstore
for about $75 (for cheaper sources,
look at the course homepage under "other information").
<p>
MASM stand for Microsoft Assembler.  It is very similar
to TASM, and it is the assembler assumed in the text book.
Moreover, TASM has a mode that makes it emulates MASM.

<p>
Associated with assemblers are typically two other
pieces of software called the <b>linker</b>
and <b>debugger</b>.  The linker and debugger that
comes with TASM are called TLINK and TD, respectively.
The linker and debugger that comes with MASM are
called LINK and CODEVIEW (or, DEBUG, the DOS version
of the debugger), respectively.

<p>Appendix E in the textbook describes LINK, CODEVIEW and DEBUG.
It is useful to to read this even if you are working
with TASM.

<h3><font color=ff0000>What are the functions of the assembler and
linker?</font></h3>

Basically, the assembler converts symbolic addresses
into concrete addresses, and translates assembly
instructions into machine instructions (essentially, bytes).
But these ``concrete'' addresses are still not fully resolved
because it may depend on where the instructions and data
are physically loaded in the machine.  The linker
provides such information.  The linker is also
used to ``link'' together several modules into one
big program (this is the reason for the linker's name!).

<h3><font color=ff0000>First Steps</font></h3>

You should read section 4.10 (p.70) of the textbook for
this.  There are 4 essential steps from creating
an assembly program to producing an executable code.

<ol>
<li> Use any text editor to create a <b>source program</b>.
This file normally has name that ends with <b>.asm</b>.
For example, <b>hw1.asm</b> might be appropriate for homework 1.
A very simple editor which is available from DOS is called
<b>edit</b>.  You can begin editing by typing 
the following at the DOS prompt (indicated here by :&gt;):
        <pre>
    :&gt; edit hw1.asm
        </pre>
<li> Use TASM to convert the source program into an <b>object file</b>.
The name of an object file normally ends with <b>.obj</b>.
To do this, type the following at the DOS prompt:
	<pre>
    :&gt; tasm hw1		
	</pre>
This produces the file hw1.obj from the file hw1.asm.
<li> Use the linker TLINK to link your file(s) together
into an <b>executable file</b>.  In this case, you have
only one file (hw1.obj) to link.  The name of
the executable file normally ends with <b>.exe</b>.
For our example, you type the follwing at the DOS prompt:
        <pre>
    :&gt; tlink hw1                     
        </pre> 
This produces the executable file called hw1.exe.
<li> Finally, you can run (or execute) the executable file:
        <pre>
    :&gt; hw1                     
        </pre> 
</ol>

<font color=fa0000>
YOU NOW HAVE THE ESSENTIALS FOR DOING HOMEWORK 1. 
<br>
If you want information for debugging, click
<a href="debug.htm">HERE</a>
</font>

<p> 
<hr> 
<address> 
Comments? <a href=mailto:yap@@nyu.edu>yap@@nyu.edu</a>
</address> 
 

</body>
</html>

@


1.4
log
@*** empty log message ***
@
text
@d100 8
@


1.3
log
@*** empty log message ***
@
text
@d7 10
a16 5
<h2><font color=aa00ff>
V22.0201.002, Machine Organization I, Fall 97
<br>
Turbo Assembler Information
</font></h2>
d94 1
d96 4
a99 146

<h3><font color=ff0000> Pre-Debugger: Syntax Errors </font></h3>
Before we address the debugger, let us address
a class of errors for which it is an overkill
to use the debugger: that is when you do not
even succeed in assembling your program!  No object
file could be produced.  These
are basically <b>syntax errors</b>. 
<p>
The fix here is basically trivial (but it has to
be said): tasm will report all the lines that
has a syntax error, and all you do is to address
the problems one line at a time!  
<b>HINT:</b>
If you invoke "tasm hw1" as above,
any errors will be reported in a line-by-line fashion.
However, only the line numbers will be shown. 
To ask tasm to print out the offending instructions as well,
do this instead:
	<pre>
	:&gt; tasm /z hw1
	</pre>

<h3><font color=ff0000> The Debugger </font></h3>

Where does the debugger come in?  Well, to debug errors
that has to do with the <b>logic</b> of your program.
These are sometimes called <b>semantic errors</b>
as opposed to the ``syntax errors'' in the previous paragraph.
Of course, you can still avoid using a debugger for
small programs.  When your programs become complex
the debugger may be essential.
<p>
There are 3 versions of the Turbo Debugger: <b>TD, TDW</b> and <b>TD32</b>.
For this course, you only need to use TD.  But TD will only
work from a DOS environment.  That means that you need to
get a <b>MS-DOS prompt window</b>
before invoking TD.  This MS-DOS window can be found under
start->programs menu.
<p>
The first thing to realize is that in order to use
the debugger, your assembler and linker needs
to store certain additional information needed by
the debugger.  E.g., if you define the variable
	<pre>
	Greeting db 'Hello, World!'
	</pre>
then your .obj and .exe files
needs to retain the symbolic information
telling the debugger that data at offset ABCD0123h (or whatever)
is the same as "Greeting".  As the human
user, you prefer to see the symbolic name
"Greeting" rather than "ABCD0123h".
<p>
This can be done by calling TASM
and TLINK with certain options (/zi and /v, respectively).
Here is a slight revision of the ``First Steps'' instructions
above:
        <pre>
    	:&gt; tasm /zi hw1
	:&gt; tlink /v hw1
	:&gt; td hw1
        </pre>
Note that the resulting .obj and .exe
files with these options are bigger than they otherwise would be. 
To see other command options available with tasm or tlink,
you can invoke "tasm" or "tlink" without any arguments.
 
<h3><font color=ff0000> How to Debug </font></h3>
There are 4 basic steps:
	<ol>
	<li> <b>Discovering the Bug.</b>  Is there one?
		It is not always obvious that you have a bug.
	<li> <b>Isolating the Bug.</b>  Where is it?
		Locate the part(s) of the
		code that is causing the bug.
	<li> <b>Finding the Bug.</b>  What exactly is wrong with
		the buggy code fragment?
	<li> <b>Fixing the Bug.</b>  How should the buggy fragment be
		rewritten?
	</ol>
The debugger gives you tools to help in all these steps.
E.g., you can run the code in a step-by-step fashion or until
some <b>breakpoint</b> you set in the code.  In between these
execution steps, you can examine memory and CPU state
(variables, registers, flags and stack).

<h3><font color=ff0000> Using TD </font></h3>

Within TD are a variety of windows.  At any moment,
you can have several of these windows <b>active</b>.  The
active windows are numbered (1,2,3, etc.) and the
number is shown on the upper right hand corner of the window.
It is essential you be familiar with some of these windows,
and how to manage them.

<p><b>VIEW menu</b><br>
	The types of windows available are listed under the VIEW menu.
	We describe some of them.
	<ol>
	<li> <b>Module Window</b> This is usually the first
		window you see, and is number 1.  It shows
		your source code, and so may appear the most
		familiar to you (after all, you wrote that code!).
	<li> <b>Watch Window</b> This is usually the second
		window you see, and thus is number 2.  You can
		set up variables and expressions in this window
		to ``watch'' (their values change as your program
		is executed).
	<li> <b>CPU Window</b> This window is most useful for
		assembly language programming as it really shows
		the state of your CPU.  At the top bar of this
		window, it will tell you the CPU class
		(486, Pentium, etc) of the current machine.
		There are 6 subwindows (called <b>panes</b>)
		under the CPU window.  There is a pane for
		the registers, the flags register, stack.
	</ol>
<p><b>WINDOW menu</b><br>
	To manage the various windows, you need the WINDOW menu.
	If you pull down this menu, you will see instructions
	to step through your active windows, to zoom into
	a particular window, etc.  At the bottom of the menu
	is a list of all the currently active windows.
<p><b>RUN menu</b><br>
	Windows are for watching.  But for action, you need
	to execute your code.  For this, you need to pull down
	the RUN menu.  Basically, you can run in a variety
	of modes:
	<ol>
	<li> Run until program terminate
		(the simplest mode)
	<li> Tracing
		(i.e., machine instruction by machine instruction)
	<li> Stepping
		(i.e., assembly instruction by assembly instruction)
	<li> Run until the next break point
		(which you can set)
	<li> Animate
		(similar to run until terminate, except it
		pauses between machine instructions to allow
		you to catch what is happening)
	<li> Restart
		(move the instruction pointer
		back to the first instruction)
	</ol>
@


1.2
log
@*** empty log message ***
@
text
@d91 22
d115 7
a121 2
Where does the debugger come in?  Well, to debug your
program, especially as your programs becomes complex.
@


1.1
log
@Initial revision
@
text
@d38 13
d95 114
a208 1
We will put more information here in the future.
@
