Sha256: 8a5802c1b95226a45d2f7726551b819e125ac20e888cfe23f653590d41ae3bfd

Contents?: true

Size: 901 Bytes

Versions: 10

Compression:

Stored size: 901 Bytes

Contents

Input and output would be OS-specific and are not implemented. This routine works on the 16-bit 8086, as well as on its 32-bit and 64-bit successors: it could be trivially modified to perform 32-bit or 64-bit arithmetic on machines where those are supported. The quotient is truncated towards zero; the remainder takes its sign from the first operand.
arithm: mov      cx,          a
        mov      bx,          b
        xor      dx,          dx
        
        mov      ax,          cx
        add      ax,          bx
        mov      sum,         ax
        
        mov      ax,          cx
        imul     bx
        mov      product,     ax
        
        mov      ax,          cx
        sub      ax,          bx
        mov      difference,  ax
        
        mov      ax,          cx
        idiv     bx
        mov      quotient,    ax
        mov      remainder,   dx

        ret

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/x86_assembly.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/x86_assembly.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/x86_assembly.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/x86_assembly.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/x86_assembly.txt