Student Bugs: V22.0201.002 (fall 97)

### V22.0201, Machine Organization I
Student BUGS

We collect some errors we have commonly found in programs. Note that we generally do not include assembly time errors -- these are syntax errors and are easy to locate. Please send me your favorite errors for this list!

- Brief List of Common Errors
- Why does TD say ``no config file'' when I try to debug my program which assembles and links without error?
- End of Macro Definition (ENDM)
- Return Statement (RET)
- Bottom of this file

- Brief List of Common Errors
  1. forgetting to initialize DS, ES:
     may get garbage data.
  2. forgetting to exit dos:
     [mov ax,04c00h, int 21h]
     This cause unpredictable errors at the end of your program (e.g., divide by 0 complain)
  3. forgetting to put END at the end of a module:
     Be sure to say "END" for non-main modules and "END <starting procedure>" in the main module.
  4. forgetting a RET (or IRET or RETF) statements after a procedure.
  5. in passing arguments on the stack, forgetting to clear the arguments after calling the procedure.
  6. interrupt handlers: forgetting to save registers. Safest to do PUSHA, POPA.
  7. Look in the file "Td-asm.txt" in the TASM directory for other common errors.
- Why does TD say ``no config file'' when I try to debug my program which assembles and links without error?
  Here is one error which leads to this error: if you happen to nest the definition of a procedure within another procedure. Typically, a student will have all his or her procedures defined inside the main procedure!
- End of Macro Definition (ENDM)
  Note that you do not repeat the name of the macro before the ENDM pseudo instruction. E.g., the following example would be wrong.

      	EXAMPLE macro n
      		mov ax,n
      	EXAMPLE endm

  If you do this, you get a ``unexpected end of file'' error message from the assembler. This error is hard to track down: even if you call ``tasm /z example.asm'', the error message will say that the number of the offending line is the last line of the input file, which is not very helpful. This is in contrast to the ENDP (end of procedure) pseudo instruction.
- Return statements
  -- Students often forget their return statements in procedures.
  -- There are two other forms of return statements, RETF (return from far procedure) and IRET (return from interrupt routine).
  -- Returning to DOS (int 21h, function 04ch). This not really a return statement, but if you forget this, then the program will execute right past your last statement (so it will execute junk, and cause unpredictable program behaviour!)
- Bottom of FAQs
  Click here to go to the top of FAQs.

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