ADDSL R5,R5,1 ; multiply by 3 ADDSL R5,R5,2 ; multiply by 5 ADDSL R5,R5,2 ADDSL R5,0,1 ; multiply by 10 (10 = 2 x 5) ADDSL R5,R5,2 ADDSL R5,R5,2 ADDSL R5,0,2 ; multiply by 100 (100 = 5 x 5 x 4)
While there is not a one-to-one mapping between these and the instructions of any particular hardware, there is usually a straightforward reduction of source-language constructs to hardware constructs. For example, each while loop (a source language operator) requires one conditional forward branch and one unconditional backward branch. As a result, source-code analysis can provide considerable information to the designer of an instruction set prior to the first draft of that instruction set.
add(s1,s2,dst) int * s1; int * s2; /* all parameters are arrays of 2 elements */ int * dst; /* element 0 is the least significant 7 digits */ { int t1, t2, t5, res, carry; t1 = s1[0] + 0x06666666; t2 = t1 + s2[0]; t5 = ~(t2 ^ (t1 ^ s2[0])) & 0x11111110; res = t2 - (t5 >> 2) | (t5 >> 3); carry = (res & 0xF0000000); dst[0] = (res & 0x0FFFFFFF); t1 = s1[1] + 0x06666666 + carry; t2 = t1 + s2[1]; t5 = ~(t2 ^ (t1 ^ s2[1])) & 0x11111110; dst[1] = t2 - (t5 >> 2) | (t5 >> 3); }