Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------------------------------------------------------
- ; macro to convert multiplication to bit shift (w)
- ; in:
- ; \1 = input number
- ; out:
- ; \2 = output register
- ; to-do: esto es mulu, después hacer un muls, divu, divs?
- ; ---------------------------------------------------------------------------
- omulu: macro
- __sp: = 0
- @do: macro
- n: = \1
- i: = 0
- while n>1
- n: = n>>1
- i: = i+1
- endw
- if i>8*2
- inform 0,"Warning! Overflow will always give zero result"
- moveq #0,\2
- mexit
- endif
- if (1*\1)<>(1<<i)
- __sp: = __sp+1
- t: = ((\1)-1<<i)
- pushp '\#n'
- pushp '\#i'
- move.w \2,-(__sp*2+2)(sp) ; -> Very slow #1
- @do t,\2
- move.w \2,-(sp)
- move.w -(4-2)(sp),\2 ; -> Very slow #2
- popp bi
- popp bn
- n: = \bn
- i: = \bi
- endif
- while i>=8
- ;lsl.w #8,\2
- clr.w -(sp)
- move.b \2,(sp)
- move.w (sp)+,\2
- i: = i-8
- endw
- if i<=2
- rept i
- add.w \2,\2
- endr
- else
- lsl.w #i,\2
- endif
- endm
- @do \1, \2
- rept __sp
- add.w (sp)+,\2
- endr
- endm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement