First of all, I hope I'm understanding the question incorrectly as I'm not really sure how (n * 80) + (n * 40) + n + n + n + n + n is equal to 365 * n, but there is a variety of ways to implement multiplication with bit shifts and addition. The two I found the simplest are:
- Using a loop to implement a*b by simply adding a b-times. This is definitely slow, about the slowest way you could do it, but it is also easy since you just need a simple loop.
- Using the shift and add method. With bit shifts you can multiply any number with 2^x, so you can implement a*b by breaking down a into powers of two, multiplying b with each of them, and then adding them together. In your case (with 365) you'd get 365*b = 256*b+64*b+32*b+8*b+4*b+1*b (or b << 8 + b <<6 + b << 5 + b << 3 + b << 2 + b) . You can break a number into powers of two by finding the closest power of two that's lower than it, subtracting it from the number, and repeating until you get to 1.With this, if the only multiplications you need are fixed numbers like 365 things should be easy to do as it is just a sequence of arithmetic operations
Aside from that, ff you want to implement a function that will be able to multiply a*b for every case, you can use
binary multiplication, which is essentially the shift and add method reformulated in a slightly different way. Hopefully the Wikipedia link explains it well enough. I've never used this myself, and it looks it could be a bit tricky to implement if you're not experienced with assembly, but it is surprisingly elegant.