Frequently Asked Questions

DOS help

Full command list - A Web site with a complete list of DOS commands, explanations, answers, examples is EasyDOS.

Basic commands - The following are the basic DOS commands needed for this class.

usage: ML [ options ] filelist [ /link linkoptions]
Run "ML /help" or "ML /?" for more info
  1. Assemble io.asm
    • Download io.asm
    • ml /c /coff io.asm 
  1. Locate the .NET directory, probably:
    • C:\Program Files\Microsoft Visual Studio .NET\Vc7\Bin
  2. Copy C:\Program Files\Microsoft Visual Studio .NET\Vc7\Bin\vcvars32.bat to the directory with the assembler program.
  3. In the directory where vcvars32.bat was copied, type exactly: 
    • vcvars32                           See below for ERROR about ENVIRONMENT SPACE .
    • PATH=%PATH%;\masm32\bin
    • ml
    • You should get a window that looks like below:
usage: ML [ options ] filelist [ /link linkoptions]
Run "ML /help" or "ML /?" for more info
  1. Assemble io.asm
    • Download io.asm
    • ml /c /coff io.asm 

Assembler

1.    Enter program - Enter a program using EDIT, NotePad or word processor that can save as an ASCII file (be certain that the extension is ASM and not TXT if saving in NotePad).

2.    Assemble - Windows 95/98 run MS-DOS by Start | Programs | MS-DOS.
       Or .

To assemble the Hw1.Asm program at IUS enter:
v:\common\user\c335\assembler                Do once for DOS mappings.
ml /Fl hw1.asm                               Do each time program changed.
3.    Print - To print the assembly listing use WordPad, open the listing file Hw1.lst, enter File, Page Setup and set to print in landscape mode.

4.   Link - The assembly generates an object code corresponding to the assembly source instructions.
                 Link the object code of Hw1.Obj into an executable module named Hw1.Exe by entering:

link hw1.obj,,,,,
5.   Execute - Use the debugger to execute the Hw1.Exe file by entering:
debug hw1

Debugging

The debugger can follow the execution of a program using only a very few commands. The following lists, explains and provides examples of the most useful debugger commands. The debugger only runs at the MS-DOS prompt. Debugging
The debugger will display a command prompt of a '-'. The five commands needed are:
  1. u - Unassemble the machine code. Lists the mnemonic that correspond to the machine code. ADD AX, +06 corresponds to 83C006 machine code.
    u
    12C0:0000 BBBF12        MOV     BX,12BF
    12C0:0003 8EDB          MOV     DS,BX
    12C0:0005 A10000        MOV     AX,[0000]
    12C0:0008 83C006        ADD     AX,+06
    12C0:000B 2B060400      SUB     AX,[0004]
    12C0:000F BA3412        MOV     DX,1234
    12C0:0012 F7260200      MUL     WORD PTR [0002]
    12C0:0016 A30600        MOV     [0006],AX
    12C0:0019 B44C          MOV     AH,4C
    12C0:001B CD21          INT     21
    12C0:001D C3            RET
    12C0:001E BFB2E8        MOV     DI,E8B2
  2. r - Register view. Displays the registers and next instruction to execute.
    r
    AX=0000  BX=0000  CX=002D  DX=0000  SP=00FE  BP=0000  SI=0000  DI=000
    DS=12AF  ES=12AF  SS=12C2  CS=12C0  IP=0000   NV UP EI PL NZ NA PO NC
    12C0:0000 BBBF12        MOV     BX,12BF
  3. p - Proceed by executing the next one or more instructions. The registers and next instruction to execute are displayed.
    p2
    
    AX=0000  BX=12BF  CX=002D  DX=0000  SP=00FE  BP=0000  SI=0000  DI=0000
    DS=12AF  ES=12AF  SS=12C2  CS=12C0  IP=0003   NV UP EI PL NZ NA PO NC
    12C0:0003 8EDB          MOV     DS,BX
    
    AX=0000  BX=12BF  CX=002D  DX=0000  SP=00FE  BP=0000  SI=0000  DI=0000
    DS=12BF  ES=12AF  SS=12C2  CS=12C0  IP=0005   NV UP EI PL NZ NA PO NC
    12C0:0005 A10000        MOV     AX,[0000]                          DS:0000=0064
  4. d - Dump memory. The d ds:0 command dumps memory pointed to by the DS register. Memory containing the program data variables has been dumped, variable S has been located and underlined in the following example. 
    d ds:0
                       S
    12BF:0000  64 00 08 00 01 00 00 00-00 00 00 00 00 00 00 00   d...............
    12BF:0010  BB BF 12 8E DB A1 00 00-83 C0 06 2B 06 04 00 BA   ...........+....
    12BF:0020  34 12 F7 26 02 00 A3 06-00 B4 4C CD 21 C3 BF B2   4..&......L.!...
    12BF:0030  E8 B4 2A CD 21 98 51 52-8B F0 D1 E6 03 F0 8B CE   ..*.!.QR........
    12BF:0040  A1 12 83 B6 03 57 E8 A9-25 5F 03 F1 B9 03 00 F3   .....W..%_......
    12BF:0050  A4 B0 00 AA 5A 59 C3 8A-D0 32 F6 B8 23 65 CD 21   ....ZY...2..#e.!
    12BF:0060  C3 80 3E 27 D3 00 75 72-8B 36 D7 E2 32 D2 AC 0A   ..>'..ur.6..2...
    12BF:0070  C0 74 26 3C 2A 75 0F F6-C2 02 74 05 80 CA 01 EB   .t&<*u....t.....
  5. g - Go execute program. Starts execution at the next instruction. The following executes through the last instruction Int 21h which terminates the program.
    g
    Program terminated normally

Programming

Relative Jump Out of Range - Relative jumps can branch forward 127 bytes and backward -128 bytes. The Assembler gives an error similar to:
**Error** for.asm(13) Relative jump out of range by 0018h bytes
The error is caused when the number of bytes between the conditional branch and the branch label exceeds this limit. This problem can occur for any conditional branch, an exampleimplementing the do-while is:
do:                                ; do {
        :                                   :
        :                                   :
while:    Cmp    Ax, 5             : } while( Ax != 5 );
          Jne    do
endwhile:
This can be easily corrected by at least three methods:
  1. Reduce the number of between the do: label and Jne conditional. This may not always be practical.
  2. Complement the logic of the conditional and use an unconditional branch to the distant target label, for example:
    1. while:    Cmp    Ax, 5
                Je     endwhile
                Jmp    do
      endwhile:
  3. Keep the logic of the conditional but branch to an intermediate label that branches unconditionally to the distant target label, for example:
    1. while:    Cmp    Ax, 5
                Jne    intermediate
                Jmp    endwhile
      intermediate:
                Jmp    do
      endwhile:
Illegal Memory Reference - The error meesage usually looks something like the following:
**Error** hw4.ASM(50) Illegal memory reference
Generally due to using two variables (memory references) in one instruction. Easilty corrected by moving one of the variables to a register and using it in the original instruction. For example, the following is illegal but can be rewritten using only one variable:
Mov    AB, BA
can be rewritten as:
Mov    Ax, BA
Mov    AB, Ax
 
Unexpected end of file encountered - Typical reported errors are: Macro Locals

Macro locals need to be defined immediately after the start of the macro. For example:

.Sample    Macro    N
                Local      L
                Ifb          <&N>
                               exitm
                Endif
                    :
                    :
endm

Document last modified: