同人星球BBS -> 游戏修改 -> [汇编]数据块复制 repe movsd [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

修改众 08-07-14 19:41

这个命令可以对内存数据进行整块复制操作。

repe是重复执行前缀
ecx是重复次数。测试条件如下
等于0就结束复制,执行后面的指令。
否则,ecx=ecx-1,复制1次。

movsd, move string by double word
将esi指向的数据传送到edi指向的地址,执行1次会复制4字节的内容。然后esi,edi自动加4




举个例子,我们申请2个内存
[ENABLE]
alloc(testmem1,1000)
alloc(testmem2,1000)
registersymbol(testmem1)
registersymbol(testmem2)

testmem1:
db 01 01 01 01 01 01 01 01
db 01 01 01 01 01 01 01 01
db 01 01 01 01 01 01 01 01
db 01 01 01 01 01 01 01 01
testmem2:
db 02 02 02 02 02 02 02 02
db 02 02 02 02 02 02 02 02
db 02 02 02 02 02 02 02 02
db 02 02 02 02 02 02 02 02
[DISABLE]
dealloc(testmem1)
dealloc(testmem2)
unregistersymbol(testmem1)
unregistersymbol(testmem2)




我们要把testmem2的内容复制到testmem1中,即让testmem1也都变成02 02 02 02
汇编脚本应该这样写


[ENABLE]
createthread(copymem2to1)
alloc(copymem2to1,1000)
registersymbol(copymem2to1)

copymem2to1:
lea esi,[testmem2]
lea edi,[testmem1]
mov ecx,8
repe movsd
ret
[DISABLE]
dealloc(copymem2to1)
unregistersymbol(copymem2to1)

修改众 08-07-14 19:51
这个命令的1些英文说明

  MOVS      =  Move  String 
  MOVSB    =  Move  String  by  Byte 
  MOVSW    =  Move  String  by  word 
  MOVSD    =  Move  String  by  Doubleword 
   
  MOVS  -  Move  String  (Byte  or  Word) 
                  Usage:    MOVS        dest,src 
                                  MOVSB 
                                  MOVSW 
                                  MOVSD    (386+) 
                  Modifies  flags:  None 
                  Copies  data  from  addressed  by  DS:SI  (even  if  operands  are  given)  to 
                  the  location  ES:DI  destination  and  updates  SI  and  DI  based  on  the 
                  size  of  the  operand  or  instruction  used.    SI  and  DI  are  incremented 
                  when  the  Direction  Flag  is  cleared  and  decremented  when  the  Direction 
   
                  Flag  is  Set.    Use  with  REP  prefixes. 



相关命令
  LODS      =  Load  String 
  LODSB    =  Load  String  by  Byte 
  LODSW    =  Load  String  by  word 
  LODSD    =  Load  String  by  Doubleword 
   
  LODS  -  Load  String  (Byte,  Word  or  Double) 
                  Usage:    LODS        src 
                                  LODSB 
                                  LODSW 
                                  LODSD    (386+) 
                  Modifies  flags:  None 
                  Transfers  string  element  addressed  by  DS:SI  (even  if  an  operand  is 
                  supplied)  to  the  accumulator.      SI  is  incremented  based  on  the  size 
                  of  the  operand  or  based  on  the  instruction  used.    If  the  Direction 
                  Flag  is  set  SI  is  decremented,  if  the  Direction  Flag  is  clear  SI 
   
                  is  incremented.    Use  with  REP  prefixes. 



STOS  -  Store  String    (Byte,  Word  or  Doubleword) 
                  Usage:    STOS        dest 
                                  STOSB 
                                  STOSW 
                                  STOSD 
                  Modifies  flags:  None 
                  Stores  value  in  accumulator  to  location  at  ES:(E)DI  (even  if  operand 
                  is  given).    (E)DI  is  incremented/decremented  based  on  the  size  of 
                  the  operand  (or  instruction  format)  and  the  state  of  the  Direction 
                  Flag.      Use  with  REP  prefixes. 


查看完整版本: [-- [汇编]数据块复制 repe movsd --] [-- top --]

Powered by PHPWind v5.3 Code © 2003-05 PHPWind
Time 0.043729 second(s),query:4 Gzip enabled

You can contact us