#### rohitaudipudi

Joined Feb 28, 2010
2
MicroController Questions. Can you help me understand?
(1) Write an assembly program to subtract the hex numbers $16753284 from$98765432.

(2) Write a program to subtract the hex numbers stored at $804~$807 from the hex number
stored at $800~$803, and save the difference at $900~$903.

(3) Write an instruction sequence to divide the signed 16-bit number stored at memory locations
$805~$806 by the 16-bit unsigned number stored at memory locations $820~$821, and store the
quotient and remainder at $900~$901 and $902~$903, respectively.

(4) Since there is no 32-bit by 32-bit multiplication instructions, we will have to break a
32-bit number into two 16-bit halves and use the 16-bit by 16-bit multiply instruction to
synthesize the operation. Assume M and N are the multiplicand and the multiplier, respectively.
These two numbers can be broken down as follows:
M = MHML
N = NHNL
where, MH and NH are the upper 16 bits and ML and NL are the lower 16 bits of M and N,
respectively. Write a procedure to multiply two unsigned 32 bit numbers. (No need to write
assembly language).

(6) What are the new values of the memory location at $800 and the C flag after executing the instruction ASR$800? Assume that the memory location $800 originally contains the value of$ED and the C flag is 0.
(7) Compute the new values of accumulator B and the C flag after executing the instruction
ROLB. Assume the original value of B is $BD and C flag is 1. (8) Write a procedure followed by an assembly program to count the number of zeros contained in memory locations$800~$801 and save the result at memory location$805.
Hint: The logical shift right instruction is available for double accumulator D. We can load
this 16-bit value into D and shift it to the right sixteen times or until it becomes zero.
(9) Write an instruction sequence to create a 100-ms time delay.
(10) What is the delay that the following program creates?
ldab #100
out_loop ldx #20000
inner_loop psha
pula
psha
pula
psha
pula
psha
pula
psha
pula
psha
pula
psha
pula
psha
pula
psha
pula
nop
nop
dbne x,inner_loop
dbne b,out_loop

#### jlcstrat

Joined Jun 19, 2009
58
Is there a specific part you're having problems with?

#### rohitaudipudi

Joined Feb 28, 2010
2
Yes Sir. I would like to know how to start with, like 32 bit multiplications. how do you think in the perspective and how do you start with. how do u share registers. please explain . thank you!

#### jlcstrat

Joined Jun 19, 2009
58
For assembly, you have to go simple step by step. It looks like you just need a flow chart for the multiplication. Best thing to do is write it the exact way you would do it by hand. Leave out no steps, such as carries.