[Scripting] Fixed some writing functions in asm, fixed some reading functions in vm.

Fixed a MAJOR memory issed in the vm.