【问题标题】:Why does store() in AssemblyScript not store data at the specified pointer?为什么 AssemblyScript 中的 store() 不在指定指针处存储数据?
【发布时间】:2021-10-17 20:53:31
【问题描述】:

我有一些汇编脚本代码:

export function run(): void {
  store<string>(0, 'hello, my name is marty');
}

在内存中存储指针0处的字符串。

但是,生成的 .wat 文件将字符串存储在位置 1056 而不是 0

(module
 (type $none_=>_none (func))
 (memory $0 1)
 (data (i32.const 1036) "L")
 (data (i32.const 1048) "\01\00\00\00.\00\00\00h\00e\00l\00l\00o\00,\00 \00m\00y\00 \00n\00a\00m\00e\00 \00i\00s\00 \00m\00a\00r\00t\00y")
 (export "run" (func $assembly/index/run))
 (export "memory" (memory $0))
 (func $assembly/index/run
  i32.const 0
  i32.const 1056
  i32.store
 )
)

【问题讨论】:

    标签: webassembly assemblyscript


    【解决方案1】:

    它将值为1056的字符串指针存储到线性内存中的零(0)索引中。所以一切都正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-06
      • 2013-07-28
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      相关资源
      最近更新 更多