0

我有一些汇编脚本代码:

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

它将一个字符串存储0在内存中的指针处。

但是,生成的 .wat 文件将字符串存储在 location1056而不是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
 )
)
4

1 回答 1

0

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

于 2021-09-13T21:30:04.190 回答