  'take snapshot of registers
  '
  'requires:
  '
  'pr  string buffer
  'tab string
  'cr  new line


  '-----------
  def SNAPSHOT
  '===========
  '
  pusha 'SAVE CPU REGISTERS
  sub esp,512

  '
  'SAVE SIMD REGISTERS
  '===================
  '
  mov eax,esp
  movups [eax   ],xmm0
  movups [eax+16],xmm1
  movups [eax+32],xmm2
  movups [eax+48],xmm3
  movups [eax+64],xmm4
  movups [eax+80],xmm5
  movups [eax+96],xmm6
  movups [eax+112],xmm7
  '
  'SAVE FPU STACK
  '==============
  '
  mov eax,esp
  '
  fsave  [eax+280]
  frstor [eax+280]
  fstp qword [eax+200]
  fstp qword [eax+208]
  fstp qword [eax+216]
  fstp qword [eax+224]
  fstp qword [eax+232]
  fstp qword [eax+240]
  fstp qword [eax+248]
  fstp qword [eax+256]
  frstor [eax+280]

  '==================
  'TO DISPLAY RESULTS
  '==================
  
  mov [esp+400],ebp
  mov ebp,esp

  sys d at [ebp+512]

  pr+= "CPU Registers:" cr cr+"
  EAX:" tab hex(d(8)) "
  ECX:" tab hex(d(7)) "
  EDX:" tab hex(d(6)) "
  EBX:" tab hex(d(5)) "
  ESP:" tab hex(d(4)) "
  EBP:" tab hex(d(3)) "
  ESI:" tab hex(d(2)) "
  EDI:" tab hex(d(1)) cr cr

  single d at [ebp+0]
  sys i at [ebp+408]
  sys j at [ebp+416]
  j=48

  pr+= "SIMD Registers:" cr cr
  '
  for i=1 to 32 step 4
    pr+= "XMM" chr(j) ":" +
    tab str(d(i))   tab str(d(i+1)) +
    tab str(d(i+2)) tab str(d(i+3)) cr
    inc j
  next

  double d at [ebp+200]

  pr+=cr "FPU Registers:" cr "  
  ST0:" tab str(d(1)) "
  ST1:" tab str(d(2)) "
  ST2:" tab str(d(3)) "
  ST3:" tab str(d(4)) "
  ST4:" tab str(d(5)) "
  ST5:" tab str(d(6)) "
  ST6:" tab str(d(7)) "
  ST7:" tab str(d(8)) cr
  '
  mov ebp,[ebp+400]
  add esp,512
  popa
  end def

