max_u: Wasm SIMD Arithmetik-Instruktion
Die max_u-Instruktion vergleicht zwei v128-Darstellungen von ganzzahligen Werten ohne Vorzeichen und gibt eine neue Darstellung zurück, bei der jeder Lane auf den größeren Wert an der entsprechenden Lane-Position der beiden Eingaben gesetzt ist.
Probieren Sie es aus
(module
(import "console" "log" (func $log (param i32)))
(func $main
;; load two v128 i16x8s onto the stack
v128.const i16x8 10 400 0 86 87 9000 -5 19
v128.const i16x8 200 20 0 -5 80 9 -6 283
;; return a i16x8 containing the greatest values from each input
i16x8.max_u
i16x8.extract_lane_s 5 ;; Extract a single lane
call $log ;; log the result
)
(start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
Syntax
value_type.max_u
value_type-
Der Wertetyp, auf dem die Instruktion angewendet wird. Die folgenden Typen unterstützen
max_u:i8x16i16x8i32x4
max_u-
Die
max_u-Instruktion. Muss immer nach demvalue_typeund einem Punkt (.) angegeben werden.
Typ
[input1, input2] -> [output]
Binäre Kodierung
| Instruktion | Binärformat | Beispiel Text => Binär |
|---|---|---|
i8x16.max_u |
0xfd 121:u32 |
i8x16.max_u => 0xfd 0x79 |
i16x8.max_u |
0xfd 153:u32 |
i16x8.max_u => 0xfd 0x99 0x01 |
i32x4.max_u |
0xfd 185:u32 |
i32x4.max_u => 0xfd 0xb9 0x01 |