div

Group: arithmetic

Performs arithmetic division.

Syntax

    (0)     div r0 r1 r2
    (1)     div r0 r1 
    

(0) is the canonical form. Assembler expands (1) to "div r0 r0 r1".

div %1 local %2 local
-- expands to...
div %1 local %1 local %2 local
    

Operands "r1" and "r2" may use pointer dereference.

Semantics

Divides number in "r1" by number in "r2" and stores the result in "r0". Type of the result is determined by the type of left-hand side operand's value. Input operands are signed integers or floating point numbers.

Exceptions

Exception is thrown when either input operand has invalid (non-numeric) type.

Examples

.function: example/0
    istore %1 local 126

    -- store 3 in local register 1
    istore %2 local 3

    -- result will be stored in "%3 local"
    -- its type will be a 64 bit signed integer
    div int64 %3 local %1 local %2 local

    -- prints "42" to stdout
    print %3 local

    return
.end
    

Related instructions

add, sub, mul.