For this homework assignment, consider the following multiplication, procedure, coded in classic K&R C.
(int) times( a, b )
int a; /* multiplier */
int b; /* multiplicand */
{
int c = 0; /* product */
int i;
if (a & 0x80000000) {
c = -b; /* handle the sign bit */
}
for (i=31; i>0; i--) {
c <<= 1; /* handle the rest */
a <<= 1;
if (a & 0x80000000) {
c += b;
}
}
return c;
}
In responding to the following questions, please confine yourself to
"simple brute force" translation of this code to assembly code.
Don't try to optimize! Don't try to make effective use of registers!
int e;
(void) main()
{
e = 12;
e = times( 5, e );
exit(0);
}
. = #200 DISPPTR = #10000 ;------------------------ DSPCH: ; output char in R3 ; link through R1 ; wipes out R4-5 LIL R4,DISPPTR LOADS R5,R4 ; get display pointer ADDSI R5,1 STORES R5,R4 ; save updated pointer LOADS R4,R5 STUFFB R4,R3,R5 STORES R4,R5 ; update display JUMPS R1 ; returnNote, you can check your results by using the assembler and Hawk emulator, but you'll want the experience of doing this by hand for the upcoming exam!