本帖最后由 CrLf 于 2014-11-23 19:31 编辑
引申5:
因为寄存器有初始状态,cx=00ff bp=091e si=0100 sp=di=fffe(非Debug环境),所以:
如果要改变的内存地址在 0x120~0x17f 之间,就可以直接用 [si+N] 指向特定位置
0xff 也不需要辗转取得了,cl 初始值就是了,比较高效的办法是用 di 代替 cl,用 xor [Addr],di 一次修改两个相邻字节
---------------------------------------------------------------------
附上 寄存器状态显示.bat,关于实际运行时寄存器初始状态的结论就是用这个得到的- @echo off&setlocal enabledelayedexpansion
- set com=vr.com
- cd .>!com!
- more +19 %0|debug !com!>nul
- for /f "tokens=1-14" %%a in ('!com!') do (
- set /a "F=0x%%n,CF=F&1,PF=(F>>2)&1,AF=(F>>4)&1,ZF=(F>>6)&1"
- set /a "SF=(F>>7)&1,TF=(F>>8)&1,IF=(F>>9)&1,DF=(F>>10)&1,OF=(F>>11)&1"
- for %%A in (
- CF-CY-NC PF-PE-PO AF-AC-NA ZF-ZR-NZ SF-NG-PL IF-EI-DI DF-DN-UP OF-OV-NV
- ) do (
- for /f "tokens=1-3 delims=-" %%B in ("%%A") do (
- if !%%B!==1 (set %%B=%%C) else set %%B=%%D
- )
- )
- echo AX=%%a BX=%%b CX=%%c DX=%%d SP=%%e BP=%%f SI=%%g DI=%%h
- echo DS=%%i ES=%%j SS=%%k CS=%%l IP=%%m !OF! !DF! !IF! !SF! !ZF! !AF! !PF! !CF! TF=!TF!
- )
- del !com!>nul&pause&exit/b
-
- rds
- 1000
- rcs
- 1000
- eds:100 eb 37 50 b8 0 2 51 b9 10 0 83 e9 4 52 d3 ca
- eds:110 81 e2 f 0 80 fa a 72 3 80 c2 7 80 c2 30 cd
- eds:120 21 5a 41 e2 e5 59 52 b8 0 2 ba 20 0 cd 21 58
- eds:130 5a c3 5a 52 83 ea 7e eb c9 9c 8f 6 0 2 52 89
- eds:140 c2 e8 be ff 89 da e8 b9 ff 89 ca e8 b4 ff 5a e8
- eds:150 b0 ff 89 e2 e8 ab ff 50 89 ea e8 a5 ff 89 f2 e8
- eds:160 a0 ff 89 fa e8 9b ff 8c da e8 96 ff 8c c2 e8 91
- eds:170 ff 8c d2 e8 8c ff 8c ca e8 87 ff e8 b4 ff 8b 16
- eds:180 0 2 e8 7d ff cd 20
- rcx
- 87
- w
- q
-
-
- 原型:
- jmp 139; main;;;;
- push ax ;fun
- mov ax,200
- push cx
- mov cx,10
- sub cx,4 ;view
- push dx
- ror dx,cl
- and dx,f
- cmp dl,a
- jb 11c ;next;;; don't add 7
- add dl,7
- add dl,30;------
- int 21
- pop dx
- inc cx
- loop 10a; view;;;
- pop cx
- push dx
- mov ax,200
- mov dx,20
- int 21
- pop ax
- pop dx
- ret;;;end fun
- pop dx
- push dx
- sub dx,7e
- jmp 102; fun;;;
- pushf ;main
- pop [200]
- push dx
- mov dx,ax
- call 102;fun;;;
- mov dx,bx
- call 102;fun;;;
- mov dx,cx
- call 102;fun;;;
- pop dx
- call 102;fun;;;
- mov dx,sp
- call 102;fun;;;
- push ax
- mov dx,bp
- call 102;fun;;;
- mov dx,si
- call 102;fun;;;
- mov dx,di
- call 102;fun;;;
- mov dx,ds
- call 102;fun;;;
- mov dx,es
- call 102;fun;;;
- mov dx,ss
- call 102;fun;;;
- mov dx,cs
- call 102;fun;;;
- call 132;rip
- mov dx,[200]
- call 102;fun;;;
- int 20
复制代码
|