Data Structure and Algorithms
Prepared By: Saleem Masadeh
Consider the following division algorithm:
/ assume that y > 0
if x = 0 then return (q,r) = (0,0);
(q',r') = divide( floor(x/2), y );
if x is even the
Replace the instructions beginning at Line 75 with the following sequence: INS,
Replace the instructions beginning at Line 75 with the following sequence: PULA, RTS
Insert a PSHB instruction after the
c. LDAA 0,X
subroutine modifies the main program registers because It is not practical to restore those
registers and also clean the stack before returning.
True. The ISR must distinguish which device caused the interrupt by testing the flags for the
devices that could cause an interrupt.
Nothing has to be done because the port E pins work as both analog inputs and digital inputs at
the same tim
The operation PSHD is accomplished by PSHB, PSHA. PULD is accomplished by
One possible solution:
C12F through C22E
LDAB #$2F, ABX
LSLA, ADCA #0. The Z bit is the only condition code bit likely to be useful.
HW 2: 50 points total
2-2: 25 points
Rewrite the program in Figure 2-16 to add the three numbers together. The first instruction must
be kept at the same address; this means that the data numbers must be moved. The problems that result
from this move are
One possible Solution:
/change signs if necessary
/ multiply unsigned numbers (with MUL)
/check sign, correct if necessary.
Least significant bit
When the SCI transmitter is enabled, it sens a st