Page 1 of 1

ReWriteMemory

Posted: Sat Nov 15, 2014 1:58 pm
by oryaaaaa
hehehe.

Code: Select all

Procedure ReWriteMemory(*memory, mem_size.i)
  Protected s.i
  
  If mem_size%8>0
    s = mem_size + (8 - mem_size%8)
  Else
    s = mem_size
  EndIf
  If s = 0
    ProcedureReturn
  EndIf 
  
  CompilerSelect #PB_Compiler_Processor
    CompilerCase #PB_Processor_x86
      !PXOR xmm0, xmm0
      !MOV Eax, [p.v_s]
      !MOV Ecx, [p.p_memory]
      !ReWrite:
      !movq xmm0, [Ecx]
      !movq [Ecx], xmm0
      !ADD  Ecx, 8
      !SUB  Eax, 8
      !JNZ ReWrite
    CompilerCase #PB_Processor_x64
      !PXOR xmm0, xmm0
      !MOV Rax, [p.v_s]
      !MOV Rcx, [p.p_memory]
      !ReWrite:
      !movq xmm0, [Rcx]
      !movq [Rcx], xmm0
      !ADD  Rcx, 8
      !SUB  Rax, 8
      !JNZ ReWrite
  CompilerEndSelect 
EndProcedure