SPARC Assembly/Multiplication and Division

From Wikibooks, open books for an open world
< SPARC Assembly
Jump to: navigation, search

Looking through the lists of instructions, it becomes clear that multiplication and division operations are not provided in SPARC: at least not in a form that most programmers are familiar with. This page is going to discuss the algorithms used to perform multiplication and division operations in SPARC

Overview of the Multiplication Algorithm[edit]

The SPARC Implementation of the Multiplication Algorithm[edit]

Overview of the Division Algorithm[edit]

The SPARC Implementation of the Division Algorithm[edit]


To multiply %l3 and %l4 and store in %l5:

mov %l3 %o0 ! First operand
mov %l4 %o1 ! Second operand
call .mul ! Result stored in %o0
! To divide %l3 by %l4, use .div
! To find the remainder, use .rem
nop ! Delay slot
mov %o0 %l5 ! Copy result to %l5