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 |
| usage: ML [ options ] filelist [ /link linkoptions] Run "ML /help" or "ML /?" for more info |
- Assemble io.asm
- Download io.asm
- ml /c /coff io.asm
- Visual Studio .NET
- Locate the .NET directory, probably:
- C:\Program Files\Microsoft Visual Studio .NET\Vc7\Bin
- Copy C:\Program Files\Microsoft Visual Studio .NET\Vc7\Bin\vcvars32.bat to the directory with the assembler program.
- 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 |
- Assemble io.asm
- Download io.asm
- ml /c /coff io.asm
Type CD drive: to display the current directory in the specified
drive. Example: CD C:
Type CD without parameters to display the current drive and directory.
Example: CD
Type CD path to change to a new directory. Example to change
to the top directory: CD \
[drive:][path][filename]
Specifies drive, directory, and/or files to list.
(Could be enhanced file specification or multiple filespecs.)
/P Pauses
after each screenful of information.
/W Uses
wide list format.
/A Displays
files with specified attributes.
attributes D Directories
R Read-only files
H Hidden files
A Files ready for archiving
S System files
- Prefix meaning not
/O List
by files in sorted order.
sortorder N By name (alphabetic)
S By size (smallest first)
E By extension (alphabetic) D By date & time (earliest
first)
G Group directories first - Prefix to reverse
order
A By Last Access Date (earliest first)
/S Displays
files in specified directory and all subdirectories.
/B Uses
bare format (no heading information or summary).
/L Uses
lowercase.
/V Verbose
mode.
/4 Displays
year with 4 digits (ignored if /V also given).
Switches may be preset in the DIRCMD environment variable. Override
preset switches by prefixing any switch with - (hyphen)--for example,
/-W.
Type MD path to create a new directory path. Example to
create a new directory named C335 at the top of the directory tree:
MD \C335
2. Assemble - Windows 95/98 run MS-DOS
by Start | Programs | MS-DOS.
Or
,
,
.
To assemble the Hw1.Asm program at IUS enter:
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.v:\common\user\c335\assembler Do once for DOS mappings.
ml /Fl hw1.asm Do each time program changed.
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:
5. Execute - Use the debugger to execute the Hw1.Exe file by entering:link hw1.obj,,,,,
debug hw1
The debugger will display a command prompt of a '-'. The five commands needed are:
- u - Unassemble the machine code. Lists the mnemonic that correspond to the machine code. ADD AX, +06 corresponds to 83C006 machine code.
u12C0: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- r - Register view. Displays the registers and next instruction to execute.
rAX=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- 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- 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:0S 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.....- g - Go execute program. Starts execution at the next instruction. The following executes through the last instruction Int 21h which terminates the program.
gProgram terminated normally
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:**Error** for.asm(13) Relative jump out of range by 0018h bytes
This can be easily corrected by at least three methods:do: ; do { : : : :while: Cmp Ax, 5 : } while( Ax != 5 ); Jne do endwhile:
while: Cmp Ax, 5 Je endwhile Jmp do endwhile:
while: Cmp Ax, 5 Jne intermediate Jmp endwhile intermediate: Jmp do endwhile:
**Error** hw4.ASM(50) Illegal memory referenceGenerally 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, BAcan be rewritten as:
Mov Ax, BAUnexpected end of file encountered - Typical reported errors are:
Mov AB, Ax
while: Cmp Ax, 5
DOES define a label while.
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