680x0:Simple calculations

From Amiga Coding
Revision as of 23:38, 24 March 2008 by Spellcoder (talk | contribs) (changes so syntax highlighting is used)
Jump to: navigation, search

Simple calculations: move.l #5,d0 ; d0 = $00000005 add.l #1,d0 ; d0 = d0 + 1 (d0 is now $00000006) sub.l #2,d0 ; d0 = d0 - 2 (d0 is now $00000004) rts


Harder calculations: move.l #5,d0 ; d0 = $00000005 mulu.w #4,d0 ; d0 = d0 * 4 rts


The standard mulu (MULtiply Unsigned) only works with words so can only handle numbers up to 65535. There is an command for 68020+ processors and there are routines to multiply using longwords but whe'll ignore them for now ;)

divu uses the lower word for the quotient (the result) and the upper word for the remainder.

mulu doesn't use the upper word.