FAQs: V22.0201, Machine Org I, Yap

#### V22.0201, Machine Organization I, Yap

## FAQs: FREQUENTLY ASKED QUESTIONS

- What is TASM, MASM, the linker, debugger and related software?
- Where do I find TASM in the ACF labs?
- Can I run TASM under Windows?
- How can I use the debugger?
- What is the MS-DOS COMMAND PROMPT?
- I am unfamiliar with DOS. Can you help?
- Do I need to use a text editor? What shall I use?
- How do I print what is on my screen?
- How do I print POSTSCRIPT files?
- What are POSTSCRIPT files?
- Why does my .ASM file contain unprintable characters?
- I want the TASM directory to be automatically searched. How do I modify environment variable PATH to allow this?
- What are bat files?
- I happen to use an Windows NT system. Can you give me some hints?
- Can you please give me the basics of mouse programming?
- What are .com executable files and how do I produce them?
- Large Numbers in Computer Science (What is a petabyte, etc)
- Bottom of this file

- What is TASM, MASM, linker, debugger and other software?
  TASM is the name of the Turbo Assembler, and is the main software assumed for this class. The latest version is version 5, but older versions will probably be OK for this course. Indeed, the PC labs has version 4.1. You can purchase your own copy from the NYU bookstore for about $75 (for other sources, look at the course homepage under "other information"). MASM stand for Microsoft Assembler. Appendix D and Chapter 4 of the text has some basic information on MASM. It is very similar to TASM, and it is the assembler assumed by the text. Associated with each assembler are linkers and debuggers. Information about debugging is given in another FAQ, below. The linker for TASM (resp. MASM) is called TLINK (resp. LINK).
  >> For more information about assembling and linking, CLICK HERE.
- Where do I find TASM in the ACF labs?
  There are two answers:
  (a) If you are in windows, you can look under the start menu. In any case, there is an applications folder on the desktop. Look under the "programming" folder and then the "dos programming" folder. There is also a turbo debugger under "programming", under "C++".
  (b) If you are in the MS-DOS PROMPT, you probably want to locate the TASM directory:

              Z:\bin\tasm4\bin

  We suggest that you append this directory to the current value of your environment path variable (see another FAQ question for this). Note that Z:\bin\tasm25 contains an older version of TASM. Other folders that might be of interest in the future are Z:\courses\yap and Z:\courses\v220201.002.
- Can I run TASM under Windows 95?
  No, TASM does not run under Windows 95. You need to go into a MS-DOS PROMPT window to run TASM.
- How can I use the debugger?
  A debugger is a tool to help the debugging process. Of course, you can debug your programs without using a debugger. But the special nature of assembly language programming makes it hard to debug complex programs unless you can actually examine the registers and memory locations of your computer. These functions are provided by any debugger. Hence it pays to make the little effort to learn the basics of TD. DOS comes with a very elementary form of debugger called DEBUG. Chapter 5.4 and Appendix E of the text shows you how to use this debugger. We will be using the Turbo Debugger ``TD'', which is much more sophisticated than DEBUG.
  >> For more information, especially about TD, CLICK HERE.
- What is the MS-DOS COMMAND PROMPT?
  We assume that you will initially be facing the WINDOWS 95 operating system. But for using the Turbo Assembler, we need to fall back to the older operating system called DOS. WINDOWS 95 gives you access to this DOS environment in the form of window called MS-DOS COMMAND PROMPT (or MS-DOS PROMPT, for short). You can usually get this window from the start menu. If not, is it probably called command.com under the windows directory. (This means you can also invoke this by typing ``command'' at the start->run menu.) To find out more about DOS, see the next question. NOTE: cmd.exe is the corresponding WinNT command prompt.

  HINTS for MS-DOS PROMPT window: Usually, this is just another window on the Win95 desktop. But to make this window take over the entire screen, press ALT-ENTER. You can return to the Win95 desktop by pressing ALT-ENTER once more. There are basic window functions (such as making a copy of the window output) you can do from the MS-DOS PROMPT. To access these, left-click the icon on the left of the title bar, or right-click the title bar itself.

- I am unfamiliar with DOS. Can you help?
  The text editor ``edit'' in DOS is useful to know. (see the next question). Some useful DOS functions are
  - dir (list the current directory)
  - cd (change the current directory)
  - set (set or show environment variables)
  - type (type the contents of a file)
  - copy (copy a file)
  - ren (rename a file)
  - mkdir (create a new directory, i.e., folder)
  - rmdir (delete a directory, i.e., folder)
  - echo (echo command -- useful for batch files)
  - rem (remark command -- useful for batch files)
  - call (calls another batch file)
  - if (conditional processing)
  - for (runs a program for each file in a set)
  - goto (jumps to label)
  - pause (pauses program and awaits a key press to continue)
  - command (starts a new copy of command window)
  - edit (MSDOS editor)
  - exit (exits command window)
  To find out more about any of these commands, you can type the command name followed by ``/?''. E.g.

      	:> dir /?

  HINT:
  (a) When you do ``dir'' or ``type'', the output can fill more than one screenful. To allow you to view the output one screenful at a time, you can ``pipe'' the output to the function called more.

      	:> dir /? | more

  You type a space-bar to get the next screenful of output from more. Note that ``|'' indicates the pipe from output of ``dir'' to the input of ``more''. Another original from the UNIX world.
  (b) DOS folder or file names are 8 characters, possibly followed by a 3 character extension. E.g., myprogra.asm. But Windows 95 allows much longer file names. If the Windows 95 name of a folder is myprograms, then its DOS name is assumed to be "myprog~1". That is, the first 6 characters are taken, followed by "~1". If a previous file already have the same 6 characters, it is followed "~2", etc.
- Do I need to use a text editor? What shall I use?
  In this course, you need an editor to enter your assembly language programs. These programs are stored in a file of ascii characters.

  You can use any of your favorite editors. The simplest WYSIWYG editor from Windows 95 is Note Pad. The simplest is edit from within the MS-DOS COMMAND PROMPT. Edit is very simple and intuitive to use. You can figure it out without reading instructions. But if you wish, there is online help. Normally, you invoke "edit ". But if you simply invoke "edit", you will be put directly into the online help facilities.

  If you use Note Pad or editors such as MS WORD, you need to beware. These editors inserts all kinds of formatting commands (such as the font information, paragraphing and other commands) among your pure ascii text. If you simply "save" what you type in such an editor, you will get a file that contain these non-printable (non-ascii) characters. TASM will complain. Instead, you should choose (in Note Pad or MS WORD) the "save as" command. In the dialog box, choose the "save as text only" option.

- How do I print what is on my screen?
  The easiest is to invoke the [PRINT SCREEN] key (this is a single key). To print the image of the entire screen, press [PRINT SCREEN] To print the image of the window that is currently active, press [ALT]+[PRINT SCREEN] (this is a combination of two keys).

  Unfortunately, [PRINT SCREEN] seems to be disabled in the ACF labs. An alternative was is to use the COPY and PASTE functions of the windowing system. In the MS-DOS COMMAND PROMPT window, you can left-click the MS-DOS icon at the left corner of the title bar, or right-click the title bar. A pull-down menu appears, and you can choose edit->mark. You now mark the region of the window you want to copy: press the left button at the top-left of the region and drag the mouse to the bottom-right of the region, and release mouse. Next, use the pull-down menu again and choose edit->copy. This saves a copy of the region into a temporary file. If you now open a new file (say "foo") in a text editor, you can choose edit->paste to paste the contents of the temporary file into "foo". You may now print "foo" from your editor.

  A third option which may work for you is to re-direct the output of your program to a file and to print that file. For instance, to redirect the output of your program hw1.exe to the file "foo", you invoke

              :>   hw1 > foo

  Normally, the output of hw1 is sent to your screen ("the standard output"). The ">" command tells the system to send it to "foo" instead. (This is another idea that originated in UNIX.)
- How do I print POSTSCRIPT files?
  Basically, you send the file to a printer that has a postscript driver. This is available on any NYU printer connected to unix machines (your ACF email account is a unix account).
  >> For more information on printing postscript at NYU CLICK HERE.
- What are POSTSCRIPT files?
  Postscript is a computer language for describing layout of a document. In this class, we like to distribute notes and homework assignments using postscript files. To print a postscript file, you just send the file to any printer that has a postscript interpreter. All unix-based NYU machines will be able to print such files. We are working to get this ability in the PC labs as well (it can sometimes be done).
  A postscript file is an ascii file, so you can view it using an editor! You can recognize a postscript file by its first line, which is something like this:
  %!PS-Adobe-2.0
  (PS stands for postscript, Adobe is the company that owns postscript, and 2.0 is the version of postscript.) However, the rest of the file might not make much sense to you unless you know the postscript language (actually, the basics of this language are easy to learn). The problem is that postscript is very low level, much like an assembler language. So postscript files are often generated by some program from other files.
- Why does my .ASM file contain unprintable characters?
  This happens if you create your .ASM file using a fancy editor like MS WORD. It will not happen if you use editors such as edit which is a very simple editor available under DOS. You may not realize you have this problem, as it may show with the TASM complaining about some problems with your .ASM file (which you think is a problem with your syntax). To see if you have this problem, try to open your .ASM file using edit in MS-DOS. If what you see contains funny characters, you definitely have this problem. These funny characters may representing page formatting instructions, font changing instructions, etc.

  For related information, see editors above.

  The solution (say, from MS WORD) is to save your file using the "save as" command. This throws up a dialog window which contains an option to save your file as "text only". Choose this option.

- I want the TASM directory to be automatically searched. How do I modify environment variables PATH to allow this?
  (a) Here is how to do it in Windows 95: go to the start menu->control panel. Click on the the system icon. Choose the environment tab, and click on the user PATH variable. You can now modify its value in the appropriate value box. When done, click apply. Now when you invoke MS-DOS or WINDOWS, the new value of the path variable will be used. [Note: you can add new environment variables this way too]
  (b) You can also do this within the MS-DOS (but unlike the previous approach, it will not survive a reboot). Suppose your TASM is found is in Z:\tasm\bin. To add this to the path, you type the following to the DOS prompt:

      	:> set path = <old-path>; Z:\tasm\bin

  where <old-path> is the original value of path. One way to automate this process is to create a ``bat file'' (say, mypath.bat) which performs this function. Note that ``path'' will print the value of the current path variable. Hence, to put this information into mypath.bat, do:

            :> path > mypath.bat

  Now use an editor to edit mypath.bat, i.e., you insert ``set '' to the beginning of the line, and ``; Z:\tasm\bin'' to the end of the line. Now you can execute this bat file each time you need it.
- What are bat or batch files?
  Batch programs are stored in batch files. These are ascii files whose extension is ``.bat'' or ``.cmd''. They contain instructions for the operating system. When you execute such a file (you need not type the .bat or .cmd extension if this is unambiguous), it is as if you issued those instructions in your window (or MS-DOS prompt). It is useful to use such files to store a set of related commands that you want to use frequently. E.g., for this class, you might want to prepare a batch file containing the sequence

      	@rem my homework batch file
      	echo -- Processing Homework Batch File --
      	tasm /zi /z hw.asm
      	tlink /v hw.obj
      	hw.exe
      	echo -- Done Homework Batch File --

  Some general commands are:
  - rem (remark or comment)
  - echo (echo just prints the arguments on the screen)
  - call (calls another batch program)
  - if (conditional processing)
  - pause (pauses and asks for any key press to continue)
  - for (runs a specified command for each file in a set)
  - goto (jump to a label)
- I happen to use an Windows NT system. Can you give me some hints?
  In many ways, Windows NT (or, WinNT) feels just like Windows 95 (Win95). The difference is that WinNT is geared towards multiple users (like UNIX). Each user has his or her own ``user profile'' that is usually stored in the folder C:\winnt\profiles\<usr-name>. Thus, your will find that your desktop files and start menu are stored here.

  Two basic files in DOS, CONFIG.SYS and AUTOEXEC.BAT, used to configure your system. In WinNT, these files are called CONFIG.NT and AUTOEXEC.NT and are found in the directory /%systemroot%/System32, where %systemroot% is where WinNT system information are found (e.g., %systemroot%=WINNT). Config.nt (not config.sys) and autoexec.nt (not autoexec.bat) are used to initialize your MS-DOS environment, unless some different startup files are specified in the application's PIF.

  echoconfig: By default, no information is displayed when MS-DOS environment is initialized. To display information, add the command echoconfig in the config.nt/autoexec.nt files.

  ntcmdprompt: When you return to the command prompt from a TSR or while running a MS-DOS application, WinNT runs command.com (see above) This allows the TSR to remain active. To run cmd.exe (the WinNT command prompt) rather than command.com, add the command ntcmdprompt in CONFIG.NT or other startup file.

  dosonly: By default, you can start any application from command.com. But if you start an application other than MS-DOS application, any running TSR may be disrupted. To ensure that only MS-DOS applications can be started, add the command dosonly to config.nt or other startup file.

- Can you please give me the basics of mouse programming?
  Please click here.
- What are .com executable files and how do I produce them?
  Normally the executable files have the extension .exe. An alternative form of executables have extensions .com. Read section 14.1 in the textbook for general information this alternative format. In particular, it is more compact and useful for small programs. Section 14.1 also tells you how to create .com files from the source program, if you were using Microsoft's MASM and LINK. For Turbo's TASM and TLINK, it is slightly easier. You use TASM in the normal way, but you call TLINK with an extra ``/T'' flag. If your object file produced by TASM is called ``myprog.obj'', then you issue

      	:> TLINK /T MYPROG

  to produce MYPROG.COM.
- Large Numbers in Computer Science
  Taken from http://www.rlt.dk/~erikoest/bb_terms.htm
  1. Yottabyte (YB)
     2 to the 80th power bytes, which is approximately 10 to the 24th power (1,000,000,000,000,000,000,000,000) bytes. A yottabyte is equal to 1,024 zettabytes.
     The name yotta was chosen because it's the second-to-last last letter of the Latin alphabet and also sounds like the Greek letter iota.
  2. Zettabyte (ZB)
     2 to the 70th power bytes, which is approximately 10 to the 21st power (1,000,000,000,000,000,000,000) bytes. A zettabyte is equal to 1,024 exabytes.
     The name zetta was chosen because it's the last letter of the Latin alphabet and also sounds like the Greek letter Zeta.
  3. Exabyte (EB)
     (1) 2 to the 60th power (1,152,921,504,606,846,976) bytes. An exabyte is equal to 1,024 petabytes.
     (2) When capitalized, the name of a manufacturer of mass storage devices.
  4. Petabyte (PB) 2 to the 50th power (1,125,899,906,842,624) bytes. A petabyte is equal to 1,024 terabytes. Approximately 10 to the 15th power (1,000,000,000,000,000).
  5. Terabyte (TB) (1) 2 to the 40th power (1,099,511,627,776) bytes. This is approximately 1 trillion bytes. (2) 10 to the 12th power (1,000,000,000,000). This is exactly one trillion.
  6. Gigabyte (GB) 2 to the 30th power (1,073,741,824) bytes. One gigabyte is equal to 1,024 megabytes.
- Bottom of FAQs
  Click here to go to the top of FAQs.

Bug reports? Suggestions?
Please send email to yap@nyu.edu.