Computer Organization Assignment-2: Shyam Shankar H R EE15B127 August 21, 2017
Computer Organization Assignment-2: Shyam Shankar H R EE15B127 August 21, 2017
Shyam Shankar H R
EE15B127
August 21, 2017
Question
Aim: To implement delay subroutine with help of stack. Here, nested subroutine method is used to provide the required
delay of 5.5s. The clock frequency specified is 1Mhz. Since 2 plain nested subroutines can provide only upto a maximum
delay of about 0.9s, here a 3-level nested subroutine system has been used.
Specifications
Clock Frequency: 1MHz.
Delay: 5.5 s
Code
jmp start
;Main program
start: lxi sp,1000h ;initializing stack
mvi A,01h ;[A] = 01h = 1
mvi B,0FEh ;[B] = 0FEh= 254
add B ;[A] = [A]+[B] ;The Parity(P) and Sign(S) bits
1
;are set to 1, all others are 0. ;Accumulator content is 0FFh.
call delay1 ;delay subroutine call
hlt ;halts the program
Calculating delay:
The number of T-states for each instruction of the delay subroutines is marked to the right end of each line. The total
number of T-states is obtained as:
= 5490598
Program verification
The accumulator and flag register values are compared before and after calling the delay routines. Before the delay
routine call, accumulator holds the value 0xFF, and Flag registers are 1 for sign, and partity bits and zero for others.
It is observed to remain unchanged after the program counter returns from the delay subroutines. This verifies that the
stack operations are done properly and the delay subroutines dont corrupt the main program.