Movatterモバイル変換


[0]ホーム

URL:


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

or: Wasm text instruction

Theor instructions are used for performing a bitwise OR, similar to the| operator in other languages.

Try it

(module  (func (export "or") (param $a i32) (param $b i32) (result i32)    ;; load both numbers onto the stack    local.get $a    local.get $b    ;; `or` both numbers and return the result    i32.or  ))
const url = "{%wasm-url%}";await WebAssembly.instantiateStreaming(fetch(url), { console }).then(  (result) => {    const or = result.instance.exports.or;    const res = or(0b10000010, 0b01101111);    console.log(numToBin(res));    // Expected output: "11101111"  },);function numToBin(num) {  return (num >>> 0).toString(2).padStart(8, "0");}

Syntax

wat
;; load two numbers onto the stacki32.const 5   ;; 00000101i32.const 3   ;; 00000011;; perform a bitwise ORi32.or;; the top item on the stack will now be 7 (00000111)
InstructionBinary opcode
i32.or0x72
i64.or0x84

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp