Abahbob

Float Big Endian CE

Jan 14th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. alloc(TypeName,256)
  2. alloc(ByteSize,4)
  3. alloc(ConvertRoutine,1024)
  4. alloc(ConvertBackRoutine,1024)
  5. alloc(UsesFloat,4)
  6.  
  7. TypeName:
  8. db 'Float Big Endian',0
  9. ByteSize:
  10. dd 4
  11. UsesFloat:
  12. db 01
  13.  
  14. ConvertRoutine:
  15. [32-bit]
  16. push ebp
  17. mov ebp,esp
  18. mov eax,[ebp+8] //place the address that contains the bytes into eax
  19. mov eax,[eax] //place the bytes into eax
  20. bswap eax
  21. pop ebp
  22. ret 4
  23. [/32-bit]
  24.  
  25. [64-bit]
  26. //rcx=address of input
  27. mov eax,[rcx] //eax now contains the bytes 'input' pointed to
  28. bswap eax
  29. ret
  30. [/64-bit]
  31.  
  32. ConvertBackRoutine:
  33. [32-bit]
  34. push ebp
  35. mov ebp,esp
  36. //[ebp+8]=input
  37. //[ebp+c]=address of output
  38. push eax
  39. push ebx
  40. mov eax,[ebp+8] //load the value into eax
  41. mov ebx,[ebp+c] //load the address into ebx
  42. bswap eax
  43. mov [ebx],eax //write the value into the address
  44. pop ebx
  45. pop eax
  46.  
  47. pop ebp
  48. ret 8
  49. [/32-bit]
  50.  
  51. [64-bit]
  52. //ecx=input
  53. //rdx=address of output
  54. bswap ecx
  55. mov [rdx],ecx //place the integer the 4 bytes pointed to by rdx
  56. ret
  57. [/64-bit]
Add Comment
Please, Sign In to add comment