1234 * 567 = ? ------------------------ 1234 * 7 = 8638 + 12340 * 6 = 74040 + 123400 * 5 = 617000 ------------------------ 1234 * 567 = 699678 ========================

In single steps decimal:

- We multiply the first number by the lowest significant digit of the second number and add this to the result.
- We multiply the first number by 10 and then by the next higher digit of the second number and add to the result.
- We multiply the first number by 100, then with the third-highest digit, and add this to the result.

. | rmh = R1 = 0x00 | rm1 = R0 = 0xAA | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

Z1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |

* | . | rm2 = R2 = 0x55 | ||||||||||||||

Z2 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | ||||||||

= | reh = R4 = 0x00 | rel = R3 = 0x00 | ||||||||||||||

Erg | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

- MULT8E1.gif: The object-code has been opened, the cursor is placed on the first executable instruction. F11 does single steps.
- MULT8E2.gif: The registers R0 and R2 are set to 0xAA and 0x55, our test binaries, to be multiplied.
- MULT8E3.gif: R2 is rotated to the right, to roll the least significant bit into the carry bit. 0x55 (0101.0101) yielded 0x2A (0010.1010).
- MULT8E4.gif: Because the carry bit had a one the content of the registers R1:R0 is added to the (empty) register pair R4:R3, resulting in 0x00AA there.
- MULT8E5.gif: Now the register pair R1:R0 is rotated one position left to multiply this binary by 2. From 0x00AA, multiplication by 2 yields 0x0154.
- The whole multiplication loop is repeated as long there is at least one binary 1 in register R2. These following loops are not shown here.
- MULT8E6.gif: Using key F5 of the studio we multi-stepped over these loops to a breakpoint at the end of the multiplication routine.
- MULTBE7.gif: The result register pair R4:R3 has the result of the multiplication of 0xAA by 0x55: 0x3872.

To the top of that page

©2002 by http://www.avr-asm-tutorial.net