Download bkasm User`s Guide
Transcript
40 The 1K Target However, this particular operation is fundamentally different than the other two piggybacks mentioned so far. Because store and transfer piggybacks read from the accumulator, and every arithmetic instruction writes to the accumulator, these piggybacks must happen immediately. In order to maintain the correct semantics of the program, they can piggyback only on the subsequent statement. Anywhere else, they would grab the wrong value from the accumulator. The load piggyback, however, does not care about the accumulator; its business is only between data memory and the b register. Neither of these elements are necessarily used on every instruction, which implies that bkasm might be able to slide your load request to somewhere else in the code while keeping your program functionally equivalent. If you let it, that’s exactly what bkasm will do. Optimized Load Placement If the --optimize-load-placement option is not enabled, loads behave like stores and transfers; they either piggyback on the subsequent statement or generate a dummy instruction. But if you do enable this option (or the -O command line switch), bkasm will happily move the load piggyback up or down in the code in order to find the best possible home for it. As an example, here is a sine oscillator which you may remember from an earlier chapter: ; "modified coupled form" sine oscillator a = -0.1 * [sine] ; generates: lcm -0.1 sine <----a += [cosine] ; generates: cma 1 cosine | [cosine] = a ; piggybacks below | b = [sine] ; piggybacks above! -----------------a = 0.1 * a + b ; generates: scab 0.1 cosine [sine] = a ; generates: s1ac 0 sine bkasm doesn’t just look for any piggybackable instruction; it takes into account the precision downgrade that some piggybacks cause, and tries to avoid that if it can. b = [call_a] a += p(24, 1/3) a += 1/3 a += 1/4 a = 2*a + b ; ; ; ; ; ; ; generates: 1ac 0.3333 (can’t piggyback here; 24-bit precision required) generates: 1ac 0.3333 (can piggyback here, but would rather not) generates: l1ac 0.25 call_a (best piggyback target; no sacrifice in precision) generates: cab 2 All else being equal, bkasm will go ahead and piggyback on the statement subsequent to the load statement, so you do get some measure of control as to where the load goes. If no piggyback is possible, a dummy instruction must be generated.