Write a C program multi_casm.c that calls an assembly function multi_casmfunc.asm to multiply two numbers using the onboard dip switches. The maximum product is $3 \times 4=12$ or $4 \times 3=12$. Note that $4 \times 4=$ 16 cannot be represented with the four dip switches. Use delay loops for debouncing the switches. A partial program is included in Figure 3.25. In the main C source program, the values of $m=100$ and $n=100$ are to check when the first and second switches are pressed. Sw0 is tested and, if pressed, $m=1$, representing the first value. Similarly, $m=2,3,4$ if SW1, SW2, or SW3 is pressed, respectively. Then all LEDs are turned off. This process is repeated while $n=100$ to check for the second value (when the second switch is pressed).
The function values performs the multiplication, adding $m$ (n times) with $m$ and $n$ passed to the asm function through A4 and B4, respectively. Note that ledo is turned on if led $0=1$ (returned from the function resulto). Similarly for $1 \mathrm{ed} 1, \ldots, 1$ ed3. Then, $\mathrm{m}$ and $\mathrm{n}$ are reset to 100 and ii to 1 . The asm function multi_casmfunc.asm includes the functions values, result0,..., result3. The functions result1, result2, result 3 are similar to resulto, but A4 must be shifted first by 1 , by 2 , and by 3 , respectively, in each of these functions. Build and run this project example as multi_casm. Slightly press SW2, then SW 3 to obtain $m=3$ and $n=4$, and verify that SW2 and SW 3 turn on to represent the result of 12 .