Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fmt: .asciz "Product = %x%x\n"
- .align 4
- .global main
- main:
- save %sp, -96, %sp
- !set 0x72e8b8c, %l2 !multiplier
- !set 0x4ee67b7, %l0 !multiplicand
- !set 0x04ee67b7, %l0 !multiplicand
- !set 0xf8d17474, %l2 !multiplier
- set 0xfb119849, %l0 !multiplicand
- set 0xf8d17474, %l2 !multiplier
- set 0x0, %l1 !product
- clr %l4 !clear register
- mov 0, %l3 !counter
- set 0x8, %g3 !bitmask
- clr %l6
- negTest:
- srl %l2, 31, %g1 !get the MSB of multiplier
- andcc %g1, 1, %g0 !test if multiplier is negative
- be loop !go to loop if
- nop
- mov 1, %l4 !set negative flag to true
- nop
- loop:
- andcc %l2, 1, %g0 !test if LSB is 1.
- be shift !go to shift if LSB isn't 1.
- nop
- add %l1, %l0, %l1 !add multiplicand and product
- nop
- shift:
- and %l1, 0x1, %l6
- sll %l6, 31, %l6
- srl %l2, 1, %l2
- sra %l1, 1, %l1
- or %l2, %l6, %l2
- add %l3, 1, %l3
- subcc %l3, 32, %g0
- bl loop
- cmp %l4, 0
- be end
- nop
- sub %l1, %l0, %l1
- nop
- end: set fmt, %o0
- mov %l1, %o1
- mov %l2, %o2
- call printf
- mov 1, %g1
- ta 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement