📄 sdisassm.asm
字号:
;
; Copyright (C) 1996-2002 Supernar Systems, Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; 1. Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; 3. The end-user documentation included with the redistribution, if any,
; must include the following acknowledgment:
;
; "This product uses DOS/32 Advanced DOS Extender technology."
;
; Alternately, this acknowledgment may appear in the software itself, if
; and wherever such third-party acknowledgments normally appear.
;
; 4. Products derived from this software may not be called "DOS/32A" or
; "DOS/32 Advanced".
;
; THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS" AND ANY EXPRESSED
; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
;
.CODE
decode: push eax ebx ecx edx edi ebp
mov eax,20202020h ; clear text buffers
mov ecx,20
mov edi,offs cmdbuf
rep stosd
mov ecx,20
mov edi,offs textbuf
rep stosd
mov ecx,20
mov edi,offs commbuf
rep stosd
clr eax
mov cmdbuf+80,al
mov textbuf+80,al
mov commbuf+80,al
mov cmdadr,offs cmdbuf
mov textadr,offs textbuf
mov commadr,offs commbuf
mov _jump_taken,al ; initialize variables
mov _prefix_esp,al
mov eax,esi ; print eff. address
mov edi,textadr
cmp _show_unreloc,0
jz @@1
call show_unreloc_addr
jc @@1
jmp @@4
@@1: cmp _adrsiz,0
jz @@2
mov dptr [edi],':sc '
add textadr,4
call text_makehexax
jmp @@3
@@2: call text_makehexeax
@@3: inc textadr ; add one space
@@4: call put_textal ; get first byte (op-code)
movzx ebx,al
shr ebx,4 ; ebx = 0F0h masked opcode (group)
mov edi,cmdadr
call _grouptab[ebx*4] ; goto choosen group
mov bptr [edi],0
call merge_text
pop ebp edi edx ecx ebx eax
_empty: ret
decode2:push eax ebx ecx edx
call put_textal ; get first byte (op-code)
movzx ebx,al
shr ebx,4 ; ebx = 0F0h masked opcode (group)
call _grouptab[ebx*4] ; goto choosen group
pop edx ecx ebx eax
ret
show_unreloc_addr:
clr ebx
mov dx,wptr _cs
@@0: cmp _obj_selector[ebx*2],0
jz @@err
cmp dx,_obj_selector[ebx*2]
jz @@1
inc ebx
jmp @@0
@@1: sub eax,_obj_address[ebx*4]
call text_makehexeax
lea eax,[ebx+1]
and eax,3Fh
cmp eax,09h
lea eax,[eax+30h]
jbe @@2
lea eax,[eax+07h]
@@2: mov ah,':'
mov [edi],ax
inc textadr ; add one space
clc
ret
@@err: stc
ret
;=============================================================================
makehexal:
push ecx esi edi
mov edi,offs hexbuf
call makehex
lea esi,[edi+6]
mov ecx,2
pop edi
rep movsb
pop esi ecx
ret
makehexax:
push ecx esi edi
mov edi,offs hexbuf
call makehex
lea esi,[edi+4]
mov ecx,4
pop edi
rep movsb
pop esi ecx
ret
makehexeax:
push ecx esi edi
mov edi,offs hexbuf
call makehex
mov esi,edi
mov ecx,8
pop edi
rep movsb
pop esi ecx
ret
makehexword:
test ax,0FF00h
jz makehexal
jmp makehexax
makehexdword:
test eax,0FFFFFF00h
jz makehexal
jmp makehexeax
text_makehexal:
push edi
mov edi,textadr
call makehexal
mov textadr,edi
pop edi
ret
text_makehexax:
push edi
mov edi,textadr
call makehexax
mov textadr,edi
pop edi
ret
text_makehexeax:
push edi
mov edi,textadr
call makehexeax
mov textadr,edi
pop edi
ret
put_textal:
call load_byte
cmp _showmode_flag,0
jnz @@done
call text_makehexal
@@done: inc esi
ret
put_textax:
inc esi
call load_byte
dec esi
mov ah,al
call load_byte
cmp _showmode_flag,0
jnz @@done
xchg ah,al
call text_makehexax
xchg ah,al
@@done: add esi,2
ret
put_texteax:
add esi,3
call load_byte
dec esi
shl eax,8
call load_byte
dec esi
shl eax,8
call load_byte
dec esi
shl eax,8
call load_byte
cmp _showmode_flag,0
jnz @@done
bswap eax
call text_makehexeax
bswap eax
@@done: add esi,4
ret
@bswap: push edx
ror eax,16
mov dh,al
mov dl,ah
rol edx,16
ror eax,16
mov dh,al
mov dl,ah
rol edx,16
mov eax,edx
pop edx
ret
put_commaddr:
push eax ebx edi
mov edi,commadr
movzx ebx,_prefix
cmp bl,3 ; if prefix is not DS
jnz @@0 ; then do not check for SS
cmp _prefix_esp,0
jz @@0
mov bl,02h ; SS:[ xxx ]
@@0: lea edx,_segtab86[ebx*4]
call put_string
call put_colon
cmp _adrsiz,0
jz @@l1
movzx eax,ax
call makehexax
jmp @@l2
@@l1: call makehexeax
@@l2: mov _refaddr,eax
mov dptr [edi],' = '
add edi,3
mov commadr,edi
mov _refshow,1
pop edi ebx eax
ret
put_memx_err:
call put_string
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
ret
put_memb:
cmp _refshow,0
jz @@done
push eax esi edi
mov esi,_refaddr
mov edi,commadr
mov edx,offs err_addr_b
call get_code_byte
jnc put_memx_err
call makehexal
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
@@done: ret
put_memw:
cmp _refshow,0
jz @@done
push eax esi edi
mov esi,_refaddr
mov edi,commadr
mov edx,offs err_addr_w
inc esi
call get_code_byte
jnc put_memx_err
dec esi
mov ah,al
call get_code_byte
jnc put_memx_err
call makehexax
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
@@done: ret
put_memd:
cmp _refshow,0
jz @@done
push eax esi edi
mov esi,_refaddr
mov edi,commadr
mov edx,offs err_addr_d
add esi,3
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
call makehexeax
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
@@done: ret
put_memfw:
cmp _refshow,0
jz @@done
push eax esi edi
mov esi,_refaddr
mov edi,commadr
mov edx,offs err_addr_f2
add esi,3
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
ror eax,16
call makehexax
call put_colon
ror eax,16
call makehexax
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
@@done: ret
put_memfd:
cmp _refshow,0
jz @@done
push eax esi edi
mov esi,_refaddr
mov edi,commadr
mov edx,offs err_addr_f
add esi,5
call get_code_byte
jnc put_memx_err
dec esi
mov ah,al
call get_code_byte
jnc put_memx_err
dec esi
mov ecx,eax
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
dec esi
shl eax,8
call get_code_byte
jnc put_memx_err
xchg ecx,eax
call makehexax
call put_colon
mov eax,ecx
call makehexeax
mov commadr,edi
mov wptr [edi],0068h
pop edi esi eax
@@done: ret
put_adrmemb:
call put_commaddr
jmp put_memb
put_adrmemw:
call put_commaddr
jmp put_memw
put_adrmemd:
call put_commaddr
jmp put_memd
Align 4
__safe_load:
mov al,fs:[esi]
nop
ret
Align 4
load_byte:
push esi
cmp _cs_limit,-1
jz @@l1
cmp esi,_cs_limit
ja @@l2
@@l1: add esi,_cs_base
xor al,al
call __safe_load
pop esi
ret
@@l2: xor al,al
pop esi
ret
Align 4
get_code_byte:
push esi
movzx ebx,_prefix
cmp _prefix_esp,0
jz @@0
mov bl,02h
@@0: jmp _data_byte_tab[ebx*4]
Align 4
get_data_byte:
push esi
movzx eax,_data_override
jmp _data_byte_tab[eax*4]
Align 4
_get_byte_err:
clr al
pop esi
ret
Align 4
_get_byte_safe:
xor al,al
call __safe_load
jc _get_byte_err
pop esi
stc
ret
Align 4
_get_data_byte_es:
cmp wptr _es,0
jz _get_byte_err
cmp _es_limit,-1
jz @@l1
cmp esi,_es_limit
ja _get_byte_err
@@l1: add esi,_es_base
jmp _get_byte_safe
Align 4
_get_data_byte_cs:
cmp wptr _cs,0
jz _get_byte_err
cmp _cs_limit,-1
jz @@l1
cmp esi,_cs_limit
ja _get_byte_err
@@l1: add esi,_cs_base
jmp _get_byte_safe
get_stack_byte:
push esi
Align 4
_get_data_byte_ss:
cmp wptr _ss,0
jz _get_byte_err
cmp _ss_limit,-1
je @@l1
cmp esi,_ss_limit
ja _get_byte_err
@@l1: add esi,_ss_base
jmp _get_byte_safe
Align 4
_get_data_byte_ds:
cmp wptr _ds,0
jz _get_byte_err
cmp _ds_limit,-1
je @@l1
cmp esi,_ds_limit
ja _get_byte_err
@@l1: add esi,_ds_base
jmp _get_byte_safe
Align 4
_get_data_byte_fs:
cmp wptr _fs,0
jz _get_byte_err
cmp _fs_limit,-1
je @@l1
cmp esi,_fs_limit
ja _get_byte_err
@@l1: add esi,_fs_base
jmp _get_byte_safe
Align 4
_get_data_byte_gs:
cmp wptr _gs,0
jz _get_byte_err
cmp _gs_limit,-1
je @@l1
cmp esi,_gs_limit
ja _get_byte_err
@@l1: add esi,_gs_base
jmp _get_byte_safe
put_comma:
mov bptr [edi],','
inc edi
ret
put_colon:
mov bptr [edi],':'
inc edi
ret
put_open:
mov bptr [edi],'['
inc edi
ret
put_close:
mov bptr [edi],']'
inc edi
ret
put_plus:
mov bptr [edi],'+'
inc edi
ret
put_minus:
mov bptr [edi],'-'
inc edi
ret
put_charh:
mov bptr [edi],'h'
inc edi
ret
put_tab:mov bptr [edi],09h
inc edi
ret
put_one:mov bptr [edi],'1'
inc edi
ret
put_cl: mov wptr [edi],'lc'
inc edi
inc edi
ret
put_prefix:
cmp _prefix,03h
jnz @@l0
ret
@@l0: movzx ebx,_prefix
lea edx,_segtab86[ebx*4]
call put_string
jmp put_colon
make_indexah:
cmp ah,0
jnz @@l0
mov ah,'1'
jmp @@done
@@l0: cmp ah,1
jnz @@l1
mov ah,'2'
jmp @@done
@@l1: cmp ah,2
jnz @@l2
mov ah,'4'
jmp @@done
@@l2: mov ah,'8'
@@done: mov al,'*'
mov [edi],ax
add edi,2
ret
put_string:
push eax
@@loop: mov al,[edx]
test al,al
jz @@done
mov [edi],al
inc edx
inc edi
jmp @@loop
@@done: pop eax
ret
merge_text:
pushad
clr ebx
cmp _showmode_flag,0
mov bl,24
jz @@l1
mov bl,9
@@l1: mov esi,offs cmdbuf
mov edi,offs textbuf
cmp bptr [edi+ebx],20h
jz @@loop
mov bptr [edi+ebx-1],0AFh
@@loop: mov al,[esi]
inc esi
test al,al
jz @@done
cmp al,09h
jz @@tab
mov [edi+ebx],al
inc ebx
cmp ebx,60
jb @@loop
mov wptr [edi+ebx-1],00AFh
popad
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -