Sha256: 66215f1717865caed1e8131246929294fc13f36a13dcdf88d6bcca17ea908f4a

Contents?: true

Size: 749 Bytes

Versions: 10

Compression:

Stored size: 749 Bytes

Contents

ADD.L D0,D1 ; add two numbers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB.L D1,D0 ; subtract D1 from D0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MULU D0,D1  ; multiply two unsigned numbers. Use MULS for signed numbers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DIVU D1,D0  ; Divide D0 by D1. Use DIVS for signed numbers. Upper two bytes of D0 are the remainder, lower two are the integer quotient.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MODULUS:
DIVU D1,D0
SWAP D0     ;swap the order of the 16-bit halves of D0.
RTS

Exponentiation doesn't exist but can be implemented in a similar fashion to multiplication on the 6502:

Exponent:
;raises D0 to the D1 power. No overflow protection.
MOVE.L D0,D2
SUBQ.L #1,D1
loop_exponent:
MULU D0,D2
DBRA D1,loop_exponent
;output is in D2
RTS

Version data entries

10 entries across 7 versions & 1 rubygems

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