📄 wdisasm.gml
字号:
.do end
.do end
.np
The "p" option is ignored when the "a" option is specified.
.*
.section The Uppercase Register Option - "r"
.*
.np
.ix '&discmdup options' 'r'
The "r" option instructs the &disname to display register names
in uppercase.
The default is to display register names in lowercase.
.*
.section The Uppercase Opcode Option - "u"
.*
.np
.ix '&discmdup options' 'u'
The "u" option instructs the &disname to display instruction opcode
mnemonics in uppercase.
The default is to display instruction opcode mnemonics in lowercase.
.*
.if &version gt 90 .do begin
.*
.section Retain C++ Mangled Names - "m"
.*
.np
.ix '&discmdup options' 'm'
The "m" option instructs the &disname to retain C++ mangled names
rather than displaying their demangled form.
The default is to interpret mangled C++ names and display them in
a somewhat more intelligible form.
.do end
.*
.section An Example
.*
.np
.ix '&discmdup example'
.ix 'disassembly example'
Consider the following program contained in the file
.fi hello.&langsuff..
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.mbox begin
#include <stdio.h>
void main()
{
printf( "Hello world\n" );
}
.mbox end
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.mbox begin
program main
print *, 'Hello world'
end
.mbox end
.do end
.np
Compile it with the "d1" option.
An object file called
.fi hello&obj
will be produced.
The "d1" option causes line numbering information to be generated in
the object file.
We can use the &disname to disassemble the contents of the object file
by issuing the following command.
.millust begin
&prompt.&discmd hello &sw.l &sw.e &sw.p &sw.s &sw.r
.millust end
.pc
The output will be written to a listing file called
.fi hello&lst
(the "l" option was specified").
It will contain a list of external symbols
(the "e" option was specified),
a list of public symbols (the "p" option was specified) and
the source lines corresponding to the assembly language instructions
(the "s" option was specified).
The source input file is called
.fi hello.&langsuff..
The register names will be displayed in upper case (the "r" option was
specified).
The output, shown below, is the result of using the
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
&cmpcname
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
&cmpname
.do end
compiler.
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.if '&arch' eq '16-bit' .do begin
.code begin
Module: hello.c
Group: 'DGROUP' CONST,CONST2,_DATA,_BSS
Segment: '_TEXT' BYTE 00000011 bytes
#include <stdio.h>
void main()
{
0000 b8 04 00 main_ mov AX,0004H
0003 e8 00 00 call __STK
printf( "Hello world\n" );
0006 b8 00 00 mov AX,offset L1
0009 50 push AX
000a e8 00 00 call printf_
000d 83 c4 02 add SP,0002H
}
0010 c3 ret
No disassembly errors
.code break
List of external symbols
Symbol
----------------
__STK 00000004
printf_ 0000000b
------------------------------------------------------------
Segment: 'CONST' WORD 0000000d bytes
0000 48 65 6c 6c 6f 20 77 6f L1 - Hello wo
0008 72 6c 64 0a 00 - rld..
No disassembly errors
.code break
------------------------------------------------------------
List of public symbols
SYMBOL GROUP SEGMENT ADDRESS
---------------------------------------------------------
main_ _TEXT 00000000
------------------------------------------------------------
.code end
.do end
.if '&arch' eq '32-bit' .do begin
.code begin
Module: hello.c
Group: 'DGROUP' CONST,CONST2,_DATA,_BSS
Segment: _TEXT BYTE USE32 00000018 bytes
#include <stdio.h>
void main()
{
0000 68 08 00 00 00 main_ push 00000008H
0005 e8 00 00 00 00 call __CHK
printf( "Hello world\n" );
000a 68 00 00 00 00 push offset L1
000f e8 00 00 00 00 call printf_
0014 83 c4 04 add ESP,00000004H
}
0017 c3 ret
No disassembly errors
.code break
List of external symbols
Symbol
----------------
__CHK 00000006
printf_ 00000010
------------------------------------------------------------
Segment: CONST DWORD USE32 0000000d bytes
0000 48 65 6c 6c 6f 20 77 6f L1 - Hello wo
0008 72 6c 64 0a 00 - rld..
.code break
No disassembly errors
------------------------------------------------------------
List of public symbols
SYMBOL GROUP SEGMENT ADDRESS
---------------------------------------------------------
main_ _TEXT 00000000
------------------------------------------------------------
.code end
.do end
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.if '&arch' eq '16-bit' .do begin
.code begin
Module: hello.for
Group: 'DGROUP' CONST,_DATA,_BSS
Segment: 'FMAIN_TEXT' BYTE 00000017 bytes
program main
0000 52 FMAIN push DX
print *, 'Hello world'
0001 9a 00 00 00 00 call far RT@IOWrite
0006 b8 00 00 mov AX,offset L2
0009 8c d2 mov DX,SS
000b 9a 00 00 00 00 call far RT@OutCHAR
0010 9a 00 00 00 00 call far RT@EndIO
end
0015 5a pop DX
0016 cb retf
.code break
No disassembly errors
List of external symbols
Symbol
----------------
RT@EndIO 00000011
RT@IOWrite 00000002
RT@OutCHAR 0000000c
------------------------------------------------------------
Segment: 'CONST' WORD 0000000b bytes
0000 48 65 6c 6c 6f 20 77 6f L1 - Hello wo
0008 72 6c 64 - rld
.code break
No disassembly errors
------------------------------------------------------------
Segment: '_DATA' WORD 00000006 bytes
0000 00 00 00 00 L2 DD DGROUP:L1
0004 0b 00 - ..
.code break
No disassembly errors
------------------------------------------------------------
List of public symbols
SYMBOL GROUP SEGMENT ADDRESS
---------------------------------------------------------
FMAIN FMAIN_TEXT 00000000
------------------------------------------------------------
.code end
.do end
.if '&arch' eq '32-bit' .do begin
.code begin
Module: hello.for
Group: 'DGROUP' CONST,_DATA,_BSS
Group: 'FLAT'
Segment: 'FMAIN_TEXT' BYTE USE32 00000014 bytes
program main
print *, 'Hello world'
0000 e8 00 00 00 00 FMAIN call RT@IOWrite
0005 b8 00 00 00 00 mov EAX,offset L2
000a e8 00 00 00 00 call RT@OutCHAR
000f e9 00 00 00 00 jmp RT@EndIO
.code break
No disassembly errors
List of external symbols
Symbol
----------------
RT@EndIO 00000010
RT@IOWrite 00000001
RT@OutCHAR 0000000b
------------------------------------------------------------
Segment: 'CONST' WORD USE32 0000000b bytes
0000 48 65 6c 6c 6f 20 77 6f L1 - Hello wo
0008 72 6c 64 - rld
.code break
No disassembly errors
------------------------------------------------------------
Segment: '_DATA' WORD USE32 00000008 bytes
0000 00 00 00 00 L2 DD DGROUP:L1
0004 0b 00 00 00 - ....
.code break
No disassembly errors
------------------------------------------------------------
List of public symbols
SYMBOL GROUP SEGMENT ADDRESS
---------------------------------------------------------
FMAIN FMAIN_TEXT 00000000
------------------------------------------------------------
.code end
.do end
.do end
.keep
.np
Let us create a form of the listing file that can be used
as input to an assembler.
.millust begin
&prompt.&discmd hello &sw.l=hello.asm &sw.r &sw.a
.millust end
.pc
The output will be produced in the file
.fi hello.asm.
The output, shown below, is the result of using the
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
&cmpcname
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
&cmpname
.do end
compiler.
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.if '&arch' eq '16-bit' .do begin
.code begin
NAME hello
EXTRN _small_code_:BYTE
EXTRN _cstart_:BYTE
EXTRN printf_:BYTE
EXTRN __STK:BYTE
DGROUP GROUP CONST,CONST2,_DATA,_BSS
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT,DS:DGROUP,SS:DGROUP
PUBLIC main_
main_: mov AX,0004H
call near ptr __STK
mov AX,offset DGROUP:L1
push AX
call near ptr printf_
add SP,0002H
ret
_TEXT ENDS
.code break
CONST SEGMENT WORD PUBLIC 'DATA'
L1 LABEL BYTE
DB 48H,65H,6cH,6cH,6fH,20H,77H,6fH
DB 72H,6cH,64H,0aH,00H
CONST ENDS
CONST2 SEGMENT WORD PUBLIC 'DATA'
CONST2 ENDS
_DATA SEGMENT WORD PUBLIC 'DATA'
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS'
_BSS ENDS
END
.code end
.do end
.if '&arch' eq '32-bit' .do begin
.code begin
&sysper.386
NAME hello
EXTRN _cstart_ :BYTE
EXTRN printf_ :BYTE
EXTRN __CHK :BYTE
DGROUP GROUP CONST,CONST2,_DATA,_BSS
_TEXT SEGMENT BYTE PUBLIC USE32 'CODE'
ASSUME CS:_TEXT ,DS:DGROUP,SS:DGROUP
PUBLIC main_
main_ push 00000008H
call near ptr __CHK
push offset DGROUP:L1
call near ptr printf_
add ESP,00000004H
ret
_TEXT ENDS
.code break
CONST SEGMENT DWORD PUBLIC USE32 'DATA'
L1 DB 48H,65H,6cH,6cH,6fH,20H,77H,6fH
DB 72H,6cH,64H,0aH,00H
CONST ENDS
CONST2 SEGMENT DWORD PUBLIC USE32 'DATA'
CONST2 ENDS
_DATA SEGMENT DWORD PUBLIC USE32 'DATA'
_DATA ENDS
_BSS SEGMENT DWORD PUBLIC USE32 'BSS'
_BSS ENDS
END
.code end
.do end
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.if '&arch' eq '16-bit' .do begin
.code begin
retf MACRO POP_COUNT
LOCAL DUMMY
DUMMY PROC FAR
RET POP_COUNT
DUMMY ENDP
ENDM
NAME hello
EXTRN _cstart_:WORD
EXTRN RT@EndIO:WORD
EXTRN RT@OutCHAR:WORD
EXTRN RT@IOWrite:WORD
DGROUP GROUP CONST,_DATA,_BSS
FMAIN_TEXT SEGMENT PUBLIC BYTE 'CODE'
ASSUME CS:FMAIN_TEXT,DS:DGROUP,SS:DGROUP
PUBLIC FMAIN
FMAIN: push DX
call far ptr RT@IOWrite
mov AX,offset DGROUP:L2
mov DX,SS
call far ptr RT@OutCHAR
call far ptr RT@EndIO
pop DX
retf
FMAIN_TEXT ENDS
.code break
CONST SEGMENT PUBLIC WORD 'DATA'
L1 LABEL BYTE
DB 48H,65H,6cH,6cH,6fH,20H,77H,6fH
DB 72H,6cH,64H
CONST ENDS
_DATA SEGMENT PUBLIC WORD 'DATA'
L2 LABEL BYTE
DD DGROUP:L1
DB 0bH,00H
_DATA ENDS
_BSS SEGMENT PUBLIC WORD 'BSS'
_BSS ENDS
END
.code end
.do end
.if '&arch' eq '32-bit' .do begin
.code begin
~.386
NAME hello
EXTRN __init_387_emulator:WORD
EXTRN _cstart_:WORD
EXTRN RT@EndIO:WORD
EXTRN RT@OutCHAR:WORD
EXTRN RT@IOWrite:WORD
DGROUP GROUP CONST,_DATA,_BSS
FLAT GROUP
FMAIN_TEXT SEGMENT PUBLIC BYTE USE32 'CODE'
ASSUME CS:FMAIN_TEXT,DS:DGROUP,SS:DGROUP
PUBLIC FMAIN
FMAIN: call near ptr RT@IOWrite
mov EAX,offset DGROUP:L2
call near ptr RT@OutCHAR
jmp near ptr RT@EndIO
FMAIN_TEXT ENDS
.code break
CONST SEGMENT PUBLIC WORD USE32 'DATA'
L1 LABEL BYTE
DB 48H,65H,6cH,6cH,6fH,20H,77H,6fH
DB 72H,6cH,64H
CONST ENDS
_DATA SEGMENT PUBLIC WORD USE32 'DATA'
L2 LABEL BYTE
DD DGROUP:L1
DB 0bH,00H,00H,00H
_DATA ENDS
_BSS SEGMENT PUBLIC WORD USE32 'BSS'
_BSS ENDS
END
.code end
.do end
.do end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -