Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What are the differences between JMP instruction and BRA instruction? How muc

ID: 2249790 • Letter: 1

Question

1. What are the differences between JMP instruction and BRA instruction? How much time is saved by using the DBNE instruction instead of a decrement instruction (DECA, DECB, DEX, or DEY) followed by a BNE instruction? Assume the branch is taken (it almost always will be taken). 2. Hint: reading each byte into CPU will take one cycle and executing it wl take one cycle For example, LDAA $1000 (machine code: B6 10 10) will take 3 cycles to read in and one cycle to execute 3· The instruction sequence CLRA; L: INCA, BNE L is used to delay the execution of a program. How much time does it take to execute this code sequence (in terms of clock cycles)? Write a code sequence using an iteration control structure which will clear memory locations $2000 through S200F. 4. Write a code sequence using an iteration control structure which will store the value $23 into memory locations S2000 through S2010. Write a code sequence using an iteration control structure which given a starting address in register X, an ending address in Y, and a value in B, will store the value in B into the location specified in X through the location specified in . Write a code sequence using an iteration control structure which given a starting address in register X, a count in accumulator A, and a value in B, will store the value in B into the location specified in X for a total of A bytes. Note that A is unsigned and might be zero. Write a code sequence using an iteration control structure which will add together all the (unsigned) bytes in memory locations $2000 through S2010, storing the sum in accumulator D.

Explanation / Answer

1. Both are Program flow control uncondition jump instruction but BRA instruction uses offset / effective address in the instruction. That is the destination address is given relative to current Program Counter content.

Where as in Jump instruction, absolute address is provided usually shown as a label in assembly programming.

2. DBNE is a 3 Machine cycle instruction. It decrements given register and branches to given address if register content is not zero.

DECA/DECB.. instructions are 1 machine cycle instruction followed by BNE which is 3 machine cycle instruction. Hence by using DBNE instruction 1 machine cycle is saved.

3. CLRA is a 1 machine cycle instruction, INCA is again 1 machine cycle instruction, BNE L is a 3/2 machine cycle instruction as relative address may be 8/16 bits.

BNE L will loop back when not equal condition is met or zero flag is reset. Zero flag will set only when reg A will become zero after roll off happens. It means A is counting up and when it reaches last count (let say 0xF) then next value will be 0x0 and Z flag will be set causing termination of loop. If its a Accumulator (not mentioned in question that its motorolla 68000/ Freescale HCS12) of HCS12 then its size is 8 bits and roll off will happen when reg A reaches 0xFF and increments.

one iteration takes (1 + 3) machine cycles then total number of iterations will be 256 leading to (256 x 4) machine cycles. CLRA is executed only once. Hence total comes to 1+1024 =1025 machine cycles.

4. LDAA #0

LDAB $0F /// total 16 locations in memory to be initialized

LDAX $2000 // Base address

REP STAA X, B ///use reg B as index

DEC B

BNE REP