Movatterモバイル変換


[0]ホーム

URL:


  1. WebAssembly
  2. Reference
  3. WebAssembly numeric instructions
  4. sub

sub: Wasm text instruction

Thesub instructions, short forsubtraction, are used for subtracting one number from another number, similar to the- operator in other languages.

Try it

(module  (import "console" "log" (func $log (param i32)))  (func $main    ;; load `10` and `3` onto the stack    i32.const 10    i32.const 3    i32.sub ;; subtract on number from the other    call $log ;; log the result  )  (start $main))
const url = "{%wasm-url%}";await WebAssembly.instantiateStreaming(fetch(url), { console });

Syntax

wat
;; load two numbers onto the stacki32.const 10i32.const 3;; subtract one number from the otheri32.sub;; the top item on the stack will now be 7 (10 - 3 = 7)
InstructionBinary opcode
i32.sub0x6b
i64.sub0x7d
f32.sub0x93
f64.sub0xa1

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp