0% found this document useful (0 votes)
60 views

Tutorial 9

The document contains 8 questions regarding assembly language programming. Question 1 calculates the loop delay for a given program with register pair BC loaded with different values and clock frequencies. Question 2 builds on question 1 by calculating the total delay which includes the adjusted loop delay. Question 3 also calculates total delay but with different register and clock period values. The remaining questions specify the number of loops for different code snippets, calculate a COUNT value to achieve a given loop delay, and write a program to calculate the sum of values stored in memory locations.

Uploaded by

Nixon Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Tutorial 9

The document contains 8 questions regarding assembly language programming. Question 1 calculates the loop delay for a given program with register pair BC loaded with different values and clock frequencies. Question 2 builds on question 1 by calculating the total delay which includes the adjusted loop delay. Question 3 also calculates total delay but with different register and clock period values. The remaining questions specify the number of loops for different code snippets, calculate a COUNT value to achieve a given loop delay, and write a program to calculate the sum of values stored in memory locations.

Uploaded by

Nixon Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Tutorial 9

Program 1:

1. If register pair BC for Program 1 is loaded with 8000H, calculate the loop delay T L if
the system clock frequency is 3.072 MHz (ignore three T-state difference of the last
cycle).

1 1
Clock Frequency, T= = = 0.3255 μs = 0.0003255 ms
f 3.072

Total T-states in the loop = 6 + 4 + 4 + 10 = 24 T-states


N10 = 8000H = 32768 loops (Turn Hex to Decimal)

TL = (T x Loop T-States x N10)


= 0.0003255 x 24 x 32768
= 255.9836 ms

2. For Question 1, calculate the total delay, T D by considering the adjusted loop delay,
TLA.

TO = Total T-states outside loop x T


= 10 x 0.3255
= 3.255 μs
= 0.003225 ms

TLA = TL – (Difference T-states x T)


= 255.9836 – ((10 - 7) x 0.0003255)
= 255.9826 ms

TD = TO + TLA
= 0.003225 + 255.9826
= 255.9856 ms
3. Load register pair BC with 0000H for Program 1 and calculate the total delay TD if the
system clock period is 325 ns (adjust for the last cycle).

T = 325 ns
= 0.000325 ms

N10 = 0000H = Next of FFFFH = 65535 + 1 = 65536 loops

TL = (T x Loop T-States x N10)


= 0.000325 x 24 x 65536
= 511.1808 ms

TO = Total T-states outside loop x T


= 10 x 0.000325
= 0.00325 ms

TLA = TL – (Difference T-states x T)


= 511.1808 – ((10 - 7) x 0.000325)
= 511.1798 ms

TD = TO + TLA
= 0.00325 + 511.1798
= 511.1830 ms

4. Specify the number of times the following loops are executed:


MVI A,17H
LOOP: ORA A
RAL
JNC LOOP

Number of time looping = 4 times

5. Specify the number of times the following loops are executed:


MVI A,17H
LOOP: RAL
ORA A
JNC LOOP

Number of time looping = Infinite loop


When execute instruction ORA A, Carry Flag (CY) and Auxiliary Carry Flag (AC) are
always set to 0. Thus, instruction JNC will always jump back and loop never stop.
6. Specify the number of times the following loops are executed:
LXI B,l000H
LOOP DCX B
: NOP
JNZ LOOP

Number of time looping = Infinite loop


Register B value is not change, so the value always no zero thus the program will
keep looping.

7. Calculate the COUNT to obtain a 100 µs loop delay and express the value in Hex.
Use any clock frequency of your preference.

Just calculate like normal.


1
T= = 2 μs = 0.002 ms
0.5
Total T-states in the loop = 4 + 4 + 4 + 10 = 22 T-states

TL = (T x Loop T-States x N10)


= 0.002 x 22 x COUNT
= 0.044 x COUNT

TO = Total T-states outside loop x T


= 7 x 0.002
= 0.014 ms

TLA = TL – (Difference T-states x T)


= 0.044 x COUNT – (3 x 0.002)

TD = 100 μs = 0.1 ms
TD = TO + TLA
0.1 = 0.014 + (0.044 x COUNT - 0.006)

0.1 – 0.014+ 0.0 06


COUNT = = 2 loops
0.044

COUNT = 210 = 02H


8. Calculate the sum of series of numbers. The length of the series is in memory
location 2200H and the series itself begins from memory location 2201H. Assume
the sum to be 8-bit number so you can ignore carries. Store the sum at memory
location 2300H.

2200H = 04H
2201H = 20H
2202H = 15H
2203H = 13H
2204H = 22H

LDA 2200H ;load Accumulator with value store in 2200H


MOV C, A ;C=4
LXI H,2201H ;load address 2201H to HL as pointer
BACK: ADD M ;HL = 2201 so M = 20H
INX H ;increase 1 (HL)
DCR C ;C-1 until 0
JNZ BACK
STA 2300H ;Store final result value in 2300H
HLT

You might also like