i32.extend8_s
Pops an i32 value off the stack, only looks at the first 8 bits, converts it into an i32 value, and then pushes it back on to the stack. This only looks at the first 8 bits of the 32 bit integer. The other 24 bits are lost. The 8th bit is used as a sign flag, therefore it is treated as a signed 8 bit number.

Syntax

i32.extend8_s

Stack In

i32 The value to be converted.

Stack Out

i32 The i32 version of the first 8 bits of the i32 value.

Examples

;; Convert i32 0b00000001 (1) into an i32 value
i32.const 1
i32.extend8_s

;; The stack contains an i32 value of 0b00000001
;; Convert i32 0b11110000_00001001 (0xF009) into an i32 value
i32.const 0xF009
i32.extend8_s

;; The stack contains an i32 value of 0b00000101
;; Convert i32 0b10001001 (0x89, -119 as signed byte) into an i32 value
i32.const 0x89
i32.extend8_s

;; The stack contains an i32 value of 0b11111111_10000101 (-119 as signed
;; 32 bit integer)